greybel-interpreter 0.5.7 → 0.6.1

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.
@@ -39,10 +39,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
39
  }
40
40
  return to.concat(ar || Array.prototype.slice.call(from));
41
41
  };
42
+ var __importDefault = (this && this.__importDefault) || function (mod) {
43
+ return (mod && mod.__esModule) ? mod : { "default": mod };
44
+ };
42
45
  Object.defineProperty(exports, "__esModule", { value: true });
43
46
  exports.CustomMapIterator = void 0;
44
47
  var custom_type_1 = require("../types/custom-type");
45
48
  var operation_1 = require("../types/operation");
49
+ var string_1 = __importDefault(require("./string"));
46
50
  var CustomMapIterator = /** @class */ (function () {
47
51
  function CustomMapIterator(value) {
48
52
  var me = this;
@@ -87,8 +91,33 @@ var CustomMap = /** @class */ (function (_super) {
87
91
  me.value = new Map(__spreadArray(__spreadArray([], __read(me.value.entries()), false), __read(value.entries()), false));
88
92
  return me;
89
93
  };
94
+ CustomMap.prototype.has = function (path) {
95
+ var me = this;
96
+ if (path.length === 0) {
97
+ return Promise.resolve(true);
98
+ }
99
+ var traversalPath = [].concat(path);
100
+ var refs = me.value;
101
+ var current = traversalPath.shift();
102
+ if (current != null) {
103
+ if (refs.has(current)) {
104
+ var sub = refs.get(current);
105
+ if (traversalPath.length > 0 && sub instanceof custom_type_1.CustomObjectType) {
106
+ return sub.has(traversalPath);
107
+ }
108
+ if (traversalPath.length === 0) {
109
+ return Promise.resolve(true);
110
+ }
111
+ }
112
+ }
113
+ return Promise.resolve(false);
114
+ };
90
115
  CustomMap.prototype.set = function (path, value) {
91
116
  var me = this;
117
+ if (!path) {
118
+ console.warn('Cannot set empty path for ', me);
119
+ return;
120
+ }
92
121
  var traversalPath = [].concat(path);
93
122
  var refs = me.value;
94
123
  var last = traversalPath.pop();
@@ -100,9 +129,8 @@ var CustomMap = /** @class */ (function (_super) {
100
129
  return sub.set(traversalPath.concat(last), value);
101
130
  }
102
131
  }
103
- else {
104
- throw new Error("Cannot set path ".concat(path.join('.')));
105
- }
132
+ console.warn("Cannot set path ".concat(path === null || path === void 0 ? void 0 : path.join('.')));
133
+ return;
106
134
  }
107
135
  if (value instanceof operation_1.FunctionOperationBase) {
108
136
  refs.set(last, value.fork(me));
@@ -122,7 +150,8 @@ var CustomMap = /** @class */ (function (_super) {
122
150
  if (current != null) {
123
151
  if (refs.has(current)) {
124
152
  var sub = refs.get(current);
125
- if (traversalPath.length > 0 && sub instanceof custom_type_1.CustomObjectType) {
153
+ if (traversalPath.length > 0 &&
154
+ (sub instanceof custom_type_1.CustomObjectType || sub instanceof string_1.default)) {
126
155
  return sub.get(traversalPath);
127
156
  }
128
157
  if (traversalPath.length === 0) {
@@ -140,19 +169,13 @@ var CustomMap = /** @class */ (function (_super) {
140
169
  };
141
170
  CustomMap.prototype.getCallable = function (path) {
142
171
  var me = this;
143
- if (path.length === 0) {
144
- return Promise.resolve({
145
- origin: me.value,
146
- context: me
147
- });
148
- }
149
172
  var traversalPath = [].concat(path);
150
173
  var refs = me.value;
151
174
  var current = traversalPath.shift();
152
175
  if (current != null) {
153
176
  if (refs.has(current)) {
154
177
  var sub = refs.get(current);
155
- if (sub instanceof custom_type_1.CustomObjectType) {
178
+ if (sub instanceof custom_type_1.CustomObjectType || sub instanceof string_1.default) {
156
179
  return sub.getCallable(traversalPath);
157
180
  }
158
181
  if (traversalPath.length === 0) {
@@ -169,33 +192,13 @@ var CustomMap = /** @class */ (function (_super) {
169
192
  });
170
193
  }
171
194
  else {
172
- throw new Error("Cannot get path ".concat(path.join('.')));
173
- }
174
- }
175
- return Promise.resolve(null);
176
- };
177
- CustomMap.prototype.callMethod = function (method) {
178
- var _a;
179
- var _b;
180
- var args = [];
181
- for (var _i = 1; _i < arguments.length; _i++) {
182
- args[_i - 1] = arguments[_i];
183
- }
184
- if (method.length === 0) {
185
- throw new Error('Unexpected method length');
186
- }
187
- var me = this;
188
- var key = (_b = method[0]) === null || _b === void 0 ? void 0 : _b.toString();
189
- if (method.length > 1) {
190
- if (me.value.has(key)) {
191
- return (_a = me.value.get(key)).callMethod.apply(_a, __spreadArray([method.slice(1)], __read(args), false));
195
+ throw new Error("Cannot get callable path ".concat(path.join('.')));
192
196
  }
193
- throw new Error("Unexpected method path");
194
197
  }
195
- if (!CustomMap.intrinsics.has(key)) {
196
- throw new Error("Cannot access ".concat(key, " in map"));
197
- }
198
- return CustomMap.intrinsics.get(key).apply(void 0, __spreadArray([me], __read(args), false));
198
+ return Promise.resolve({
199
+ origin: null,
200
+ context: me
201
+ });
199
202
  };
200
203
  CustomMap.prototype.createInstance = function () {
201
204
  var me = this;
@@ -213,10 +216,11 @@ var CustomMap = /** @class */ (function (_super) {
213
216
  var me = this;
214
217
  return ((_a = me.value.get('classID')) === null || _a === void 0 ? void 0 : _a.toString()) || 'map';
215
218
  };
216
- CustomMap.prototype.valueOf = function () {
217
- var me = this;
218
- var value = me.value;
219
- return value.size === 0 ? null : me;
219
+ CustomMap.prototype.toNumber = function () {
220
+ return Number.NaN;
221
+ };
222
+ CustomMap.prototype.toTruthy = function () {
223
+ return this.value.size > 0;
220
224
  };
221
225
  CustomMap.prototype.toString = function () {
222
226
  var me = this;
@@ -224,7 +228,7 @@ var CustomMap = /** @class */ (function (_super) {
224
228
  .entries(me.value)
225
229
  .map(function (_a) {
226
230
  var _b = __read(_a, 2), key = _b[0], value = _b[1];
227
- return "\"".concat(key, "\": ").concat(value.valueOf().toString());
231
+ return "\"".concat(key, "\": ").concat(value === null || value === void 0 ? void 0 : value.toString());
228
232
  });
229
233
  return "{".concat(body.join(','), "}");
230
234
  };
@@ -3,6 +3,7 @@ export default class CustomNil extends CustomLiteralType {
3
3
  static intrinsics: Map<string, Function>;
4
4
  value: null;
5
5
  getType(): string;
6
- valueOf(): null;
6
+ toNumber(): number;
7
+ toTruthy(): boolean;
7
8
  toString(): string;
8
9
  }
@@ -26,8 +26,11 @@ var CustomNil = /** @class */ (function (_super) {
26
26
  CustomNil.prototype.getType = function () {
27
27
  return 'null';
28
28
  };
29
- CustomNil.prototype.valueOf = function () {
30
- return null;
29
+ CustomNil.prototype.toNumber = function () {
30
+ return Number.NaN;
31
+ };
32
+ CustomNil.prototype.toTruthy = function () {
33
+ return false;
31
34
  };
32
35
  CustomNil.prototype.toString = function () {
33
36
  return 'null';
@@ -4,7 +4,8 @@ export default class CustomNumber extends CustomLiteralType {
4
4
  value: number;
5
5
  constructor(value: number);
6
6
  getType(): string;
7
- valueOf(): number;
8
7
  toString(): string;
8
+ toNumber(): number;
9
+ toTruthy(): boolean;
9
10
  fork(): CustomNumber;
10
11
  }
@@ -26,12 +26,15 @@ var CustomNumber = /** @class */ (function (_super) {
26
26
  CustomNumber.prototype.getType = function () {
27
27
  return 'number';
28
28
  };
29
- CustomNumber.prototype.valueOf = function () {
30
- return this.value;
31
- };
32
29
  CustomNumber.prototype.toString = function () {
33
30
  return this.value.toString();
34
31
  };
32
+ CustomNumber.prototype.toNumber = function () {
33
+ return this.value;
34
+ };
35
+ CustomNumber.prototype.toTruthy = function () {
36
+ return Number.isNaN(this.value) ? false : !!this.value;
37
+ };
35
38
  CustomNumber.prototype.fork = function () {
36
39
  return new CustomNumber(this.value);
37
40
  };
@@ -1,3 +1,4 @@
1
+ import { Callable } from '../types/custom-type';
1
2
  import { CustomLiteralType } from '../types/custom-type';
2
3
  export declare class CustomStringIterator implements Iterator<string> {
3
4
  value: string;
@@ -5,6 +6,7 @@ export declare class CustomStringIterator implements Iterator<string> {
5
6
  constructor(value: string);
6
7
  next(): IteratorResult<string>;
7
8
  }
9
+ export declare function itemAtIndex(str: any, n: number): number | null;
8
10
  export default class CustomString extends CustomLiteralType {
9
11
  static intrinsics: Map<string, Function>;
10
12
  value: string;
@@ -12,10 +14,11 @@ export default class CustomString extends CustomLiteralType {
12
14
  constructor(value: string);
13
15
  slice(a: CustomLiteralType, b: CustomLiteralType): CustomString;
14
16
  [Symbol.iterator](): CustomStringIterator;
15
- toIndex(value: string): number;
16
- callMethod(method: string[], ...args: any[]): any;
17
+ get(path: any[]): Promise<any>;
18
+ getCallable(path: any[]): Promise<Callable>;
17
19
  getType(): string;
18
- valueOf(): string | null;
19
20
  toString(): string;
21
+ toNumber(): number;
22
+ toTruthy(): boolean;
20
23
  fork(): CustomString;
21
24
  }
@@ -14,33 +14,44 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
- var __read = (this && this.__read) || function (o, n) {
18
- var m = typeof Symbol === "function" && o[Symbol.iterator];
19
- if (!m) return o;
20
- var i = m.call(o), r, ar = [], e;
21
- try {
22
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
23
- }
24
- catch (error) { e = { error: error }; }
25
- finally {
26
- try {
27
- if (r && !r.done && (m = i["return"])) m.call(i);
28
- }
29
- finally { if (e) throw e.error; }
30
- }
31
- return ar;
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
32
25
  };
33
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
34
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
35
- if (ar || !(i in from)) {
36
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
37
- ar[i] = from[i];
38
- }
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
39
51
  }
40
- return to.concat(ar || Array.prototype.slice.call(from));
41
52
  };
42
53
  Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.CustomStringIterator = void 0;
54
+ exports.itemAtIndex = exports.CustomStringIterator = void 0;
44
55
  var custom_type_1 = require("../types/custom-type");
45
56
  var CustomStringIterator = /** @class */ (function () {
46
57
  function CustomStringIterator(value) {
@@ -64,6 +75,17 @@ var CustomStringIterator = /** @class */ (function () {
64
75
  return CustomStringIterator;
65
76
  }());
66
77
  exports.CustomStringIterator = CustomStringIterator;
78
+ function itemAtIndex(str, n) {
79
+ if (Number.isNaN(n))
80
+ return null;
81
+ n = Math.trunc(n) || 0;
82
+ if (n < 0)
83
+ n += str.length;
84
+ if (n < 0 || n >= str.length)
85
+ return -1;
86
+ return n;
87
+ }
88
+ exports.itemAtIndex = itemAtIndex;
67
89
  var CustomString = /** @class */ (function (_super) {
68
90
  __extends(CustomString, _super);
69
91
  function CustomString(value) {
@@ -75,53 +97,69 @@ var CustomString = /** @class */ (function (_super) {
75
97
  return !Number.isNaN(Number(value));
76
98
  };
77
99
  CustomString.prototype.slice = function (a, b) {
78
- return new CustomString(this.value.slice(a === null || a === void 0 ? void 0 : a.valueOf(), b === null || b === void 0 ? void 0 : b.valueOf()));
100
+ return new CustomString(this.value.slice(a === null || a === void 0 ? void 0 : a.toNumber(), b === null || b === void 0 ? void 0 : b.toNumber()));
79
101
  };
80
102
  CustomString.prototype[Symbol.iterator] = function () {
81
103
  return new CustomStringIterator(this.value);
82
104
  };
83
- CustomString.prototype.toIndex = function (value) {
84
- var me = this;
85
- var casted = Number(value);
86
- return casted < 0 ? me.value.length + casted : casted;
105
+ CustomString.prototype.get = function (path) {
106
+ return __awaiter(this, void 0, void 0, function () {
107
+ var me, traversalPath, str, current, currentIndex;
108
+ return __generator(this, function (_a) {
109
+ me = this;
110
+ if (path.length === 0) {
111
+ return [2 /*return*/, me];
112
+ }
113
+ traversalPath = [].concat(path);
114
+ str = me.value;
115
+ current = traversalPath.shift();
116
+ if (current != null) {
117
+ currentIndex = itemAtIndex(str, Number(current));
118
+ if (currentIndex != null && str.charAt(currentIndex) != null) {
119
+ return [2 /*return*/, new CustomString(str.charAt(currentIndex))];
120
+ }
121
+ else if (path.length === 1 && CustomString.intrinsics.has(current)) {
122
+ return [2 /*return*/, CustomString.intrinsics.get(current).bind(null, me)];
123
+ }
124
+ }
125
+ return [2 /*return*/, null];
126
+ });
127
+ });
87
128
  };
88
- CustomString.prototype.callMethod = function (method) {
89
- var args = [];
90
- for (var _i = 1; _i < arguments.length; _i++) {
91
- args[_i - 1] = arguments[_i];
92
- }
93
- if (method.length === 0) {
94
- throw new Error('Unexpected method length');
95
- }
96
- var me = this;
97
- var member = method[0].valueOf();
98
- if (CustomString.isNumber(member)) {
99
- var index = me.toIndex(member);
100
- if (!me.value[index]) {
101
- console.error(method, member, args);
102
- throw new Error("Unexpected index ".concat(index));
103
- }
104
- var value = new CustomString(me.value[index]);
105
- if (method.length > 1) {
106
- return value.callMethod.apply(value, __spreadArray([method.slice(1)], __read(args), false));
107
- }
108
- return value;
109
- }
110
- if (!CustomString.intrinsics.has(member)) {
111
- throw new Error("Cannot access ".concat(member, " in string"));
112
- }
113
- return CustomString.intrinsics.get(member).apply(void 0, __spreadArray([me], __read(args), false));
129
+ CustomString.prototype.getCallable = function (path) {
130
+ return __awaiter(this, void 0, void 0, function () {
131
+ var me, traversalPath, current;
132
+ return __generator(this, function (_a) {
133
+ me = this;
134
+ traversalPath = [].concat(path);
135
+ current = traversalPath.shift();
136
+ if (current != null) {
137
+ if (path.length === 1 && CustomString.intrinsics.has(current)) {
138
+ return [2 /*return*/, {
139
+ origin: CustomString.intrinsics.get(current).bind(null, me),
140
+ context: me
141
+ }];
142
+ }
143
+ }
144
+ return [2 /*return*/, {
145
+ origin: null,
146
+ context: me
147
+ }];
148
+ });
149
+ });
114
150
  };
115
151
  CustomString.prototype.getType = function () {
116
152
  return 'string';
117
153
  };
118
- CustomString.prototype.valueOf = function () {
119
- var me = this;
120
- return me.value.length === 0 ? null : me.value;
121
- };
122
154
  CustomString.prototype.toString = function () {
123
155
  return this.value;
124
156
  };
157
+ CustomString.prototype.toNumber = function () {
158
+ return Number(this.value);
159
+ };
160
+ CustomString.prototype.toTruthy = function () {
161
+ return this.value.length > 0;
162
+ };
125
163
  CustomString.prototype.fork = function () {
126
164
  return new CustomString(this.value);
127
165
  };
@@ -2,7 +2,6 @@ import { ASTUnaryExpression } from 'greybel-core';
2
2
  import { Expression } from '../types/expression';
3
3
  import { OperationContext } from '../context';
4
4
  import { CustomType } from '../types/custom-type';
5
- export declare const toPrimitive: (v: CustomType | any) => any;
6
5
  export declare type OperationMap = {
7
6
  [key: string]: (a: CustomType) => any;
8
7
  };
@@ -52,17 +52,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
52
52
  };
53
53
  var _a;
54
54
  Object.defineProperty(exports, "__esModule", { value: true });
55
- exports.ExpressionSegment = exports.toPrimitive = void 0;
55
+ exports.ExpressionSegment = void 0;
56
56
  var greybel_core_1 = require("greybel-core");
57
57
  var expression_1 = require("../types/expression");
58
58
  var typer_1 = require("../typer");
59
- var toPrimitive = function (v) {
60
- return (0, typer_1.isCustomValue)(v) ? v.valueOf() : v;
61
- };
62
- exports.toPrimitive = toPrimitive;
63
59
  var OPERATIONS = (_a = {},
64
- _a[greybel_core_1.Operator.Plus] = function (a) { return (0, exports.toPrimitive)(a); },
65
- _a[greybel_core_1.Operator.Minus] = function (a) { return -(0, exports.toPrimitive)(a); },
60
+ _a[greybel_core_1.Operator.Plus] = function (a) { return a.toNumber(); },
61
+ _a[greybel_core_1.Operator.Minus] = function (a) { return -a.toNumber(); },
66
62
  _a);
67
63
  var ExpressionSegment = /** @class */ (function () {
68
64
  function ExpressionSegment(operator, arg) {
@@ -152,25 +152,27 @@ var CallExpression = /** @class */ (function (_super) {
152
152
  var evaluate = function (node) {
153
153
  return __awaiter(this, void 0, void 0, function () {
154
154
  var args, pathExpr, callable_1, _a, callable, _b;
155
- var _c, _d, _e;
156
- return __generator(this, function (_f) {
157
- switch (_f.label) {
155
+ var _c, _d;
156
+ return __generator(this, function (_e) {
157
+ switch (_e.label) {
158
158
  case 0:
159
159
  if (node instanceof expression_1.Expression) {
160
160
  return [2 /*return*/, node.get(opc)];
161
161
  }
162
162
  return [4 /*yield*/, node.resolveArgs(operationContext)];
163
163
  case 1:
164
- args = _f.sent();
164
+ args = _e.sent();
165
165
  return [4 /*yield*/, node.path.get(opc, me.expr)];
166
166
  case 2:
167
- pathExpr = _f.sent();
167
+ pathExpr = _e.sent();
168
168
  operationContext.debugger.debug('Line', me.ast.start.line, 'CallExpression', 'pathExpr', pathExpr);
169
- if (!pathExpr.handle) return [3 /*break*/, 8];
170
- if (!(0, typer_1.isCustomMap)(pathExpr.handle)) return [3 /*break*/, 7];
169
+ if (!pathExpr.handle) return [3 /*break*/, 7];
170
+ if (!((0, typer_1.isCustomMap)(pathExpr.handle) ||
171
+ (0, typer_1.isCustomList)(pathExpr.handle) ||
172
+ (0, typer_1.isCustomString)(pathExpr.handle))) return [3 /*break*/, 6];
171
173
  return [4 /*yield*/, pathExpr.handle.getCallable(pathExpr.path)];
172
174
  case 3:
173
- callable_1 = _f.sent();
175
+ callable_1 = _e.sent();
174
176
  if (!(callable_1.origin instanceof operation_1.Operation)) return [3 /*break*/, 4];
175
177
  opc.setMemory('args', args);
176
178
  return [2 /*return*/, callable_1.origin.run(opc)];
@@ -178,23 +180,22 @@ var CallExpression = /** @class */ (function (_super) {
178
180
  if (!(callable_1.origin instanceof Function)) return [3 /*break*/, 6];
179
181
  _a = typer_1.cast;
180
182
  return [4 /*yield*/, (_c = callable_1.origin).call.apply(_c, __spreadArray([pathExpr.handle], __read(args), false))];
181
- case 5: return [2 /*return*/, _a.apply(void 0, [_f.sent()])];
183
+ case 5: return [2 /*return*/, _a.apply(void 0, [_e.sent()])];
182
184
  case 6:
183
- operationContext.debugger.raise('Unexpected handle call', me, callable_1);
184
- _f.label = 7;
185
- case 7: return [2 /*return*/, (0, typer_1.cast)((_d = pathExpr.handle).callMethod.apply(_d, __spreadArray([pathExpr.path], __read(args), false)))];
186
- case 8: return [4 /*yield*/, opc.getCallable(pathExpr.path)];
187
- case 9:
188
- callable = _f.sent();
185
+ operationContext.debugger.raise('Unexpected handle call', me, pathExpr);
186
+ _e.label = 7;
187
+ case 7: return [4 /*yield*/, opc.getCallable(pathExpr.path)];
188
+ case 8:
189
+ callable = _e.sent();
189
190
  opc.setMemory('args', args);
190
- if (!(callable.origin instanceof operation_1.Operation)) return [3 /*break*/, 10];
191
+ if (!(callable.origin instanceof operation_1.Operation)) return [3 /*break*/, 9];
191
192
  return [2 /*return*/, callable.origin.run(opc)];
192
- case 10:
193
- if (!(callable.origin instanceof Function)) return [3 /*break*/, 12];
193
+ case 9:
194
+ if (!(callable.origin instanceof Function)) return [3 /*break*/, 11];
194
195
  _b = typer_1.cast;
195
- return [4 /*yield*/, (_e = callable.origin).call.apply(_e, __spreadArray([callable.context], __read(args), false))];
196
- case 11: return [2 /*return*/, _b.apply(void 0, [_f.sent()])];
197
- case 12: return [2 /*return*/, (0, typer_1.cast)(callable.origin)];
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()])];
198
+ case 11: return [2 /*return*/, (0, typer_1.cast)(callable.origin)];
198
199
  }
199
200
  });
200
201
  });
@@ -2,7 +2,6 @@ import { ASTEvaluationExpression } from 'greybel-core';
2
2
  import { Expression } from '../types/expression';
3
3
  import { OperationContext } from '../context';
4
4
  import { CustomType } from '../types/custom-type';
5
- export declare const toPrimitive: (v: CustomType | any) => any;
6
5
  export declare const multiplyString: (a: CustomType, b: CustomType) => string;
7
6
  export declare type OperationMap = {
8
7
  [key: string]: (a: CustomType, b: CustomType) => any;