Skip to content

Commit 2c06833

Browse files
committed
passing modume names to all ast blocks
1 parent 9f5cb9c commit 2c06833

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/evaluator/evaluator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class Evaluator {
4949
if (err instanceof JspyEvalError) {
5050
throw err;
5151
} else {
52-
const loc = node.loc ? node.loc : [0, 0]
52+
const loc = node.loc ? node.loc : [0, 0];
5353
throw new JspyEvalError(ast.name, loc[0], loc[1], err.message || err)
5454
}
5555
}
@@ -131,9 +131,9 @@ export class Evaluator {
131131
if (node.type === 'if') {
132132
const ifNode = node as IfNode;
133133
if (this.evalNode(ifNode.conditionNode, blockContext)) {
134-
this.evalBlock({ type: 'if', body: ifNode.ifBody } as AstBlock, blockContext);
134+
this.evalBlock({ name: blockContext.moduleName, type: 'if', body: ifNode.ifBody } as AstBlock, blockContext);
135135
} else if (ifNode.elseBody) {
136-
this.evalBlock({ type: 'if', body: ifNode.elseBody } as AstBlock, blockContext);
136+
this.evalBlock({ name: blockContext.moduleName, type: 'if', body: ifNode.elseBody } as AstBlock, blockContext);
137137
}
138138

139139
return;
@@ -166,7 +166,7 @@ export class Evaluator {
166166

167167
for (let item of array) {
168168
blockContext.blockScope.set(forNode.itemVarName, item);
169-
this.evalBlock({ type: 'for', body: forNode.body } as AstBlock, blockContext);
169+
this.evalBlock({ name: blockContext.moduleName, type: 'for', body: forNode.body } as AstBlock, blockContext);
170170
if (blockContext.continueCalled) { blockContext.continueCalled = false; }
171171
if (blockContext.breakCalled) { break; }
172172
}
@@ -178,7 +178,7 @@ export class Evaluator {
178178
const whileNode = node as WhileNode;
179179

180180
while (this.evalNode(whileNode.condition, blockContext)) {
181-
this.evalBlock({ type: 'while', body: whileNode.body } as AstBlock, blockContext);
181+
this.evalBlock({ name: blockContext.moduleName, type: 'while', body: whileNode.body } as AstBlock, blockContext);
182182

183183
if (blockContext.continueCalled) { blockContext.continueCalled = false; }
184184
if (blockContext.breakCalled) { break; }

src/evaluator/evaluatorAsync.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ export class EvaluatorAsync {
138138
if (node.type === 'if') {
139139
const ifNode = node as IfNode;
140140
if (await this.evalNodeAsync(ifNode.conditionNode, blockContext)) {
141-
await this.evalBlockAsync({ type: 'if', body: ifNode.ifBody } as AstBlock, blockContext);
141+
await this.evalBlockAsync({ name: blockContext.moduleName, type: 'if', body: ifNode.ifBody } as AstBlock, blockContext);
142142
} else if (ifNode.elseBody) {
143-
await this.evalBlockAsync({ type: 'if', body: ifNode.elseBody } as AstBlock, blockContext);
143+
await this.evalBlockAsync({ name: blockContext.moduleName, type: 'if', body: ifNode.elseBody } as AstBlock, blockContext);
144144
}
145145

146146
return;
@@ -173,7 +173,7 @@ export class EvaluatorAsync {
173173

174174
for (let item of array) {
175175
blockContext.blockScope.set(forNode.itemVarName, item);
176-
await this.evalBlockAsync({ type: 'for', body: forNode.body } as AstBlock, blockContext);
176+
await this.evalBlockAsync({ name: blockContext.moduleName, type: 'for', body: forNode.body } as AstBlock, blockContext);
177177
if (blockContext.continueCalled) { blockContext.continueCalled = false; }
178178
if (blockContext.breakCalled) { break; }
179179
}
@@ -185,7 +185,7 @@ export class EvaluatorAsync {
185185
const whileNode = node as WhileNode;
186186

187187
while (await this.evalNodeAsync(whileNode.condition, blockContext)) {
188-
await this.evalBlockAsync({ type: 'while', body: whileNode.body } as AstBlock, blockContext);
188+
await this.evalBlockAsync({ name: blockContext.moduleName, type: 'while', body: whileNode.body } as AstBlock, blockContext);
189189

190190
if (blockContext.continueCalled) { blockContext.continueCalled = false; }
191191
if (blockContext.breakCalled) { break; }

0 commit comments

Comments
 (0)