circuitscript 0.1.29 → 0.1.32
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/cjs/BaseVisitor.js +185 -22
- package/dist/cjs/RefdesAnnotationVisitor.js +27 -10
- package/dist/cjs/antlr/CircuitScriptLexer.js +241 -236
- package/dist/cjs/antlr/CircuitScriptParser.js +1197 -901
- package/dist/cjs/builtinMethods.js +6 -2
- package/dist/cjs/draw_symbols.js +38 -34
- package/dist/cjs/environment.js +28 -4
- package/dist/cjs/execute.js +195 -125
- package/dist/cjs/globals.js +6 -1
- package/dist/cjs/graph.js +14 -12
- package/dist/cjs/helpers.js +90 -17
- package/dist/cjs/layout.js +50 -25
- package/dist/cjs/main.js +16 -14
- package/dist/cjs/objects/ClassComponent.js +199 -30
- package/dist/cjs/objects/ExecutionScope.js +9 -0
- package/dist/cjs/objects/types.js +25 -2
- package/dist/cjs/parser.js +6 -2
- package/dist/cjs/regenerate-tests.js +3 -3
- package/dist/cjs/render.js +5 -3
- package/dist/cjs/rules-check/no-connect-on-connected-pin.js +9 -8
- package/dist/cjs/rules-check/rules.js +7 -2
- package/dist/cjs/rules-check/unconnected-pins.js +10 -8
- package/dist/cjs/utils.js +2 -1
- package/dist/cjs/validate/SymbolTable.js +7 -1
- package/dist/cjs/validate/SymbolValidatorVisitor.js +54 -17
- package/dist/cjs/visitor.js +299 -238
- package/dist/esm/BaseVisitor.js +187 -24
- package/dist/esm/RefdesAnnotationVisitor.js +27 -10
- package/dist/esm/antlr/CircuitScriptLexer.js +241 -236
- package/dist/esm/antlr/CircuitScriptParser.js +1196 -899
- package/dist/esm/antlr/CircuitScriptVisitor.js +4 -1
- package/dist/esm/builtinMethods.js +7 -3
- package/dist/esm/draw_symbols.js +38 -34
- package/dist/esm/environment.js +25 -1
- package/dist/esm/execute.js +197 -127
- package/dist/esm/globals.js +4 -0
- package/dist/esm/graph.js +14 -12
- package/dist/esm/helpers.js +91 -18
- package/dist/esm/layout.js +51 -26
- package/dist/esm/main.js +16 -14
- package/dist/esm/objects/ClassComponent.js +201 -30
- package/dist/esm/objects/ExecutionScope.js +9 -0
- package/dist/esm/objects/types.js +33 -1
- package/dist/esm/parser.js +6 -2
- package/dist/esm/regenerate-tests.js +3 -3
- package/dist/esm/render.js +5 -3
- package/dist/esm/rules-check/no-connect-on-connected-pin.js +9 -8
- package/dist/esm/rules-check/rules.js +7 -2
- package/dist/esm/rules-check/unconnected-pins.js +10 -8
- package/dist/esm/utils.js +2 -1
- package/dist/esm/validate/SymbolTable.js +5 -0
- package/dist/esm/validate/SymbolValidatorVisitor.js +53 -16
- package/dist/esm/visitor.js +201 -137
- package/dist/types/BaseVisitor.d.ts +27 -10
- package/dist/types/RefdesAnnotationVisitor.d.ts +2 -0
- package/dist/types/antlr/CircuitScriptLexer.d.ts +43 -42
- package/dist/types/antlr/CircuitScriptParser.d.ts +102 -58
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +8 -2
- package/dist/types/environment.d.ts +8 -1
- package/dist/types/execute.d.ts +6 -3
- package/dist/types/globals.d.ts +4 -0
- package/dist/types/graph.d.ts +2 -2
- package/dist/types/helpers.d.ts +2 -1
- package/dist/types/layout.d.ts +5 -4
- package/dist/types/objects/ClassComponent.d.ts +34 -9
- package/dist/types/objects/ExecutionScope.d.ts +3 -1
- package/dist/types/objects/types.d.ts +40 -3
- package/dist/types/validate/SymbolTable.d.ts +1 -0
- package/dist/types/validate/SymbolValidatorVisitor.d.ts +6 -6
- package/dist/types/visitor.d.ts +10 -2
- package/package.json +4 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NetTypes = exports.TypeProps = exports.Direction = exports.ParseSymbolType = exports.DeclaredReference = exports.UndeclaredReference = exports.AnyReference = exports.CFunctionEntry = void 0;
|
|
3
|
+
exports.ImportFunctionHandling = exports.ImportedModule = exports.NetTypes = exports.TypeProps = exports.Direction = exports.ParseSymbolType = exports.DeclaredReference = exports.UndeclaredReference = exports.AnyReference = exports.CFunctionEntry = void 0;
|
|
4
4
|
const globals_js_1 = require("../globals.js");
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
6
|
class CFunctionEntry {
|
|
7
|
-
constructor(name, execute, source, uniqueId) {
|
|
7
|
+
constructor(namespace, name, execute, source, uniqueId) {
|
|
8
8
|
this.name = name;
|
|
9
|
+
this.namespace = namespace;
|
|
10
|
+
this.originalNamespace = namespace;
|
|
9
11
|
this.execute = execute;
|
|
10
12
|
this.uniqueId = uniqueId;
|
|
11
13
|
this.source = source;
|
|
@@ -125,3 +127,24 @@ var NetTypes;
|
|
|
125
127
|
NetTypes["Any"] = "any";
|
|
126
128
|
NetTypes["Source"] = "source";
|
|
127
129
|
})(NetTypes || (exports.NetTypes = NetTypes = {}));
|
|
130
|
+
class ImportedModule {
|
|
131
|
+
constructor(moduleName, moduleNamespace, moduleFilePath, tree, tokens, context, flag, specifiedImports) {
|
|
132
|
+
this.enableRefdesAnnotation = false;
|
|
133
|
+
this.enableRefdesAnnotationFile = false;
|
|
134
|
+
this.moduleName = moduleName;
|
|
135
|
+
this.moduleNamespace = moduleNamespace;
|
|
136
|
+
this.moduleFilePath = moduleFilePath;
|
|
137
|
+
this.tree = tree;
|
|
138
|
+
this.tokens = tokens;
|
|
139
|
+
this.context = context;
|
|
140
|
+
this.importHandlingFlag = flag;
|
|
141
|
+
this.specifiedImports = specifiedImports;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.ImportedModule = ImportedModule;
|
|
145
|
+
var ImportFunctionHandling;
|
|
146
|
+
(function (ImportFunctionHandling) {
|
|
147
|
+
ImportFunctionHandling["AllWithNamespace"] = "all-with-namespace";
|
|
148
|
+
ImportFunctionHandling["AllMergeIntoNamespace"] = "all-merge-into-namespace";
|
|
149
|
+
ImportFunctionHandling["SpecificMergeIntoNamespace"] = "specific-merge-into-namespace";
|
|
150
|
+
})(ImportFunctionHandling || (exports.ImportFunctionHandling = ImportFunctionHandling = {}));
|
package/dist/cjs/parser.js
CHANGED
|
@@ -22,6 +22,8 @@ async function parseFileWithVisitor(visitor, data) {
|
|
|
22
22
|
parser.addErrorListener(parserErrorListener);
|
|
23
23
|
const tree = parser.script();
|
|
24
24
|
let throwError;
|
|
25
|
+
let hasError = false;
|
|
26
|
+
let hasParseError = false;
|
|
25
27
|
try {
|
|
26
28
|
await visitor.visitAsync(tree);
|
|
27
29
|
}
|
|
@@ -34,13 +36,15 @@ async function parseFileWithVisitor(visitor, data) {
|
|
|
34
36
|
throwError = error;
|
|
35
37
|
}
|
|
36
38
|
}
|
|
39
|
+
hasError = true;
|
|
40
|
+
hasParseError = true;
|
|
37
41
|
}
|
|
38
42
|
const parserTimeTaken = parserTimer.lap();
|
|
39
43
|
return {
|
|
40
44
|
tree, parser,
|
|
41
45
|
tokens,
|
|
42
|
-
hasParseError
|
|
43
|
-
hasError
|
|
46
|
+
hasParseError,
|
|
47
|
+
hasError,
|
|
44
48
|
parserTimeTaken,
|
|
45
49
|
lexerTimeTaken,
|
|
46
50
|
throwError
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
7
|
const helpers_js_1 = require("./helpers.js");
|
|
8
8
|
const environment_js_1 = require("./environment.js");
|
|
9
|
-
const mainDir = './__tests__/renderData/';
|
|
9
|
+
const mainDir = './__tests__/testData/renderData/';
|
|
10
10
|
const env = new environment_js_1.NodeScriptEnvironment();
|
|
11
11
|
environment_js_1.NodeScriptEnvironment.setInstance(env);
|
|
12
12
|
async function regenerateTests(extra = "") {
|
|
@@ -14,7 +14,7 @@ async function regenerateTests(extra = "") {
|
|
|
14
14
|
const cstFiles = [];
|
|
15
15
|
const files = fs_1.default.readdirSync(mainDir);
|
|
16
16
|
files.forEach(file => {
|
|
17
|
-
if (file.endsWith('.cst')) {
|
|
17
|
+
if (file.endsWith('.cst') && file.startsWith('script')) {
|
|
18
18
|
cstFiles.push(file);
|
|
19
19
|
}
|
|
20
20
|
});
|
|
@@ -24,7 +24,7 @@ async function regenerateTests(extra = "") {
|
|
|
24
24
|
const scriptData = fs_1.default.readFileSync(inputPath, { encoding: 'utf-8' });
|
|
25
25
|
const outputPath = mainDir + 'svgs/' + file + extra + '.svg';
|
|
26
26
|
env.setModuleDirectory(mainDir);
|
|
27
|
-
env.setDefaultLibsPath(mainDir + '
|
|
27
|
+
env.setDefaultLibsPath(mainDir + '../../../libs/');
|
|
28
28
|
await (0, helpers_js_1.renderScript)(scriptData, outputPath, {
|
|
29
29
|
dumpNets: false,
|
|
30
30
|
dumpData: false,
|
package/dist/cjs/render.js
CHANGED
|
@@ -42,10 +42,11 @@ function renderSheetsToSVG(sheetFrames, logger) {
|
|
|
42
42
|
const frameComponent = sheet.frame.frame.parameters
|
|
43
43
|
.get(Frame_js_1.FrameParamKeys.SheetType);
|
|
44
44
|
if (frameComponent) {
|
|
45
|
-
|
|
45
|
+
const frameComponentUnit = frameComponent.getUnit();
|
|
46
|
+
if (frameComponentUnit.displayProp === null) {
|
|
46
47
|
throw 'Invalid graphic object for sheet frame';
|
|
47
48
|
}
|
|
48
|
-
const frameRects = (0, layout_js_1.ExtractDrawingRects)(
|
|
49
|
+
const frameRects = (0, layout_js_1.ExtractDrawingRects)(frameComponentUnit.displayProp) ?? [];
|
|
49
50
|
let originalWidthMM = (0, ParamDefinition_js_1.numeric)(0);
|
|
50
51
|
let originalHeightMM = (0, ParamDefinition_js_1.numeric)(0);
|
|
51
52
|
let widthMM = (0, ParamDefinition_js_1.numeric)(0);
|
|
@@ -334,7 +335,8 @@ function drawSheetFrameBorder(frameGroup, frame) {
|
|
|
334
335
|
const frameParams = frame.frame.parameters;
|
|
335
336
|
if (frameParams.has(Frame_js_1.FrameParamKeys.SheetType)) {
|
|
336
337
|
const frameComponent = frameParams.get(Frame_js_1.FrameParamKeys.SheetType);
|
|
337
|
-
const
|
|
338
|
+
const frameComponentUnit = frameComponent.getUnit();
|
|
339
|
+
const { displayProp = null } = frameComponentUnit ?? {};
|
|
338
340
|
if (displayProp) {
|
|
339
341
|
const sheetFrameGroup = frameGroup.group();
|
|
340
342
|
const symbol = new draw_symbols_js_1.SymbolPlaceholder(displayProp);
|
|
@@ -11,25 +11,26 @@ function RuleCheck_NoConnectOnConnectedPin(graph, nets) {
|
|
|
11
11
|
const makeComponentPinHash = (instanceName, pin) => {
|
|
12
12
|
return instanceName + '-' + pin.getHashValue();
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
const [component, pin, net] = item;
|
|
14
|
+
for (const [component, pin, net] of nets) {
|
|
16
15
|
if (!netComponentPins.has(net)) {
|
|
17
16
|
netComponentPins.set(net, []);
|
|
18
17
|
}
|
|
19
18
|
const items = netComponentPins.get(net);
|
|
19
|
+
const unit = component.getUnitForPin(pin);
|
|
20
20
|
items.push([
|
|
21
|
-
|
|
21
|
+
unit.instanceName,
|
|
22
22
|
pin
|
|
23
23
|
]);
|
|
24
24
|
netComponentPins.set(net, items);
|
|
25
|
-
pinMapping.set(makeComponentPinHash(
|
|
26
|
-
}
|
|
27
|
-
|
|
25
|
+
pinMapping.set(makeComponentPinHash(unit.instanceName, pin), net);
|
|
26
|
+
}
|
|
27
|
+
;
|
|
28
|
+
for (const node of allNodes) {
|
|
28
29
|
const nodeInfo = graph.node(node);
|
|
29
30
|
if (nodeInfo[0] === graph_js_1.RenderItemType.Component) {
|
|
30
31
|
const { component } = nodeInfo[1];
|
|
31
32
|
if (component.hasParam('no_connect')) {
|
|
32
|
-
const instanceName = component.instanceName;
|
|
33
|
+
const instanceName = component.getUnit().instanceName;
|
|
33
34
|
const edges = graph.nodeEdges(node);
|
|
34
35
|
const otherNodes = [];
|
|
35
36
|
edges.forEach(edge => {
|
|
@@ -75,7 +76,7 @@ function RuleCheck_NoConnectOnConnectedPin(graph, nets) {
|
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
}
|
|
79
|
+
}
|
|
79
80
|
return items;
|
|
80
81
|
}
|
|
81
82
|
exports.RuleCheck_NoConnectOnConnectedPin = RuleCheck_NoConnectOnConnectedPin;
|
|
@@ -25,7 +25,7 @@ function EvaluateERCRules(visitor, graph, nets) {
|
|
|
25
25
|
reportItems.push({
|
|
26
26
|
type,
|
|
27
27
|
start: token,
|
|
28
|
-
message: `Unconnected pin ${item.pin}
|
|
28
|
+
message: `Unconnected pin: ${instance.assignedRefDes} pin ${item.pin}`
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -47,12 +47,17 @@ function EvaluateERCRules(visitor, graph, nets) {
|
|
|
47
47
|
case ERC_Rules.NoConnectOnConnectedPin:
|
|
48
48
|
{
|
|
49
49
|
const instance = item.instance;
|
|
50
|
+
const { instance: targetComponent, pin: targetPin } = item.target;
|
|
51
|
+
let extra = '';
|
|
52
|
+
if (targetComponent && targetComponent.assignedRefDes) {
|
|
53
|
+
extra = `: ${targetComponent.assignedRefDes} pin ${targetPin}`;
|
|
54
|
+
}
|
|
50
55
|
const token = getComponentFirstCtxToken(instance);
|
|
51
56
|
if (token) {
|
|
52
57
|
reportItems.push({
|
|
53
58
|
type,
|
|
54
59
|
start: token,
|
|
55
|
-
message: `No connect on connected pin`
|
|
60
|
+
message: `No connect on connected pin${extra}`
|
|
56
61
|
});
|
|
57
62
|
}
|
|
58
63
|
}
|
|
@@ -6,13 +6,15 @@ const rules_js_1 = require("./rules.js");
|
|
|
6
6
|
function RuleCheck_UnconnectedPinsWires(graph) {
|
|
7
7
|
const items = [];
|
|
8
8
|
const allNodes = graph.nodes();
|
|
9
|
-
|
|
9
|
+
for (const node of allNodes) {
|
|
10
10
|
const nodeInfo = graph.node(node);
|
|
11
11
|
if (nodeInfo[0] === graph_js_1.RenderItemType.Component) {
|
|
12
|
-
const
|
|
12
|
+
const renderComponent = nodeInfo[1];
|
|
13
|
+
const { component, unitId } = renderComponent;
|
|
13
14
|
const edges = graph.nodeEdges(node);
|
|
14
|
-
const
|
|
15
|
-
const
|
|
15
|
+
const componentUnit = component.getUnit(unitId);
|
|
16
|
+
const instanceName = componentUnit.instanceName;
|
|
17
|
+
const connectedUnitPins = [];
|
|
16
18
|
edges.forEach(edge => {
|
|
17
19
|
const edgeInfo = graph.edge(edge.v, edge.w);
|
|
18
20
|
let pin;
|
|
@@ -22,12 +24,12 @@ function RuleCheck_UnconnectedPinsWires(graph) {
|
|
|
22
24
|
else if (edge.w === instanceName) {
|
|
23
25
|
pin = edgeInfo[3];
|
|
24
26
|
}
|
|
25
|
-
|
|
27
|
+
connectedUnitPins.push(pin.getHashValue());
|
|
26
28
|
});
|
|
27
|
-
const pinIds = Array.from(
|
|
29
|
+
const pinIds = Array.from(componentUnit.pins.keys());
|
|
28
30
|
pinIds.forEach(pinId => {
|
|
29
31
|
const hashValue = pinId.getHashValue();
|
|
30
|
-
if (
|
|
32
|
+
if (connectedUnitPins.indexOf(hashValue) === -1) {
|
|
31
33
|
items.push({
|
|
32
34
|
type: rules_js_1.ERC_Rules.UnconnectedPin,
|
|
33
35
|
instance: component,
|
|
@@ -46,7 +48,7 @@ function RuleCheck_UnconnectedPinsWires(graph) {
|
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
|
-
}
|
|
51
|
+
}
|
|
50
52
|
return items;
|
|
51
53
|
}
|
|
52
54
|
exports.RuleCheck_UnconnectedPinsWires = RuleCheck_UnconnectedPinsWires;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -66,7 +66,8 @@ function getBoundsSize(bounds) {
|
|
|
66
66
|
}
|
|
67
67
|
exports.getBoundsSize = getBoundsSize;
|
|
68
68
|
function getPortType(component) {
|
|
69
|
-
const
|
|
69
|
+
const targetUnit = component.getUnit();
|
|
70
|
+
const drawingCommands = targetUnit.displayProp;
|
|
70
71
|
let foundPinType = null;
|
|
71
72
|
const commands = drawingCommands.getCommands();
|
|
72
73
|
commands.some(item => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SymbolTable = void 0;
|
|
3
|
+
exports.cloneSymbol = exports.SymbolTable = void 0;
|
|
4
4
|
const types_js_1 = require("../objects/types.js");
|
|
5
5
|
class SymbolTable {
|
|
6
6
|
constructor() {
|
|
@@ -94,3 +94,9 @@ class SymbolTable {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
exports.SymbolTable = SymbolTable;
|
|
97
|
+
function cloneSymbol(symbol) {
|
|
98
|
+
return {
|
|
99
|
+
...symbol
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
exports.cloneSymbol = cloneSymbol;
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SymbolValidatorVisitor = void 0;
|
|
4
|
+
const CircuitScriptParser_js_1 = require("../antlr/CircuitScriptParser.js");
|
|
4
5
|
const builtinMethods_js_1 = require("../builtinMethods.js");
|
|
5
6
|
const types_js_1 = require("../objects/types.js");
|
|
6
7
|
const SymbolTable_js_1 = require("./SymbolTable.js");
|
|
8
|
+
const SymbolTable_js_2 = require("./SymbolTable.js");
|
|
7
9
|
const BaseVisitor_js_1 = require("../BaseVisitor.js");
|
|
8
10
|
const globals_js_1 = require("../globals.js");
|
|
9
11
|
class SymbolValidatorVisitor extends BaseVisitor_js_1.BaseVisitor {
|
|
10
12
|
constructor() {
|
|
11
13
|
super(...arguments);
|
|
12
|
-
this.symbolTable = new
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
this.symbolTable = new SymbolTable_js_2.SymbolTable();
|
|
15
|
+
this.visitImport_simple = async (ctx) => {
|
|
16
|
+
await this.importCommon(ctx, types_js_1.ImportFunctionHandling.AllWithNamespace);
|
|
17
|
+
};
|
|
18
|
+
this.visitImport_all_simple = async (ctx) => {
|
|
19
|
+
await this.importCommon(ctx, types_js_1.ImportFunctionHandling.AllMergeIntoNamespace);
|
|
20
|
+
};
|
|
21
|
+
this.visitImport_specific = async (ctx) => {
|
|
22
|
+
await this.importCommon(ctx, types_js_1.ImportFunctionHandling.SpecificMergeIntoNamespace);
|
|
20
23
|
};
|
|
21
24
|
this.visitAssignment_expr = (ctx) => {
|
|
22
25
|
const ctxDataExpr = ctx.data_expr();
|
|
@@ -109,15 +112,6 @@ class SymbolValidatorVisitor extends BaseVisitor_js_1.BaseVisitor {
|
|
|
109
112
|
});
|
|
110
113
|
};
|
|
111
114
|
}
|
|
112
|
-
enterFile(filePath) {
|
|
113
|
-
this.filePathStack.push(filePath);
|
|
114
|
-
}
|
|
115
|
-
exitFile() {
|
|
116
|
-
this.filePathStack.pop();
|
|
117
|
-
}
|
|
118
|
-
getCurrentFile() {
|
|
119
|
-
return this.filePathStack[this.filePathStack.length - 1];
|
|
120
|
-
}
|
|
121
115
|
addSymbolVariable(token, name, value, executor = null) {
|
|
122
116
|
const useExecutor = executor === null ? this.getExecutor() : executor;
|
|
123
117
|
this.symbolTable.addVariable(token, this.getCurrentFile(), useExecutor, name, value);
|
|
@@ -165,6 +159,49 @@ class SymbolValidatorVisitor extends BaseVisitor_js_1.BaseVisitor {
|
|
|
165
159
|
setSymbols(symbolTable) {
|
|
166
160
|
this.symbolTable = symbolTable;
|
|
167
161
|
}
|
|
162
|
+
async importCommon(ctx, handling) {
|
|
163
|
+
const specifiedImports = [];
|
|
164
|
+
if (ctx instanceof CircuitScriptParser_js_1.Import_specificContext) {
|
|
165
|
+
const tmpImports = ctx._funcNames.map(item => {
|
|
166
|
+
return item.text;
|
|
167
|
+
});
|
|
168
|
+
specifiedImports.push(...tmpImports);
|
|
169
|
+
}
|
|
170
|
+
const id = ctx._moduleName.text;
|
|
171
|
+
const { pathExists, importedModule } = await this.handleImportFile(id, handling, true, ctx, specifiedImports);
|
|
172
|
+
if (!pathExists) {
|
|
173
|
+
this.symbolTable.addUndefined(this.getCurrentFile(), this.getExecutor(), id, ctx._moduleName);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
this.applyModuleImports(importedModule);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
applyModuleImports(module) {
|
|
180
|
+
const { importHandlingFlag: importHandling, specifiedImports } = module;
|
|
181
|
+
const addedSymbols = [];
|
|
182
|
+
const executor = this.getExecutor();
|
|
183
|
+
const symbolTable = this.symbolTable.getSymbols();
|
|
184
|
+
symbolTable.forEach((value, key) => {
|
|
185
|
+
if (value.type === types_js_1.ParseSymbolType.Function) {
|
|
186
|
+
const definedSymbol = value;
|
|
187
|
+
if (definedSymbol.fileName === module.moduleFilePath) {
|
|
188
|
+
const addSymbolToNamespace = importHandling === types_js_1.ImportFunctionHandling.AllMergeIntoNamespace
|
|
189
|
+
|| (importHandling === types_js_1.ImportFunctionHandling.SpecificMergeIntoNamespace
|
|
190
|
+
&& specifiedImports.indexOf(definedSymbol.id) !== -1);
|
|
191
|
+
if (addSymbolToNamespace) {
|
|
192
|
+
const funcPath = `${globals_js_1.BaseNamespace}${definedSymbol.id}`;
|
|
193
|
+
const tmpSymbol = (0, SymbolTable_js_1.cloneSymbol)(value);
|
|
194
|
+
tmpSymbol.context = executor;
|
|
195
|
+
addedSymbols.push([funcPath, tmpSymbol]);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
addedSymbols.forEach(item => {
|
|
201
|
+
const [key, value] = item;
|
|
202
|
+
symbolTable.set(key, value);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
168
205
|
getSymbols() {
|
|
169
206
|
return this.symbolTable;
|
|
170
207
|
}
|