greybel-interpreter 4.0.9 → 4.0.10
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 +2 -0
- package/dist/context.js +23 -0
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { CustomMap } from './types/map';
|
|
|
3
3
|
import { ObjectValue } from './utils/object-value';
|
|
4
4
|
import { ContextTypeIntrinsics } from './context/types';
|
|
5
5
|
import { Instruction } from './byte-compiler/instruction';
|
|
6
|
+
import { CustomValueWithIntrinsicsResult } from './types/with-intrinsics';
|
|
6
7
|
export declare enum ContextType {
|
|
7
8
|
Api = 0,
|
|
8
9
|
Global = 1,
|
|
@@ -13,6 +14,7 @@ export declare class Scope extends CustomMap {
|
|
|
13
14
|
private readonly context;
|
|
14
15
|
constructor(context: OperationContext);
|
|
15
16
|
get(current: CustomValue, typeIntrinsics: ContextTypeIntrinsics): CustomValue;
|
|
17
|
+
getWithOrigin(current: CustomValue, typeIntrinsics: ContextTypeIntrinsics): CustomValueWithIntrinsicsResult;
|
|
16
18
|
}
|
|
17
19
|
export interface ContextOptions {
|
|
18
20
|
code: Instruction[];
|
package/dist/context.js
CHANGED
|
@@ -35,6 +35,29 @@ class Scope extends map_1.CustomMap {
|
|
|
35
35
|
}
|
|
36
36
|
throw new Error(`Unknown path ${current.toString()}.`);
|
|
37
37
|
}
|
|
38
|
+
getWithOrigin(current, typeIntrinsics) {
|
|
39
|
+
var _a, _b, _c, _d;
|
|
40
|
+
if (this.has(current)) {
|
|
41
|
+
return super.getWithOrigin(current, typeIntrinsics);
|
|
42
|
+
}
|
|
43
|
+
else if ((_a = this.context.outer) === null || _a === void 0 ? void 0 : _a.scope.has(current)) {
|
|
44
|
+
return this.context.outer.scope.getWithOrigin(current, typeIntrinsics);
|
|
45
|
+
}
|
|
46
|
+
else if ((_b = this.context.globals) === null || _b === void 0 ? void 0 : _b.scope.has(current)) {
|
|
47
|
+
return this.context.globals.scope.getWithOrigin(current, typeIntrinsics);
|
|
48
|
+
}
|
|
49
|
+
else if ((_c = this.context.api) === null || _c === void 0 ? void 0 : _c.scope.has(current)) {
|
|
50
|
+
return this.context.api.scope.getWithOrigin(current, typeIntrinsics);
|
|
51
|
+
}
|
|
52
|
+
const intrinsics = (_d = typeIntrinsics.map) !== null && _d !== void 0 ? _d : map_1.CustomMap.getIntrinsics();
|
|
53
|
+
if (intrinsics.has(current)) {
|
|
54
|
+
return {
|
|
55
|
+
value: intrinsics.get(current),
|
|
56
|
+
origin: null
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`Unknown path ${current.toString()}.`);
|
|
60
|
+
}
|
|
38
61
|
}
|
|
39
62
|
exports.Scope = Scope;
|
|
40
63
|
class OperationContext {
|