
class
compiler::CheckErrors
sys::Obj compiler::CompilerSupport compiler::CompilerStep compiler::CheckErrors
CheckErrors walks the tree of statements and expressions looking for errors the compiler can detect such as invalid type usage. We attempt to leave all the error reporting to this step, so that we can batch report as many errors as possible.
Since CheckErrors already performs a full tree walk down to each leaf expression, we also do a couple of other AST decorations in this step:
1) add temp local for field assignments like return ++x 2) add temp local for returns inside protected region 3) check for field accessor optimization 4) check for field storage requirements 5) add implicit cast when assigning Obj to non-Obj 6) implicit call to toImmutable when assigning to const field
Slots
-
private Void checkAssign(BinaryExpr expr)
-
private Expr checkAssignField(FieldExpr lhs, Expr rhs)
Check if field is assignable, return new rhs.
-
private Void checkContinue(ContinueStmt stmt)
-
private Void checkLocalDef(LocalDefStmt stmt)
-
private Void checkRangeLiteral(RangeLiteralExpr range)
-
private Void checkReturn(ReturnStmt stmt)
-
private Void checkSame(BinaryExpr expr)
-
private Void checkShortcut(ShortcutExpr shortcut)
-
private Void checkSlotProtection(CSlot slot, Location loc, Bool setter := false)
-
private Void checkSwitch(SwitchStmt stmt)
-
private Void checkTernary(TernaryExpr expr)
-
private Void checkTypeCheck(TypeCheckExpr expr)
-
private Void checkWithBlock(WithBlockExpr expr)
- enterFinally
-
override Void enterFinally(TryStmt stmt)
Callback when entering a finally block
- enterStmt
-
override Void enterStmt(Stmt stmt)
Callback when entering a stmt.
- exitFinally
-
override Void exitFinally(TryStmt stmt)
Callback when exiting a finally block
- exitStmt
-
override Void exitStmt(Stmt stmt)
Callback when exiting a stmt.
-
private Int finallyDepth := 0
-
private Expr implicitToImmutable(CType fieldType, Expr rhs, CMethod toImmutable)
-
private Bool isSys
- make
-
new make(Compiler compiler)
-
private Int protectedRegionDepth := 0
- run
-
override Void run()
Run the step
-
private Str slotProtectionErr(CSlot slot, Bool setter := false)
- visitExpr
-
override Expr visitExpr(Expr expr)
Call to visit an expression. Return expr or a new expression if doing a replacement for the expression in the abstract syntax tree.
- visitFieldDef
-
override Void visitFieldDef(FieldDef f)
Callback when visiting a field definition.
- visitMethodDef
-
override Void visitMethodDef(MethodDef m)
Callback when visiting a method.
- visitStmt
-
override Void visitStmt(Stmt stmt)
Callback when visiting a stmt.
- visitTypeDef
-
override Void visitTypeDef(TypeDef t)
Callback when visiting a type definition.
More Info
Slots
- cast
- checkAbstractSlots
- checkArgs
- checkAssign
- checkAssignField
- checkBool
- checkBools
- checkBreak
- checkCall
- checkCompare
- checkConstType
- checkConstruction
- checkContinue
- checkCtor
- checkExprStmt
- checkField
- checkFieldFlags
- checkFor
- checkIf
- checkLocalDef
- checkMethodFlags
- checkMethodReturn
- checkNoNullSafes
- checkParam
- checkParams
- checkProtectionFlags
- checkRangeLiteral
- checkReturn
- checkSame
- checkShortcut
- checkSlotProtection
- checkSuper
- checkSwitch
- checkTernary
- checkThis
- checkThrow
- checkTry
- checkTypeCheck
- checkTypeFlags
- checkWhile
- checkWithBlock
- enterFinally
- enterStmt
- exitFinally
- exitStmt
- finallyDepth
- implicitToImmutable
- isConstFieldType
- isSys
- make
- protectedRegionDepth
- run
- slotProtectionErr
- useFieldAccessor
- visitExpr
- visitFieldDef
- visitMethodDef
- visitStmt
- visitTypeDef