greybel-interpreter 2.3.1 → 2.3.3

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/cps.js CHANGED
@@ -32,7 +32,6 @@ const negated_binary_1 = require("./operations/negated-binary");
32
32
  const new_instance_1 = require("./operations/new-instance");
33
33
  const noop_1 = require("./operations/noop");
34
34
  const not_1 = require("./operations/not");
35
- const resolve_1 = require("./operations/resolve");
36
35
  const return_1 = require("./operations/return");
37
36
  const while_1 = require("./operations/while");
38
37
  const error_1 = require("./utils/error");
@@ -56,12 +55,11 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
56
55
  case greyscript_core_1.ASTType.AssignmentStatement:
57
56
  return (0, create_assign_1.createAssign)(item, currentTarget).build(defaultVisit);
58
57
  case greyscript_core_1.ASTType.MemberExpression:
58
+ case greyscript_core_1.ASTType.IndexExpression:
59
+ case greyscript_core_1.ASTType.SliceExpression:
59
60
  return (0, create_resolve_1.createResolve)(item, currentTarget).build(defaultVisit);
60
61
  case greyscript_core_1.ASTType.Identifier:
61
62
  return (0, create_resolve_1.createIdentifierResolve)(item, currentTarget).build(defaultVisit);
62
- case greyscript_core_1.ASTType.IndexExpression:
63
- case greyscript_core_1.ASTType.SliceExpression:
64
- return new resolve_1.Resolve(item, currentTarget).build(defaultVisit);
65
63
  case greyscript_core_1.ASTType.FunctionDeclaration:
66
64
  return new function_1.FunctionOperation(item, currentTarget).build(defaultVisit);
67
65
  case greyscript_core_1.ASTType.InvalidCodeExpression:
@@ -34,10 +34,12 @@ const optResolveMap = {
34
34
  outer: resolve_outer_1.ResolveOuter
35
35
  };
36
36
  function createResolve(item, target) {
37
- if (item instanceof greyscript_core_1.ASTMemberExpression) {
38
- const memberExpr = item;
39
- const path = (0, lookup_path_1.lookupPath)(memberExpr);
37
+ if (item instanceof greyscript_core_1.ASTMemberExpression ||
38
+ item instanceof greyscript_core_1.ASTIndexExpression ||
39
+ item instanceof greyscript_core_1.ASTSliceExpression) {
40
+ const path = (0, lookup_path_1.lookupPath)(item);
40
41
  if (path.length > 0 &&
42
+ path[0] instanceof greyscript_core_1.ASTMemberExpression &&
41
43
  path[0].base instanceof greyscript_core_1.ASTIdentifier &&
42
44
  hasOwnProperty.call(optResolveMap, path[0].base.name)) {
43
45
  const OptResolve = optResolveMap[path[0].base.name];
@@ -47,7 +49,7 @@ function createResolve(item, target) {
47
49
  }
48
50
  const newBase = path[1];
49
51
  newBase.base = right;
50
- return new OptResolve(memberExpr, target);
52
+ return new OptResolve(item, target);
51
53
  }
52
54
  }
53
55
  return new resolve_1.Resolve(item, target);
@@ -1,2 +1,5 @@
1
- import { ASTMemberExpression } from 'greyscript-core';
2
- export declare function lookupPath(item: ASTMemberExpression): ASTMemberExpression[];
1
+ import { ASTBase } from 'greyscript-core';
2
+ export type PathItem = ASTBase & {
3
+ base: ASTBase;
4
+ };
5
+ export declare function lookupPath(item: PathItem): PathItem[];
@@ -5,7 +5,9 @@ const greyscript_core_1 = require("greyscript-core");
5
5
  function lookupPath(item) {
6
6
  const path = [item];
7
7
  let current = item.base;
8
- while (current instanceof greyscript_core_1.ASTMemberExpression) {
8
+ while (current instanceof greyscript_core_1.ASTMemberExpression ||
9
+ current instanceof greyscript_core_1.ASTIndexExpression ||
10
+ current instanceof greyscript_core_1.ASTSliceExpression) {
9
11
  path.unshift(current);
10
12
  current = current.base;
11
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",