Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.etheller.interpreter.ast.execution.instruction;

import com.etheller.interpreter.ast.execution.JassThread;

public class GlobalBeginFunctionInstruction extends BeginFunctionInstruction {
private boolean isDefined = false; // Prevent from multiple JassProgram::initialize calls to re-register the already defined global variables.

public GlobalBeginFunctionInstruction(final int lineNo, final String sourceFile, final String name) {
super(lineNo, sourceFile, name);
}

@Override
public void run(JassThread thread) {
super.run(thread);
if (isDefined) {
thread.instructionPtr = thread.stackFrame.returnAddressInstructionPtr;
return;
}
isDefined = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.etheller.interpreter.ast.execution.JassThread;
import com.etheller.interpreter.ast.execution.instruction.BeginFunctionInstruction;
import com.etheller.interpreter.ast.execution.instruction.BranchInstruction;
import com.etheller.interpreter.ast.execution.instruction.GlobalBeginFunctionInstruction;
import com.etheller.interpreter.ast.execution.instruction.InstructionAppendingJassStatementVisitor;
import com.etheller.interpreter.ast.execution.instruction.JassInstruction;
import com.etheller.interpreter.ast.execution.instruction.PushLiteralInstruction;
Expand Down Expand Up @@ -384,7 +385,7 @@ public void innerBeginDefiningGlobals(final int lineNo, final String sourceFile)
else {
this.functionNameToInstructionPtr.put(INIT_GLOBALS_AUTOGEN_FXN_NAME, this.instructions.size());
}
this.instructions.add(new BeginFunctionInstruction(lineNo, sourceFile, INIT_GLOBALS_AUTOGEN_FXN_NAME));
this.instructions.add(new GlobalBeginFunctionInstruction(lineNo, sourceFile, INIT_GLOBALS_AUTOGEN_FXN_NAME));
}

public UserJassFunction getFunctionDefinitionByName(final String name) {
Expand Down