| 88 | * Executing this operation returns the identifier which can be used to refer to the variable. |
| 89 | */ |
| 90 | export class TcbBlockVariableOp extends TcbOp { |
| 91 | constructor( |
| 92 | private tcb: Context, |
| 93 | private scope: Scope, |
| 94 | private initializer: TcbExpr, |
| 95 | private variable: Variable, |
| 96 | ) { |
| 97 | super(); |
| 98 | } |
| 99 | |
| 100 | override get optional() { |
| 101 | return false; |
| 102 | } |
| 103 | |
| 104 | override execute(): TcbExpr { |
| 105 | const id = new TcbExpr(this.tcb.allocateId()); |
| 106 | id.addParseSpanInfo(this.variable.keySpan); |
| 107 | this.initializer.wrapForTypeChecker(); |
| 108 | const variable = new TcbExpr(`var ${id.print()} = ${this.initializer.print()}`); |
| 109 | variable.addParseSpanInfo(this.variable.sourceSpan); |
| 110 | this.scope.addStatement(variable); |
| 111 | return id; |
| 112 | } |
| 113 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…