greybel-interpreter 2.3.3 → 2.3.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.
|
@@ -108,20 +108,23 @@ class Resolve extends operation_1.Operation {
|
|
|
108
108
|
switch (node.type) {
|
|
109
109
|
case greyscript_core_1.ASTType.MemberExpression: {
|
|
110
110
|
const memberExpr = node;
|
|
111
|
-
|
|
111
|
+
if (memberExpr.base != null)
|
|
112
|
+
yield this.buildProcessor(memberExpr.base, visit);
|
|
112
113
|
yield this.buildProcessor(memberExpr.identifier, visit);
|
|
113
114
|
break;
|
|
114
115
|
}
|
|
115
116
|
case greyscript_core_1.ASTType.IndexExpression: {
|
|
116
117
|
const indexExpr = node;
|
|
117
|
-
|
|
118
|
+
if (indexExpr.base != null)
|
|
119
|
+
yield this.buildProcessor(indexExpr.base, visit);
|
|
118
120
|
const indexSegment = new IndexSegment(yield visit(indexExpr.index));
|
|
119
121
|
this.path.push(indexSegment);
|
|
120
122
|
break;
|
|
121
123
|
}
|
|
122
124
|
case greyscript_core_1.ASTType.SliceExpression: {
|
|
123
125
|
const sliceExpr = node;
|
|
124
|
-
|
|
126
|
+
if (sliceExpr.base != null)
|
|
127
|
+
yield this.buildProcessor(sliceExpr.base, visit);
|
|
125
128
|
const left = yield visit(sliceExpr.left);
|
|
126
129
|
const right = yield visit(sliceExpr.right);
|
|
127
130
|
const sliceSegment = new SliceSegment(left, right);
|
|
@@ -39,16 +39,10 @@ function createResolve(item, target) {
|
|
|
39
39
|
item instanceof greyscript_core_1.ASTSliceExpression) {
|
|
40
40
|
const path = (0, lookup_path_1.lookupPath)(item);
|
|
41
41
|
if (path.length > 0 &&
|
|
42
|
-
path[0] instanceof greyscript_core_1.ASTMemberExpression &&
|
|
43
42
|
path[0].base instanceof greyscript_core_1.ASTIdentifier &&
|
|
44
43
|
hasOwnProperty.call(optResolveMap, path[0].base.name)) {
|
|
45
44
|
const OptResolve = optResolveMap[path[0].base.name];
|
|
46
|
-
|
|
47
|
-
if (path.length === 1) {
|
|
48
|
-
return new OptResolve(right, target);
|
|
49
|
-
}
|
|
50
|
-
const newBase = path[1];
|
|
51
|
-
newBase.base = right;
|
|
45
|
+
path[0].base = null;
|
|
52
46
|
return new OptResolve(item, target);
|
|
53
47
|
}
|
|
54
48
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type PathItem =
|
|
3
|
-
base: ASTBase;
|
|
4
|
-
};
|
|
1
|
+
import { ASTIndexExpression, ASTMemberExpression, ASTSliceExpression } from 'greyscript-core';
|
|
2
|
+
export type PathItem = ASTMemberExpression | ASTIndexExpression | ASTSliceExpression;
|
|
5
3
|
export declare function lookupPath(item: PathItem): PathItem[];
|