MCPcopy Create free account
hub / github.com/dynjs/dynjs / IRJSProgram

Class IRJSProgram

src/main/java/org/dynjs/ir/IRJSProgram.java:27–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25import java.util.List;
26
27public class IRJSProgram implements JSProgram {
28
29 private final BlockManager blockManager;
30 private Scope scope;
31 private Instruction[] instructions;
32
33 public IRJSProgram(BlockManager blockManager, Scope scope) {
34 this.blockManager = blockManager;
35 this.scope = scope;
36 this.instructions = scope.prepareForInterpret();
37
38// System.out.println("PROGRAM:");
39 int size = instructions.length;
40 for (int i = 0; i < size; i++) {
41 System.out.println("" + instructions[i]);
42 }
43 }
44
45 @Override
46 public Completion execute(ExecutionContext context) {
47 // Allocate space for variables of this function and establish link to captured ones.
48 context.allocVars(scope.getLocalVariableSize(), null);
49
50 return Completion.createNormal(Interpreter.execute(context, scope, instructions));
51 }
52
53 @Override
54 public BlockManager getBlockManager() {
55 return this.blockManager;
56 }
57
58 @Override
59 public String getFileName() {
60 return scope.getFileName();
61 }
62
63 @Override
64 public boolean isStrict() {
65 return scope.isStrict();
66 }
67
68 // FIXME: Remove or replace once we learn how IR should handle these
69 @Override
70 public List<FunctionDeclaration> getFunctionDeclarations() {
71 return FunctionDeclaration.EMPTY_LIST;
72 }
73
74 // FIXME: Remove or replace once we learn how IR should handle these
75 @Override
76 public List<VariableDeclaration> getVariableDeclarations() {
77 return VariableDeclaration.EMPTY_LIST;
78 }
79}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected