Class in macro compiler

FnDecl

class FnDecl
Import
use macro::{FnDecl};
Source: compiler/src/prelude/macro.hy

A function or method handed to an attribute macro.

Fields#

FieldTypeDescription
nameIdent
paramsVec<Param>
retTypeRefReturn type as written, or unit when the function declares none.
type_paramsVec<Ident>
attrsVec<Attr>Remaining attributes (the macro’s own attribute is removed).
ownerstringOwning class for an impl method, else "".
is_pubboolpub (methods; top-level functions are always visible).
is_staticbool
is_corobool
declares_effectsboolDeclares its effects: pure fn or uses {…}.
is_pureboolSpelled pure fn.
effectsVec<string>The names in uses {…}: read, write, net, env, exec, ffi, thread, suspend, mutate.
requiresVec<string>requires clauses as written after the keyword (n >= 0 or n >= 0, "message"), in order.
ensuresVec<string>ensures clauses, like requires.
docsVec<string>
bodystringThe body block as written, braces included.
sourcestringThe whole declaration as written (the macro’s own attribute removed).

Methods#

NameDescription
body_source
signaturename(T a, U b) -> R: the signature as written, under a new name.
with_nameThe function under another name, with its remaining attributes: #[other] pub fn name(T a) -> R { body }.
contract_clausesThe requires / ensures clauses, each as requires … (empty when there are none).
uses_clauseuses {read, write} as declared (uses {} for none).
callA call of name with this function’s arguments (self.name(a, b) for an instance method).
arg_namesa, b: the parameter names, for forwarding a call.

See also#

  • unit
  • io::net
  • env
  • ffi
  • thread
  • Code: Generated coil source: declarations, an expression, statements or a type.
  • Ident: A name as written in source.
  • Expr: A function-style macro argument as written: f(1), a + b, "text".
↑ ↓ navigate ↵ open