greybel-interpreter 3.3.0 → 3.4.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/context.d.ts +2 -0
- package/dist/context.js +17 -15
- package/dist/operations/evaluate.js +3 -3
- package/package.json +2 -2
package/dist/context.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export interface ContextOptions {
|
|
|
76
76
|
environmentVariables?: Map<string, string>;
|
|
77
77
|
ignoreOuter?: boolean;
|
|
78
78
|
contextTypeIntrinsics?: ContextTypeIntrinsics;
|
|
79
|
+
time?: number;
|
|
79
80
|
}
|
|
80
81
|
export interface ContextForkOptions {
|
|
81
82
|
type: ContextType;
|
|
@@ -97,6 +98,7 @@ export declare class OperationContext {
|
|
|
97
98
|
readonly state: ContextState;
|
|
98
99
|
readonly scope: Scope;
|
|
99
100
|
readonly cps: CPS;
|
|
101
|
+
readonly time: number;
|
|
100
102
|
readonly processState: ProcessState;
|
|
101
103
|
loopState: LoopState;
|
|
102
104
|
functionState: FunctionState;
|
package/dist/context.js
CHANGED
|
@@ -163,33 +163,34 @@ class FunctionState {
|
|
|
163
163
|
exports.FunctionState = FunctionState;
|
|
164
164
|
class OperationContext {
|
|
165
165
|
constructor(options = {}) {
|
|
166
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
166
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
167
167
|
this.target = (_a = options.target) !== null && _a !== void 0 ? _a : 'unknown';
|
|
168
168
|
this.stackTrace = (_b = options.stackTrace) !== null && _b !== void 0 ? _b : [];
|
|
169
|
-
this.
|
|
170
|
-
this.
|
|
171
|
-
this.
|
|
169
|
+
this.time = (_c = options.time) !== null && _c !== void 0 ? _c : Date.now();
|
|
170
|
+
this.previous = (_d = options.previous) !== null && _d !== void 0 ? _d : null;
|
|
171
|
+
this.type = (_e = options.type) !== null && _e !== void 0 ? _e : ContextType.Api;
|
|
172
|
+
this.state = (_f = options.state) !== null && _f !== void 0 ? _f : ContextState.Default;
|
|
172
173
|
this.scope = new Scope(this);
|
|
173
|
-
this.isProtected = (
|
|
174
|
-
this.injected = (
|
|
175
|
-
this.debugger = (
|
|
176
|
-
this.handler = (
|
|
177
|
-
this.contextTypeIntrinsics = (
|
|
174
|
+
this.isProtected = (_g = options.isProtected) !== null && _g !== void 0 ? _g : false;
|
|
175
|
+
this.injected = (_h = options.injected) !== null && _h !== void 0 ? _h : false;
|
|
176
|
+
this.debugger = (_j = options.debugger) !== null && _j !== void 0 ? _j : new Debugger();
|
|
177
|
+
this.handler = (_k = options.handler) !== null && _k !== void 0 ? _k : new handler_container_1.HandlerContainer();
|
|
178
|
+
this.contextTypeIntrinsics = (_l = options.contextTypeIntrinsics) !== null && _l !== void 0 ? _l : {
|
|
178
179
|
string: null,
|
|
179
180
|
number: null,
|
|
180
181
|
list: null,
|
|
181
182
|
map: null,
|
|
182
183
|
function: null
|
|
183
184
|
};
|
|
184
|
-
this.cps = (
|
|
185
|
-
this.processState = (
|
|
186
|
-
this.environmentVariables = (
|
|
185
|
+
this.cps = (_m = options.cps) !== null && _m !== void 0 ? _m : null;
|
|
186
|
+
this.processState = (_o = options.processState) !== null && _o !== void 0 ? _o : new ProcessState();
|
|
187
|
+
this.environmentVariables = (_p = options.environmentVariables) !== null && _p !== void 0 ? _p : new Map();
|
|
187
188
|
this.functionState = new FunctionState();
|
|
188
189
|
this.loopState = new LoopState();
|
|
189
190
|
this.api = this.lookupApi();
|
|
190
191
|
this.globals = this.lookupGlobals();
|
|
191
|
-
this.locals = (
|
|
192
|
-
this.outer = (
|
|
192
|
+
this.locals = (_q = this.lookupLocals()) !== null && _q !== void 0 ? _q : this;
|
|
193
|
+
this.outer = (_r = (options.ignoreOuter ? null : this.lookupOuter())) !== null && _r !== void 0 ? _r : this.globals;
|
|
193
194
|
}
|
|
194
195
|
isIgnoredInDebugging(op) {
|
|
195
196
|
return op instanceof operation_1.OperationBlock || op instanceof noop_1.Noop;
|
|
@@ -344,7 +345,8 @@ class OperationContext {
|
|
|
344
345
|
cps: this.cps,
|
|
345
346
|
processState: (_b = options.processState) !== null && _b !== void 0 ? _b : this.processState,
|
|
346
347
|
environmentVariables: this.environmentVariables,
|
|
347
|
-
contextTypeIntrinsics: this.contextTypeIntrinsics
|
|
348
|
+
contextTypeIntrinsics: this.contextTypeIntrinsics,
|
|
349
|
+
time: this.time
|
|
348
350
|
});
|
|
349
351
|
if (options.type !== ContextType.Function) {
|
|
350
352
|
if (options.type !== ContextType.Loop) {
|
|
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Evaluate = exports.handle = exports.handleFunction = exports.handleNil = exports.handleMap = exports.handleList = exports.handleString = exports.handleNumber = exports.FunctionProcessorHandler = exports.NilProcessorHandler = exports.MapProcessorHandler = exports.ListProcessorHandler = exports.divideList = exports.multiplyList = exports.StringProcessorHandler = exports.divideString = exports.multiplyString = exports.minusString = exports.NumberProcessorHandler = exports.GenericProcessorHandler = void 0;
|
|
13
|
-
const miniscript_core_1 = require("miniscript-core");
|
|
14
13
|
const operators_1 = require("greybel-core/dist/types/operators");
|
|
14
|
+
const miniscript_core_1 = require("miniscript-core");
|
|
15
15
|
const boolean_1 = require("../types/boolean");
|
|
16
16
|
const default_1 = require("../types/default");
|
|
17
17
|
const function_1 = require("../types/function");
|
|
@@ -39,7 +39,7 @@ exports.NumberProcessorHandler = {
|
|
|
39
39
|
[operators_1.Operator.RightShift]: (a, b) => new number_1.CustomNumber(a.toInt() >> b.toInt()),
|
|
40
40
|
[operators_1.Operator.UnsignedRightShift]: (a, b) => new number_1.CustomNumber(a.toInt() >> b.toInt()),
|
|
41
41
|
[operators_1.Operator.BitwiseAnd]: (a, b) => new number_1.CustomNumber(a.toInt() & b.toInt()),
|
|
42
|
-
[miniscript_core_1.Operator.
|
|
42
|
+
[miniscript_core_1.Operator.Modulo]: (a, b) => new number_1.CustomNumber(a.toNumber() % b.toNumber()),
|
|
43
43
|
[miniscript_core_1.Operator.GreaterThanOrEqual]: (a, b) => new boolean_1.CustomBoolean(a.toNumber() >= b.toNumber()),
|
|
44
44
|
[miniscript_core_1.Operator.Equal]: (a, b) => new boolean_1.CustomBoolean(a.toNumber() === b.toNumber()),
|
|
45
45
|
[miniscript_core_1.Operator.LessThanOrEqual]: (a, b) => new boolean_1.CustomBoolean(a.toNumber() <= b.toNumber()),
|
|
@@ -176,7 +176,7 @@ exports.NilProcessorHandler = {
|
|
|
176
176
|
[miniscript_core_1.Operator.Slash]: () => default_1.DefaultType.Void,
|
|
177
177
|
[miniscript_core_1.Operator.Asterik]: () => default_1.DefaultType.Void,
|
|
178
178
|
[miniscript_core_1.Operator.Power]: () => default_1.DefaultType.Void,
|
|
179
|
-
[miniscript_core_1.Operator.
|
|
179
|
+
[miniscript_core_1.Operator.Modulo]: () => default_1.DefaultType.Void,
|
|
180
180
|
[miniscript_core_1.Operator.Equal]: (_a, b) => new boolean_1.CustomBoolean(b instanceof nil_1.CustomNil),
|
|
181
181
|
[miniscript_core_1.Operator.NotEqual]: (_a, b) => new boolean_1.CustomBoolean(!(b instanceof nil_1.CustomNil))
|
|
182
182
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greybel-interpreter",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Interpreter",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"lru-cache": "^10.0.1",
|
|
52
|
-
"greybel-core": "
|
|
52
|
+
"greybel-core": "~1.4.0"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
55
55
|
"miniscript"
|