Skip to content

Commit

Permalink
fix: update uid of CALL_MAIN for each evaluate
Browse files Browse the repository at this point in the history
Currently, we are doing a in-place uid assign to `CALL_MAIN` and we only
assign a uid if there no uid in the node. However, since `CALL_MAIN` in
the outer scope of `evaluate`, we do not assign the right uid on each
run of `evaluate`, since the `SourceFile` uid changes.
  • Loading branch information
shenyih0ng committed Mar 31, 2024
1 parent 9f8e249 commit e0caae7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/go-slang/ece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ interface Context {
A: AstMap
}

const CALL_MAIN: CallExpression = {
type: NodeType.CallExpression,
callee: { type: NodeType.Identifier, name: 'main' },
args: []
}

export function evaluate(program: SourceFile, slangContext: SlangContext): Value {
const C = new Stack<Instruction | HeapAddress>()
const S = new Stack<any>()
Expand Down Expand Up @@ -95,6 +89,11 @@ export function evaluate(program: SourceFile, slangContext: SlangContext): Value
const Context = { C, S, E, B, H, A }

// start the program by calling `main`
const CALL_MAIN: CallExpression = {
type: NodeType.CallExpression,
callee: { type: NodeType.Identifier, name: 'main' },
args: []
}
C.pushR(H.alloc(program), H.alloc(CALL_MAIN))

while (!C.isEmpty()) {
Expand Down

0 comments on commit e0caae7

Please sign in to comment.