greybel-interpreter 1.4.6 → 1.4.7
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/.editorconfig +14 -14
- package/.eslintrc +47 -47
- package/LICENSE +21 -21
- package/README.md +2 -2
- package/dist/context.d.ts +110 -110
- package/dist/context.js +306 -306
- package/dist/cps.d.ts +14 -14
- package/dist/cps.js +160 -160
- package/dist/handler/error.d.ts +6 -6
- package/dist/handler/error.js +12 -12
- package/dist/handler/output.d.ts +18 -18
- package/dist/handler/output.js +29 -29
- package/dist/handler/resource.d.ts +12 -12
- package/dist/handler/resource.js +28 -28
- package/dist/handler-container.d.ts +14 -14
- package/dist/handler-container.js +14 -14
- package/dist/index.d.ts +46 -46
- package/dist/index.js +132 -132
- package/dist/interpreter.d.ts +42 -42
- package/dist/interpreter.js +218 -218
- package/dist/operations/assign.d.ts +13 -13
- package/dist/operations/assign.js +46 -46
- package/dist/operations/block.d.ts +12 -12
- package/dist/operations/block.js +52 -52
- package/dist/operations/break.d.ts +10 -10
- package/dist/operations/break.js +23 -23
- package/dist/operations/call.d.ts +13 -13
- package/dist/operations/call.js +49 -49
- package/dist/operations/chunk.d.ts +12 -12
- package/dist/operations/chunk.js +33 -33
- package/dist/operations/continue.d.ts +10 -10
- package/dist/operations/continue.js +23 -23
- package/dist/operations/debugger-statement.d.ts +10 -10
- package/dist/operations/debugger-statement.js +21 -21
- package/dist/operations/evaluate.d.ts +40 -40
- package/dist/operations/evaluate.js +334 -334
- package/dist/operations/for.d.ts +14 -14
- package/dist/operations/for.js +81 -81
- package/dist/operations/function-reference.d.ts +12 -12
- package/dist/operations/function-reference.js +44 -44
- package/dist/operations/function.d.ts +14 -14
- package/dist/operations/function.js +72 -72
- package/dist/operations/if-statement.d.ts +19 -19
- package/dist/operations/if-statement.js +85 -85
- package/dist/operations/import.d.ts +17 -17
- package/dist/operations/import.js +57 -57
- package/dist/operations/include.d.ts +13 -13
- package/dist/operations/include.js +41 -41
- package/dist/operations/list.d.ts +11 -11
- package/dist/operations/list.js +42 -42
- package/dist/operations/literal.d.ts +11 -11
- package/dist/operations/literal.js +40 -40
- package/dist/operations/map.d.ts +11 -11
- package/dist/operations/map.js +44 -44
- package/dist/operations/negated-binary.d.ts +11 -11
- package/dist/operations/negated-binary.js +42 -42
- package/dist/operations/new-instance.d.ts +11 -11
- package/dist/operations/new-instance.js +39 -39
- package/dist/operations/noop.d.ts +9 -9
- package/dist/operations/noop.js +19 -19
- package/dist/operations/not.d.ts +11 -11
- package/dist/operations/not.js +35 -35
- package/dist/operations/operation.d.ts +13 -13
- package/dist/operations/operation.js +9 -9
- package/dist/operations/reference.d.ts +9 -9
- package/dist/operations/reference.js +19 -19
- package/dist/operations/resolve.d.ts +38 -38
- package/dist/operations/resolve.js +210 -210
- package/dist/operations/return.d.ts +11 -11
- package/dist/operations/return.js +45 -45
- package/dist/operations/while.d.ts +13 -13
- package/dist/operations/while.js +65 -65
- package/dist/types/base.d.ts +9 -9
- package/dist/types/base.js +5 -5
- package/dist/types/boolean.d.ts +13 -13
- package/dist/types/boolean.js +34 -34
- package/dist/types/default.d.ts +8 -8
- package/dist/types/default.js +14 -14
- package/dist/types/function.d.ts +32 -32
- package/dist/types/function.js +104 -104
- package/dist/types/interface.d.ts +24 -24
- package/dist/types/interface.js +83 -83
- package/dist/types/list.d.ts +29 -29
- package/dist/types/list.js +158 -158
- package/dist/types/map.d.ts +33 -33
- package/dist/types/map.js +200 -200
- package/dist/types/nil.d.ts +11 -11
- package/dist/types/nil.js +33 -33
- package/dist/types/number.d.ts +25 -25
- package/dist/types/number.js +69 -69
- package/dist/types/string.d.ts +31 -31
- package/dist/types/string.js +121 -121
- package/dist/types/with-intrinsics.d.ts +15 -15
- package/dist/types/with-intrinsics.js +19 -19
- package/dist/utils/deep-equal.d.ts +1 -1
- package/dist/utils/deep-equal.js +37 -37
- package/dist/utils/object-value.d.ts +7 -7
- package/dist/utils/object-value.js +42 -42
- package/dist/utils/path.d.ts +10 -10
- package/dist/utils/path.js +32 -32
- package/package.json +58 -58
package/dist/operations/map.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ASTMapConstructorExpression } from 'greyscript-core';
|
|
2
|
-
import context from '../context';
|
|
3
|
-
import CustomValue from '../types/base';
|
|
4
|
-
import Operation, { CPSVisit } from './operation';
|
|
5
|
-
export default class MapOperation extends Operation {
|
|
6
|
-
readonly item: ASTMapConstructorExpression;
|
|
7
|
-
fields: Map<Operation, Operation>;
|
|
8
|
-
constructor(item: ASTMapConstructorExpression, target?: string);
|
|
9
|
-
build(visit: CPSVisit): Promise<Operation>;
|
|
10
|
-
handle(ctx: context): Promise<CustomValue>;
|
|
11
|
-
}
|
|
1
|
+
import { ASTMapConstructorExpression } from 'greyscript-core';
|
|
2
|
+
import context from '../context';
|
|
3
|
+
import CustomValue from '../types/base';
|
|
4
|
+
import Operation, { CPSVisit } from './operation';
|
|
5
|
+
export default class MapOperation extends Operation {
|
|
6
|
+
readonly item: ASTMapConstructorExpression;
|
|
7
|
+
fields: Map<Operation, Operation>;
|
|
8
|
+
constructor(item: ASTMapConstructorExpression, target?: string);
|
|
9
|
+
build(visit: CPSVisit): Promise<Operation>;
|
|
10
|
+
handle(ctx: context): Promise<CustomValue>;
|
|
11
|
+
}
|
package/dist/operations/map.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const map_1 = __importDefault(require("../types/map"));
|
|
16
|
-
const object_value_1 = __importDefault(require("../utils/object-value"));
|
|
17
|
-
const operation_1 = __importDefault(require("./operation"));
|
|
18
|
-
class MapOperation extends operation_1.default {
|
|
19
|
-
constructor(item, target) {
|
|
20
|
-
super(null, target);
|
|
21
|
-
this.item = item;
|
|
22
|
-
}
|
|
23
|
-
build(visit) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
this.fields = new Map();
|
|
26
|
-
const defers = this.item.fields.map((child) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const mapKeyString = child;
|
|
28
|
-
this.fields.set(yield visit(mapKeyString.key), yield visit(mapKeyString.value));
|
|
29
|
-
}));
|
|
30
|
-
yield Promise.all(defers);
|
|
31
|
-
return this;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
handle(ctx) {
|
|
35
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const newMap = new object_value_1.default();
|
|
37
|
-
for (const [key, value] of this.fields) {
|
|
38
|
-
newMap.set(yield key.handle(ctx), yield value.handle(ctx));
|
|
39
|
-
}
|
|
40
|
-
return new map_1.default(newMap);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.default = MapOperation;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const map_1 = __importDefault(require("../types/map"));
|
|
16
|
+
const object_value_1 = __importDefault(require("../utils/object-value"));
|
|
17
|
+
const operation_1 = __importDefault(require("./operation"));
|
|
18
|
+
class MapOperation extends operation_1.default {
|
|
19
|
+
constructor(item, target) {
|
|
20
|
+
super(null, target);
|
|
21
|
+
this.item = item;
|
|
22
|
+
}
|
|
23
|
+
build(visit) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
this.fields = new Map();
|
|
26
|
+
const defers = this.item.fields.map((child) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const mapKeyString = child;
|
|
28
|
+
this.fields.set(yield visit(mapKeyString.key), yield visit(mapKeyString.value));
|
|
29
|
+
}));
|
|
30
|
+
yield Promise.all(defers);
|
|
31
|
+
return this;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
handle(ctx) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const newMap = new object_value_1.default();
|
|
37
|
+
for (const [key, value] of this.fields) {
|
|
38
|
+
newMap.set(yield key.handle(ctx), yield value.handle(ctx));
|
|
39
|
+
}
|
|
40
|
+
return new map_1.default(newMap);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = MapOperation;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ASTUnaryExpression } from 'greyscript-core';
|
|
2
|
-
import context from '../context';
|
|
3
|
-
import CustomValue from '../types/base';
|
|
4
|
-
import Operation, { CPSVisit } from './operation';
|
|
5
|
-
export default class NegatedBinary extends Operation {
|
|
6
|
-
readonly item: ASTUnaryExpression;
|
|
7
|
-
arg: Operation;
|
|
8
|
-
constructor(item: ASTUnaryExpression, target?: string);
|
|
9
|
-
build(visit: CPSVisit): Promise<Operation>;
|
|
10
|
-
handle(ctx: context): Promise<CustomValue>;
|
|
11
|
-
}
|
|
1
|
+
import { ASTUnaryExpression } from 'greyscript-core';
|
|
2
|
+
import context from '../context';
|
|
3
|
+
import CustomValue from '../types/base';
|
|
4
|
+
import Operation, { CPSVisit } from './operation';
|
|
5
|
+
export default class NegatedBinary extends Operation {
|
|
6
|
+
readonly item: ASTUnaryExpression;
|
|
7
|
+
arg: Operation;
|
|
8
|
+
constructor(item: ASTUnaryExpression, target?: string);
|
|
9
|
+
build(visit: CPSVisit): Promise<Operation>;
|
|
10
|
+
handle(ctx: context): Promise<CustomValue>;
|
|
11
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const greyscript_core_1 = require("greyscript-core");
|
|
16
|
-
const number_1 = __importDefault(require("../types/number"));
|
|
17
|
-
const operation_1 = __importDefault(require("./operation"));
|
|
18
|
-
class NegatedBinary extends operation_1.default {
|
|
19
|
-
constructor(item, target) {
|
|
20
|
-
super(null, target);
|
|
21
|
-
this.item = item;
|
|
22
|
-
}
|
|
23
|
-
build(visit) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
this.arg = yield visit(this.item.argument);
|
|
26
|
-
return this;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
handle(ctx) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
switch (this.item.operator) {
|
|
32
|
-
case greyscript_core_1.Operator.Minus:
|
|
33
|
-
return new number_1.default(-(yield this.arg.handle(ctx)).toNumber());
|
|
34
|
-
case greyscript_core_1.Operator.Plus:
|
|
35
|
-
return new number_1.default(+(yield this.arg.handle(ctx)).toNumber());
|
|
36
|
-
default:
|
|
37
|
-
throw new Error('Unexpected negation operator.');
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.default = NegatedBinary;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const greyscript_core_1 = require("greyscript-core");
|
|
16
|
+
const number_1 = __importDefault(require("../types/number"));
|
|
17
|
+
const operation_1 = __importDefault(require("./operation"));
|
|
18
|
+
class NegatedBinary extends operation_1.default {
|
|
19
|
+
constructor(item, target) {
|
|
20
|
+
super(null, target);
|
|
21
|
+
this.item = item;
|
|
22
|
+
}
|
|
23
|
+
build(visit) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
this.arg = yield visit(this.item.argument);
|
|
26
|
+
return this;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
handle(ctx) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
switch (this.item.operator) {
|
|
32
|
+
case greyscript_core_1.Operator.Minus:
|
|
33
|
+
return new number_1.default(-(yield this.arg.handle(ctx)).toNumber());
|
|
34
|
+
case greyscript_core_1.Operator.Plus:
|
|
35
|
+
return new number_1.default(+(yield this.arg.handle(ctx)).toNumber());
|
|
36
|
+
default:
|
|
37
|
+
throw new Error('Unexpected negation operator.');
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = NegatedBinary;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ASTUnaryExpression } from 'greyscript-core';
|
|
2
|
-
import context from '../context';
|
|
3
|
-
import CustomValue from '../types/base';
|
|
4
|
-
import Operation, { CPSVisit } from './operation';
|
|
5
|
-
export default class NewInstance extends Operation {
|
|
6
|
-
readonly item: ASTUnaryExpression;
|
|
7
|
-
arg: Operation;
|
|
8
|
-
constructor(item: ASTUnaryExpression, target?: string);
|
|
9
|
-
build(visit: CPSVisit): Promise<Operation>;
|
|
10
|
-
handle(ctx: context): Promise<CustomValue>;
|
|
11
|
-
}
|
|
1
|
+
import { ASTUnaryExpression } from 'greyscript-core';
|
|
2
|
+
import context from '../context';
|
|
3
|
+
import CustomValue from '../types/base';
|
|
4
|
+
import Operation, { CPSVisit } from './operation';
|
|
5
|
+
export default class NewInstance extends Operation {
|
|
6
|
+
readonly item: ASTUnaryExpression;
|
|
7
|
+
arg: Operation;
|
|
8
|
+
constructor(item: ASTUnaryExpression, target?: string);
|
|
9
|
+
build(visit: CPSVisit): Promise<Operation>;
|
|
10
|
+
handle(ctx: context): Promise<CustomValue>;
|
|
11
|
+
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const default_1 = __importDefault(require("../types/default"));
|
|
16
|
-
const map_1 = __importDefault(require("../types/map"));
|
|
17
|
-
const operation_1 = __importDefault(require("./operation"));
|
|
18
|
-
class NewInstance extends operation_1.default {
|
|
19
|
-
constructor(item, target) {
|
|
20
|
-
super(null, target);
|
|
21
|
-
this.item = item;
|
|
22
|
-
}
|
|
23
|
-
build(visit) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
this.arg = yield visit(this.item.argument);
|
|
26
|
-
return this;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
handle(ctx) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const resolvedArg = yield this.arg.handle(ctx);
|
|
32
|
-
if (resolvedArg instanceof map_1.default) {
|
|
33
|
-
return resolvedArg.createInstance();
|
|
34
|
-
}
|
|
35
|
-
return default_1.default.Void;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.default = NewInstance;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const default_1 = __importDefault(require("../types/default"));
|
|
16
|
+
const map_1 = __importDefault(require("../types/map"));
|
|
17
|
+
const operation_1 = __importDefault(require("./operation"));
|
|
18
|
+
class NewInstance extends operation_1.default {
|
|
19
|
+
constructor(item, target) {
|
|
20
|
+
super(null, target);
|
|
21
|
+
this.item = item;
|
|
22
|
+
}
|
|
23
|
+
build(visit) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
this.arg = yield visit(this.item.argument);
|
|
26
|
+
return this;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
handle(ctx) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const resolvedArg = yield this.arg.handle(ctx);
|
|
32
|
+
if (resolvedArg instanceof map_1.default) {
|
|
33
|
+
return resolvedArg.createInstance();
|
|
34
|
+
}
|
|
35
|
+
return default_1.default.Void;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = NewInstance;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ASTBase } from 'greyscript-core';
|
|
2
|
-
import context from '../context';
|
|
3
|
-
import CustomValue from '../types/base';
|
|
4
|
-
import Operation, { CPSVisit } from './operation';
|
|
5
|
-
export default class Noop extends Operation {
|
|
6
|
-
constructor(item?: ASTBase, target?: string);
|
|
7
|
-
build(_visit: CPSVisit): Promise<Operation>;
|
|
8
|
-
handle(_ctx: context): Promise<CustomValue>;
|
|
9
|
-
}
|
|
1
|
+
import { ASTBase } from 'greyscript-core';
|
|
2
|
+
import context from '../context';
|
|
3
|
+
import CustomValue from '../types/base';
|
|
4
|
+
import Operation, { CPSVisit } from './operation';
|
|
5
|
+
export default class Noop extends Operation {
|
|
6
|
+
constructor(item?: ASTBase, target?: string);
|
|
7
|
+
build(_visit: CPSVisit): Promise<Operation>;
|
|
8
|
+
handle(_ctx: context): Promise<CustomValue>;
|
|
9
|
+
}
|
package/dist/operations/noop.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const default_1 = __importDefault(require("../types/default"));
|
|
7
|
-
const operation_1 = __importDefault(require("./operation"));
|
|
8
|
-
class Noop extends operation_1.default {
|
|
9
|
-
constructor(item, target) {
|
|
10
|
-
super(null, target);
|
|
11
|
-
}
|
|
12
|
-
build(_visit) {
|
|
13
|
-
return Promise.resolve(this);
|
|
14
|
-
}
|
|
15
|
-
handle(_ctx) {
|
|
16
|
-
return Promise.resolve(default_1.default.Void);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.default = Noop;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const default_1 = __importDefault(require("../types/default"));
|
|
7
|
+
const operation_1 = __importDefault(require("./operation"));
|
|
8
|
+
class Noop extends operation_1.default {
|
|
9
|
+
constructor(item, target) {
|
|
10
|
+
super(null, target);
|
|
11
|
+
}
|
|
12
|
+
build(_visit) {
|
|
13
|
+
return Promise.resolve(this);
|
|
14
|
+
}
|
|
15
|
+
handle(_ctx) {
|
|
16
|
+
return Promise.resolve(default_1.default.Void);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = Noop;
|
package/dist/operations/not.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ASTUnaryExpression } from 'greyscript-core';
|
|
2
|
-
import context from '../context';
|
|
3
|
-
import CustomValue from '../types/base';
|
|
4
|
-
import Operation, { CPSVisit } from './operation';
|
|
5
|
-
export default class Not extends Operation {
|
|
6
|
-
readonly item: ASTUnaryExpression;
|
|
7
|
-
arg: Operation;
|
|
8
|
-
constructor(item: ASTUnaryExpression, target?: string);
|
|
9
|
-
build(visit: CPSVisit): Promise<Operation>;
|
|
10
|
-
handle(ctx: context): Promise<CustomValue>;
|
|
11
|
-
}
|
|
1
|
+
import { ASTUnaryExpression } from 'greyscript-core';
|
|
2
|
+
import context from '../context';
|
|
3
|
+
import CustomValue from '../types/base';
|
|
4
|
+
import Operation, { CPSVisit } from './operation';
|
|
5
|
+
export default class Not extends Operation {
|
|
6
|
+
readonly item: ASTUnaryExpression;
|
|
7
|
+
arg: Operation;
|
|
8
|
+
constructor(item: ASTUnaryExpression, target?: string);
|
|
9
|
+
build(visit: CPSVisit): Promise<Operation>;
|
|
10
|
+
handle(ctx: context): Promise<CustomValue>;
|
|
11
|
+
}
|
package/dist/operations/not.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const boolean_1 = __importDefault(require("../types/boolean"));
|
|
16
|
-
const operation_1 = __importDefault(require("./operation"));
|
|
17
|
-
class Not extends operation_1.default {
|
|
18
|
-
constructor(item, target) {
|
|
19
|
-
super(null, target);
|
|
20
|
-
this.item = item;
|
|
21
|
-
}
|
|
22
|
-
build(visit) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
this.arg = yield visit(this.item.argument);
|
|
25
|
-
return this;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
handle(ctx) {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const result = yield this.arg.handle(ctx);
|
|
31
|
-
return new boolean_1.default(!result.toTruthy());
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.default = Not;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const boolean_1 = __importDefault(require("../types/boolean"));
|
|
16
|
+
const operation_1 = __importDefault(require("./operation"));
|
|
17
|
+
class Not extends operation_1.default {
|
|
18
|
+
constructor(item, target) {
|
|
19
|
+
super(null, target);
|
|
20
|
+
this.item = item;
|
|
21
|
+
}
|
|
22
|
+
build(visit) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
this.arg = yield visit(this.item.argument);
|
|
25
|
+
return this;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
handle(ctx) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const result = yield this.arg.handle(ctx);
|
|
31
|
+
return new boolean_1.default(!result.toTruthy());
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = Not;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ASTBase } from 'greyscript-core';
|
|
2
|
-
import OperationContext from '../context';
|
|
3
|
-
import CustomValue from '../types/base';
|
|
4
|
-
export interface CPSVisit {
|
|
5
|
-
(item: ASTBase): Promise<Operation>;
|
|
6
|
-
}
|
|
7
|
-
export default abstract class Operation {
|
|
8
|
-
readonly item: ASTBase;
|
|
9
|
-
readonly target: string;
|
|
10
|
-
constructor(item: ASTBase, target?: string);
|
|
11
|
-
abstract build(visit: CPSVisit): Promise<Operation>;
|
|
12
|
-
abstract handle(ctx: OperationContext): Promise<CustomValue>;
|
|
13
|
-
}
|
|
1
|
+
import { ASTBase } from 'greyscript-core';
|
|
2
|
+
import OperationContext from '../context';
|
|
3
|
+
import CustomValue from '../types/base';
|
|
4
|
+
export interface CPSVisit {
|
|
5
|
+
(item: ASTBase): Promise<Operation>;
|
|
6
|
+
}
|
|
7
|
+
export default abstract class Operation {
|
|
8
|
+
readonly item: ASTBase;
|
|
9
|
+
readonly target: string;
|
|
10
|
+
constructor(item: ASTBase, target?: string);
|
|
11
|
+
abstract build(visit: CPSVisit): Promise<Operation>;
|
|
12
|
+
abstract handle(ctx: OperationContext): Promise<CustomValue>;
|
|
13
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class Operation {
|
|
4
|
-
constructor(item, target = null) {
|
|
5
|
-
this.item = item;
|
|
6
|
-
this.target = target;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.default = Operation;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Operation {
|
|
4
|
+
constructor(item, target = null) {
|
|
5
|
+
this.item = item;
|
|
6
|
+
this.target = target;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.default = Operation;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import OperationContext from '../context';
|
|
2
|
-
import CustomValue from '../types/base';
|
|
3
|
-
import Operation, { CPSVisit } from './operation';
|
|
4
|
-
export default class Reference extends Operation {
|
|
5
|
-
readonly value: CustomValue;
|
|
6
|
-
constructor(value: CustomValue);
|
|
7
|
-
build(_visit: CPSVisit): Promise<Reference>;
|
|
8
|
-
handle(_ctx: OperationContext): Promise<CustomValue>;
|
|
9
|
-
}
|
|
1
|
+
import OperationContext from '../context';
|
|
2
|
+
import CustomValue from '../types/base';
|
|
3
|
+
import Operation, { CPSVisit } from './operation';
|
|
4
|
+
export default class Reference extends Operation {
|
|
5
|
+
readonly value: CustomValue;
|
|
6
|
+
constructor(value: CustomValue);
|
|
7
|
+
build(_visit: CPSVisit): Promise<Reference>;
|
|
8
|
+
handle(_ctx: OperationContext): Promise<CustomValue>;
|
|
9
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const operation_1 = __importDefault(require("./operation"));
|
|
7
|
-
class Reference extends operation_1.default {
|
|
8
|
-
constructor(value) {
|
|
9
|
-
super(null, 'native');
|
|
10
|
-
this.value = value;
|
|
11
|
-
}
|
|
12
|
-
build(_visit) {
|
|
13
|
-
return Promise.resolve(this);
|
|
14
|
-
}
|
|
15
|
-
handle(_ctx) {
|
|
16
|
-
return Promise.resolve(this.value);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.default = Reference;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const operation_1 = __importDefault(require("./operation"));
|
|
7
|
+
class Reference extends operation_1.default {
|
|
8
|
+
constructor(value) {
|
|
9
|
+
super(null, 'native');
|
|
10
|
+
this.value = value;
|
|
11
|
+
}
|
|
12
|
+
build(_visit) {
|
|
13
|
+
return Promise.resolve(this);
|
|
14
|
+
}
|
|
15
|
+
handle(_ctx) {
|
|
16
|
+
return Promise.resolve(this.value);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = Reference;
|