greybel-interpreter 2.1.8 → 2.2.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.
|
@@ -13,6 +13,7 @@ export interface ProcessorHandler {
|
|
|
13
13
|
export declare const GenericProcessorHandler: ProcessorHandler;
|
|
14
14
|
export declare const NumberProcessorHandler: ProcessorHandler;
|
|
15
15
|
export declare const multiplyString: (a: CustomValue, b: CustomValue) => CustomValue;
|
|
16
|
+
export declare const minusString: (a: CustomValue, b: CustomValue) => CustomValue;
|
|
16
17
|
export declare const StringProcessorHandler: ProcessorHandler;
|
|
17
18
|
export declare const multiplyList: (a: CustomList, b: CustomValue) => CustomValue;
|
|
18
19
|
export declare const divideList: (a: CustomList, b: CustomValue) => CustomValue;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Evaluate = exports.handle = exports.handleFunction = exports.handleNil = exports.handleInterface = exports.handleMap = exports.handleList = exports.handleString = exports.handleNumber = exports.FunctionProcessorHandler = exports.NilProcessorHandler = exports.InterfaceProcessorHandler = exports.MapProcessorHandler = exports.ListProcessorHandler = exports.divideList = exports.multiplyList = exports.StringProcessorHandler = exports.multiplyString = exports.NumberProcessorHandler = exports.GenericProcessorHandler = void 0;
|
|
12
|
+
exports.Evaluate = exports.handle = exports.handleFunction = exports.handleNil = exports.handleInterface = exports.handleMap = exports.handleList = exports.handleString = exports.handleNumber = exports.FunctionProcessorHandler = exports.NilProcessorHandler = exports.InterfaceProcessorHandler = exports.MapProcessorHandler = exports.ListProcessorHandler = exports.divideList = exports.multiplyList = exports.StringProcessorHandler = exports.minusString = exports.multiplyString = exports.NumberProcessorHandler = exports.GenericProcessorHandler = void 0;
|
|
13
13
|
const greyscript_core_1 = require("greyscript-core");
|
|
14
14
|
const boolean_1 = require("../types/boolean");
|
|
15
15
|
const default_1 = require("../types/default");
|
|
@@ -50,8 +50,18 @@ const multiplyString = (a, b) => {
|
|
|
50
50
|
return new string_1.CustomString(multiStr);
|
|
51
51
|
};
|
|
52
52
|
exports.multiplyString = multiplyString;
|
|
53
|
+
const minusString = (a, b) => {
|
|
54
|
+
const origin = a.toString();
|
|
55
|
+
const toRemove = b.toString();
|
|
56
|
+
if (origin.endsWith(toRemove)) {
|
|
57
|
+
return new string_1.CustomString(origin.substring(0, origin.length - toRemove.length));
|
|
58
|
+
}
|
|
59
|
+
return new string_1.CustomString(origin);
|
|
60
|
+
};
|
|
61
|
+
exports.minusString = minusString;
|
|
53
62
|
exports.StringProcessorHandler = {
|
|
54
63
|
[greyscript_core_1.Operator.Plus]: (a, b) => new string_1.CustomString(a.toString() + b.toString()),
|
|
64
|
+
[greyscript_core_1.Operator.Minus]: (a, b) => (0, exports.minusString)(a, b),
|
|
55
65
|
[greyscript_core_1.Operator.Asterik]: (a, b) => (0, exports.multiplyString)(a, b),
|
|
56
66
|
[greyscript_core_1.Operator.LessThan]: (a, b) => new boolean_1.CustomBoolean(a.toString().length < b.toString().length),
|
|
57
67
|
[greyscript_core_1.Operator.GreaterThan]: (a, b) => new boolean_1.CustomBoolean(a.toString().length > b.toString().length),
|
|
@@ -221,13 +221,18 @@ class Resolve extends operation_1.Operation {
|
|
|
221
221
|
}
|
|
222
222
|
if (result.handle instanceof with_intrinsics_1.CustomValueWithIntrinsics) {
|
|
223
223
|
const customValueCtx = result.handle;
|
|
224
|
+
if (this.path.isSuper() && customValueCtx instanceof map_1.CustomMap) {
|
|
225
|
+
const superChild = customValueCtx.isa.get(result.path);
|
|
226
|
+
if (autoCall && superChild instanceof function_1.CustomFunction) {
|
|
227
|
+
if (ctx.functionState.context) {
|
|
228
|
+
return superChild.run(ctx.functionState.context, [], ctx, customValueCtx.isa);
|
|
229
|
+
}
|
|
230
|
+
return superChild.run(customValueCtx, [], ctx);
|
|
231
|
+
}
|
|
232
|
+
return superChild;
|
|
233
|
+
}
|
|
224
234
|
const child = customValueCtx.get(result.path);
|
|
225
235
|
if (autoCall && child instanceof function_1.CustomFunction) {
|
|
226
|
-
if (this.path.isSuper() &&
|
|
227
|
-
ctx.functionState.context &&
|
|
228
|
-
customValueCtx instanceof map_1.CustomMap) {
|
|
229
|
-
return child.run(ctx.functionState.context, [], ctx, customValueCtx.isa);
|
|
230
|
-
}
|
|
231
236
|
return child.run(customValueCtx, [], ctx);
|
|
232
237
|
}
|
|
233
238
|
return child;
|