greybel-interpreter 1.7.0 → 1.7.2
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 +9 -9
- package/dist/context.js +19 -22
- package/dist/cps.d.ts +3 -3
- package/dist/cps.js +56 -59
- package/dist/handler/output.d.ts +6 -7
- package/dist/handler/output.js +6 -11
- package/dist/handler-container.d.ts +1 -1
- package/dist/handler-container.js +2 -1
- package/dist/index.d.ts +42 -42
- package/dist/index.js +43 -46
- package/dist/interpreter.d.ts +9 -9
- package/dist/interpreter.js +33 -59
- package/dist/operations/assign.d.ts +5 -5
- package/dist/operations/assign.js +9 -11
- package/dist/operations/block.d.ts +4 -4
- package/dist/operations/block.js +6 -8
- package/dist/operations/break.d.ts +4 -4
- package/dist/operations/break.js +6 -8
- package/dist/operations/call.d.ts +5 -5
- package/dist/operations/call.js +12 -14
- package/dist/operations/chunk.d.ts +6 -6
- package/dist/operations/chunk.js +8 -10
- package/dist/operations/continue.d.ts +4 -4
- package/dist/operations/continue.js +6 -8
- package/dist/operations/debugger-statement.d.ts +5 -5
- package/dist/operations/debugger-statement.js +6 -8
- package/dist/operations/envar.d.ts +5 -5
- package/dist/operations/envar.js +6 -8
- package/dist/operations/evaluate.d.ts +6 -5
- package/dist/operations/evaluate.js +109 -112
- package/dist/operations/for.d.ts +6 -6
- package/dist/operations/for.js +15 -17
- package/dist/operations/function-reference.d.ts +5 -5
- package/dist/operations/function-reference.js +8 -10
- package/dist/operations/function.d.ts +5 -5
- package/dist/operations/function.js +17 -20
- package/dist/operations/if-statement.d.ts +6 -6
- package/dist/operations/if-statement.js +12 -15
- package/dist/operations/import.d.ts +7 -7
- package/dist/operations/import.js +15 -18
- package/dist/operations/include.d.ts +5 -5
- package/dist/operations/include.js +4 -6
- package/dist/operations/list.d.ts +5 -5
- package/dist/operations/list.js +6 -8
- package/dist/operations/literal.d.ts +5 -5
- package/dist/operations/literal.js +12 -14
- package/dist/operations/map.d.ts +5 -5
- package/dist/operations/map.js +8 -10
- package/dist/operations/negated-binary.d.ts +5 -5
- package/dist/operations/negated-binary.js +7 -9
- package/dist/operations/new-instance.d.ts +5 -5
- package/dist/operations/new-instance.js +8 -10
- package/dist/operations/noop.d.ts +5 -5
- package/dist/operations/noop.js +6 -8
- package/dist/operations/not.d.ts +5 -5
- package/dist/operations/not.js +6 -8
- package/dist/operations/operation.d.ts +3 -3
- package/dist/operations/operation.js +2 -1
- package/dist/operations/reference.d.ts +4 -4
- package/dist/operations/reference.js +4 -6
- package/dist/operations/resolve.d.ts +6 -6
- package/dist/operations/resolve.js +27 -30
- package/dist/operations/return.d.ts +5 -5
- package/dist/operations/return.js +8 -10
- package/dist/operations/while.d.ts +6 -6
- package/dist/operations/while.js +9 -11
- package/dist/types/base.d.ts +1 -1
- package/dist/types/base.js +2 -1
- package/dist/types/boolean.d.ts +2 -2
- package/dist/types/boolean.js +4 -7
- package/dist/types/default.d.ts +7 -7
- package/dist/types/default.js +9 -8
- package/dist/types/function.d.ts +5 -5
- package/dist/types/function.js +27 -30
- package/dist/types/interface.d.ts +4 -4
- package/dist/types/interface.js +10 -13
- package/dist/types/list.d.ts +4 -4
- package/dist/types/list.js +21 -24
- package/dist/types/map.d.ts +5 -5
- package/dist/types/map.js +26 -29
- package/dist/types/nil.d.ts +2 -2
- package/dist/types/nil.js +4 -7
- package/dist/types/number.d.ts +4 -4
- package/dist/types/number.js +8 -11
- package/dist/types/string.d.ts +4 -4
- package/dist/types/string.js +19 -22
- package/dist/types/with-intrinsics.d.ts +4 -4
- package/dist/types/with-intrinsics.js +2 -5
- package/dist/utils/deep-equal.d.ts +1 -1
- package/dist/utils/deep-equal.js +4 -3
- package/dist/utils/object-value.d.ts +2 -2
- package/dist/utils/object-value.js +6 -8
- package/dist/utils/path.d.ts +1 -1
- package/dist/utils/path.js +2 -1
- package/package.json +2 -3
package/dist/context.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ASTBase } from 'greyscript-core';
|
|
2
|
-
import CPS from './cps';
|
|
3
|
-
import HandlerContainer from './handler-container';
|
|
4
|
-
import Operation from './operations/operation';
|
|
5
|
-
import CustomValue from './types/base';
|
|
6
|
-
import CustomMap from './types/map';
|
|
7
|
-
import CustomNil from './types/nil';
|
|
8
|
-
import ObjectValue from './utils/object-value';
|
|
9
|
-
import Path from './utils/path';
|
|
2
|
+
import { CPS } from './cps';
|
|
3
|
+
import { HandlerContainer } from './handler-container';
|
|
4
|
+
import { Operation } from './operations/operation';
|
|
5
|
+
import { CustomValue } from './types/base';
|
|
6
|
+
import { CustomMap } from './types/map';
|
|
7
|
+
import { CustomNil } from './types/nil';
|
|
8
|
+
import { ObjectValue } from './utils/object-value';
|
|
9
|
+
import { Path } from './utils/path';
|
|
10
10
|
export declare enum ContextType {
|
|
11
11
|
Api = 0,
|
|
12
12
|
Global = 1,
|
|
@@ -71,7 +71,7 @@ export interface ContextForkOptions {
|
|
|
71
71
|
target?: string;
|
|
72
72
|
injected?: boolean;
|
|
73
73
|
}
|
|
74
|
-
export
|
|
74
|
+
export declare class OperationContext {
|
|
75
75
|
target: string;
|
|
76
76
|
stackItem: ASTBase;
|
|
77
77
|
debugger: Debugger;
|
package/dist/context.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FunctionState = exports.LoopState = exports.ProcessState = exports.Debugger = exports.Scope = exports.ContextState = exports.ContextType = void 0;
|
|
7
|
-
const handler_container_1 =
|
|
8
|
-
const base_1 =
|
|
9
|
-
const default_1 =
|
|
10
|
-
const map_1 =
|
|
11
|
-
const path_1 =
|
|
3
|
+
exports.OperationContext = exports.FunctionState = exports.LoopState = exports.ProcessState = exports.Debugger = exports.Scope = exports.ContextState = exports.ContextType = void 0;
|
|
4
|
+
const handler_container_1 = require("./handler-container");
|
|
5
|
+
const base_1 = require("./types/base");
|
|
6
|
+
const default_1 = require("./types/default");
|
|
7
|
+
const map_1 = require("./types/map");
|
|
8
|
+
const path_1 = require("./utils/path");
|
|
12
9
|
var ContextType;
|
|
13
10
|
(function (ContextType) {
|
|
14
11
|
ContextType[ContextType["Api"] = 0] = "Api";
|
|
@@ -24,14 +21,14 @@ var ContextState;
|
|
|
24
21
|
ContextState[ContextState["Temporary"] = 0] = "Temporary";
|
|
25
22
|
ContextState[ContextState["Default"] = 1] = "Default";
|
|
26
23
|
})(ContextState = exports.ContextState || (exports.ContextState = {}));
|
|
27
|
-
class Scope extends map_1.
|
|
24
|
+
class Scope extends map_1.CustomMap {
|
|
28
25
|
constructor(context) {
|
|
29
26
|
super();
|
|
30
27
|
this.context = context;
|
|
31
28
|
}
|
|
32
29
|
get(path) {
|
|
33
|
-
if (path instanceof base_1.
|
|
34
|
-
return this.get(new path_1.
|
|
30
|
+
if (path instanceof base_1.CustomValue) {
|
|
31
|
+
return this.get(new path_1.Path([path]));
|
|
35
32
|
}
|
|
36
33
|
if (path.count() === 0) {
|
|
37
34
|
return this;
|
|
@@ -44,8 +41,8 @@ class Scope extends map_1.default {
|
|
|
44
41
|
else if (this.context.api.scope.has(path)) {
|
|
45
42
|
return this.context.api.scope.get(path);
|
|
46
43
|
}
|
|
47
|
-
else if (path.count() === 1 && map_1.
|
|
48
|
-
return map_1.
|
|
44
|
+
else if (path.count() === 1 && map_1.CustomMap.getIntrinsics().has(current)) {
|
|
45
|
+
return map_1.CustomMap.getIntrinsics().get(current);
|
|
49
46
|
}
|
|
50
47
|
else if (this.context.previous !== null) {
|
|
51
48
|
return this.context.previous.get(path);
|
|
@@ -66,7 +63,7 @@ class Debugger {
|
|
|
66
63
|
}
|
|
67
64
|
debug(...segments) {
|
|
68
65
|
console.debug(...segments);
|
|
69
|
-
return default_1.
|
|
66
|
+
return default_1.DefaultType.Void;
|
|
70
67
|
}
|
|
71
68
|
setBreakpoint(breakpoint) {
|
|
72
69
|
this.breakpoint = breakpoint;
|
|
@@ -125,7 +122,7 @@ class LoopState {
|
|
|
125
122
|
exports.LoopState = LoopState;
|
|
126
123
|
class FunctionState {
|
|
127
124
|
constructor() {
|
|
128
|
-
this.value = default_1.
|
|
125
|
+
this.value = default_1.DefaultType.Void;
|
|
129
126
|
this.isReturn = false;
|
|
130
127
|
this.context = null;
|
|
131
128
|
this.super = null;
|
|
@@ -143,7 +140,7 @@ class OperationContext {
|
|
|
143
140
|
this.isProtected = options.isProtected || false;
|
|
144
141
|
this.injected = options.injected || false;
|
|
145
142
|
this.debugger = options.debugger || new Debugger();
|
|
146
|
-
this.handler = options.handler || new handler_container_1.
|
|
143
|
+
this.handler = options.handler || new handler_container_1.HandlerContainer();
|
|
147
144
|
this.cps = options.cps || null;
|
|
148
145
|
this.processState = options.processState || new ProcessState();
|
|
149
146
|
this.environmentVariables = options.environmentVariables || new Map();
|
|
@@ -252,8 +249,8 @@ class OperationContext {
|
|
|
252
249
|
}
|
|
253
250
|
set(path, value) {
|
|
254
251
|
var _a;
|
|
255
|
-
if (path instanceof base_1.
|
|
256
|
-
this.set(new path_1.
|
|
252
|
+
if (path instanceof base_1.CustomValue) {
|
|
253
|
+
this.set(new path_1.Path([path]), value);
|
|
257
254
|
return;
|
|
258
255
|
}
|
|
259
256
|
if (this.state === ContextState.Temporary) {
|
|
@@ -265,8 +262,8 @@ class OperationContext {
|
|
|
265
262
|
}
|
|
266
263
|
get(path) {
|
|
267
264
|
var _a;
|
|
268
|
-
if (path instanceof base_1.
|
|
269
|
-
return this.get(new path_1.
|
|
265
|
+
if (path instanceof base_1.CustomValue) {
|
|
266
|
+
return this.get(new path_1.Path([path]));
|
|
270
267
|
}
|
|
271
268
|
if (path.count() === 0) {
|
|
272
269
|
return this.scope;
|
|
@@ -299,7 +296,6 @@ class OperationContext {
|
|
|
299
296
|
return newContext;
|
|
300
297
|
}
|
|
301
298
|
}
|
|
302
|
-
exports.default = OperationContext;
|
|
303
299
|
OperationContext.lookupApiType = [ContextType.Api];
|
|
304
300
|
OperationContext.lookupGlobalsType = [
|
|
305
301
|
ContextType.Global
|
|
@@ -308,3 +304,4 @@ OperationContext.lookupLocalsType = [
|
|
|
308
304
|
ContextType.Global,
|
|
309
305
|
ContextType.Function
|
|
310
306
|
];
|
|
307
|
+
exports.OperationContext = OperationContext;
|
package/dist/cps.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ASTBase } from 'greyscript-core';
|
|
2
|
-
import HandlerContainer from './handler-container';
|
|
3
|
-
import Operation from './operations/operation';
|
|
2
|
+
import { HandlerContainer } from './handler-container';
|
|
3
|
+
import { Operation } from './operations/operation';
|
|
4
4
|
export declare class CPSContext {
|
|
5
5
|
readonly target: string;
|
|
6
6
|
readonly handler: HandlerContainer;
|
|
7
7
|
constructor(target: string, handler: HandlerContainer);
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export declare class CPS {
|
|
10
10
|
private readonly context;
|
|
11
11
|
private __visit;
|
|
12
12
|
constructor(context: CPSContext);
|
package/dist/cps.js
CHANGED
|
@@ -8,37 +8,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.CPSContext = void 0;
|
|
12
|
+
exports.CPS = exports.CPSContext = void 0;
|
|
16
13
|
const greybel_core_1 = require("greybel-core");
|
|
17
14
|
const greyscript_core_1 = require("greyscript-core");
|
|
18
|
-
const assign_1 =
|
|
19
|
-
const break_1 =
|
|
20
|
-
const call_1 =
|
|
21
|
-
const chunk_1 =
|
|
22
|
-
const continue_1 =
|
|
23
|
-
const debugger_statement_1 =
|
|
24
|
-
const envar_1 =
|
|
25
|
-
const evaluate_1 =
|
|
26
|
-
const for_1 =
|
|
27
|
-
const function_1 =
|
|
28
|
-
const function_reference_1 =
|
|
29
|
-
const if_statement_1 =
|
|
30
|
-
const import_1 =
|
|
31
|
-
const include_1 =
|
|
32
|
-
const list_1 =
|
|
33
|
-
const literal_1 =
|
|
34
|
-
const map_1 =
|
|
35
|
-
const negated_binary_1 =
|
|
36
|
-
const new_instance_1 =
|
|
37
|
-
const noop_1 =
|
|
38
|
-
const not_1 =
|
|
39
|
-
const resolve_1 =
|
|
40
|
-
const return_1 =
|
|
41
|
-
const while_1 =
|
|
15
|
+
const assign_1 = require("./operations/assign");
|
|
16
|
+
const break_1 = require("./operations/break");
|
|
17
|
+
const call_1 = require("./operations/call");
|
|
18
|
+
const chunk_1 = require("./operations/chunk");
|
|
19
|
+
const continue_1 = require("./operations/continue");
|
|
20
|
+
const debugger_statement_1 = require("./operations/debugger-statement");
|
|
21
|
+
const envar_1 = require("./operations/envar");
|
|
22
|
+
const evaluate_1 = require("./operations/evaluate");
|
|
23
|
+
const for_1 = require("./operations/for");
|
|
24
|
+
const function_1 = require("./operations/function");
|
|
25
|
+
const function_reference_1 = require("./operations/function-reference");
|
|
26
|
+
const if_statement_1 = require("./operations/if-statement");
|
|
27
|
+
const import_1 = require("./operations/import");
|
|
28
|
+
const include_1 = require("./operations/include");
|
|
29
|
+
const list_1 = require("./operations/list");
|
|
30
|
+
const literal_1 = require("./operations/literal");
|
|
31
|
+
const map_1 = require("./operations/map");
|
|
32
|
+
const negated_binary_1 = require("./operations/negated-binary");
|
|
33
|
+
const new_instance_1 = require("./operations/new-instance");
|
|
34
|
+
const noop_1 = require("./operations/noop");
|
|
35
|
+
const not_1 = require("./operations/not");
|
|
36
|
+
const resolve_1 = require("./operations/resolve");
|
|
37
|
+
const return_1 = require("./operations/return");
|
|
38
|
+
const while_1 = require("./operations/while");
|
|
42
39
|
class CPSContext {
|
|
43
40
|
constructor(target, handler) {
|
|
44
41
|
this.target = target;
|
|
@@ -51,34 +48,34 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
51
48
|
const defaultVisit = visit.bind(null, context, stack);
|
|
52
49
|
switch (item.type) {
|
|
53
50
|
case greyscript_core_1.ASTType.MapConstructorExpression:
|
|
54
|
-
return new map_1.
|
|
51
|
+
return new map_1.MapOperation(item, currentTarget).build(defaultVisit);
|
|
55
52
|
case greyscript_core_1.ASTType.ListConstructorExpression:
|
|
56
|
-
return new list_1.
|
|
53
|
+
return new list_1.List(item, currentTarget).build(defaultVisit);
|
|
57
54
|
case greyscript_core_1.ASTType.AssignmentStatement:
|
|
58
|
-
return new assign_1.
|
|
55
|
+
return new assign_1.Assign(item, currentTarget).build(defaultVisit);
|
|
59
56
|
case greyscript_core_1.ASTType.MemberExpression:
|
|
60
57
|
case greyscript_core_1.ASTType.Identifier:
|
|
61
58
|
case greyscript_core_1.ASTType.IndexExpression:
|
|
62
|
-
return new resolve_1.
|
|
59
|
+
return new resolve_1.Resolve(item, currentTarget).build(defaultVisit);
|
|
63
60
|
case greyscript_core_1.ASTType.FunctionDeclaration:
|
|
64
|
-
return new function_1.
|
|
61
|
+
return new function_1.FunctionOperation(item, currentTarget).build(defaultVisit);
|
|
65
62
|
case greyscript_core_1.ASTType.InvalidCodeExpression:
|
|
66
|
-
return new noop_1.
|
|
63
|
+
return new noop_1.Noop(item, currentTarget).build(defaultVisit);
|
|
67
64
|
case greyscript_core_1.ASTType.WhileStatement:
|
|
68
|
-
return new while_1.
|
|
65
|
+
return new while_1.While(item, currentTarget).build(defaultVisit);
|
|
69
66
|
case greyscript_core_1.ASTType.ForGenericStatement:
|
|
70
|
-
return new for_1.
|
|
67
|
+
return new for_1.For(item, currentTarget).build(defaultVisit);
|
|
71
68
|
case greyscript_core_1.ASTType.IfStatement:
|
|
72
69
|
case greyscript_core_1.ASTType.IfShortcutStatement:
|
|
73
|
-
return new if_statement_1.
|
|
70
|
+
return new if_statement_1.IfStatement(item, currentTarget).build(defaultVisit);
|
|
74
71
|
case greyscript_core_1.ASTType.ReturnStatement:
|
|
75
|
-
return new return_1.
|
|
72
|
+
return new return_1.Return(item, currentTarget).build(defaultVisit);
|
|
76
73
|
case greyscript_core_1.ASTType.BreakStatement:
|
|
77
|
-
return new break_1.
|
|
74
|
+
return new break_1.Break(item, currentTarget).build(defaultVisit);
|
|
78
75
|
case greyscript_core_1.ASTType.ContinueStatement:
|
|
79
|
-
return new continue_1.
|
|
76
|
+
return new continue_1.Continue(item, currentTarget).build(defaultVisit);
|
|
80
77
|
case greyscript_core_1.ASTType.CallExpression:
|
|
81
|
-
return new call_1.
|
|
78
|
+
return new call_1.Call(item, currentTarget).build(defaultVisit);
|
|
82
79
|
case greyscript_core_1.ASTType.CallStatement:
|
|
83
80
|
return defaultVisit(item.expression);
|
|
84
81
|
case greybel_core_1.ASTType.FeatureImportExpression: {
|
|
@@ -86,14 +83,14 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
86
83
|
const target = yield context.handler.resourceHandler.getTargetRelativeTo(currentTarget, importExpr.path);
|
|
87
84
|
if (stack.includes(target)) {
|
|
88
85
|
console.warn('Found circluar dependency. Using noop operation.');
|
|
89
|
-
return new noop_1.
|
|
86
|
+
return new noop_1.Noop(item, target);
|
|
90
87
|
}
|
|
91
88
|
const code = yield context.handler.resourceHandler.get(target);
|
|
92
89
|
if (code == null) {
|
|
93
90
|
throw new Error(`Cannot find import ${currentTarget}.`);
|
|
94
91
|
}
|
|
95
92
|
const subVisit = visit.bind(null, context, [...stack, target]);
|
|
96
|
-
const importStatement = yield new import_1.
|
|
93
|
+
const importStatement = yield new import_1.Import(importExpr, target, code).build(subVisit);
|
|
97
94
|
return importStatement;
|
|
98
95
|
}
|
|
99
96
|
case greybel_core_1.ASTType.FeatureIncludeExpression: {
|
|
@@ -101,14 +98,14 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
101
98
|
const target = yield context.handler.resourceHandler.getTargetRelativeTo(currentTarget, includeExpr.path);
|
|
102
99
|
if (stack.includes(target)) {
|
|
103
100
|
console.warn('Found circluar dependency. Using noop operation.');
|
|
104
|
-
return new noop_1.
|
|
101
|
+
return new noop_1.Noop(item, target);
|
|
105
102
|
}
|
|
106
103
|
const code = yield context.handler.resourceHandler.get(target);
|
|
107
104
|
if (code == null) {
|
|
108
105
|
throw new Error(`Cannot find include ${currentTarget}.`);
|
|
109
106
|
}
|
|
110
107
|
const subVisit = visit.bind(null, context, [...stack, target]);
|
|
111
|
-
const importStatement = yield new include_1.
|
|
108
|
+
const importStatement = yield new include_1.Include(includeExpr, target, code).build(subVisit);
|
|
112
109
|
return importStatement;
|
|
113
110
|
}
|
|
114
111
|
case greyscript_core_1.ASTType.ImportCodeExpression: {
|
|
@@ -116,49 +113,49 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
116
113
|
const target = yield context.handler.resourceHandler.getTargetRelativeTo(currentTarget, importExpr.fileSystemDirectory);
|
|
117
114
|
if (stack.includes(target)) {
|
|
118
115
|
console.warn('Found circluar dependency. Using noop operation.');
|
|
119
|
-
return new noop_1.
|
|
116
|
+
return new noop_1.Noop(item, target);
|
|
120
117
|
}
|
|
121
118
|
const code = yield context.handler.resourceHandler.get(target);
|
|
122
119
|
if (code == null) {
|
|
123
120
|
throw new Error(`Cannot find native import ${currentTarget}.`);
|
|
124
121
|
}
|
|
125
122
|
const subVisit = visit.bind(null, context, [...stack, target]);
|
|
126
|
-
const importStatement = yield new include_1.
|
|
123
|
+
const importStatement = yield new include_1.Include(importExpr, target, code).build(subVisit);
|
|
127
124
|
return importStatement;
|
|
128
125
|
}
|
|
129
126
|
case greybel_core_1.ASTType.FeatureDebuggerExpression:
|
|
130
|
-
return new debugger_statement_1.
|
|
127
|
+
return new debugger_statement_1.DebuggerStatement(item, currentTarget);
|
|
131
128
|
case greybel_core_1.ASTType.FeatureEnvarExpression:
|
|
132
|
-
return new envar_1.
|
|
129
|
+
return new envar_1.EnvarExpression(item, currentTarget);
|
|
133
130
|
case greyscript_core_1.ASTType.BooleanLiteral:
|
|
134
131
|
case greyscript_core_1.ASTType.StringLiteral:
|
|
135
132
|
case greyscript_core_1.ASTType.NumericLiteral:
|
|
136
133
|
case greyscript_core_1.ASTType.NilLiteral:
|
|
137
|
-
return new literal_1.
|
|
134
|
+
return new literal_1.Literal(item, currentTarget).build(defaultVisit);
|
|
138
135
|
case greyscript_core_1.ASTType.EmptyExpression:
|
|
139
|
-
return new noop_1.
|
|
136
|
+
return new noop_1.Noop(item, currentTarget).build(defaultVisit);
|
|
140
137
|
case greyscript_core_1.ASTType.IsaExpression:
|
|
141
138
|
case greyscript_core_1.ASTType.BinaryExpression:
|
|
142
139
|
case greyscript_core_1.ASTType.LogicalExpression:
|
|
143
|
-
return new evaluate_1.
|
|
140
|
+
return new evaluate_1.Evaluate(item, currentTarget).build(defaultVisit);
|
|
144
141
|
case greyscript_core_1.ASTType.NegationExpression:
|
|
145
|
-
return new not_1.
|
|
142
|
+
return new not_1.Not(item, currentTarget).build(defaultVisit);
|
|
146
143
|
case greyscript_core_1.ASTType.BinaryNegatedExpression:
|
|
147
|
-
return new negated_binary_1.
|
|
144
|
+
return new negated_binary_1.NegatedBinary(item, currentTarget).build(defaultVisit);
|
|
148
145
|
case greyscript_core_1.ASTType.UnaryExpression: {
|
|
149
146
|
const unaryExpr = item;
|
|
150
147
|
if (unaryExpr.operator === 'new') {
|
|
151
|
-
return new new_instance_1.
|
|
148
|
+
return new new_instance_1.NewInstance(unaryExpr).build(defaultVisit);
|
|
152
149
|
}
|
|
153
150
|
else if (unaryExpr.operator === '@') {
|
|
154
|
-
return new function_reference_1.
|
|
151
|
+
return new function_reference_1.FunctionReference(unaryExpr).build(defaultVisit);
|
|
155
152
|
}
|
|
156
153
|
throw new Error('Unknown unary expression.');
|
|
157
154
|
}
|
|
158
155
|
case greyscript_core_1.ASTType.Chunk:
|
|
159
|
-
return new chunk_1.
|
|
156
|
+
return new chunk_1.Chunk(item, currentTarget).build(defaultVisit);
|
|
160
157
|
case greyscript_core_1.ASTType.Comment:
|
|
161
|
-
return new noop_1.
|
|
158
|
+
return new noop_1.Noop(item, currentTarget);
|
|
162
159
|
case greyscript_core_1.ASTType.ParenthesisExpression:
|
|
163
160
|
return defaultVisit(item.expression);
|
|
164
161
|
default:
|
|
@@ -174,4 +171,4 @@ class CPS {
|
|
|
174
171
|
return this.__visit(item);
|
|
175
172
|
}
|
|
176
173
|
}
|
|
177
|
-
exports.
|
|
174
|
+
exports.CPS = CPS;
|
package/dist/handler/output.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { CancelablePromise } from 'cancelable-promise';
|
|
2
1
|
export interface KeyEvent {
|
|
3
2
|
keyCode: number;
|
|
4
3
|
code: string;
|
|
5
4
|
}
|
|
6
5
|
export declare abstract class OutputHandler {
|
|
7
6
|
abstract print(message: string, appendNewLine?: boolean): void;
|
|
8
|
-
abstract progress(timeout: number):
|
|
9
|
-
abstract waitForInput(isPassword: boolean):
|
|
10
|
-
abstract waitForKeyPress():
|
|
7
|
+
abstract progress(timeout: number): PromiseLike<void>;
|
|
8
|
+
abstract waitForInput(isPassword: boolean, message?: string): PromiseLike<string>;
|
|
9
|
+
abstract waitForKeyPress(message?: string): PromiseLike<KeyEvent>;
|
|
11
10
|
abstract clear(): void;
|
|
12
11
|
}
|
|
13
12
|
export declare class DefaultOutputHandler extends OutputHandler {
|
|
14
13
|
print(message: string, appendNewLine?: boolean): void;
|
|
15
|
-
progress(timeout: number):
|
|
16
|
-
waitForInput(_isPassword: boolean):
|
|
17
|
-
waitForKeyPress():
|
|
14
|
+
progress(timeout: number): PromiseLike<void>;
|
|
15
|
+
waitForInput(_isPassword: boolean, _message?: string): PromiseLike<string>;
|
|
16
|
+
waitForKeyPress(_message?: string): PromiseLike<KeyEvent>;
|
|
18
17
|
clear(): void;
|
|
19
18
|
}
|
package/dist/handler/output.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultOutputHandler = exports.OutputHandler = void 0;
|
|
4
|
-
const cancelable_promise_1 = require("cancelable-promise");
|
|
5
4
|
class OutputHandler {
|
|
6
5
|
}
|
|
7
6
|
exports.OutputHandler = OutputHandler;
|
|
@@ -15,19 +14,15 @@ class DefaultOutputHandler extends OutputHandler {
|
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
progress(timeout) {
|
|
18
|
-
return new
|
|
19
|
-
|
|
20
|
-
onCancel(() => {
|
|
21
|
-
clearTimeout(timer);
|
|
22
|
-
resolve();
|
|
23
|
-
});
|
|
17
|
+
return new Promise((resolve, _reject) => {
|
|
18
|
+
setTimeout(resolve, timeout);
|
|
24
19
|
});
|
|
25
20
|
}
|
|
26
|
-
waitForInput(_isPassword) {
|
|
27
|
-
return
|
|
21
|
+
waitForInput(_isPassword, _message) {
|
|
22
|
+
return Promise.resolve('test');
|
|
28
23
|
}
|
|
29
|
-
waitForKeyPress() {
|
|
30
|
-
return
|
|
24
|
+
waitForKeyPress(_message) {
|
|
25
|
+
return Promise.resolve({
|
|
31
26
|
keyCode: 13,
|
|
32
27
|
code: 'Enter'
|
|
33
28
|
});
|
|
@@ -6,7 +6,7 @@ export interface HandlerContainerOptions {
|
|
|
6
6
|
outputHandler?: OutputHandler;
|
|
7
7
|
errorHandler?: ErrorHandler;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export declare class HandlerContainer {
|
|
10
10
|
readonly resourceHandler: ResourceHandler;
|
|
11
11
|
readonly outputHandler: OutputHandler;
|
|
12
12
|
readonly errorHandler: ErrorHandler;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HandlerContainer = void 0;
|
|
3
4
|
const error_1 = require("./handler/error");
|
|
4
5
|
const output_1 = require("./handler/output");
|
|
5
6
|
const resource_1 = require("./handler/resource");
|
|
@@ -11,4 +12,4 @@ class HandlerContainer {
|
|
|
11
12
|
this.errorHandler = (options === null || options === void 0 ? void 0 : options.errorHandler) || new error_1.DefaultErrorHandler();
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
|
-
exports.
|
|
15
|
+
exports.HandlerContainer = HandlerContainer;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
export { ContextForkOptions, ContextOptions, ContextState, ContextType, Debugger, FunctionState, LoopState,
|
|
2
|
-
export {
|
|
1
|
+
export { ContextForkOptions, ContextOptions, ContextState, ContextType, Debugger, FunctionState, LoopState, OperationContext, ProcessState, Scope } from './context';
|
|
2
|
+
export { CPS, CPSContext } from './cps';
|
|
3
3
|
export { DefaultErrorHandler, ErrorHandler } from './handler/error';
|
|
4
4
|
export { DefaultOutputHandler, KeyEvent, OutputHandler } from './handler/output';
|
|
5
5
|
export { DefaultResourceHandler, ResourceHandler } from './handler/resource';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export { Clause,
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export { CPSVisit,
|
|
29
|
-
export {
|
|
30
|
-
export { IdentifierSegment, IndexSegment, OperationSegment,
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
export { Argument, Callback,
|
|
37
|
-
export {
|
|
38
|
-
export {
|
|
39
|
-
export {
|
|
40
|
-
export {
|
|
41
|
-
export {
|
|
42
|
-
export {
|
|
6
|
+
export { HandlerContainer } from './handler-container';
|
|
7
|
+
export { Interpreter, InterpreterOptions } from './interpreter';
|
|
8
|
+
export { Assign } from './operations/assign';
|
|
9
|
+
export { Block, IsEOL } from './operations/block';
|
|
10
|
+
export { Break } from './operations/break';
|
|
11
|
+
export { Call } from './operations/call';
|
|
12
|
+
export { Chunk } from './operations/chunk';
|
|
13
|
+
export { Continue } from './operations/continue';
|
|
14
|
+
export { DebuggerStatement } from './operations/debugger-statement';
|
|
15
|
+
export { Evaluate, GenericProcessorHandler, handle, handleInterface, handleList, handleMap, handleNumber, handleString, ListProcessorHandler, MapProcessorHandler, NumberProcessorHandler, ProcessorHandler, ProcessorHandlerFunction, StringProcessorHandler } from './operations/evaluate';
|
|
16
|
+
export { For } from './operations/for';
|
|
17
|
+
export { FunctionOperation } from './operations/function';
|
|
18
|
+
export { Clause, IfStatement } from './operations/if-statement';
|
|
19
|
+
export { Import } from './operations/import';
|
|
20
|
+
export { Include } from './operations/include';
|
|
21
|
+
export { List } from './operations/list';
|
|
22
|
+
export { Literal } from './operations/literal';
|
|
23
|
+
export { MapOperation } from './operations/map';
|
|
24
|
+
export { NegatedBinary } from './operations/negated-binary';
|
|
25
|
+
export { NewInstance } from './operations/new-instance';
|
|
26
|
+
export { Noop } from './operations/noop';
|
|
27
|
+
export { Not } from './operations/not';
|
|
28
|
+
export { CPSVisit, Operation } from './operations/operation';
|
|
29
|
+
export { Reference } from './operations/reference';
|
|
30
|
+
export { IdentifierSegment, IndexSegment, OperationSegment, Resolve, ResolveResult, Segment } from './operations/resolve';
|
|
31
|
+
export { Return } from './operations/return';
|
|
32
|
+
export { While } from './operations/while';
|
|
33
|
+
export { CustomValue } from './types/base';
|
|
34
|
+
export { CustomBoolean } from './types/boolean';
|
|
35
|
+
export { DefaultType } from './types/default';
|
|
36
|
+
export { Argument, Callback, CustomFunction } from './types/function';
|
|
37
|
+
export { CustomInterface, CustomInterfaceIterator } from './types/interface';
|
|
38
|
+
export { CustomList, CustomListIterator } from './types/list';
|
|
39
|
+
export { CustomMap, CustomMapIterator } from './types/map';
|
|
40
|
+
export { CustomNil } from './types/nil';
|
|
41
|
+
export { CustomNumber } from './types/number';
|
|
42
|
+
export { CustomString, CustomStringIterator } from './types/string';
|
|
43
43
|
export { CustomObject, CustomValueWithIntrinsics } from './types/with-intrinsics';
|
|
44
|
-
export {
|
|
45
|
-
export {
|
|
46
|
-
export {
|
|
44
|
+
export { deepEqual } from './utils/deep-equal';
|
|
45
|
+
export { ObjectValue } from './utils/object-value';
|
|
46
|
+
export { Path } from './utils/path';
|