class compiler::ConstChecks

sys::Obj
  compiler::CompilerSupport
    compiler::CompilerStep
      compiler::ConstChecks

Source

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
}
curCtor

MethodDef? curCtor

Source

fieldCheck

MethodDef? fieldCheck

Source

make

new make(Compiler compiler)

Source

run

virtual override Void run()

Source

visitStmt

virtual override Stmt[]? visitStmt(Stmt stmt)

Source