starlight-cli 1.0.32 → 1.0.34
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 +406 -344
- package/package.json +1 -1
- package/src/evaluator.js +4 -5
- package/src/parser.js +403 -340
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
|
|