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
|
@@ -8,14 +8,12 @@ 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 });
|
|
12
|
+
exports.NegatedBinary = void 0;
|
|
15
13
|
const greyscript_core_1 = require("greyscript-core");
|
|
16
|
-
const number_1 =
|
|
17
|
-
const operation_1 =
|
|
18
|
-
class NegatedBinary extends operation_1.
|
|
14
|
+
const number_1 = require("../types/number");
|
|
15
|
+
const operation_1 = require("./operation");
|
|
16
|
+
class NegatedBinary extends operation_1.Operation {
|
|
19
17
|
constructor(item, target) {
|
|
20
18
|
super(null, target);
|
|
21
19
|
this.item = item;
|
|
@@ -30,13 +28,13 @@ class NegatedBinary extends operation_1.default {
|
|
|
30
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
29
|
switch (this.item.operator) {
|
|
32
30
|
case greyscript_core_1.Operator.Minus:
|
|
33
|
-
return new number_1.
|
|
31
|
+
return new number_1.CustomNumber(-(yield this.arg.handle(ctx)).toNumber());
|
|
34
32
|
case greyscript_core_1.Operator.Plus:
|
|
35
|
-
return new number_1.
|
|
33
|
+
return new number_1.CustomNumber(+(yield this.arg.handle(ctx)).toNumber());
|
|
36
34
|
default:
|
|
37
35
|
throw new Error('Unexpected negation operator.');
|
|
38
36
|
}
|
|
39
37
|
});
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
exports.
|
|
40
|
+
exports.NegatedBinary = NegatedBinary;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ASTUnaryExpression } from 'greyscript-core';
|
|
2
|
-
import
|
|
3
|
-
import CustomValue from '../types/base';
|
|
4
|
-
import
|
|
5
|
-
export
|
|
2
|
+
import { OperationContext } from '../context';
|
|
3
|
+
import { CustomValue } from '../types/base';
|
|
4
|
+
import { CPSVisit, Operation } from './operation';
|
|
5
|
+
export declare class NewInstance extends Operation {
|
|
6
6
|
readonly item: ASTUnaryExpression;
|
|
7
7
|
arg: Operation;
|
|
8
8
|
constructor(item: ASTUnaryExpression, target?: string);
|
|
9
9
|
build(visit: CPSVisit): Promise<Operation>;
|
|
10
|
-
handle(ctx:
|
|
10
|
+
handle(ctx: OperationContext): Promise<CustomValue>;
|
|
11
11
|
}
|
|
@@ -8,14 +8,12 @@ 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
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
12
|
+
exports.NewInstance = void 0;
|
|
13
|
+
const default_1 = require("../types/default");
|
|
14
|
+
const map_1 = require("../types/map");
|
|
15
|
+
const operation_1 = require("./operation");
|
|
16
|
+
class NewInstance extends operation_1.Operation {
|
|
19
17
|
constructor(item, target) {
|
|
20
18
|
super(null, target);
|
|
21
19
|
this.item = item;
|
|
@@ -29,11 +27,11 @@ class NewInstance extends operation_1.default {
|
|
|
29
27
|
handle(ctx) {
|
|
30
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
29
|
const resolvedArg = yield this.arg.handle(ctx);
|
|
32
|
-
if (resolvedArg instanceof map_1.
|
|
30
|
+
if (resolvedArg instanceof map_1.CustomMap) {
|
|
33
31
|
return resolvedArg.createInstance();
|
|
34
32
|
}
|
|
35
|
-
return default_1.
|
|
33
|
+
return default_1.DefaultType.Void;
|
|
36
34
|
});
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
|
-
exports.
|
|
37
|
+
exports.NewInstance = NewInstance;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import CustomValue from '../types/base';
|
|
3
|
-
import
|
|
4
|
-
export
|
|
1
|
+
import { OperationContext } from '../context';
|
|
2
|
+
import { CustomValue } from '../types/base';
|
|
3
|
+
import { CPSVisit, Operation } from './operation';
|
|
4
|
+
export declare class Noop extends Operation {
|
|
5
5
|
build(_visit: CPSVisit): Promise<Operation>;
|
|
6
|
-
handle(_ctx:
|
|
6
|
+
handle(_ctx: OperationContext): Promise<CustomValue>;
|
|
7
7
|
}
|
package/dist/operations/noop.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
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
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
3
|
+
exports.Noop = void 0;
|
|
4
|
+
const default_1 = require("../types/default");
|
|
5
|
+
const operation_1 = require("./operation");
|
|
6
|
+
class Noop extends operation_1.Operation {
|
|
9
7
|
build(_visit) {
|
|
10
8
|
return Promise.resolve(this);
|
|
11
9
|
}
|
|
12
10
|
handle(_ctx) {
|
|
13
|
-
return Promise.resolve(default_1.
|
|
11
|
+
return Promise.resolve(default_1.DefaultType.Void);
|
|
14
12
|
}
|
|
15
13
|
}
|
|
16
|
-
exports.
|
|
14
|
+
exports.Noop = Noop;
|
package/dist/operations/not.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ASTUnaryExpression } from 'greyscript-core';
|
|
2
|
-
import
|
|
3
|
-
import CustomValue from '../types/base';
|
|
4
|
-
import
|
|
5
|
-
export
|
|
2
|
+
import { OperationContext } from '../context';
|
|
3
|
+
import { CustomValue } from '../types/base';
|
|
4
|
+
import { CPSVisit, Operation } from './operation';
|
|
5
|
+
export declare class Not extends Operation {
|
|
6
6
|
readonly item: ASTUnaryExpression;
|
|
7
7
|
arg: Operation;
|
|
8
8
|
constructor(item: ASTUnaryExpression, target?: string);
|
|
9
9
|
build(visit: CPSVisit): Promise<Operation>;
|
|
10
|
-
handle(ctx:
|
|
10
|
+
handle(ctx: OperationContext): Promise<CustomValue>;
|
|
11
11
|
}
|
package/dist/operations/not.js
CHANGED
|
@@ -8,13 +8,11 @@ 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
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
12
|
+
exports.Not = void 0;
|
|
13
|
+
const boolean_1 = require("../types/boolean");
|
|
14
|
+
const operation_1 = require("./operation");
|
|
15
|
+
class Not extends operation_1.Operation {
|
|
18
16
|
constructor(item, target) {
|
|
19
17
|
super(null, target);
|
|
20
18
|
this.item = item;
|
|
@@ -28,8 +26,8 @@ class Not extends operation_1.default {
|
|
|
28
26
|
handle(ctx) {
|
|
29
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
28
|
const result = yield this.arg.handle(ctx);
|
|
31
|
-
return new boolean_1.
|
|
29
|
+
return new boolean_1.CustomBoolean(!result.toTruthy());
|
|
32
30
|
});
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
|
-
exports.
|
|
33
|
+
exports.Not = Not;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ASTBase } from 'greyscript-core';
|
|
2
|
-
import OperationContext from '../context';
|
|
3
|
-
import CustomValue from '../types/base';
|
|
2
|
+
import { OperationContext } from '../context';
|
|
3
|
+
import { CustomValue } from '../types/base';
|
|
4
4
|
export interface CPSVisit {
|
|
5
5
|
(item: ASTBase): Promise<Operation>;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export declare abstract class Operation {
|
|
8
8
|
readonly item: ASTBase;
|
|
9
9
|
readonly target: string;
|
|
10
10
|
constructor(item: ASTBase, target?: string);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Operation = void 0;
|
|
3
4
|
class Operation {
|
|
4
5
|
constructor(item, target = null) {
|
|
5
6
|
this.item = item;
|
|
6
7
|
this.target = target;
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
|
-
exports.
|
|
10
|
+
exports.Operation = Operation;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import OperationContext from '../context';
|
|
2
|
-
import CustomValue from '../types/base';
|
|
3
|
-
import
|
|
4
|
-
export
|
|
1
|
+
import { OperationContext } from '../context';
|
|
2
|
+
import { CustomValue } from '../types/base';
|
|
3
|
+
import { CPSVisit, Operation } from './operation';
|
|
4
|
+
export declare class Reference extends Operation {
|
|
5
5
|
readonly value: CustomValue;
|
|
6
6
|
constructor(value: CustomValue);
|
|
7
7
|
build(_visit: CPSVisit): Promise<Reference>;
|
|
@@ -1,10 +1,8 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
3
|
+
exports.Reference = void 0;
|
|
4
|
+
const operation_1 = require("./operation");
|
|
5
|
+
class Reference extends operation_1.Operation {
|
|
8
6
|
constructor(value) {
|
|
9
7
|
super(null, 'native');
|
|
10
8
|
this.value = value;
|
|
@@ -16,4 +14,4 @@ class Reference extends operation_1.default {
|
|
|
16
14
|
return Promise.resolve(this.value);
|
|
17
15
|
}
|
|
18
16
|
}
|
|
19
|
-
exports.
|
|
17
|
+
exports.Reference = Reference;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ASTBase } from 'greyscript-core';
|
|
2
|
-
import OperationContext from '../context';
|
|
3
|
-
import CustomValue from '../types/base';
|
|
4
|
-
import Path from '../utils/path';
|
|
5
|
-
import
|
|
2
|
+
import { OperationContext } from '../context';
|
|
3
|
+
import { CustomValue } from '../types/base';
|
|
4
|
+
import { Path } from '../utils/path';
|
|
5
|
+
import { CPSVisit, Operation } from './operation';
|
|
6
6
|
export declare class SliceSegment {
|
|
7
7
|
readonly left: Operation;
|
|
8
8
|
readonly right: Operation;
|
|
@@ -25,7 +25,7 @@ export declare class OperationSegment {
|
|
|
25
25
|
readonly op: Operation;
|
|
26
26
|
constructor(op: Operation);
|
|
27
27
|
}
|
|
28
|
-
export
|
|
28
|
+
export type Segment = SliceSegment | IdentifierSegment | IndexSegment | OperationSegment;
|
|
29
29
|
export declare class SegmentContainer {
|
|
30
30
|
path: Array<Segment>;
|
|
31
31
|
constructor();
|
|
@@ -40,7 +40,7 @@ export declare class ResolveResult {
|
|
|
40
40
|
readonly handle: CustomValue;
|
|
41
41
|
constructor(path: Path<CustomValue>, handle: CustomValue);
|
|
42
42
|
}
|
|
43
|
-
export
|
|
43
|
+
export declare class Resolve extends Operation {
|
|
44
44
|
readonly item: ASTBase;
|
|
45
45
|
path: SegmentContainer;
|
|
46
46
|
last: Segment;
|
|
@@ -8,20 +8,17 @@ 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.ResolveResult = exports.SegmentContainer = exports.OperationSegment = exports.IndexSegment = exports.IdentifierSegment = exports.PathSegment = exports.SliceSegment = void 0;
|
|
12
|
+
exports.Resolve = exports.ResolveResult = exports.SegmentContainer = exports.OperationSegment = exports.IndexSegment = exports.IdentifierSegment = exports.PathSegment = exports.SliceSegment = void 0;
|
|
16
13
|
const greyscript_core_1 = require("greyscript-core");
|
|
17
|
-
const default_1 =
|
|
18
|
-
const function_1 =
|
|
19
|
-
const list_1 =
|
|
20
|
-
const map_1 =
|
|
21
|
-
const string_1 =
|
|
14
|
+
const default_1 = require("../types/default");
|
|
15
|
+
const function_1 = require("../types/function");
|
|
16
|
+
const list_1 = require("../types/list");
|
|
17
|
+
const map_1 = require("../types/map");
|
|
18
|
+
const string_1 = require("../types/string");
|
|
22
19
|
const with_intrinsics_1 = require("../types/with-intrinsics");
|
|
23
|
-
const path_1 =
|
|
24
|
-
const operation_1 =
|
|
20
|
+
const path_1 = require("../utils/path");
|
|
21
|
+
const operation_1 = require("./operation");
|
|
25
22
|
class SliceSegment {
|
|
26
23
|
constructor(left, right) {
|
|
27
24
|
this.left = left;
|
|
@@ -32,7 +29,7 @@ exports.SliceSegment = SliceSegment;
|
|
|
32
29
|
class PathSegment {
|
|
33
30
|
toPath(_ctx) {
|
|
34
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
return Promise.resolve(default_1.
|
|
32
|
+
return Promise.resolve(default_1.DefaultType.Void);
|
|
36
33
|
});
|
|
37
34
|
}
|
|
38
35
|
}
|
|
@@ -43,7 +40,7 @@ class IdentifierSegment extends PathSegment {
|
|
|
43
40
|
this.value = value;
|
|
44
41
|
}
|
|
45
42
|
toPath(_ctx) {
|
|
46
|
-
return Promise.resolve(new string_1.
|
|
43
|
+
return Promise.resolve(new string_1.CustomString(this.value));
|
|
47
44
|
}
|
|
48
45
|
}
|
|
49
46
|
exports.IdentifierSegment = IdentifierSegment;
|
|
@@ -96,7 +93,7 @@ class ResolveResult {
|
|
|
96
93
|
}
|
|
97
94
|
}
|
|
98
95
|
exports.ResolveResult = ResolveResult;
|
|
99
|
-
class Resolve extends operation_1.
|
|
96
|
+
class Resolve extends operation_1.Operation {
|
|
100
97
|
constructor(item, target) {
|
|
101
98
|
super(null, target);
|
|
102
99
|
this.item = item;
|
|
@@ -150,8 +147,8 @@ class Resolve extends operation_1.default {
|
|
|
150
147
|
}
|
|
151
148
|
getResult(ctx) {
|
|
152
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
let traversedPath = new path_1.
|
|
154
|
-
let handle = default_1.
|
|
150
|
+
let traversedPath = new path_1.Path();
|
|
151
|
+
let handle = default_1.DefaultType.Void;
|
|
155
152
|
const maxIndex = this.path.count();
|
|
156
153
|
const lastIndex = maxIndex - 1;
|
|
157
154
|
for (let index = 0; index < maxIndex; index++) {
|
|
@@ -166,7 +163,7 @@ class Resolve extends operation_1.default {
|
|
|
166
163
|
break;
|
|
167
164
|
}
|
|
168
165
|
const previous = handle;
|
|
169
|
-
if (handle !== default_1.
|
|
166
|
+
if (handle !== default_1.DefaultType.Void) {
|
|
170
167
|
if (handle instanceof with_intrinsics_1.CustomValueWithIntrinsics) {
|
|
171
168
|
const customValueCtx = handle;
|
|
172
169
|
handle = customValueCtx.get(traversedPath);
|
|
@@ -178,24 +175,24 @@ class Resolve extends operation_1.default {
|
|
|
178
175
|
else {
|
|
179
176
|
handle = ctx.get(traversedPath);
|
|
180
177
|
}
|
|
181
|
-
if (handle instanceof function_1.
|
|
178
|
+
if (handle instanceof function_1.CustomFunction) {
|
|
182
179
|
if (index === 1 &&
|
|
183
180
|
traversedPath.toString() === 'super' &&
|
|
184
181
|
ctx.functionState.context &&
|
|
185
|
-
previous instanceof map_1.
|
|
182
|
+
previous instanceof map_1.CustomMap) {
|
|
186
183
|
handle = yield handle.run(ctx.functionState.context, [], ctx, previous.isa);
|
|
187
184
|
}
|
|
188
185
|
else {
|
|
189
|
-
handle = yield handle.run(previous || default_1.
|
|
186
|
+
handle = yield handle.run(previous || default_1.DefaultType.Void, [], ctx);
|
|
190
187
|
}
|
|
191
188
|
}
|
|
192
|
-
traversedPath = new path_1.
|
|
189
|
+
traversedPath = new path_1.Path();
|
|
193
190
|
}
|
|
194
191
|
else if (current instanceof SliceSegment) {
|
|
195
192
|
const sliceSegment = current;
|
|
196
193
|
const left = yield sliceSegment.left.handle(ctx);
|
|
197
194
|
const right = yield sliceSegment.right.handle(ctx);
|
|
198
|
-
if (handle instanceof list_1.
|
|
195
|
+
if (handle instanceof list_1.CustomList || handle instanceof string_1.CustomString) {
|
|
199
196
|
handle = handle.slice(left, right);
|
|
200
197
|
}
|
|
201
198
|
else {
|
|
@@ -211,19 +208,19 @@ class Resolve extends operation_1.default {
|
|
|
211
208
|
if (result === null) {
|
|
212
209
|
result = yield this.getResult(ctx);
|
|
213
210
|
}
|
|
214
|
-
if (result.handle !== default_1.
|
|
211
|
+
if (result.handle !== default_1.DefaultType.Void) {
|
|
215
212
|
if (result.path.count() === 0) {
|
|
216
|
-
if (autoCall && result.handle instanceof function_1.
|
|
217
|
-
return result.handle.run(default_1.
|
|
213
|
+
if (autoCall && result.handle instanceof function_1.CustomFunction) {
|
|
214
|
+
return result.handle.run(default_1.DefaultType.Void, [], ctx);
|
|
218
215
|
}
|
|
219
216
|
return result.handle;
|
|
220
217
|
}
|
|
221
218
|
const customValueCtx = result.handle;
|
|
222
219
|
const child = customValueCtx.get(result.path);
|
|
223
|
-
if (autoCall && child instanceof function_1.
|
|
220
|
+
if (autoCall && child instanceof function_1.CustomFunction) {
|
|
224
221
|
if (this.path.isSuper() &&
|
|
225
222
|
ctx.functionState.context &&
|
|
226
|
-
customValueCtx instanceof map_1.
|
|
223
|
+
customValueCtx instanceof map_1.CustomMap) {
|
|
227
224
|
return child.run(ctx.functionState.context, [], ctx, customValueCtx.isa);
|
|
228
225
|
}
|
|
229
226
|
return child.run(customValueCtx, [], ctx);
|
|
@@ -231,11 +228,11 @@ class Resolve extends operation_1.default {
|
|
|
231
228
|
return child;
|
|
232
229
|
}
|
|
233
230
|
const handle = ctx.get(result.path);
|
|
234
|
-
if (autoCall && handle instanceof function_1.
|
|
235
|
-
return handle.run(default_1.
|
|
231
|
+
if (autoCall && handle instanceof function_1.CustomFunction) {
|
|
232
|
+
return handle.run(default_1.DefaultType.Void, [], ctx);
|
|
236
233
|
}
|
|
237
234
|
return handle;
|
|
238
235
|
});
|
|
239
236
|
}
|
|
240
237
|
}
|
|
241
|
-
exports.
|
|
238
|
+
exports.Resolve = Resolve;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ASTReturnStatement } from 'greyscript-core';
|
|
2
|
-
import
|
|
3
|
-
import CustomValue from '../types/base';
|
|
4
|
-
import
|
|
5
|
-
export
|
|
2
|
+
import { OperationContext } from '../context';
|
|
3
|
+
import { CustomValue } from '../types/base';
|
|
4
|
+
import { CPSVisit, Operation } from './operation';
|
|
5
|
+
export declare class Return extends Operation {
|
|
6
6
|
readonly item: ASTReturnStatement;
|
|
7
7
|
arg: Operation;
|
|
8
8
|
constructor(item: ASTReturnStatement, target?: string);
|
|
9
9
|
build(visit: CPSVisit): Promise<Operation>;
|
|
10
|
-
handle(ctx:
|
|
10
|
+
handle(ctx: OperationContext): Promise<CustomValue>;
|
|
11
11
|
}
|
|
@@ -8,14 +8,12 @@ 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
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
12
|
+
exports.Return = void 0;
|
|
13
|
+
const default_1 = require("../types/default");
|
|
14
|
+
const operation_1 = require("./operation");
|
|
15
|
+
const reference_1 = require("./reference");
|
|
16
|
+
class Return extends operation_1.Operation {
|
|
19
17
|
constructor(item, target) {
|
|
20
18
|
super(null, target);
|
|
21
19
|
this.item = item;
|
|
@@ -26,7 +24,7 @@ class Return extends operation_1.default {
|
|
|
26
24
|
this.arg = yield visit(this.item.argument);
|
|
27
25
|
}
|
|
28
26
|
else {
|
|
29
|
-
this.arg = new reference_1.
|
|
27
|
+
this.arg = new reference_1.Reference(default_1.DefaultType.Void);
|
|
30
28
|
}
|
|
31
29
|
return this;
|
|
32
30
|
});
|
|
@@ -38,8 +36,8 @@ class Return extends operation_1.default {
|
|
|
38
36
|
ctx.functionState.value = yield this.arg.handle(ctx);
|
|
39
37
|
ctx.functionState.isReturn = true;
|
|
40
38
|
}
|
|
41
|
-
return default_1.
|
|
39
|
+
return default_1.DefaultType.Void;
|
|
42
40
|
});
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
|
-
exports.
|
|
43
|
+
exports.Return = Return;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ASTWhileStatement } from 'greyscript-core';
|
|
2
|
-
import
|
|
3
|
-
import CustomValue from '../types/base';
|
|
4
|
-
import Block from './block';
|
|
5
|
-
import
|
|
6
|
-
export
|
|
2
|
+
import { OperationContext } from '../context';
|
|
3
|
+
import { CustomValue } from '../types/base';
|
|
4
|
+
import { Block } from './block';
|
|
5
|
+
import { CPSVisit, Operation } from './operation';
|
|
6
|
+
export declare class While extends Operation {
|
|
7
7
|
readonly item: ASTWhileStatement;
|
|
8
8
|
block: Block;
|
|
9
9
|
condition: Operation;
|
|
10
10
|
constructor(item: ASTWhileStatement, target?: string);
|
|
11
11
|
build(visit: CPSVisit): Promise<Operation>;
|
|
12
|
-
handle(ctx:
|
|
12
|
+
handle(ctx: OperationContext): Promise<CustomValue>;
|
|
13
13
|
}
|
package/dist/operations/while.js
CHANGED
|
@@ -8,15 +8,13 @@ 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 });
|
|
12
|
+
exports.While = void 0;
|
|
15
13
|
const context_1 = require("../context");
|
|
16
|
-
const default_1 =
|
|
17
|
-
const block_1 =
|
|
18
|
-
const operation_1 =
|
|
19
|
-
class While extends operation_1.
|
|
14
|
+
const default_1 = require("../types/default");
|
|
15
|
+
const block_1 = require("./block");
|
|
16
|
+
const operation_1 = require("./operation");
|
|
17
|
+
class While extends operation_1.Operation {
|
|
20
18
|
constructor(item, target) {
|
|
21
19
|
super(null, target);
|
|
22
20
|
this.item = item;
|
|
@@ -24,7 +22,7 @@ class While extends operation_1.default {
|
|
|
24
22
|
build(visit) {
|
|
25
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
24
|
const stack = yield Promise.all(this.item.body.map((child) => visit(child)));
|
|
27
|
-
this.block = new block_1.
|
|
25
|
+
this.block = new block_1.Block(this.item, stack);
|
|
28
26
|
this.condition = yield visit(this.item.condition);
|
|
29
27
|
return this;
|
|
30
28
|
});
|
|
@@ -42,13 +40,13 @@ class While extends operation_1.default {
|
|
|
42
40
|
try {
|
|
43
41
|
const conditionResult = yield this.condition.handle(whileCtx);
|
|
44
42
|
if (!conditionResult.toTruthy()) {
|
|
45
|
-
resolve(default_1.
|
|
43
|
+
resolve(default_1.DefaultType.Void);
|
|
46
44
|
return;
|
|
47
45
|
}
|
|
48
46
|
loopState.isContinue = false;
|
|
49
47
|
yield this.block.handle(whileCtx);
|
|
50
48
|
if (loopState.isBreak || ctx.isExit()) {
|
|
51
|
-
resolve(default_1.
|
|
49
|
+
resolve(default_1.DefaultType.Void);
|
|
52
50
|
return;
|
|
53
51
|
}
|
|
54
52
|
process.nextTick(iteration);
|
|
@@ -62,4 +60,4 @@ class While extends operation_1.default {
|
|
|
62
60
|
});
|
|
63
61
|
}
|
|
64
62
|
}
|
|
65
|
-
exports.
|
|
63
|
+
exports.While = While;
|
package/dist/types/base.d.ts
CHANGED
package/dist/types/base.js
CHANGED
package/dist/types/boolean.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import CustomValue from './base';
|
|
2
|
-
export
|
|
1
|
+
import { CustomValue } from './base';
|
|
2
|
+
export declare class CustomBoolean extends CustomValue {
|
|
3
3
|
readonly value: boolean;
|
|
4
4
|
constructor(value: boolean);
|
|
5
5
|
getCustomType(): string;
|
package/dist/types/boolean.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
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.DefaultFalse = exports.DefaultTrue = void 0;
|
|
7
|
-
const base_1 =
|
|
8
|
-
class CustomBoolean extends base_1.
|
|
3
|
+
exports.DefaultFalse = exports.DefaultTrue = exports.CustomBoolean = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
class CustomBoolean extends base_1.CustomValue {
|
|
9
6
|
constructor(value) {
|
|
10
7
|
super();
|
|
11
8
|
this.value = !!value;
|
|
@@ -35,6 +32,6 @@ class CustomBoolean extends base_1.default {
|
|
|
35
32
|
return v instanceof CustomBoolean;
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
exports.
|
|
35
|
+
exports.CustomBoolean = CustomBoolean;
|
|
39
36
|
exports.DefaultTrue = new CustomBoolean(true);
|
|
40
37
|
exports.DefaultFalse = new CustomBoolean(false);
|
package/dist/types/default.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
static readonly Void: import("./nil").
|
|
3
|
-
static readonly True: import("./boolean").
|
|
4
|
-
static readonly False: import("./boolean").
|
|
5
|
-
static readonly NegativeOne: import("./number").
|
|
6
|
-
static readonly PositiveOne: import("./number").
|
|
7
|
-
static readonly Zero: import("./number").
|
|
1
|
+
export declare class DefaultType {
|
|
2
|
+
static readonly Void: import("./nil").CustomNil;
|
|
3
|
+
static readonly True: import("./boolean").CustomBoolean;
|
|
4
|
+
static readonly False: import("./boolean").CustomBoolean;
|
|
5
|
+
static readonly NegativeOne: import("./number").CustomNumber;
|
|
6
|
+
static readonly PositiveOne: import("./number").CustomNumber;
|
|
7
|
+
static readonly Zero: import("./number").CustomNumber;
|
|
8
8
|
}
|
package/dist/types/default.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultType = void 0;
|
|
3
4
|
const boolean_1 = require("./boolean");
|
|
4
5
|
const nil_1 = require("./nil");
|
|
5
6
|
const number_1 = require("./number");
|
|
6
|
-
class
|
|
7
|
+
class DefaultType {
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
DefaultType.Void = nil_1.Void;
|
|
10
|
+
DefaultType.True = boolean_1.DefaultTrue;
|
|
11
|
+
DefaultType.False = boolean_1.DefaultFalse;
|
|
12
|
+
DefaultType.NegativeOne = number_1.NegativeOne;
|
|
13
|
+
DefaultType.PositiveOne = number_1.PositiveOne;
|
|
14
|
+
DefaultType.Zero = number_1.Zero;
|
|
15
|
+
exports.DefaultType = DefaultType;
|