Skip to content

Commit 0d114d0

Browse files
committed
execute global initialization after all the other declarations have finished
1 parent 30cf1b2 commit 0d114d0

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/org/rascalmpl/semantics/dynamic/Module.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,18 @@ public Result<IValue> interpret(IEvaluator<Result<IValue>> eval) {
5858
List<Toplevel> decls = this.getBody().getToplevels();
5959
eval.__getTypeDeclarator().evaluateDeclarations(decls, eval.getCurrentEnvt(), false);
6060

61+
// first everything that is not a global
6162
for (Toplevel l : decls) {
62-
l.interpret(eval);
63+
if (!l.getDeclaration().isVariable()) {
64+
l.interpret(eval);
65+
}
66+
}
67+
68+
// then the globals which may depend on the previous
69+
for (Toplevel l : decls) {
70+
if (l.getDeclaration().isVariable()) {
71+
l.interpret(eval);
72+
}
6373
}
6474
}
6575
finally {

0 commit comments

Comments
 (0)