starlight-cli 1.0.48 → 1.0.49

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 CHANGED
@@ -1388,12 +1388,13 @@ class Environment {
1388
1388
  return false;
1389
1389
  }
1390
1390
 
1391
- get(name, node) {
1391
+ get(name, node, source) {
1392
1392
  if (name in this.store) return this.store[name];
1393
- if (this.parent) return this.parent.get(name, node);
1394
- throw new RuntimeError(`Undefined variable: ${name}`, node);
1393
+ if (this.parent) return this.parent.get(name, node, source);
1394
+ throw new RuntimeError(`Undefined variable: ${name}`, node, source);
1395
1395
  }
1396
1396
 
1397
+
1397
1398
  set(name, value) {
1398
1399
  if (name in this.store) { this.store[name] = value; return value; }
1399
1400
  if (this.parent && this.parent.has(name)) { return this.parent.set(name, value); }
@@ -1577,7 +1578,7 @@ async evaluate(node, env = this.global) {
1577
1578
  case 'LogicalExpression': return await this.evalLogical(node, env);
1578
1579
  case 'UnaryExpression': return await this.evalUnary(node, env);
1579
1580
  case 'Literal': return node.value;
1580
- case 'Identifier': return env.get(node.name, node);
1581
+ case 'Identifier': return env.get(node.name, node, this.source);
1581
1582
  case 'IfStatement': return await this.evalIf(node, env);
1582
1583
  case 'WhileStatement': return await this.evalWhile(node, env);
1583
1584
  case 'ForStatement':
@@ -1805,7 +1806,7 @@ async evalCompoundAssignment(node, env) {
1805
1806
  const left = node.left;
1806
1807
  let current;
1807
1808
 
1808
- if (left.type === 'Identifier') current = env.get(left.name);
1809
+ if (left.type === 'Identifier') current = env.get(left.name, left, this.source);
1809
1810
  else if (left.type === 'MemberExpression') current = await this.evalMember(left, env);
1810
1811
  else if (left.type === 'IndexExpression') current = await this.evalIndex(left, env);
1811
1812
  else throw new RuntimeError('Invalid compound assignment target', node, this.source);
@@ -2109,7 +2110,7 @@ if (!(node.property in obj)) throw new RuntimeError(`Property '${node.property}'
2109
2110
  async evalUpdate(node, env) {
2110
2111
  const arg = node.argument;
2111
2112
  const getCurrent = async () => {
2112
- if (arg.type === 'Identifier') return env.get(arg.name);
2113
+ if (arg.type === 'Identifier') return env.get(arg.name, arg, this.source);
2113
2114
  if (arg.type === 'MemberExpression') return await this.evalMember(arg, env);
2114
2115
  if (arg.type === 'IndexExpression') return await this.evalIndex(arg, env);
2115
2116
  throw new RuntimeError('Invalid update target', node, this.source);
@@ -3300,7 +3301,7 @@ const Lexer = __nccwpck_require__(211);
3300
3301
  const Parser = __nccwpck_require__(222);
3301
3302
  const Evaluator = __nccwpck_require__(112);
3302
3303
 
3303
- const VERSION = '1.0.48';
3304
+ const VERSION = '1.0.49';
3304
3305
 
3305
3306
  const COLOR = {
3306
3307
  reset: '\x1b[0m',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-cli",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "description": "Starlight Programming Language CLI",
5
5
  "bin": {
6
6
  "starlight": "index.js"
package/src/evaluator.js CHANGED
@@ -45,12 +45,13 @@ class Environment {
45
45
  return false;
46
46
  }
47
47
 
48
- get(name, node) {
48
+ get(name, node, source) {
49
49
  if (name in this.store) return this.store[name];
50
- if (this.parent) return this.parent.get(name, node);
51
- throw new RuntimeError(`Undefined variable: ${name}`, node);
50
+ if (this.parent) return this.parent.get(name, node, source);
51
+ throw new RuntimeError(`Undefined variable: ${name}`, node, source);
52
52
  }
53
53
 
54
+
54
55
  set(name, value) {
55
56
  if (name in this.store) { this.store[name] = value; return value; }
56
57
  if (this.parent && this.parent.has(name)) { return this.parent.set(name, value); }
@@ -234,7 +235,7 @@ async evaluate(node, env = this.global) {
234
235
  case 'LogicalExpression': return await this.evalLogical(node, env);
235
236
  case 'UnaryExpression': return await this.evalUnary(node, env);
236
237
  case 'Literal': return node.value;
237
- case 'Identifier': return env.get(node.name, node);
238
+ case 'Identifier': return env.get(node.name, node, this.source);
238
239
  case 'IfStatement': return await this.evalIf(node, env);
239
240
  case 'WhileStatement': return await this.evalWhile(node, env);
240
241
  case 'ForStatement':
@@ -462,7 +463,7 @@ async evalCompoundAssignment(node, env) {
462
463
  const left = node.left;
463
464
  let current;
464
465
 
465
- if (left.type === 'Identifier') current = env.get(left.name);
466
+ if (left.type === 'Identifier') current = env.get(left.name, left, this.source);
466
467
  else if (left.type === 'MemberExpression') current = await this.evalMember(left, env);
467
468
  else if (left.type === 'IndexExpression') current = await this.evalIndex(left, env);
468
469
  else throw new RuntimeError('Invalid compound assignment target', node, this.source);
@@ -766,7 +767,7 @@ if (!(node.property in obj)) throw new RuntimeError(`Property '${node.property}'
766
767
  async evalUpdate(node, env) {
767
768
  const arg = node.argument;
768
769
  const getCurrent = async () => {
769
- if (arg.type === 'Identifier') return env.get(arg.name);
770
+ if (arg.type === 'Identifier') return env.get(arg.name, arg, this.source);
770
771
  if (arg.type === 'MemberExpression') return await this.evalMember(arg, env);
771
772
  if (arg.type === 'IndexExpression') return await this.evalIndex(arg, env);
772
773
  throw new RuntimeError('Invalid update target', node, this.source);
package/src/starlight.js CHANGED
@@ -9,7 +9,7 @@ const Lexer = require('./lexer');
9
9
  const Parser = require('./parser');
10
10
  const Evaluator = require('./evaluator');
11
11
 
12
- const VERSION = '1.0.48';
12
+ const VERSION = '1.0.49';
13
13
 
14
14
  const COLOR = {
15
15
  reset: '\x1b[0m',