greybel-interpreter 4.0.9 → 4.0.11

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 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 {
package/dist/vm.js CHANGED
@@ -17,7 +17,6 @@ const context_1 = require("./context");
17
17
  const instruction_1 = require("./byte-compiler/instruction");
18
18
  const default_1 = require("./types/default");
19
19
  const stack_1 = require("./utils/stack");
20
- const nil_1 = require("./types/nil");
21
20
  const error_1 = require("./utils/error");
22
21
  const with_intrinsics_1 = require("./types/with-intrinsics");
23
22
  const boolean_1 = require("./types/boolean");
@@ -221,9 +220,6 @@ class VM {
221
220
  if (!(base instanceof with_intrinsics_1.CustomValueWithIntrinsics)) {
222
221
  throw new error_1.RuntimeError(`Base left side must be a value with intrinsics!`, this);
223
222
  }
224
- else if (key instanceof nil_1.CustomNil) {
225
- throw new error_1.RuntimeError(`Key left side cannot be null!`, this);
226
- }
227
223
  base.set(key, value);
228
224
  break;
229
225
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "4.0.9",
3
+ "version": "4.0.11",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",