greybel-interpreter 2.1.0 → 2.1.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 +1 -1
- package/dist/cps.js +23 -16
- package/dist/interpreter.js +1 -1
- package/dist/utils/error.d.ts +4 -4
- package/dist/utils/error.js +2 -2
- package/package.json +3 -3
package/dist/context.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { ASTBase } from 'greyscript-core';
|
|
3
2
|
import { EventEmitter } from 'events';
|
|
3
|
+
import { ASTBase } from 'greyscript-core';
|
|
4
4
|
import { CPS } from './cps';
|
|
5
5
|
import { HandlerContainer } from './handler-container';
|
|
6
6
|
import { Operation } from './operations/operation';
|
package/dist/cps.js
CHANGED
|
@@ -83,14 +83,15 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
83
83
|
const importExpr = item;
|
|
84
84
|
const target = yield context.handler.resourceHandler.getTargetRelativeTo(currentTarget, importExpr.path);
|
|
85
85
|
if (stack.includes(target)) {
|
|
86
|
-
console.warn(`Found
|
|
86
|
+
console.warn(`Found circular dependency between "${currentTarget}" and "${target}" at line ${item.start.line}. Using noop instead to prevent overflow.`);
|
|
87
87
|
return new noop_1.Noop(item, target);
|
|
88
88
|
}
|
|
89
89
|
const code = yield context.handler.resourceHandler.get(target);
|
|
90
90
|
if (code == null) {
|
|
91
|
-
|
|
91
|
+
const range = new greyscript_core_1.ASTRange(item.start, item.end);
|
|
92
|
+
throw new error_1.PrepareError(`Cannot find import "${currentTarget}" at ${range}.`, {
|
|
92
93
|
target: currentTarget,
|
|
93
|
-
|
|
94
|
+
range
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
try {
|
|
@@ -104,7 +105,7 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
104
105
|
}
|
|
105
106
|
throw new error_1.PrepareError(err.message, {
|
|
106
107
|
target,
|
|
107
|
-
item
|
|
108
|
+
range: new greyscript_core_1.ASTRange(item.start, item.end)
|
|
108
109
|
}, err);
|
|
109
110
|
}
|
|
110
111
|
}
|
|
@@ -112,14 +113,15 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
112
113
|
const includeExpr = item;
|
|
113
114
|
const target = yield context.handler.resourceHandler.getTargetRelativeTo(currentTarget, includeExpr.path);
|
|
114
115
|
if (stack.includes(target)) {
|
|
115
|
-
console.warn(`Found
|
|
116
|
+
console.warn(`Found circular dependency between "${currentTarget}" and "${target}" at line ${item.start.line}. Using noop instead to prevent overflow.`);
|
|
116
117
|
return new noop_1.Noop(item, target);
|
|
117
118
|
}
|
|
118
119
|
const code = yield context.handler.resourceHandler.get(target);
|
|
119
120
|
if (code == null) {
|
|
120
|
-
|
|
121
|
+
const range = new greyscript_core_1.ASTRange(item.start, item.end);
|
|
122
|
+
throw new error_1.PrepareError(`Cannot find include "${currentTarget}" at ${range}.`, {
|
|
121
123
|
target: currentTarget,
|
|
122
|
-
|
|
124
|
+
range
|
|
123
125
|
});
|
|
124
126
|
}
|
|
125
127
|
try {
|
|
@@ -133,7 +135,7 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
133
135
|
}
|
|
134
136
|
throw new error_1.PrepareError(err.message, {
|
|
135
137
|
target,
|
|
136
|
-
item
|
|
138
|
+
range: new greyscript_core_1.ASTRange(item.start, item.end)
|
|
137
139
|
}, err);
|
|
138
140
|
}
|
|
139
141
|
}
|
|
@@ -141,14 +143,15 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
141
143
|
const importExpr = item;
|
|
142
144
|
const target = yield context.handler.resourceHandler.getTargetRelativeTo(currentTarget, importExpr.directory);
|
|
143
145
|
if (stack.includes(target)) {
|
|
144
|
-
console.warn(`Found
|
|
146
|
+
console.warn(`Found circular dependency between "${currentTarget}" and "${target}" at line ${item.start.line}. Using noop instead to prevent overflow.`);
|
|
145
147
|
return new noop_1.Noop(item, target);
|
|
146
148
|
}
|
|
147
149
|
const code = yield context.handler.resourceHandler.get(target);
|
|
148
150
|
if (code == null) {
|
|
149
|
-
|
|
151
|
+
const range = new greyscript_core_1.ASTRange(item.start, item.end);
|
|
152
|
+
throw new error_1.PrepareError(`Cannot find native import "${currentTarget}" at ${range}.`, {
|
|
150
153
|
target: currentTarget,
|
|
151
|
-
|
|
154
|
+
range
|
|
152
155
|
});
|
|
153
156
|
}
|
|
154
157
|
try {
|
|
@@ -162,7 +165,7 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
162
165
|
}
|
|
163
166
|
throw new error_1.PrepareError(err.message, {
|
|
164
167
|
target,
|
|
165
|
-
item
|
|
168
|
+
range: new greyscript_core_1.ASTRange(item.start, item.end)
|
|
166
169
|
}, err);
|
|
167
170
|
}
|
|
168
171
|
}
|
|
@@ -193,8 +196,10 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
193
196
|
else if (unaryExpr.operator === '@') {
|
|
194
197
|
return new function_reference_1.FunctionReference(unaryExpr).build(defaultVisit);
|
|
195
198
|
}
|
|
196
|
-
|
|
197
|
-
|
|
199
|
+
const range = new greyscript_core_1.ASTRange(item.start, item.end);
|
|
200
|
+
throw new error_1.PrepareError(`Unknown unary expression at ${range}.`, {
|
|
201
|
+
target: currentTarget,
|
|
202
|
+
range
|
|
198
203
|
});
|
|
199
204
|
}
|
|
200
205
|
case greyscript_core_1.ASTType.Chunk:
|
|
@@ -204,8 +209,10 @@ const visit = (context, stack, item) => __awaiter(void 0, void 0, void 0, functi
|
|
|
204
209
|
case greyscript_core_1.ASTType.ParenthesisExpression:
|
|
205
210
|
return defaultVisit(item.expression);
|
|
206
211
|
default:
|
|
207
|
-
|
|
208
|
-
|
|
212
|
+
const range = new greyscript_core_1.ASTRange(item.start, item.end);
|
|
213
|
+
throw new error_1.PrepareError(`Unexpected AST type ${item.type} at ${range}.`, {
|
|
214
|
+
target: currentTarget,
|
|
215
|
+
range
|
|
209
216
|
});
|
|
210
217
|
}
|
|
211
218
|
});
|
package/dist/interpreter.js
CHANGED
package/dist/utils/error.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ASTRange } from 'greyscript-core';
|
|
2
2
|
import { Operation } from '../operations/operation';
|
|
3
3
|
interface RuntimeContext {
|
|
4
4
|
stackTrace?: Operation[];
|
|
@@ -12,12 +12,12 @@ export declare class RuntimeError extends Error {
|
|
|
12
12
|
private createTrace;
|
|
13
13
|
}
|
|
14
14
|
interface PrepareContext {
|
|
15
|
-
|
|
15
|
+
range: ASTRange;
|
|
16
16
|
target: string;
|
|
17
17
|
}
|
|
18
18
|
export declare class PrepareError extends Error {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
range: ASTRange;
|
|
20
|
+
target: string;
|
|
21
21
|
source?: Error;
|
|
22
22
|
constructor(message: string, context: PrepareContext, source?: Error);
|
|
23
23
|
}
|
package/dist/utils/error.js
CHANGED
|
@@ -22,8 +22,8 @@ exports.RuntimeError = RuntimeError;
|
|
|
22
22
|
class PrepareError extends Error {
|
|
23
23
|
constructor(message, context, source) {
|
|
24
24
|
super(message);
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
25
|
+
this.range = context.range;
|
|
26
|
+
this.target = context.target;
|
|
27
27
|
this.source = source;
|
|
28
28
|
}
|
|
29
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greybel-interpreter",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Interpreter",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"typescript": "^5.0.4"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"greybel-core": "^0.9.
|
|
52
|
-
"greyscript-core": "^0.9.
|
|
51
|
+
"greybel-core": "^0.9.2",
|
|
52
|
+
"greyscript-core": "^0.9.4"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
55
55
|
"greyscript",
|