
class
compiler::ResolveExpr
sys::Obj compiler::CompilerSupport compiler::CompilerStep compiler::ResolveExpr
Walk the AST to resolve:
- Manage local variable scope
- Resolve loop for breaks and continues
- Resolve LocalDefStmt.init into full assignment expression
- Resolve Expr.ctype
- Resolve UknownVarExpr -> LocalVarExpr, FieldExpr, or CallExpr
- Resolve CallExpr to their CMethod
Slots
-
private Void bindToMethodVar(LocalDefStmt def)
Bind the specified local variable definition to a MethodVar (and register number).
- blockStack
-
Block[] blockStack
-
private Block currentBlock()
Get the current block which defines our scope. We make a special case for "for" loops which can declare variables.
- curryCount
-
Int curryCount
- enterBlock
- enterMethodDef
- enterStmt
- exitBlock
-
private Stmt findLoop()
- inClosure
-
Bool inClosure
-
private Void initMethodVars()
Setup the MethodVars for the parameters.
-
private Bool isBlockInScope(Block block)
Check if the specified block is currently in scope. We make a specialcase for "for" loops which can declare variables.
-
private Str:MethodVar localsInScope()
Get a list of all the local method variables that are currently in scope.
- make
-
new make(Compiler compiler)
-
private Expr resolveAssign(BinaryExpr expr)
Resolve an assignment operation
-
private Expr resolveCall(CallExpr call)
Resolve a call to it's Method and return type.
-
private Expr resolveCallOnLocalVar(CallExpr call, LocalVarExpr binding)
Resolve the () operator on a local variable - if the local is a Method, then () is syntactic sugar for Method.callx()
-
private Void resolveClosure(ClosureExpr expr)
ClosureExpr will just output it's substitute expression. But we take this opportunity to capture the local variables in the closure's scope and cache them on the ClosureExpr. We also do variable name checking.
-
private Void resolveContinue(ContinueStmt stmt)
-
private Expr resolveCurry(CurryExpr expr)
CurryExpr
-
private Expr resolveIndexedAssign(ShortcutExpr orig)
If we have an assignment against an indexed shortcut such as x[y] += z, then process specially to return a IndexedAssignExpr subclass of ShortcutExpr.
-
private Expr resolveList(ListLiteralExpr expr)
Resolve list literal
-
private MethodVar resolveLocal(Str name)
Resolve a local variable using current scope based on the block stack and possibly the scope of a closure.
-
private Void resolveLocalVarDef(LocalDefStmt def)
-
private Expr resolveMap(MapLiteralExpr expr)
Resolve map literal
-
private Expr resolveShortcut(ShortcutExpr expr)
Resolve ShortcutExpr.
-
private Expr resolveStorage(UnknownVarExpr var)
Resolve storage operator
-
private Expr resolveSuper(SuperExpr expr)
Resolve super keyword expression
-
private Expr resolveTernary(TernaryExpr expr)
Resolve "x ? y : z" ternary expression
-
private Expr resolveThis(ThisExpr expr)
Resolve this keyword expression
-
private Expr resolveVar(UnknownVarExpr var)
Resolve an UnknownVar to its replacement node.
-
private Expr resolveWithBlock(WithBlockExpr expr)
Resolve with block
- run
-
override Void run()
- stmtStack
-
Stmt[] stmtStack
- visitExpr
- visitStmt
More Info
Slots
- bindToMethodVar
- blockStack
- currentBlock
- curryCount
- enterBlock
- enterMethodDef
- enterStmt
- exitBlock
- findLoop
- inClosure
- initMethodVars
- isBlockInScope
- localsInScope
- make
- resolveAssign
- resolveBreak
- resolveCall
- resolveCallOnLocalVar
- resolveClosure
- resolveContinue
- resolveCurry
- resolveExpr
- resolveExprStmt
- resolveFor
- resolveIndexedAssign
- resolveList
- resolveLocal
- resolveLocalVarDef
- resolveMap
- resolveShortcut
- resolveStorage
- resolveSuper
- resolveTernary
- resolveThis
- resolveVar
- resolveWithBlock
- run
- stmtStack
- visitExpr
- visitStmt