starlight-cli 1.0.32 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -5
- package/package.json +1 -1
- package/src/evaluator.js +4 -5
package/dist/index.js
CHANGED
|
@@ -1500,19 +1500,18 @@ async evaluate(node, env = this.global) {
|
|
|
1500
1500
|
const callee = await this.evaluate(node.callee, env);
|
|
1501
1501
|
|
|
1502
1502
|
if (typeof callee === 'object' && callee.body) {
|
|
1503
|
-
|
|
1503
|
+
const evaluator = this; // <- capture the current evaluator
|
|
1504
1504
|
const Constructor = function(...args) {
|
|
1505
1505
|
const newEnv = new Environment(callee.env);
|
|
1506
|
-
newEnv.define('this', this);
|
|
1506
|
+
newEnv.define('this', this);
|
|
1507
1507
|
for (let i = 0; i < callee.params.length; i++) {
|
|
1508
1508
|
newEnv.define(callee.params[i], args[i]);
|
|
1509
1509
|
}
|
|
1510
|
-
return
|
|
1511
|
-
}
|
|
1510
|
+
return evaluator.evaluate(callee.body, newEnv); // use captured evaluator
|
|
1511
|
+
};
|
|
1512
1512
|
|
|
1513
1513
|
const args = [];
|
|
1514
1514
|
for (const a of node.arguments) args.push(await this.evaluate(a, env));
|
|
1515
|
-
|
|
1516
1515
|
return new Constructor(...args);
|
|
1517
1516
|
}
|
|
1518
1517
|
|
package/package.json
CHANGED
package/src/evaluator.js
CHANGED
|
@@ -157,19 +157,18 @@ async evaluate(node, env = this.global) {
|
|
|
157
157
|
const callee = await this.evaluate(node.callee, env);
|
|
158
158
|
|
|
159
159
|
if (typeof callee === 'object' && callee.body) {
|
|
160
|
-
|
|
160
|
+
const evaluator = this; // <- capture the current evaluator
|
|
161
161
|
const Constructor = function(...args) {
|
|
162
162
|
const newEnv = new Environment(callee.env);
|
|
163
|
-
newEnv.define('this', this);
|
|
163
|
+
newEnv.define('this', this);
|
|
164
164
|
for (let i = 0; i < callee.params.length; i++) {
|
|
165
165
|
newEnv.define(callee.params[i], args[i]);
|
|
166
166
|
}
|
|
167
|
-
return
|
|
168
|
-
}
|
|
167
|
+
return evaluator.evaluate(callee.body, newEnv); // use captured evaluator
|
|
168
|
+
};
|
|
169
169
|
|
|
170
170
|
const args = [];
|
|
171
171
|
for (const a of node.arguments) args.push(await this.evaluate(a, env));
|
|
172
|
-
|
|
173
172
|
return new Constructor(...args);
|
|
174
173
|
}
|
|
175
174
|
|