circuitscript 0.1.4 → 0.1.7

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.
Files changed (102) hide show
  1. package/dist/cjs/BaseVisitor.js +149 -80
  2. package/dist/cjs/SemanticTokenVisitor.js +19 -13
  3. package/dist/cjs/antlr/CircuitScriptParser.js +711 -671
  4. package/dist/cjs/builtinMethods.js +48 -22
  5. package/dist/cjs/draw_symbols.js +4 -1
  6. package/dist/cjs/environment.js +118 -0
  7. package/dist/cjs/execute.js +98 -46
  8. package/dist/cjs/geometry.js +1 -0
  9. package/dist/cjs/globals.js +14 -7
  10. package/dist/cjs/helpers.js +142 -150
  11. package/dist/cjs/index.js +5 -0
  12. package/dist/cjs/layout.js +39 -14
  13. package/dist/cjs/main.js +34 -21
  14. package/dist/cjs/objects/ClassComponent.js +4 -1
  15. package/dist/cjs/objects/ExecutionScope.js +40 -2
  16. package/dist/cjs/objects/ParamDefinition.js +15 -15
  17. package/dist/cjs/parser.js +27 -21
  18. package/dist/cjs/regenerate-tests.js +9 -6
  19. package/dist/cjs/render.js +3 -1
  20. package/dist/cjs/sizing.js +10 -60
  21. package/dist/cjs/utils.js +148 -17
  22. package/dist/cjs/validate/SymbolTable.js +96 -0
  23. package/dist/cjs/validate/SymbolValidatorResolveVisitor.js +14 -0
  24. package/dist/cjs/validate/SymbolValidatorVisitor.js +170 -0
  25. package/dist/cjs/validate.js +52 -44
  26. package/dist/cjs/visitor.js +149 -31
  27. package/dist/esm/{BaseVisitor.mjs → BaseVisitor.js} +124 -56
  28. package/dist/esm/{SemanticTokenVisitor.mjs → SemanticTokenVisitor.js} +17 -11
  29. package/dist/esm/antlr/{CircuitScriptParser.mjs → CircuitScriptParser.js} +711 -671
  30. package/dist/esm/{builtinMethods.mjs → builtinMethods.js} +40 -14
  31. package/dist/esm/{draw_symbols.mjs → draw_symbols.js} +11 -8
  32. package/dist/esm/environment.js +110 -0
  33. package/dist/esm/{execute.mjs → execute.js} +111 -58
  34. package/dist/esm/{export.mjs → export.js} +2 -2
  35. package/dist/esm/{geometry.mjs → geometry.js} +6 -5
  36. package/dist/esm/{globals.mjs → globals.js} +9 -2
  37. package/dist/esm/helpers.js +377 -0
  38. package/dist/esm/index.js +20 -0
  39. package/dist/esm/{layout.mjs → layout.js} +44 -22
  40. package/dist/esm/{lexer.mjs → lexer.js} +2 -2
  41. package/dist/esm/{main.mjs → main.js} +36 -23
  42. package/dist/esm/objects/{ClassComponent.mjs → ClassComponent.js} +9 -5
  43. package/dist/esm/objects/{ExecutionScope.mjs → ExecutionScope.js} +40 -2
  44. package/dist/esm/objects/{Frame.mjs → Frame.js} +1 -1
  45. package/dist/esm/objects/{ParamDefinition.mjs → ParamDefinition.js} +1 -1
  46. package/dist/esm/objects/{PinDefinition.mjs → PinDefinition.js} +1 -1
  47. package/dist/esm/parser.js +71 -0
  48. package/dist/esm/{regenerate-tests.mjs → regenerate-tests.js} +10 -7
  49. package/dist/esm/{render.mjs → render.js} +11 -9
  50. package/dist/esm/{sizing.mjs → sizing.js} +11 -36
  51. package/dist/esm/utils.js +286 -0
  52. package/dist/esm/validate/SymbolTable.js +90 -0
  53. package/dist/esm/validate/SymbolValidatorResolveVisitor.js +10 -0
  54. package/dist/esm/validate/SymbolValidatorVisitor.js +163 -0
  55. package/dist/esm/validate.js +86 -0
  56. package/dist/esm/{visitor.mjs → visitor.js} +160 -42
  57. package/dist/fonts/Arial.ttf +0 -0
  58. package/dist/fonts/Inter-Bold.ttf +0 -0
  59. package/dist/fonts/Inter-Regular.ttf +0 -0
  60. package/dist/fonts/OpenSans-Regular.ttf +0 -0
  61. package/dist/fonts/Roboto-Regular.ttf +0 -0
  62. package/dist/libs/lib.cst +423 -0
  63. package/dist/types/BaseVisitor.d.ts +36 -22
  64. package/dist/types/SemanticTokenVisitor.d.ts +6 -5
  65. package/dist/types/antlr/CircuitScriptParser.d.ts +4 -2
  66. package/dist/types/builtinMethods.d.ts +3 -2
  67. package/dist/types/draw_symbols.d.ts +2 -6
  68. package/dist/types/environment.d.ts +31 -0
  69. package/dist/types/execute.d.ts +2 -3
  70. package/dist/types/globals.d.ts +7 -2
  71. package/dist/types/helpers.d.ts +12 -14
  72. package/dist/types/index.d.ts +5 -0
  73. package/dist/types/objects/ClassComponent.d.ts +2 -3
  74. package/dist/types/objects/ExecutionScope.d.ts +20 -6
  75. package/dist/types/objects/types.d.ts +6 -1
  76. package/dist/types/parser.d.ts +7 -11
  77. package/dist/types/sizing.d.ts +0 -3
  78. package/dist/types/utils.d.ts +33 -4
  79. package/dist/types/validate/SymbolTable.d.ts +40 -0
  80. package/dist/types/validate/SymbolValidatorResolveVisitor.d.ts +7 -0
  81. package/dist/types/validate/SymbolValidatorVisitor.d.ts +32 -0
  82. package/dist/types/validate.d.ts +1 -1
  83. package/libs/lib.cst +12 -22
  84. package/package.json +14 -13
  85. package/dist/cjs/SymbolValidatorVisitor.js +0 -233
  86. package/dist/esm/SymbolValidatorVisitor.mjs +0 -222
  87. package/dist/esm/helpers.mjs +0 -380
  88. package/dist/esm/index.mjs +0 -15
  89. package/dist/esm/parser.mjs +0 -64
  90. package/dist/esm/utils.mjs +0 -169
  91. package/dist/esm/validate.mjs +0 -74
  92. package/dist/types/SymbolValidatorVisitor.d.ts +0 -61
  93. package/dist/types/layout.d.ts +0 -148
  94. /package/dist/esm/antlr/{CircuitScriptLexer.mjs → CircuitScriptLexer.js} +0 -0
  95. /package/dist/esm/antlr/{CircuitScriptVisitor.mjs → CircuitScriptVisitor.js} +0 -0
  96. /package/dist/esm/{fonts.mjs → fonts.js} +0 -0
  97. /package/dist/esm/{logger.mjs → logger.js} +0 -0
  98. /package/dist/esm/objects/{Net.mjs → Net.js} +0 -0
  99. /package/dist/esm/objects/{PinTypes.mjs → PinTypes.js} +0 -0
  100. /package/dist/esm/objects/{Wire.mjs → Wire.js} +0 -0
  101. /package/dist/esm/objects/{types.mjs → types.js} +0 -0
  102. /package/dist/esm/{server.mjs → server.js} +0 -0
