class
compiler::ConstChecks
sys::Obj compiler::CompilerSupport compiler::CompilerStep compiler::ConstChecks
ConstChecks adds hooks into constructors and it-blocks to ensure that an attempt to set a const field will throw ConstErr if not in the objects constructor. We also use this step to insert the runtime checks for non-nullable fields.
For each it-block which sets const fields:
doCall(Foo it) { this.checkInCtor(it) ... }
For each constructor which takes an it-block:
new make(..., |This| f) { f?.enterCtor(this) ... checksField$Foo() // if non-nullable fields need runtime checks f?.exitCtor() // for every return return }
Slots
- curCtorSource
-
MethodDef? curCtor
- fieldCheckSource
-
MethodDef? fieldCheck
-
private MethodVar itBlockVar()
- makeSource
-
new make(Compiler compiler)
-
private Void processClosure(ClosureExpr c)
- runSource
-
override Void run()
Overrides compiler::CompilerStep.run
Doc inherited from compiler::CompilerStep.run
Run the step
- visitStmtSource
-
override Stmt[]? visitStmt(Stmt stmt)
Overrides compiler::Visitor.visitStmt
Doc inherited from compiler::Visitor.visitStmt
Callback when visiting a stmt. Return a list to replace the statement with new statements, or return null to keep existing statement.