greybel-interpreter 0.6.6 → 0.7.0

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/cps.js CHANGED
@@ -243,6 +243,7 @@ var CPSMap = function (visit, context) {
243
243
  'FeatureEnvarExpression': function (_item) {
244
244
  throw new Error('Not supported');
245
245
  },
246
+ 'InvalidCodeExpression': function (_item) { },
246
247
  'IfShortcutStatement': function (item) {
247
248
  return __awaiter(this, void 0, void 0, function () {
248
249
  var op, _a, _b, clausesItem, _c, _d, e_4_1;
@@ -685,7 +686,9 @@ var CPSMap = function (visit, context) {
685
686
  case 2:
686
687
  code = _a.sent();
687
688
  context.currentTarget = target;
688
- chunk = new import_1.default(item, target, code).prepare(visit);
689
+ return [4 /*yield*/, (new import_1.default(item, target, code).prepare(visit))];
690
+ case 3:
691
+ chunk = _a.sent();
689
692
  context.currentTarget = context.target;
690
693
  return [2 /*return*/, chunk];
691
694
  }
@@ -708,7 +711,9 @@ var CPSMap = function (visit, context) {
708
711
  case 2:
709
712
  code = _a.sent();
710
713
  context.currentTarget = target;
711
- chunk = new include_1.default(item, target, code).prepare(visit);
714
+ return [4 /*yield*/, (new include_1.default(item, target, code).prepare(visit))];
715
+ case 3:
716
+ chunk = _a.sent();
712
717
  context.currentTarget = context.target;
713
718
  return [2 /*return*/, chunk];
714
719
  }
@@ -731,7 +736,9 @@ var CPSMap = function (visit, context) {
731
736
  case 2:
732
737
  code = _a.sent();
733
738
  context.currentTarget = target;
734
- chunk = new include_1.default(item, target, code).prepare(visit);
739
+ return [4 /*yield*/, (new include_1.default(item, target, code).prepare(visit))];
740
+ case 3:
741
+ chunk = _a.sent();
735
742
  context.currentTarget = context.target;
736
743
  return [2 /*return*/, chunk];
737
744
  }
@@ -842,12 +849,12 @@ var CPS = /** @class */ (function () {
842
849
  return [2 /*return*/, ''];
843
850
  if (o.type == null) {
844
851
  console.error('Error ast type:', o);
845
- throw new Error('Unexpected as type');
852
+ throw new Error("Current CPS iteration item does not have a type.");
846
853
  }
847
854
  fn = me.cpsMap[o.type];
848
855
  if (fn == null) {
849
856
  console.error('Error ast:', o);
850
- throw new Error('Type does not exist ' + o.type);
857
+ throw new Error("".concat(o.type, " is not a supported AST type."));
851
858
  }
852
859
  return [4 /*yield*/, fn.call(me, o)];
853
860
  case 1:
@@ -1,15 +1,11 @@
1
1
  import { CustomObjectType, Callable } from '../types/custom-type';
2
- export interface CustomMapIterableItem {
3
- key: string;
4
- value: any;
5
- }
6
- export declare class CustomMapIterator implements Iterator<CustomMapIterableItem> {
7
- value: any;
2
+ export declare class CustomMapIterator implements Iterator<CustomMap> {
3
+ value: Map<string, any>;
8
4
  index: number;
9
- constructor(value: any);
10
- next(): IteratorResult<CustomMapIterableItem>;
5
+ constructor(value: Map<string, any>);
6
+ next(): IteratorResult<CustomMap>;
11
7
  }
12
- export default class CustomMap extends CustomObjectType implements Iterable<CustomMapIterableItem> {
8
+ export default class CustomMap extends CustomObjectType implements Iterable<CustomMap> {
13
9
  static intrinsics: Map<string, Function>;
14
10
  value: Map<string, any>;
15
11
  isInstance: boolean;
@@ -44,6 +44,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.CustomMapIterator = void 0;
47
+ var nil_1 = __importDefault(require("./nil"));
47
48
  var custom_type_1 = require("../types/custom-type");
48
49
  var operation_1 = require("../types/operation");
49
50
  var string_1 = __importDefault(require("./string"));
@@ -55,19 +56,19 @@ var CustomMapIterator = /** @class */ (function () {
55
56
  }
56
57
  CustomMapIterator.prototype.next = function () {
57
58
  var me = this;
58
- var keys = Object.keys(me.value);
59
+ var keys = Array.from(me.value.keys());
59
60
  if (me.index === keys.length) {
60
61
  return {
61
- value: null,
62
+ value: new nil_1.default(),
62
63
  done: true
63
64
  };
64
65
  }
65
66
  var key = keys[me.index++];
66
67
  return {
67
- value: {
68
- key: key,
69
- value: me.value[key]
70
- },
68
+ value: new CustomMap(new Map([
69
+ ['key', new string_1.default(key)],
70
+ ['value', me.value.get(key)]
71
+ ])),
71
72
  done: false
72
73
  };
73
74
  };
@@ -150,21 +150,22 @@ var CallExpression = /** @class */ (function (_super) {
150
150
  state: context_1.ContextState.TEMPORARY
151
151
  });
152
152
  var evaluate = function (node) {
153
+ var _a;
153
154
  return __awaiter(this, void 0, void 0, function () {
154
- var args, pathExpr, callable_1, _a, callable, _b;
155
- var _c, _d;
156
- return __generator(this, function (_e) {
157
- switch (_e.label) {
155
+ var args, pathExpr, callable_1, _b, callable, _c;
156
+ var _d, _e;
157
+ return __generator(this, function (_f) {
158
+ switch (_f.label) {
158
159
  case 0:
159
160
  if (node instanceof expression_1.Expression) {
160
161
  return [2 /*return*/, node.get(opc)];
161
162
  }
162
163
  return [4 /*yield*/, node.resolveArgs(operationContext)];
163
164
  case 1:
164
- args = _e.sent();
165
+ args = _f.sent();
165
166
  return [4 /*yield*/, node.path.get(opc, me.expr)];
166
167
  case 2:
167
- pathExpr = _e.sent();
168
+ pathExpr = _f.sent();
168
169
  operationContext.debugger.debug('Line', me.ast.start.line, 'CallExpression', 'pathExpr', pathExpr);
169
170
  if (!pathExpr.handle) return [3 /*break*/, 7];
170
171
  if (!((0, typer_1.isCustomMap)(pathExpr.handle) ||
@@ -172,29 +173,29 @@ var CallExpression = /** @class */ (function (_super) {
172
173
  (0, typer_1.isCustomString)(pathExpr.handle))) return [3 /*break*/, 6];
173
174
  return [4 /*yield*/, pathExpr.handle.getCallable(pathExpr.path)];
174
175
  case 3:
175
- callable_1 = _e.sent();
176
+ callable_1 = _f.sent();
176
177
  if (!(callable_1.origin instanceof operation_1.Operation)) return [3 /*break*/, 4];
177
178
  opc.setMemory('args', args);
178
179
  return [2 /*return*/, callable_1.origin.run(opc)];
179
180
  case 4:
180
181
  if (!(callable_1.origin instanceof Function)) return [3 /*break*/, 6];
181
- _a = typer_1.cast;
182
- return [4 /*yield*/, (_c = callable_1.origin).call.apply(_c, __spreadArray([pathExpr.handle], __read(args), false))];
183
- case 5: return [2 /*return*/, _a.apply(void 0, [_e.sent()])];
182
+ _b = typer_1.cast;
183
+ return [4 /*yield*/, (_d = callable_1.origin).call.apply(_d, __spreadArray([pathExpr.handle], __read(args), false))];
184
+ case 5: return [2 /*return*/, _b.apply(void 0, [_f.sent()])];
184
185
  case 6:
185
- operationContext.debugger.raise('Unexpected handle call', me, pathExpr);
186
- _e.label = 7;
186
+ operationContext.debugger.raise("Cannot call ".concat((_a = pathExpr.path) === null || _a === void 0 ? void 0 : _a.join('.'), ". Doesn't seem to be a function."), me, pathExpr);
187
+ _f.label = 7;
187
188
  case 7: return [4 /*yield*/, opc.getCallable(pathExpr.path)];
188
189
  case 8:
189
- callable = _e.sent();
190
+ callable = _f.sent();
190
191
  opc.setMemory('args', args);
191
192
  if (!(callable.origin instanceof operation_1.Operation)) return [3 /*break*/, 9];
192
193
  return [2 /*return*/, callable.origin.run(opc)];
193
194
  case 9:
194
195
  if (!(callable.origin instanceof Function)) return [3 /*break*/, 11];
195
- _b = typer_1.cast;
196
- return [4 /*yield*/, (_d = callable.origin).call.apply(_d, __spreadArray([callable.context], __read(args), false))];
197
- case 10: return [2 /*return*/, _b.apply(void 0, [_e.sent()])];
196
+ _c = typer_1.cast;
197
+ return [4 /*yield*/, (_e = callable.origin).call.apply(_e, __spreadArray([callable.context], __read(args), false))];
198
+ case 10: return [2 /*return*/, _c.apply(void 0, [_f.sent()])];
198
199
  case 11: return [2 /*return*/, (0, typer_1.cast)(callable.origin)];
199
200
  }
200
201
  });
@@ -56,6 +56,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
56
56
  Object.defineProperty(exports, "__esModule", { value: true });
57
57
  exports.ExpressionSegment = void 0;
58
58
  var expression_1 = require("../types/expression");
59
+ var operation_1 = require("../types/operation");
59
60
  var list_1 = __importDefault(require("../custom-types/list"));
60
61
  var typer_1 = require("../typer");
61
62
  var ExpressionSegment = /** @class */ (function () {
@@ -98,30 +99,37 @@ var ListExpression = /** @class */ (function (_super) {
98
99
  var me = this;
99
100
  var evaluate = function (node) {
100
101
  return __awaiter(this, void 0, void 0, function () {
101
- var traverselPath, list, current, _a, _b;
102
- return __generator(this, function (_c) {
103
- switch (_c.label) {
102
+ var traverselPath, list, current, _a, _b, _c, _d;
103
+ return __generator(this, function (_e) {
104
+ switch (_e.label) {
104
105
  case 0:
105
106
  traverselPath = [].concat(node);
106
107
  list = [];
107
- _c.label = 1;
108
+ _e.label = 1;
108
109
  case 1:
109
- if (!(current = traverselPath.shift())) return [3 /*break*/, 6];
110
+ if (!(current = traverselPath.shift())) return [3 /*break*/, 8];
110
111
  if (!(0, typer_1.isCustomValue)(current)) return [3 /*break*/, 2];
111
112
  list.push(current);
112
- return [3 /*break*/, 5];
113
+ return [3 /*break*/, 7];
113
114
  case 2:
114
115
  if (!(current instanceof expression_1.Expression)) return [3 /*break*/, 4];
115
116
  _b = (_a = list).push;
116
117
  return [4 /*yield*/, current.get(operationContext)];
117
118
  case 3:
118
- _b.apply(_a, [_c.sent()]);
119
- return [3 /*break*/, 5];
119
+ _b.apply(_a, [_e.sent()]);
120
+ return [3 /*break*/, 7];
120
121
  case 4:
121
- operationContext.debugger.raise('Unexpected handle', me, current);
122
- _c.label = 5;
123
- case 5: return [3 /*break*/, 1];
124
- case 6: return [2 /*return*/, new list_1.default(list)];
122
+ if (!(current.value instanceof operation_1.Operation)) return [3 /*break*/, 6];
123
+ _d = (_c = list).push;
124
+ return [4 /*yield*/, current.value.get(operationContext)];
125
+ case 5:
126
+ _d.apply(_c, [_e.sent()]);
127
+ return [3 /*break*/, 7];
128
+ case 6:
129
+ operationContext.debugger.raise('Unexpected value in list.', me, current.value);
130
+ _e.label = 7;
131
+ case 7: return [3 /*break*/, 1];
132
+ case 8: return [2 /*return*/, new list_1.default(list)];
125
133
  }
126
134
  });
127
135
  });
@@ -167,7 +167,7 @@ var LogicalAndBinaryExpression = /** @class */ (function (_super) {
167
167
  if (!(node instanceof LogicalAndBinaryExpression)) return [3 /*break*/, 8];
168
168
  expr = node.expr;
169
169
  if (!exports.OPERATIONS[expr.operator]) {
170
- operationContext.debugger.raise('Unexpected expression type', me, expr);
170
+ operationContext.debugger.raise("Unexpected operator in condition. ".concat(expr.operator, " is not supported."), me, expr);
171
171
  }
172
172
  _a = expr.type;
173
173
  switch (_a) {
@@ -164,7 +164,7 @@ var MapExpression = /** @class */ (function (_super) {
164
164
  value = _b.sent();
165
165
  return [3 /*break*/, 8];
166
166
  case 7:
167
- operationContext.debugger.raise('Unexpected value', me, current.value);
167
+ operationContext.debugger.raise('Unexpected value in map.', me, current.value);
168
168
  _b.label = 8;
169
169
  case 8:
170
170
  // @ts-ignore: Key is always a literal
@@ -190,10 +190,11 @@ var PathExpression = /** @class */ (function (_super) {
190
190
  });
191
191
  };
192
192
  PathExpression.prototype.get = function (operationContext, parentExpr) {
193
+ var _a;
193
194
  return __awaiter(this, void 0, void 0, function () {
194
- var me, evaluate, resultExpr, context, value_1, _a, value, callable, _b;
195
- return __generator(this, function (_c) {
196
- switch (_c.label) {
195
+ var me, evaluate, resultExpr, context, value_1, _b, value, callable, _c;
196
+ return __generator(this, function (_d) {
197
+ switch (_d.label) {
197
198
  case 0:
198
199
  me = this;
199
200
  evaluate = function (node) {
@@ -231,7 +232,7 @@ var PathExpression = /** @class */ (function (_super) {
231
232
  handle = functionContext.context;
232
233
  }
233
234
  else {
234
- operationContext.debugger.raise('Unexpected self', me, current);
235
+ operationContext.debugger.raise('Unexpected self. Function does not appear to be bound to any context.', me, current);
235
236
  }
236
237
  return [3 /*break*/, 11];
237
238
  case 7:
@@ -267,7 +268,7 @@ var PathExpression = /** @class */ (function (_super) {
267
268
  traversedPath.push(value.toString());
268
269
  return [3 /*break*/, 16];
269
270
  case 15:
270
- operationContext.debugger.raise('Unexpected index', me, current);
271
+ operationContext.debugger.raise("Unexpected index with value ".concat(current === null || current === void 0 ? void 0 : current.toString(), " in path ").concat(traversedPath === null || traversedPath === void 0 ? void 0 : traversedPath.join('.'), " found."), me, current);
271
272
  _b.label = 16;
272
273
  case 16:
273
274
  if (!(handle && !parentExpr)) return [3 /*break*/, 18];
@@ -290,7 +291,7 @@ var PathExpression = /** @class */ (function (_super) {
290
291
  _b.label = 21;
291
292
  case 21:
292
293
  if (!(0, typer_1.isCustomList)(handle) && !(0, typer_1.isCustomString)(handle)) {
293
- operationContext.debugger.raise('Invalid type for slice', me, handle);
294
+ operationContext.debugger.raise("Unexpected slice attempt. ".concat(handle === null || handle === void 0 ? void 0 : handle.toString(), " does not seem to support slicing."), me, handle);
294
295
  }
295
296
  left = current.left;
296
297
  if (!(0, typer_1.isCustomValue)(left)) return [3 /*break*/, 22];
@@ -317,7 +318,7 @@ var PathExpression = /** @class */ (function (_super) {
317
318
  handle = handle.slice(left, right);
318
319
  return [3 /*break*/, 29];
319
320
  case 28:
320
- operationContext.debugger.raise('Unexpected handle', me, current);
321
+ operationContext.debugger.raise("Unexpected object in ".concat(traversedPath === null || traversedPath === void 0 ? void 0 : traversedPath.join('.'), ". Doesn't seem to be a function."), me, current);
321
322
  _b.label = 29;
322
323
  case 29:
323
324
  position++;
@@ -333,7 +334,7 @@ var PathExpression = /** @class */ (function (_super) {
333
334
  operationContext.debugger.debug('Line', me.ast.start.line, 'PathExpression', 'get', 'expr', me.expr);
334
335
  return [4 /*yield*/, evaluate(me.expr)];
335
336
  case 1:
336
- resultExpr = _c.sent();
337
+ resultExpr = _d.sent();
337
338
  if (!!parentExpr) return [3 /*break*/, 14];
338
339
  if (!resultExpr.handle) return [3 /*break*/, 8];
339
340
  if (!(resultExpr.path.length === 0)) return [3 /*break*/, 2];
@@ -345,33 +346,33 @@ var PathExpression = /** @class */ (function (_super) {
345
346
  context = resultExpr.handle;
346
347
  return [4 /*yield*/, context.get(resultExpr.path)];
347
348
  case 3:
348
- value_1 = _c.sent();
349
+ value_1 = _d.sent();
349
350
  if (!(value_1 instanceof operation_1.Operation)) return [3 /*break*/, 4];
350
351
  return [2 /*return*/, value_1.run(operationContext)];
351
352
  case 4:
352
353
  if (!(value_1 instanceof Function)) return [3 /*break*/, 6];
353
- _a = typer_1.cast;
354
+ _b = typer_1.cast;
354
355
  return [4 /*yield*/, value_1.call(context)];
355
- case 5: return [2 /*return*/, _a.apply(void 0, [_c.sent()])];
356
+ case 5: return [2 /*return*/, _b.apply(void 0, [_d.sent()])];
356
357
  case 6: return [2 /*return*/, value_1];
357
358
  case 7:
358
- operationContext.debugger.raise('Unexpected handle get', me, resultExpr);
359
- _c.label = 8;
359
+ operationContext.debugger.raise("Cannot call ".concat((_a = resultExpr.path) === null || _a === void 0 ? void 0 : _a.join('.'), ". Doesn't seem to be a function."), me, resultExpr);
360
+ _d.label = 8;
360
361
  case 8: return [4 /*yield*/, operationContext.get(resultExpr.path)];
361
362
  case 9:
362
- value = _c.sent();
363
+ value = _d.sent();
363
364
  if (!(value instanceof Function)) return [3 /*break*/, 12];
364
365
  return [4 /*yield*/, operationContext.getCallable(resultExpr.path)];
365
366
  case 10:
366
- callable = _c.sent();
367
- _b = typer_1.cast;
367
+ callable = _d.sent();
368
+ _c = typer_1.cast;
368
369
  return [4 /*yield*/, callable.origin.call(callable.context)];
369
- case 11: return [2 /*return*/, _b.apply(void 0, [_c.sent()])];
370
+ case 11: return [2 /*return*/, _c.apply(void 0, [_d.sent()])];
370
371
  case 12:
371
372
  if (value instanceof operation_1.Operation) {
372
373
  return [2 /*return*/, value.run(operationContext)];
373
374
  }
374
- _c.label = 13;
375
+ _d.label = 13;
375
376
  case 13: return [2 /*return*/, value];
376
377
  case 14: return [2 /*return*/, resultExpr];
377
378
  }
@@ -116,7 +116,7 @@ var ForOperation = /** @class */ (function (_super) {
116
116
  _b.sent();
117
117
  if (loopContext.isContinue)
118
118
  return [3 /*break*/, 7];
119
- if (loopContext.isBreak)
119
+ if (loopContext.isBreak || operationContext.isExit())
120
120
  return [3 /*break*/, 8];
121
121
  _b.label = 7;
122
122
  case 7:
@@ -8,10 +8,12 @@ export interface FunctionOperationOptions {
8
8
  body: BodyOperation;
9
9
  }
10
10
  export default class FunctionOperation extends FunctionOperationBase {
11
+ static incrementalId: number;
11
12
  args: ArgumentOperation;
12
13
  body: BodyOperation;
13
14
  context: any;
14
- id: string;
15
+ id: number;
16
+ static generateId(): number;
15
17
  constructor(ast: ASTBase, options: FunctionOperationOptions);
16
18
  getType(): string;
17
19
  fork(context: any): FunctionOperation;
@@ -52,7 +52,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
52
52
  };
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  var operation_1 = require("../types/operation");
55
- var uuid_1 = require("uuid");
56
55
  var context_1 = require("../context");
57
56
  var typer_1 = require("../typer");
58
57
  var FunctionOperation = /** @class */ (function (_super) {
@@ -61,12 +60,15 @@ var FunctionOperation = /** @class */ (function (_super) {
61
60
  var _this = _super.call(this) || this;
62
61
  var me = _this;
63
62
  me.ast = ast;
64
- me.id = (0, uuid_1.v4)();
63
+ me.id = FunctionOperation.generateId();
65
64
  me.args = options.args;
66
65
  me.body = options.body;
67
66
  me.context = null;
68
67
  return _this;
69
68
  }
69
+ FunctionOperation.generateId = function () {
70
+ return FunctionOperation.incrementalId++;
71
+ };
70
72
  FunctionOperation.prototype.getType = function () {
71
73
  return 'function';
72
74
  };
@@ -137,6 +139,7 @@ var FunctionOperation = /** @class */ (function (_super) {
137
139
  });
138
140
  });
139
141
  };
142
+ FunctionOperation.incrementalId = 0;
140
143
  return FunctionOperation;
141
144
  }(operation_1.FunctionOperationBase));
142
145
  exports.default = FunctionOperation;
@@ -122,7 +122,7 @@ var IfStatementOperation = /** @class */ (function (_super) {
122
122
  }
123
123
  _a.label = 5;
124
124
  case 5:
125
- operationContext.debugger.raise('Unexpected condition', me, item);
125
+ operationContext.debugger.raise("Unexpected object in condition ".concat(item === null || item === void 0 ? void 0 : item.toString(), "."), me, item);
126
126
  return [2 /*return*/];
127
127
  }
128
128
  });
@@ -143,7 +143,7 @@ var IfStatementOperation = /** @class */ (function (_super) {
143
143
  _b.sent();
144
144
  return [3 /*break*/, 10];
145
145
  case 8:
146
- operationContext.debugger.raise('Invalid operation in if statement.', me, clause);
146
+ operationContext.debugger.raise("Unexpected operation in if statement ".concat(clause === null || clause === void 0 ? void 0 : clause.toString(), "."), me, clause);
147
147
  _b.label = 9;
148
148
  case 9:
149
149
  clauses_1_1 = clauses_1.next();
@@ -64,10 +64,11 @@ var NewOperation = /** @class */ (function (_super) {
64
64
  return _this;
65
65
  }
66
66
  NewOperation.prototype.get = function (operationContext) {
67
+ var _a;
67
68
  return __awaiter(this, void 0, void 0, function () {
68
69
  var me, arg;
69
- return __generator(this, function (_a) {
70
- switch (_a.label) {
70
+ return __generator(this, function (_b) {
71
+ switch (_b.label) {
71
72
  case 0:
72
73
  me = this;
73
74
  if (!(0, typer_1.isCustomValue)(me.arg)) return [3 /*break*/, 1];
@@ -77,14 +78,14 @@ var NewOperation = /** @class */ (function (_super) {
77
78
  if (!(me.arg instanceof expression_1.Expression)) return [3 /*break*/, 3];
78
79
  return [4 /*yield*/, me.arg.get(operationContext)];
79
80
  case 2:
80
- arg = _a.sent();
81
+ arg = _b.sent();
81
82
  return [3 /*break*/, 4];
82
83
  case 3:
83
- operationContext.debugger.raise('Unexpected reference', me, me.arg);
84
- _a.label = 4;
84
+ operationContext.debugger.raise("Unexpected object used in new unary ".concat((_a = me.arg) === null || _a === void 0 ? void 0 : _a.toString(), "."), me, me.arg);
85
+ _b.label = 4;
85
86
  case 4:
86
87
  if (!(0, typer_1.isCustomMap)(arg)) {
87
- operationContext.debugger.raise('Unexpected type for new operator', me, arg);
88
+ operationContext.debugger.raise('Only maps can be initiated.', me, arg);
88
89
  }
89
90
  return [2 /*return*/, arg.createInstance()];
90
91
  }
@@ -64,27 +64,28 @@ var NotOperation = /** @class */ (function (_super) {
64
64
  return _this;
65
65
  }
66
66
  NotOperation.prototype.get = function (operationContext) {
67
+ var _a;
67
68
  return __awaiter(this, void 0, void 0, function () {
68
69
  var me, arg;
69
- return __generator(this, function (_a) {
70
- switch (_a.label) {
70
+ return __generator(this, function (_b) {
71
+ switch (_b.label) {
71
72
  case 0:
72
73
  me = this;
73
74
  if (!(0, typer_1.isCustomValue)(me.arg)) return [3 /*break*/, 1];
74
75
  arg = me.arg.toTruthy();
75
76
  return [3 /*break*/, 4];
76
77
  case 1:
77
- if (!(me.arg instanceof expression_1.Expression)) return [3 /*break*/, 3];
78
+ if (!(me.arg instanceof expression_1.Expression || me.arg instanceof operation_1.Operation)) return [3 /*break*/, 3];
78
79
  return [4 /*yield*/, me.arg.get(operationContext)];
79
80
  case 2:
80
- arg = _a.sent();
81
+ arg = _b.sent();
81
82
  if ((0, typer_1.isCustomValue)(arg)) {
82
83
  arg = arg.toTruthy();
83
84
  }
84
85
  return [3 /*break*/, 4];
85
86
  case 3:
86
- operationContext.debugger.raise('Unexpected not operation', me, me.arg);
87
- _a.label = 4;
87
+ operationContext.debugger.raise("Unexpected object used in not unary ".concat((_a = me.arg) === null || _a === void 0 ? void 0 : _a.toString(), "."), me, me.arg);
88
+ _b.label = 4;
88
89
  case 4: return [2 /*return*/, (0, typer_1.cast)(!arg)];
89
90
  }
90
91
  });
@@ -65,10 +65,11 @@ var ReferenceOperation = /** @class */ (function (_super) {
65
65
  return _this;
66
66
  }
67
67
  ReferenceOperation.prototype.get = function (operationContext) {
68
+ var _a, _b;
68
69
  return __awaiter(this, void 0, void 0, function () {
69
70
  var me, arg;
70
- return __generator(this, function (_a) {
71
- switch (_a.label) {
71
+ return __generator(this, function (_c) {
72
+ switch (_c.label) {
72
73
  case 0:
73
74
  me = this;
74
75
  if (!(0, typer_1.isCustomValue)(me.arg)) return [3 /*break*/, 1];
@@ -77,11 +78,11 @@ var ReferenceOperation = /** @class */ (function (_super) {
77
78
  if (!(me.arg instanceof expression_1.Expression)) return [3 /*break*/, 3];
78
79
  return [4 /*yield*/, me.arg.get(operationContext, me)];
79
80
  case 2:
80
- arg = _a.sent();
81
+ arg = _c.sent();
81
82
  return [3 /*break*/, 4];
82
83
  case 3:
83
- operationContext.debugger.raise('Unexpected reference', me, me.arg);
84
- _a.label = 4;
84
+ operationContext.debugger.raise("Unexpected reference ".concat((_a = me.arg) === null || _a === void 0 ? void 0 : _a.toString(), "."), me, me.arg);
85
+ _c.label = 4;
85
86
  case 4:
86
87
  if ((0, typer_1.isCustomValue)(arg)) {
87
88
  return [2 /*return*/, arg];
@@ -90,7 +91,7 @@ var ReferenceOperation = /** @class */ (function (_super) {
90
91
  if (arg.handle instanceof custom_type_1.CustomObjectType) {
91
92
  return [2 /*return*/, arg.handle.get(arg.path)];
92
93
  }
93
- operationContext.debugger.raise('Unexpected handle in reference statement', me, arg.handle);
94
+ operationContext.debugger.raise("Unexpected object as reference ".concat((_b = arg.handle) === null || _b === void 0 ? void 0 : _b.toString(), "."), me, arg.handle);
94
95
  }
95
96
  return [2 /*return*/, operationContext.get(arg.path)];
96
97
  }
@@ -120,7 +120,7 @@ var WhileOperation = /** @class */ (function (_super) {
120
120
  _a.sent();
121
121
  if (loopContext.isContinue)
122
122
  return [3 /*break*/, 1];
123
- if (loopContext.isBreak)
123
+ if (loopContext.isBreak || operationContext.isExit())
124
124
  return [3 /*break*/, 4];
125
125
  return [3 /*break*/, 1];
126
126
  case 4: return [2 /*return*/];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "0.6.6",
3
+ "version": "0.7.0",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",
@@ -35,8 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "greybel-core": "^0.2.5",
38
- "greyscript-core": "^0.2.6",
39
- "uuid": "^8.3.2"
38
+ "greyscript-core": "^0.2.6"
40
39
  },
41
40
  "keywords": [
42
41
  "greyscript",