@@ -1,233 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SymbolTable = exports.SymbolValidatorResolveVisitor = exports.SymbolValidatorVisitor = void 0;
4
- const BaseVisitor_js_1 = require("./BaseVisitor.js");
5
- const types_js_1 = require("./objects/types.js");
6
- class SymbolValidatorVisitor extends BaseVisitor_js_1.BaseVisitor {
7
- constructor() {
8
- super(...arguments);
9
- this.symbolTable = new SymbolTable();
10
- this.visitImport_expr = (ctx) => {
11
- const ID = ctx.ID().toString();
12
- const { pathExists } = this.handleImportFile(ID, false, ctx);
13
- if (!pathExists) {
14
- this.symbolTable.addUndefined(this.getExecutor(), ID, ctx.ID());
15
- }
16
- };
17
- this.visitAssignment_expr = (ctx) => {
18
- const atomStr = ctx.atom_expr().getText();
19
- const ctxDataExpr = ctx.data_expr();
20
- this.visit(ctxDataExpr);
21
- const value = this.getResult(ctxDataExpr);
22
- this.addSymbolVariable(atomStr, value);
23
- return null;
24
- };
25
- this.visitAtom_expr = (ctx) => {
26
- const tmpSymbol = this.handleAtomSymbol(ctx.ID(0));
27
- this.setResult(ctx, tmpSymbol);
28
- };
29
- this.visitFunction_call_expr = (ctx) => {
30
- this.handleAtomSymbol(ctx.ID());
31
- if (ctx.trailer_expr().length > 0) {
32
- ctx.trailer_expr().forEach(item => {
33
- if (item.OPEN_PAREN() && item.CLOSE_PAREN()) {
34
- const params = item.parameters();
35
- if (params) {
36
- this.visit(params);
37
- }
38
- }
39
- });
40
- }
41
- };
42
- this.visitValueAtomExpr = (ctx) => {
43
- let value = null;
44
- const ctxValueExpr = ctx.value_expr();
45
- const cxtAtomExpr = ctx.atom_expr();
46
- if (ctxValueExpr) {
47
- this.visit(ctxValueExpr);
48
- value = this.getResult(ctxValueExpr);
49
- }
50
- else if (cxtAtomExpr) {
51
- this.visit(cxtAtomExpr);
52
- value = this.getResult(cxtAtomExpr);
53
- }
54
- this.setResult(ctx, value);
55
- };
56
- this.visitUnaryOperatorExpr = (ctx) => {
57
- this.visit(ctx.data_expr());
58
- };
59
- this.visitMultiplyExpr = (ctx) => {
60
- this.visit(ctx.data_expr(0));
61
- this.visit(ctx.data_expr(1));
62
- };
63
- this.visitAdditionExpr = (ctx) => {
64
- this.visit(ctx.data_expr(0));
65
- this.visit(ctx.data_expr(1));
66
- };
67
- this.visitBinaryOperatorExpr = (ctx) => {
68
- this.visit(ctx.data_expr(0));
69
- this.visit(ctx.data_expr(1));
70
- };
71
- this.visitDataExpr = (ctx) => {
72
- return;
73
- };
74
- this.visitFunction_def_expr = (ctx) => {
75
- const functionName = ctx.ID().getText();
76
- let funcDefinedParameters = [];
77
- const ctxFunctionArgsExpr = ctx.function_args_expr();
78
- if (ctxFunctionArgsExpr) {
79
- this.visit(ctxFunctionArgsExpr);
80
- funcDefinedParameters = this.getResult(ctxFunctionArgsExpr);
81
- }
82
- this.addSymbolFunction(functionName, funcDefinedParameters);
83
- const executionContextName = functionName + '_validate';
84
- const passedInParamsNull = funcDefinedParameters.map((param, index) => {
85
- return ['position', index, null];
86
- });
87
- const newExecutor = this.enterNewChildContext(this.executionStack, this.getExecutor(), executionContextName, { netNamespace: "" }, funcDefinedParameters, passedInParamsNull);
88
- funcDefinedParameters.forEach(param => {
89
- this.addSymbolVariable(param[0], null, newExecutor);
90
- });
91
- this.runExpressions(newExecutor, ctx.function_expr());
92
- this.executionStack.pop();
93
- };
94
- }
95
- addSymbolVariable(name, value, executor = null) {
96
- const useExecutor = executor === null ? this.getExecutor() : executor;
97
- this.symbolTable.addVariable(useExecutor, name, value);
98
- this.log2('add symbol variable: ' + name);
99
- }
100
- addSymbolFunction(functionName, funcDefinedParameters) {
101
- if (!this.symbolTable.exists(this.getExecutor(), functionName)) {
102
- this.symbolTable.addFunction(this.getExecutor(), functionName, funcDefinedParameters);
103
- this.log2('add symbol function: ' + functionName);
104
- }
105
- }
106
- handleAtomSymbol(atom) {
107
- const atomId = atom.getText();
108
- const executor = this.getExecutor();
109
- let tmpSymbol;
110
- if (this.symbolTable.exists(executor, atomId)) {
111
- tmpSymbol = this.symbolTable.get(executor, atomId);
112
- }
113
- else {
114
- const foundContext = this.symbolTable.searchParentContext(executor, atomId);
115
- if (foundContext === null) {
116
- tmpSymbol = this.symbolTable.addUndefined(executor, atomId, atom);
117
- this.log2('symbol not found: ' + atomId);
118
- }
119
- else {
120
- tmpSymbol = this.symbolTable.get(foundContext, atomId);
121
- }
122
- }
123
- return tmpSymbol;
124
- }
125
- setSymbols(symbolTable) {
126
- this.symbolTable = symbolTable;
127
- }
128
- getSymbols() {
129
- return this.symbolTable;
130
- }
131
- dumpSymbols() {
132
- this.symbolTable.dumpSymbols();
133
- }
134
- }
135
- exports.SymbolValidatorVisitor = SymbolValidatorVisitor;
136
- class SymbolValidatorResolveVisitor extends SymbolValidatorVisitor {
137
- addSymbolVariable(name, value) {
138
- }
139
- addSymbolFunction(functionName, funcDefinedParameters) {
140
- if (this.symbolTable.exists(this.getExecutor(), functionName)) {
141
- this.symbolTable.addFunction(this.getExecutor(), functionName, funcDefinedParameters);
142
- }
143
- }
144
- }
145
- exports.SymbolValidatorResolveVisitor = SymbolValidatorResolveVisitor;
146
- class SymbolTable {
147
- constructor() {
148
- this.symbols = new Map();
149
- this.executonContextsNamespaces = [];
150
- }
151
- getSymbols() {
152
- return this.symbols;
153
- }
154
- addFunction(executionContext, id, funcDefinedParameters) {
155
- return this.add(executionContext, id, types_js_1.ParseSymbolType.Function, {
156
- funcDefinedParameters
157
- });
158
- }
159
- addVariable(executionContext, id, variableValue) {
160
- return this.add(executionContext, id, types_js_1.ParseSymbolType.Variable, {
161
- variableValue
162
- });
163
- }
164
- addUndefined(executionContext, id, node) {
165
- return this.add(executionContext, id, types_js_1.ParseSymbolType.Undefined, {
166
- node
167
- });
168
- }
169
- add(executionContext, id, type, extra) {
170
- if (this.executonContextsNamespaces.indexOf(executionContext.namespace) === -1) {
171
- this.executonContextsNamespaces.push(executionContext.namespace);
172
- }
173
- const item = {
174
- id,
175
- type,
176
- context: executionContext,
177
- extra
178
- };
179
- this.symbols.set(this.idName(executionContext, id), item);
180
- return item;
181
- }
182
- idName(executionContext, id) {
183
- return executionContext.namespace + id;
184
- }
185
- dumpSymbols() {
186
- for (const [key, value] of this.symbols) {
187
- console.log(value.type.padEnd(10, " "), key);
188
- }
189
- }
190
- exists(executionContext, id) {
191
- const name = this.idName(executionContext, id);
192
- return this.symbols.has(name);
193
- }
194
- existsAny(executionContext, id) {
195
- if (this.exists(executionContext, id)) {
196
- return true;
197
- }
198
- else {
199
- return this.searchParentContext(executionContext, id) !== null;
200
- }
201
- }
202
- get(executionContext, id) {
203
- const name = this.idName(executionContext, id);
204
- return this.symbols.get(name);
205
- }
206
- getParentContexts(executionContext, contextsNamespace) {
207
- if (executionContext.parentContext !== null) {
208
- contextsNamespace.push(executionContext.parentContext.namespace);
209
- this.getParentContexts(executionContext.parentContext, contextsNamespace);
210
- }
211
- return contextsNamespace;
212
- }
213
- searchParentContext(executionContext, id) {
214
- const contextNames = this.getParentContexts(executionContext, []);
215
- for (const [key,] of this.symbols) {
216
- if (key.endsWith(`.${id}`)) {
217
- const { context } = this.symbols.get(key);
218
- if (contextNames.indexOf(context.namespace) !== -1) {
219
- return context;
220
- }
221
- }
222
- }
223
- return null;
224
- }
225
- clearUndefined() {
226
- for (const [key, value] of this.symbols) {
227
- if (value.type === types_js_1.ParseSymbolType.Undefined) {
228
- this.symbols.delete(key);
229
- }
230
- }
231
- }
232
- }
233
- exports.SymbolTable = SymbolTable;
@@ -1,222 +0,0 @@
1
- import { BaseVisitor } from "./BaseVisitor.mjs";
2
- import { ParseSymbolType } from "./objects/types.mjs";
3
- export class SymbolValidatorVisitor extends BaseVisitor {
4
- symbolTable = new SymbolTable();
5
- addSymbolVariable(name, value, executor = null) {
6
- const useExecutor = executor === null ? this.getExecutor() : executor;
7
- this.symbolTable.addVariable(useExecutor, name, value);
8
- this.log2('add symbol variable: ' + name);
9
- }
10
- addSymbolFunction(functionName, funcDefinedParameters) {
11
- if (!this.symbolTable.exists(this.getExecutor(), functionName)) {
12
- this.symbolTable.addFunction(this.getExecutor(), functionName, funcDefinedParameters);
13
- this.log2('add symbol function: ' + functionName);
14
- }
15
- }
16
- handleAtomSymbol(atom) {
17
- const atomId = atom.getText();
18
- const executor = this.getExecutor();
19
- let tmpSymbol;
20
- if (this.symbolTable.exists(executor, atomId)) {
21
- tmpSymbol = this.symbolTable.get(executor, atomId);
22
- }
23
- else {
24
- const foundContext = this.symbolTable.searchParentContext(executor, atomId);
25
- if (foundContext === null) {
26
- tmpSymbol = this.symbolTable.addUndefined(executor, atomId, atom);
27
- this.log2('symbol not found: ' + atomId);
28
- }
29
- else {
30
- tmpSymbol = this.symbolTable.get(foundContext, atomId);
31
- }
32
- }
33
- return tmpSymbol;
34
- }
35
- setSymbols(symbolTable) {
36
- this.symbolTable = symbolTable;
37
- }
38
- visitImport_expr = (ctx) => {
39
- const ID = ctx.ID().toString();
40
- const { pathExists } = this.handleImportFile(ID, false, ctx);
41
- if (!pathExists) {
42
- this.symbolTable.addUndefined(this.getExecutor(), ID, ctx.ID());
43
- }
44
- };
45
- visitAssignment_expr = (ctx) => {
46
- const atomStr = ctx.atom_expr().getText();
47
- const ctxDataExpr = ctx.data_expr();
48
- this.visit(ctxDataExpr);
49
- const value = this.getResult(ctxDataExpr);
50
- this.addSymbolVariable(atomStr, value);
51
- return null;
52
- };
53
- visitAtom_expr = (ctx) => {
54
- const tmpSymbol = this.handleAtomSymbol(ctx.ID(0));
55
- this.setResult(ctx, tmpSymbol);
56
- };
57
- visitFunction_call_expr = (ctx) => {
58
- this.handleAtomSymbol(ctx.ID());
59
- if (ctx.trailer_expr().length > 0) {
60
- ctx.trailer_expr().forEach(item => {
61
- if (item.OPEN_PAREN() && item.CLOSE_PAREN()) {
62
- const params = item.parameters();
63
- if (params) {
64
- this.visit(params);
65
- }
66
- }
67
- });
68
- }
69
- };
70
- visitValueAtomExpr = (ctx) => {
71
- let value = null;
72
- const ctxValueExpr = ctx.value_expr();
73
- const cxtAtomExpr = ctx.atom_expr();
74
- if (ctxValueExpr) {
75
- this.visit(ctxValueExpr);
76
- value = this.getResult(ctxValueExpr);
77
- }
78
- else if (cxtAtomExpr) {
79
- this.visit(cxtAtomExpr);
80
- value = this.getResult(cxtAtomExpr);
81
- }
82
- this.setResult(ctx, value);
83
- };
84
- visitUnaryOperatorExpr = (ctx) => {
85
- this.visit(ctx.data_expr());
86
- };
87
- visitMultiplyExpr = (ctx) => {
88
- this.visit(ctx.data_expr(0));
89
- this.visit(ctx.data_expr(1));
90
- };
91
- visitAdditionExpr = (ctx) => {
92
- this.visit(ctx.data_expr(0));
93
- this.visit(ctx.data_expr(1));
94
- };
95
- visitBinaryOperatorExpr = (ctx) => {
96
- this.visit(ctx.data_expr(0));
97
- this.visit(ctx.data_expr(1));
98
- };
99
- visitDataExpr = (ctx) => {
100
- return;
101
- };
102
- visitFunction_def_expr = (ctx) => {
103
- const functionName = ctx.ID().getText();
104
- let funcDefinedParameters = [];
105
- const ctxFunctionArgsExpr = ctx.function_args_expr();
106
- if (ctxFunctionArgsExpr) {
107
- this.visit(ctxFunctionArgsExpr);
108
- funcDefinedParameters = this.getResult(ctxFunctionArgsExpr);
109
- }
110
- this.addSymbolFunction(functionName, funcDefinedParameters);
111
- const executionContextName = functionName + '_validate';
112
- const passedInParamsNull = funcDefinedParameters.map((param, index) => {
113
- return ['position', index, null];
114
- });
115
- const newExecutor = this.enterNewChildContext(this.executionStack, this.getExecutor(), executionContextName, { netNamespace: "" }, funcDefinedParameters, passedInParamsNull);
116
- funcDefinedParameters.forEach(param => {
117
- this.addSymbolVariable(param[0], null, newExecutor);
118
- });
119
- this.runExpressions(newExecutor, ctx.function_expr());
120
- this.executionStack.pop();
121
- };
122
- getSymbols() {
123
- return this.symbolTable;
124
- }
125
- dumpSymbols() {
126
- this.symbolTable.dumpSymbols();
127
- }
128
- }
129
- export class SymbolValidatorResolveVisitor extends SymbolValidatorVisitor {
130
- addSymbolVariable(name, value) {
131
- }
132
- addSymbolFunction(functionName, funcDefinedParameters) {
133
- if (this.symbolTable.exists(this.getExecutor(), functionName)) {
134
- this.symbolTable.addFunction(this.getExecutor(), functionName, funcDefinedParameters);
135
- }
136
- }
137
- }
138
- export class SymbolTable {
139
- symbols = new Map();
140
- executonContextsNamespaces = [];
141
- getSymbols() {
142
- return this.symbols;
143
- }
144
- addFunction(executionContext, id, funcDefinedParameters) {
145
- return this.add(executionContext, id, ParseSymbolType.Function, {
146
- funcDefinedParameters
147
- });
148
- }
149
- addVariable(executionContext, id, variableValue) {
150
- return this.add(executionContext, id, ParseSymbolType.Variable, {
151
- variableValue
152
- });
153
- }
154
- addUndefined(executionContext, id, node) {
155
- return this.add(executionContext, id, ParseSymbolType.Undefined, {
156
- node
157
- });
158
- }
159
- add(executionContext, id, type, extra) {
160
- if (this.executonContextsNamespaces.indexOf(executionContext.namespace) === -1) {
161
- this.executonContextsNamespaces.push(executionContext.namespace);
162
- }
163
- const item = {
164
- id,
165
- type,
166
- context: executionContext,
167
- extra
168
- };
169
- this.symbols.set(this.idName(executionContext, id), item);
170
- return item;
171
- }
172
- idName(executionContext, id) {
173
- return executionContext.namespace + id;
174
- }
175
- dumpSymbols() {
176
- for (const [key, value] of this.symbols) {
177
- console.log(value.type.padEnd(10, " "), key);
178
- }
179
- }
180
- exists(executionContext, id) {
181
- const name = this.idName(executionContext, id);
182
- return this.symbols.has(name);
183
- }
184
- existsAny(executionContext, id) {
185
- if (this.exists(executionContext, id)) {
186
- return true;
187
- }
188
- else {
189
- return this.searchParentContext(executionContext, id) !== null;
190
- }
191
- }
192
- get(executionContext, id) {
193
- const name = this.idName(executionContext, id);
194
- return this.symbols.get(name);
195
- }
196
- getParentContexts(executionContext, contextsNamespace) {
197
- if (executionContext.parentContext !== null) {
198
- contextsNamespace.push(executionContext.parentContext.namespace);
199
- this.getParentContexts(executionContext.parentContext, contextsNamespace);
200
- }
201
- return contextsNamespace;
202
- }
203
- searchParentContext(executionContext, id) {
204
- const contextNames = this.getParentContexts(executionContext, []);
205
- for (const [key,] of this.symbols) {
206
- if (key.endsWith(`.${id}`)) {
207
- const { context } = this.symbols.get(key);
208
- if (contextNames.indexOf(context.namespace) !== -1) {
209
- return context;
210
- }
211
- }
212
- }
213
- return null;
214
- }
215
- clearUndefined() {
216
- for (const [key, value] of this.symbols) {
217
- if (value.type === ParseSymbolType.Undefined) {
218
- this.symbols.delete(key);
219
- }
220
- }
221
- }
222
- }