greybel-interpreter 1.6.2 → 1.6.4

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.
@@ -114,7 +114,7 @@ class Interpreter extends events_1.default {
114
114
  catch (err) {
115
115
  this.handler.errorHandler.raise(err);
116
116
  }
117
- return Promise.resolve(new noop_1.default());
117
+ return Promise.resolve(new noop_1.default(null));
118
118
  }
119
119
  inject(code, context) {
120
120
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,3 +1,4 @@
1
+ import { ASTBase } from 'greyscript-core';
1
2
  import OperationContext from '../context';
2
3
  import CustomValue from '../types/base';
3
4
  import Operation, { CPSVisit } from './operation';
@@ -6,7 +7,7 @@ export interface IsEOL {
6
7
  }
7
8
  export default class Block extends Operation {
8
9
  readonly stack: Array<Operation>;
9
- constructor(stack: Array<Operation>);
10
+ constructor(item: ASTBase, stack: Array<Operation>);
10
11
  build(_visit: CPSVisit): Promise<Block>;
11
12
  handle(ctx: OperationContext): Promise<CustomValue>;
12
13
  }
@@ -16,8 +16,8 @@ const context_1 = require("../context");
16
16
  const default_1 = __importDefault(require("../types/default"));
17
17
  const operation_1 = __importDefault(require("./operation"));
18
18
  class Block extends operation_1.default {
19
- constructor(stack) {
20
- super(null, 'block');
19
+ constructor(item, stack) {
20
+ super(item, 'block');
21
21
  this.stack = stack;
22
22
  }
23
23
  build(_visit) {
@@ -23,7 +23,7 @@ class Chunk extends operation_1.default {
23
23
  build(visit) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  const stack = yield Promise.all(this.item.body.map((child) => visit(child)));
26
- this.block = new block_1.default(stack);
26
+ this.block = new block_1.default(this.item, stack);
27
27
  return this;
28
28
  });
29
29
  }
@@ -34,7 +34,7 @@ exports.NumberProcessorHandler = {
34
34
  [greyscript_core_1.Operator.Minus]: (a, b) => new number_1.default(a.toNumber() - b.toNumber()),
35
35
  [greyscript_core_1.Operator.Slash]: (a, b) => new number_1.default(a.toNumber() / b.toNumber()),
36
36
  [greyscript_core_1.Operator.Asterik]: (a, b) => new number_1.default(a.toNumber() * b.toNumber()),
37
- [greyscript_core_1.Operator.Xor]: (a, b) => new number_1.default(a.toInt() ^ b.toInt()),
37
+ [greyscript_core_1.Operator.Power]: (a, b) => new number_1.default(Math.pow(a.toNumber(), b.toNumber())),
38
38
  [greyscript_core_1.Operator.BitwiseOr]: (a, b) => new number_1.default(a.toInt() | b.toInt()),
39
39
  [greyscript_core_1.Operator.LessThan]: (a, b) => new boolean_1.default(a.toNumber() < b.toNumber()),
40
40
  [greyscript_core_1.Operator.GreaterThan]: (a, b) => new boolean_1.default(a.toNumber() > b.toNumber()),
@@ -26,7 +26,7 @@ class For extends operation_1.default {
26
26
  build(visit) {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
28
  const stack = yield Promise.all(this.item.body.map((child) => visit(child)));
29
- this.block = new block_1.default(stack);
29
+ this.block = new block_1.default(this.item, stack);
30
30
  this.variable = this.item.variable;
31
31
  this.iterator = yield visit(this.item.iterator);
32
32
  return this;
@@ -31,7 +31,7 @@ class FunctionOperation extends operation_1.default {
31
31
  build(visit) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
33
  const stack = yield Promise.all(this.item.body.map((child) => visit(child)));
34
- this.block = new block_1.default(stack);
34
+ this.block = new block_1.default(this.item, stack);
35
35
  this.args = new Map();
36
36
  const defers = this.item.parameters.map((child) => __awaiter(this, void 0, void 0, function* () {
37
37
  switch (child.type) {
@@ -35,7 +35,7 @@ class IfStatement extends operation_1.default {
35
35
  return __awaiter(this, void 0, void 0, function* () {
36
36
  const condition = yield visit(node.condition);
37
37
  const stack = yield Promise.all(node.body.map((child) => visit(child)));
38
- const block = new block_1.default(stack);
38
+ const block = new block_1.default(this.item, stack);
39
39
  this.clauses.push(new Clause(condition, block));
40
40
  });
41
41
  }
@@ -43,7 +43,7 @@ class IfStatement extends operation_1.default {
43
43
  return __awaiter(this, void 0, void 0, function* () {
44
44
  const condition = new reference_1.default(new boolean_1.default(true));
45
45
  const stack = yield Promise.all(node.body.map((child) => visit(child)));
46
- const block = new block_1.default(stack);
46
+ const block = new block_1.default(this.item, stack);
47
47
  this.clauses.push(new Clause(condition, block));
48
48
  });
49
49
  }
@@ -1,9 +1,7 @@
1
- import { ASTBase } from 'greyscript-core';
2
1
  import context from '../context';
3
2
  import CustomValue from '../types/base';
4
3
  import Operation, { CPSVisit } from './operation';
5
4
  export default class Noop extends Operation {
6
- constructor(item?: ASTBase, target?: string);
7
5
  build(_visit: CPSVisit): Promise<Operation>;
8
6
  handle(_ctx: context): Promise<CustomValue>;
9
7
  }
@@ -6,9 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const default_1 = __importDefault(require("../types/default"));
7
7
  const operation_1 = __importDefault(require("./operation"));
8
8
  class Noop extends operation_1.default {
9
- constructor(item, target) {
10
- super(null, target);
11
- }
12
9
  build(_visit) {
13
10
  return Promise.resolve(this);
14
11
  }
@@ -24,7 +24,7 @@ class While extends operation_1.default {
24
24
  build(visit) {
25
25
  return __awaiter(this, void 0, void 0, function* () {
26
26
  const stack = yield Promise.all(this.item.body.map((child) => visit(child)));
27
- this.block = new block_1.default(stack);
27
+ this.block = new block_1.default(this.item, stack);
28
28
  this.condition = yield visit(this.item.condition);
29
29
  return this;
30
30
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",
@@ -48,8 +48,8 @@
48
48
  "typescript": "^4.5.4"
49
49
  },
50
50
  "dependencies": {
51
- "greybel-core": "^0.6.6",
52
- "greyscript-core": "^0.6.1"
51
+ "greybel-core": "^0.6.7",
52
+ "greyscript-core": "^0.6.2"
53
53
  },
54
54
  "keywords": [
55
55
  "greyscript",