Fantom

 

class

compiler::ClosureExpr

sys::Obj
  compiler::Node
    compiler::Expr
      compiler::ClosureExpr

ClosureExpr is an "inlined anonymous method" which closes over it's lexical scope. ClosureExpr is placed into the AST by the parser with the code field containing the method implementation. In InitClosures we remap a ClosureExpr to an anonymous class TypeDef which extends Func. The function implementation is moved to the anonymous class's doCall() method. However we leave ClosureExpr in the AST in it's original location with a substitute expression. The substitute expr just creates an instance of the anonymous class. But by leaving the ClosureExpr in the tree, we can keep track of the original lexical scope of the closure.

Slots

callSource

MethodDef? call

clsSource

TypeDef? cls

codeSource

Block? code

collapseExprAndReturnSource

Void collapseExprAndReturn(MethodDef m)

doCallSource

MethodDef? doCall

enclosingClosureSource

ClosureExpr? enclosingClosure

enclosingSlotSource

SlotDef enclosingSlot

enclosingTypeSource

TypeDef enclosingType

enclosingVarsSource

[Str:MethodVar]? enclosingVars

isItBlockSource

Bool isItBlock

itTypeSource

CType? itType

makeSource

new make(Loc loc, TypeDef enclosingType, SlotDef enclosingSlot, ClosureExpr? enclosingClosure, FuncType signature, Str name)

nameSource

Str name

outerThisFieldSource

CField outerThisField()

printSource

override Void print(AstWriter out)

Overrides compiler::Expr.print

Doc inherited from compiler::Node.print

Pretty print this node and it's descendants.

setInferredSignatureSource

Void setInferredSignature(FuncType t)

setsConstSource

Bool setsConst

signatureSource

FuncType signature

substituteSource

CallExpr? substitute

toStrSource

override Str toStr()

Overrides compiler::Expr.toStr

Doc inherited from sys::Obj.toStr

Return a string representation of this object.

toWithSource

Expr toWith(Expr target)