starlight-cli 1.0.49 → 1.0.50
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 +25 -7
- package/package.json +1 -1
- package/src/evaluator.js +24 -6
- package/src/starlight.js +1 -1
package/dist/index.js
CHANGED
|
@@ -1741,15 +1741,27 @@ async evalBlock(node, env) {
|
|
|
1741
1741
|
try {
|
|
1742
1742
|
result = await this.evaluate(stmt, env);
|
|
1743
1743
|
} catch (e) {
|
|
1744
|
-
if (
|
|
1745
|
-
|
|
1746
|
-
|
|
1744
|
+
if (
|
|
1745
|
+
e instanceof RuntimeError ||
|
|
1746
|
+
e instanceof ReturnValue ||
|
|
1747
|
+
e instanceof BreakSignal ||
|
|
1748
|
+
e instanceof ContinueSignal
|
|
1749
|
+
) {
|
|
1750
|
+
throw e;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
throw new RuntimeError(
|
|
1754
|
+
e.message || 'Error in block',
|
|
1755
|
+
stmt,
|
|
1756
|
+
this.source
|
|
1757
|
+
);
|
|
1747
1758
|
}
|
|
1748
1759
|
}
|
|
1749
1760
|
return result;
|
|
1750
1761
|
}
|
|
1751
1762
|
|
|
1752
1763
|
|
|
1764
|
+
|
|
1753
1765
|
async evalVarDeclaration(node, env) {
|
|
1754
1766
|
if (!node.expr) {
|
|
1755
1767
|
throw new RuntimeError('Variable declaration requires an initializer', node, this.source);
|
|
@@ -2057,9 +2069,15 @@ async evalCall(node, env) {
|
|
|
2057
2069
|
const callEnv = new Environment(fn.env);
|
|
2058
2070
|
|
|
2059
2071
|
for (let i = 0; i < fn.params.length; i++) {
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2072
|
+
const argVal = node.arguments[i]
|
|
2073
|
+
? await this.evaluate(node.arguments[i], env)
|
|
2074
|
+
: null;
|
|
2075
|
+
|
|
2076
|
+
const param = fn.params[i];
|
|
2077
|
+
const paramName = typeof param === 'string' ? param : param.name;
|
|
2078
|
+
|
|
2079
|
+
callEnv.define(paramName, argVal);
|
|
2080
|
+
}
|
|
2063
2081
|
|
|
2064
2082
|
try {
|
|
2065
2083
|
const result = await this.evaluate(fn.body, callEnv);
|
|
@@ -3301,7 +3319,7 @@ const Lexer = __nccwpck_require__(211);
|
|
|
3301
3319
|
const Parser = __nccwpck_require__(222);
|
|
3302
3320
|
const Evaluator = __nccwpck_require__(112);
|
|
3303
3321
|
|
|
3304
|
-
const VERSION = '1.0.
|
|
3322
|
+
const VERSION = '1.0.50';
|
|
3305
3323
|
|
|
3306
3324
|
const COLOR = {
|
|
3307
3325
|
reset: '\x1b[0m',
|
package/package.json
CHANGED
package/src/evaluator.js
CHANGED
|
@@ -398,15 +398,27 @@ async evalBlock(node, env) {
|
|
|
398
398
|
try {
|
|
399
399
|
result = await this.evaluate(stmt, env);
|
|
400
400
|
} catch (e) {
|
|
401
|
-
if (
|
|
402
|
-
|
|
403
|
-
|
|
401
|
+
if (
|
|
402
|
+
e instanceof RuntimeError ||
|
|
403
|
+
e instanceof ReturnValue ||
|
|
404
|
+
e instanceof BreakSignal ||
|
|
405
|
+
e instanceof ContinueSignal
|
|
406
|
+
) {
|
|
407
|
+
throw e;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
throw new RuntimeError(
|
|
411
|
+
e.message || 'Error in block',
|
|
412
|
+
stmt,
|
|
413
|
+
this.source
|
|
414
|
+
);
|
|
404
415
|
}
|
|
405
416
|
}
|
|
406
417
|
return result;
|
|
407
418
|
}
|
|
408
419
|
|
|
409
420
|
|
|
421
|
+
|
|
410
422
|
async evalVarDeclaration(node, env) {
|
|
411
423
|
if (!node.expr) {
|
|
412
424
|
throw new RuntimeError('Variable declaration requires an initializer', node, this.source);
|
|
@@ -714,9 +726,15 @@ async evalCall(node, env) {
|
|
|
714
726
|
const callEnv = new Environment(fn.env);
|
|
715
727
|
|
|
716
728
|
for (let i = 0; i < fn.params.length; i++) {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
729
|
+
const argVal = node.arguments[i]
|
|
730
|
+
? await this.evaluate(node.arguments[i], env)
|
|
731
|
+
: null;
|
|
732
|
+
|
|
733
|
+
const param = fn.params[i];
|
|
734
|
+
const paramName = typeof param === 'string' ? param : param.name;
|
|
735
|
+
|
|
736
|
+
callEnv.define(paramName, argVal);
|
|
737
|
+
}
|
|
720
738
|
|
|
721
739
|
try {
|
|
722
740
|
const result = await this.evaluate(fn.body, callEnv);
|