circuitscript 0.1.15 → 0.1.17
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 +98 -35
- package/dist/cjs/antlr/CircuitScriptLexer.js +3 -3
- package/dist/cjs/antlr/CircuitScriptParser.js +868 -757
- package/dist/cjs/builtinMethods.js +11 -1
- package/dist/cjs/draw_symbols.js +18 -17
- package/dist/cjs/execute.js +58 -31
- package/dist/cjs/globals.js +4 -1
- package/dist/cjs/graph.js +372 -0
- package/dist/cjs/helpers.js +6 -2
- package/dist/cjs/layout.js +18 -259
- package/dist/cjs/objects/ClassComponent.js +27 -20
- package/dist/cjs/objects/ExecutionScope.js +7 -2
- package/dist/cjs/objects/Net.js +1 -1
- package/dist/cjs/objects/PinDefinition.js +55 -3
- package/dist/cjs/objects/types.js +42 -6
- package/dist/cjs/visitor.js +88 -48
- package/dist/esm/BaseVisitor.js +98 -35
- package/dist/esm/antlr/CircuitScriptLexer.js +3 -3
- package/dist/esm/antlr/CircuitScriptParser.js +864 -755
- package/dist/esm/antlr/CircuitScriptVisitor.js +2 -0
- package/dist/esm/builtinMethods.js +11 -1
- package/dist/esm/draw_symbols.js +18 -17
- package/dist/esm/execute.js +60 -33
- package/dist/esm/globals.js +3 -0
- package/dist/esm/graph.js +344 -0
- package/dist/esm/helpers.js +6 -2
- package/dist/esm/layout.js +14 -235
- package/dist/esm/objects/ClassComponent.js +28 -21
- package/dist/esm/objects/ExecutionScope.js +7 -2
- package/dist/esm/objects/Net.js +1 -1
- package/dist/esm/objects/PinDefinition.js +53 -2
- package/dist/esm/objects/types.js +42 -6
- package/dist/esm/visitor.js +90 -50
- package/dist/libs/std.cst +3 -2
- package/dist/types/BaseVisitor.d.ts +5 -2
- package/dist/types/antlr/CircuitScriptParser.d.ts +42 -26
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +4 -0
- package/dist/types/draw_symbols.d.ts +13 -7
- package/dist/types/execute.d.ts +12 -12
- package/dist/types/globals.d.ts +4 -1
- package/dist/types/graph.d.ts +29 -0
- package/dist/types/layout.d.ts +4 -9
- package/dist/types/objects/ClassComponent.d.ts +8 -8
- package/dist/types/objects/ExecutionScope.d.ts +8 -7
- package/dist/types/objects/Net.d.ts +2 -2
- package/dist/types/objects/PinDefinition.d.ts +17 -2
- package/dist/types/objects/types.d.ts +31 -7
- package/libs/std.cst +3 -2
- package/package.json +2 -1
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.linkBuiltInMethods = exports.buildInMethodNamesList = void 0;
|
|
7
7
|
const big_js_1 = __importDefault(require("big.js"));
|
|
8
8
|
const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
|
|
9
|
+
const types_js_1 = require("./objects/types.js");
|
|
9
10
|
const utils_js_1 = require("./utils.js");
|
|
10
11
|
const builtInMethods = [
|
|
11
12
|
['enumerate', enumerate],
|
|
@@ -151,8 +152,17 @@ function toString(obj) {
|
|
|
151
152
|
else if (obj instanceof ParamDefinition_js_1.NumericValue) {
|
|
152
153
|
return obj.toBigNumber().toString();
|
|
153
154
|
}
|
|
155
|
+
else if (obj instanceof types_js_1.CFunctionEntry) {
|
|
156
|
+
return obj.toString();
|
|
157
|
+
}
|
|
154
158
|
else {
|
|
155
|
-
if (obj
|
|
159
|
+
if (obj === undefined) {
|
|
160
|
+
return 'undefined';
|
|
161
|
+
}
|
|
162
|
+
else if (obj === null) {
|
|
163
|
+
return 'null';
|
|
164
|
+
}
|
|
165
|
+
else if (obj.toDisplayString) {
|
|
156
166
|
return obj.toDisplayString();
|
|
157
167
|
}
|
|
158
168
|
else if (obj.toString) {
|
package/dist/cjs/draw_symbols.js
CHANGED
|
@@ -8,6 +8,7 @@ const PinTypes_js_1 = require("./objects/PinTypes.js");
|
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
9
|
const types_js_1 = require("./objects/types.js");
|
|
10
10
|
const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
|
|
11
|
+
const PinDefinition_js_1 = require("./objects/PinDefinition.js");
|
|
11
12
|
class SymbolGraphic {
|
|
12
13
|
constructor() {
|
|
13
14
|
this.drawPortsName = true;
|
|
@@ -563,6 +564,12 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
563
564
|
(0, helpers_js_1.milsToMM)(endY)
|
|
564
565
|
];
|
|
565
566
|
}
|
|
567
|
+
if (positionParams[0] instanceof ParamDefinition_js_1.NumericValue) {
|
|
568
|
+
positionParams[0] = new PinDefinition_js_1.PinId(positionParams[0].toNumber());
|
|
569
|
+
}
|
|
570
|
+
else if (typeof positionParams[0] === 'number' || typeof positionParams[0] === 'string') {
|
|
571
|
+
positionParams[0] = new PinDefinition_js_1.PinId(positionParams[0]);
|
|
572
|
+
}
|
|
566
573
|
drawing.addPinMM(...positionParams, lineColor);
|
|
567
574
|
const lastAddedPin = this.drawing.pins[this.drawing.pins.length - 1];
|
|
568
575
|
const [pinId, , angle] = lastAddedPin;
|
|
@@ -607,7 +614,8 @@ class SymbolPlaceholder extends SymbolGraphic {
|
|
|
607
614
|
vanchor: geometry_js_1.VerticalAlign.Middle,
|
|
608
615
|
textColor: pinNameColor,
|
|
609
616
|
});
|
|
610
|
-
|
|
617
|
+
const pinDisplayText = pinId.toString();
|
|
618
|
+
displayPinId && drawing.addLabel(endX.add(pinIdOffsetX), endY.add(pinIdOffsetY), pinDisplayText, {
|
|
611
619
|
fontSize: (0, ParamDefinition_js_1.numeric)(globals_js_1.defaultPinIdTextSize),
|
|
612
620
|
anchor: pinIdAlignment,
|
|
613
621
|
vanchor: pinIdVAlignment,
|
|
@@ -707,7 +715,7 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
707
715
|
leftPins.forEach(pin => {
|
|
708
716
|
const position = pin.position;
|
|
709
717
|
const pinY = pinStartY.add((position + 1) * tmpPinSpacing);
|
|
710
|
-
drawing.addPinMM(
|
|
718
|
+
drawing.addPinMM(pin.pinId, leftPinStart.sub(this.pinLength), pinY, leftPinStart, pinY, defaultLineColor);
|
|
711
719
|
drawing.addLabel(leftPinStart.add((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
|
|
712
720
|
fontSize: (0, ParamDefinition_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
|
|
713
721
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
@@ -724,7 +732,7 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
724
732
|
rightPins.forEach(pin => {
|
|
725
733
|
const position = pin.position;
|
|
726
734
|
const pinY = pinStartY.add((position + 1) * tmpPinSpacing);
|
|
727
|
-
drawing.addPinMM(
|
|
735
|
+
drawing.addPinMM(pin.pinId, rightPinStart.add(this.pinLength), pinY, rightPinStart, pinY, defaultLineColor);
|
|
728
736
|
drawing.addLabel(rightPinStart.sub((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
|
|
729
737
|
fontSize: (0, ParamDefinition_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
|
|
730
738
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
@@ -741,7 +749,7 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
741
749
|
topPins.forEach(pin => {
|
|
742
750
|
const position = pin.position;
|
|
743
751
|
const pinX = pinStartX.add((position + 1) * tmpPinSpacing);
|
|
744
|
-
drawing.addPinMM(
|
|
752
|
+
drawing.addPinMM(pin.pinId, pinX, topPinStart.sub(this.pinLength), pinX, topPinStart, defaultLineColor);
|
|
745
753
|
drawing.addLabel(pinX, topPinStart.add((0, helpers_js_1.milsToMM)(20)), pin.text, {
|
|
746
754
|
fontSize: (0, ParamDefinition_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
|
|
747
755
|
anchor: geometry_js_1.HorizontalAlign.Right,
|
|
@@ -760,7 +768,7 @@ class SymbolCustom extends SymbolGraphic {
|
|
|
760
768
|
bottomPins.forEach(pin => {
|
|
761
769
|
const position = pin.position;
|
|
762
770
|
const pinX = pinStartX.add((position + 1) * tmpPinSpacing);
|
|
763
|
-
drawing.addPinMM(
|
|
771
|
+
drawing.addPinMM(pin.pinId, pinX, bottomPinStart.add(this.pinLength), pinX, bottomPinStart, defaultLineColor);
|
|
764
772
|
drawing.addLabel(pinX, bottomPinStart.sub((0, helpers_js_1.milsToMM)(20)), pin.text, {
|
|
765
773
|
fontSize: (0, ParamDefinition_js_1.numeric)(globals_js_1.CustomSymbolPinTextSize),
|
|
766
774
|
anchor: geometry_js_1.HorizontalAlign.Left,
|
|
@@ -846,7 +854,7 @@ class SymbolCustomModule extends SymbolCustom {
|
|
|
846
854
|
leftPins.forEach(pin => {
|
|
847
855
|
const position = pin.position;
|
|
848
856
|
const pinY = pinStartY.add((position + 1) * tmpPinSpacing);
|
|
849
|
-
drawing.addPinMM(
|
|
857
|
+
drawing.addPinMM(pin.pinId, leftPinStart.sub(this.pinLength), pinY, leftPinStart, pinY, defaultLineColor);
|
|
850
858
|
drawing.addModulePort(leftPinStart, pinY, this.portWidth, this.portHeight, pin.pinType);
|
|
851
859
|
drawing.addLabel(leftPinStart.add(this.portWidth).add((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
|
|
852
860
|
fontSize: (0, ParamDefinition_js_1.numeric)(40),
|
|
@@ -858,7 +866,7 @@ class SymbolCustomModule extends SymbolCustom {
|
|
|
858
866
|
rightPins.forEach(pin => {
|
|
859
867
|
const position = pin.position;
|
|
860
868
|
const pinY = pinStartY.add((position + 1) * tmpPinSpacing);
|
|
861
|
-
drawing.addPinMM(
|
|
869
|
+
drawing.addPinMM(pin.pinId, rightPinStart.add(this.pinLength), pinY, rightPinStart, pinY, defaultLineColor);
|
|
862
870
|
drawing.addModulePort(rightPinStart, pinY, this.portWidth, this.portHeight, pin.pinType, -1);
|
|
863
871
|
drawing.addLabel(rightPinStart.sub(this.portWidth).sub((0, helpers_js_1.milsToMM)(20)), pinY, pin.text, {
|
|
864
872
|
fontSize: (0, ParamDefinition_js_1.numeric)(40),
|
|
@@ -870,7 +878,7 @@ class SymbolCustomModule extends SymbolCustom {
|
|
|
870
878
|
topPins.forEach(pin => {
|
|
871
879
|
const position = pin.position;
|
|
872
880
|
const pinX = pinStartX.add((position + 1) * tmpPinSpacing);
|
|
873
|
-
drawing.addPinMM(
|
|
881
|
+
drawing.addPinMM(pin.pinId, pinX, topPinStart.sub(this.pinLength), pinX, topPinStart, defaultLineColor);
|
|
874
882
|
drawing.addModulePort(pinX, topPinStart, this.portWidth, this.portHeight, pin.pinType, 1, 90);
|
|
875
883
|
drawing.addLabel(pinX, topPinStart.add(this.portWidth).add((0, helpers_js_1.milsToMM)(20)), pin.text, {
|
|
876
884
|
fontSize: (0, ParamDefinition_js_1.numeric)(40),
|
|
@@ -883,7 +891,7 @@ class SymbolCustomModule extends SymbolCustom {
|
|
|
883
891
|
bottomPins.forEach(pin => {
|
|
884
892
|
const position = pin.position;
|
|
885
893
|
const pinX = pinStartX.add((position + 1) * tmpPinSpacing);
|
|
886
|
-
drawing.addPinMM(
|
|
894
|
+
drawing.addPinMM(pin.pinId, pinX, bottomPinStart, pinX, bottomPinStart.sub(this.pinLength), defaultLineColor);
|
|
887
895
|
drawing.addModulePort(pinX, bottomPinStart, this.portWidth, this.portHeight, pin.pinType, 1, -90);
|
|
888
896
|
drawing.addLabel(pinX, bottomPinStart.sub(this.portWidth).sub((0, helpers_js_1.milsToMM)(20)), pin.text, {
|
|
889
897
|
fontSize: (0, ParamDefinition_js_1.numeric)(40),
|
|
@@ -922,13 +930,6 @@ class SymbolDrawing {
|
|
|
922
930
|
this.items.push(geometry_js_1.Geometry.segment([startX, startY], [endX, endY]));
|
|
923
931
|
return this;
|
|
924
932
|
}
|
|
925
|
-
addPin(pinId, startX, startY, endX, endY, lineColor) {
|
|
926
|
-
startX = (0, helpers_js_1.milsToMM)(startX);
|
|
927
|
-
startY = (0, helpers_js_1.milsToMM)(startY);
|
|
928
|
-
endX = (0, helpers_js_1.milsToMM)(endX);
|
|
929
|
-
endY = (0, helpers_js_1.milsToMM)(endY);
|
|
930
|
-
return this.addPinMM(pinId, startX, startY, endX, endY, lineColor);
|
|
931
|
-
}
|
|
932
933
|
addPinMM(pinId, startXMM, startYMM, endXMM, endYMM, lineColor) {
|
|
933
934
|
let angle = 0;
|
|
934
935
|
const tmpStartXMM = startXMM.toNumber();
|
|
@@ -1231,7 +1232,7 @@ class SymbolDrawing {
|
|
|
1231
1232
|
}
|
|
1232
1233
|
getPinPosition(pinId) {
|
|
1233
1234
|
const pin = this.pins.find(item => {
|
|
1234
|
-
return item[0].
|
|
1235
|
+
return item[0].equals(pinId);
|
|
1235
1236
|
});
|
|
1236
1237
|
if (pin) {
|
|
1237
1238
|
const [, feature, angle] = pin;
|
package/dist/cjs/execute.js
CHANGED
|
@@ -21,7 +21,7 @@ class ExecutionContext {
|
|
|
21
21
|
this.stopFurtherExpressions = false;
|
|
22
22
|
this.returnValue = null;
|
|
23
23
|
this.silent = false;
|
|
24
|
-
this.__functionCache =
|
|
24
|
+
this.__functionCache = new Map();
|
|
25
25
|
this.componentAngleFollowsWire = true;
|
|
26
26
|
this.warnings = [];
|
|
27
27
|
this.name = name;
|
|
@@ -146,7 +146,7 @@ class ExecutionContext {
|
|
|
146
146
|
const tmpArrangeRight = [];
|
|
147
147
|
pins.forEach((pin, index) => {
|
|
148
148
|
const useArray = (index % 2 === 0) ? tmpArrangeLeft : tmpArrangeRight;
|
|
149
|
-
useArray.push(
|
|
149
|
+
useArray.push(pin.id);
|
|
150
150
|
});
|
|
151
151
|
const arrangeProp = new Map([
|
|
152
152
|
[globals_js_1.SymbolPinSide.Left, tmpArrangeLeft],
|
|
@@ -156,11 +156,9 @@ class ExecutionContext {
|
|
|
156
156
|
}
|
|
157
157
|
if (props.arrange !== null) {
|
|
158
158
|
component.arrangeProps = this.removeArrangePropDuplicates(props.arrange);
|
|
159
|
-
const arrangePropPins = this.getArrangePropPins(component.arrangeProps)
|
|
160
|
-
return item.toNumber();
|
|
161
|
-
});
|
|
159
|
+
const arrangePropPins = this.getArrangePropPins(component.arrangeProps);
|
|
162
160
|
pins.forEach(pin => {
|
|
163
|
-
if (arrangePropPins.
|
|
161
|
+
if (arrangePropPins.find(id => id.equals(pin.id)) === undefined) {
|
|
164
162
|
this.logWarning(`Pin ${pin.id} is not specified in arrange property`);
|
|
165
163
|
}
|
|
166
164
|
});
|
|
@@ -177,6 +175,7 @@ class ExecutionContext {
|
|
|
177
175
|
});
|
|
178
176
|
if (component.typeProp === globals_js_1.ComponentTypes.net) {
|
|
179
177
|
const netName = paramsMap.get(globals_js_1.ParamKeys.net_name);
|
|
178
|
+
const netType = paramsMap.get(globals_js_1.ParamKeys.net_type);
|
|
180
179
|
let priority = 0;
|
|
181
180
|
if (paramsMap.has(globals_js_1.ParamKeys.priority)) {
|
|
182
181
|
priority = paramsMap.get(globals_js_1.ParamKeys.priority).toNumber();
|
|
@@ -188,21 +187,26 @@ class ExecutionContext {
|
|
|
188
187
|
this.log('net found', tmpNet.namespace, tmpNet.name);
|
|
189
188
|
}
|
|
190
189
|
else {
|
|
191
|
-
tmpNet = new Net_js_1.Net(this.netNamespace, netName, priority);
|
|
190
|
+
tmpNet = new Net_js_1.Net(this.netNamespace, netName, priority, netType);
|
|
192
191
|
this.log('net not found, added net instance', tmpNet.namespace, tmpNet.name);
|
|
193
192
|
}
|
|
194
|
-
const defaultPin = 1;
|
|
193
|
+
const defaultPin = new PinDefinition_js_1.PinId(1);
|
|
195
194
|
this.scope.setNet(component, defaultPin, tmpNet);
|
|
196
195
|
this.log('set net', netName, 'component', component, defaultPin);
|
|
197
196
|
}
|
|
198
197
|
const { pins: pinSides, maxPositions } = getPortSide(component.pins, component.arrangeProps);
|
|
199
198
|
component.pinsMaxPositions = maxPositions;
|
|
199
|
+
const pinIdKeys = Array.from(component.pins.keys());
|
|
200
200
|
pinSides.forEach(({ pinId, side, position }) => {
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
const matchedPinId = pinIdKeys.find(id => id.equals(pinId));
|
|
202
|
+
if (matchedPinId) {
|
|
203
|
+
const tmpPin = component.pins.get(matchedPinId);
|
|
203
204
|
tmpPin.side = side;
|
|
204
205
|
tmpPin.position = position;
|
|
205
206
|
}
|
|
207
|
+
else {
|
|
208
|
+
throw 'Not found!';
|
|
209
|
+
}
|
|
206
210
|
});
|
|
207
211
|
this.scope.instances.set(instanceName, component);
|
|
208
212
|
const pinsOutput = pins.map((pin) => {
|
|
@@ -225,15 +229,32 @@ class ExecutionContext {
|
|
|
225
229
|
if (!Array.isArray(items)) {
|
|
226
230
|
items = [items];
|
|
227
231
|
}
|
|
232
|
+
items = items.map(item => {
|
|
233
|
+
if (item instanceof ParamDefinition_js_1.NumericValue) {
|
|
234
|
+
item = item.toNumber();
|
|
235
|
+
}
|
|
236
|
+
if (item instanceof PinDefinition_js_1.PinId) {
|
|
237
|
+
return item;
|
|
238
|
+
}
|
|
239
|
+
else if (PinDefinition_js_1.PinId.isPinIdType(item)) {
|
|
240
|
+
return new PinDefinition_js_1.PinId(item);
|
|
241
|
+
}
|
|
242
|
+
return item;
|
|
243
|
+
});
|
|
244
|
+
arrangeProp.set(side, items);
|
|
245
|
+
if (!Array.isArray(items)) {
|
|
246
|
+
items = [items];
|
|
247
|
+
}
|
|
228
248
|
const uniqueItems = [];
|
|
229
249
|
items.forEach(item => {
|
|
230
|
-
if (item instanceof
|
|
231
|
-
|
|
232
|
-
|
|
250
|
+
if (item instanceof PinDefinition_js_1.PinId) {
|
|
251
|
+
const found = seenIds.find(id => id.equals(item));
|
|
252
|
+
if (!found) {
|
|
253
|
+
seenIds.push(item);
|
|
233
254
|
uniqueItems.push(item);
|
|
234
255
|
}
|
|
235
256
|
else {
|
|
236
|
-
this.logWarning(`Pin ${item.
|
|
257
|
+
this.logWarning(`Pin ${item.toString()} specified more than once in arrange property`);
|
|
237
258
|
}
|
|
238
259
|
}
|
|
239
260
|
else {
|
|
@@ -256,7 +277,7 @@ class ExecutionContext {
|
|
|
256
277
|
const items = arrangeProps.get(side);
|
|
257
278
|
if (items) {
|
|
258
279
|
items.forEach(item => {
|
|
259
|
-
if (item instanceof
|
|
280
|
+
if (item instanceof PinDefinition_js_1.PinId) {
|
|
260
281
|
pins.push(item);
|
|
261
282
|
}
|
|
262
283
|
});
|
|
@@ -378,7 +399,7 @@ class ExecutionContext {
|
|
|
378
399
|
const cloneInstanceName = component.instanceName + ':' + idNum;
|
|
379
400
|
this.scope.instances.set(cloneInstanceName, componentCopy);
|
|
380
401
|
componentCopy.instanceName = cloneInstanceName;
|
|
381
|
-
const defaultPin = 1;
|
|
402
|
+
const defaultPin = new PinDefinition_js_1.PinId(1);
|
|
382
403
|
if (this.scope.getNet(component, defaultPin) === null) {
|
|
383
404
|
const foundNet = this.resolveComponentPinNet(component, defaultPin);
|
|
384
405
|
if (foundNet !== null) {
|
|
@@ -533,9 +554,9 @@ class ExecutionContext {
|
|
|
533
554
|
getBreakContext() {
|
|
534
555
|
return this.scope.breakStack[this.scope.breakStack.length - 1];
|
|
535
556
|
}
|
|
536
|
-
createFunction(functionName, __runFunc) {
|
|
537
|
-
this.scope.functions.set(functionName, __runFunc);
|
|
538
|
-
this.__functionCache
|
|
557
|
+
createFunction(functionName, __runFunc, source, uniqueId) {
|
|
558
|
+
this.scope.functions.set(functionName, new types_js_1.CFunctionEntry(functionName, __runFunc, source, uniqueId));
|
|
559
|
+
this.__functionCache.set(functionName, __runFunc);
|
|
539
560
|
this.log(`defined new function '${functionName}'`);
|
|
540
561
|
}
|
|
541
562
|
hasFunction(functionName) {
|
|
@@ -597,19 +618,24 @@ class ExecutionContext {
|
|
|
597
618
|
else if (type === globals_js_1.ReferenceTypes.instance) {
|
|
598
619
|
const tmpComponent = parentValue;
|
|
599
620
|
if (tmpComponent.typeProp === globals_js_1.ComponentTypes.net) {
|
|
600
|
-
const usedNet = this.scope.getNet(tmpComponent, 1);
|
|
621
|
+
const usedNet = this.scope.getNet(tmpComponent, new PinDefinition_js_1.PinId(1));
|
|
601
622
|
if (usedNet) {
|
|
602
623
|
const trailerValue = trailers.join(".");
|
|
603
624
|
useValue = usedNet.params.get(trailerValue) ?? null;
|
|
604
625
|
}
|
|
605
626
|
}
|
|
606
627
|
else {
|
|
607
|
-
useValue = parentValue
|
|
628
|
+
useValue = parentValue
|
|
629
|
+
.parameters.get(trailersPath);
|
|
608
630
|
}
|
|
609
631
|
}
|
|
610
632
|
}
|
|
633
|
+
let found = false;
|
|
634
|
+
if (parentValue !== undefined && useValue !== undefined) {
|
|
635
|
+
found = true;
|
|
636
|
+
}
|
|
611
637
|
return new types_js_1.AnyReference({
|
|
612
|
-
found
|
|
638
|
+
found,
|
|
613
639
|
type: type,
|
|
614
640
|
parentValue,
|
|
615
641
|
trailers,
|
|
@@ -618,26 +644,28 @@ class ExecutionContext {
|
|
|
618
644
|
}
|
|
619
645
|
callFunction(functionName, functionParams, executionStack, netNamespace) {
|
|
620
646
|
let __runFunc = null;
|
|
621
|
-
if (this.__functionCache
|
|
647
|
+
if (!this.__functionCache.has(functionName)) {
|
|
622
648
|
if (this.hasFunction(functionName)) {
|
|
623
|
-
|
|
649
|
+
const entry = this.getFunction(functionName);
|
|
650
|
+
__runFunc = entry.execute;
|
|
624
651
|
}
|
|
625
652
|
if (__runFunc === null) {
|
|
626
653
|
this.log(`searching for function ${functionName} in upper context`);
|
|
627
654
|
const tmpResolveResult = this.resolveVariable(executionStack, functionName);
|
|
628
655
|
if (tmpResolveResult.found) {
|
|
629
|
-
|
|
656
|
+
const entry = tmpResolveResult.value;
|
|
657
|
+
__runFunc = entry.execute;
|
|
630
658
|
}
|
|
631
659
|
else {
|
|
632
660
|
throw `Invalid function ${functionName}`;
|
|
633
661
|
}
|
|
634
662
|
}
|
|
635
663
|
this.log('save function to cache:', functionName);
|
|
636
|
-
this.__functionCache
|
|
664
|
+
this.__functionCache.set(functionName, __runFunc);
|
|
637
665
|
}
|
|
638
666
|
else {
|
|
639
667
|
this.log('found function in cache:', functionName);
|
|
640
|
-
__runFunc = this.__functionCache
|
|
668
|
+
__runFunc = this.__functionCache.get(functionName);
|
|
641
669
|
}
|
|
642
670
|
if (__runFunc !== null) {
|
|
643
671
|
this.log(`call function '${functionName}'`);
|
|
@@ -684,7 +712,7 @@ class ExecutionContext {
|
|
|
684
712
|
const linkRootComponent = true;
|
|
685
713
|
const tmpRoot = childScope.componentRoot;
|
|
686
714
|
if (linkRootComponent) {
|
|
687
|
-
const netConnectedToRoot = childScope.getNet(tmpRoot, 1);
|
|
715
|
+
const netConnectedToRoot = childScope.getNet(tmpRoot, new PinDefinition_js_1.PinId(1));
|
|
688
716
|
if (netConnectedToRoot !== null) {
|
|
689
717
|
let currentNet = this.scope.getNet(currentComponent, currentPin);
|
|
690
718
|
if (currentNet === null) {
|
|
@@ -1032,10 +1060,9 @@ function getPortSide(pins, arrangeProps) {
|
|
|
1032
1060
|
position += item[0].toNumber();
|
|
1033
1061
|
}
|
|
1034
1062
|
else {
|
|
1035
|
-
|
|
1036
|
-
if (existingPinIds.indexOf(itemValue) !== -1) {
|
|
1063
|
+
if (existingPinIds.find(id => id.equals(item))) {
|
|
1037
1064
|
result.push({
|
|
1038
|
-
pinId:
|
|
1065
|
+
pinId: item,
|
|
1039
1066
|
side: useSide,
|
|
1040
1067
|
position,
|
|
1041
1068
|
order: counter
|
package/dist/cjs/globals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SymbolValidatorContext = exports.RenderFlags = exports.GlobalDocumentName = exports.ModuleContainsKeyword = exports.FrameType = exports.NetGraphicsParams = exports.BlockTypes = exports.ReferenceTypes = exports.ComponentTypes = exports.ColorScheme = exports.PortPaddingVertical = exports.PortPaddingHorizontal = exports.PortArrowSize = exports.junctionSize = exports.defaultFontSize = exports.defaultFontBold = exports.defaultFont = exports.displayUnits = exports.defaultFrameTitleTextSize = exports.CustomSymbolParamTextSize = exports.CustomSymbolRefDesSize = exports.CustomSymbolPinIdSize = exports.CustomSymbolPinTextSize = exports.defaultPageSpacingMM = exports.defaultPageMarginMM = exports.defaultPinIdTextSize = exports.defaultPinNameTextSize = exports.defaultWireLineWidth = exports.defaultSymbolLineWidth = exports.fontDisplayScale = exports.defaultZoomScale = exports.defaultGridSizeUnits = exports.portHeight = exports.portWidth = exports.PxToMM = exports.MMToPt = exports.MMToPx = exports.MilsToMM = exports.WireAutoDirection = exports.LengthUnit = exports.ValidPinSides = exports.SymbolPinSide = exports.LayoutDirection = exports.ParamKeys = exports.NoNetText = exports.GlobalNames = exports.DoubleDelimiter1 = exports.Delimiter1 = exports.TOOL_VERSION = void 0;
|
|
3
|
+
exports.TrailerArrayIndex = exports.SymbolValidatorContext = exports.RenderFlags = exports.GlobalDocumentName = exports.ModuleContainsKeyword = exports.FrameType = exports.NetGraphicsParams = exports.BlockTypes = exports.ReferenceTypes = exports.ComponentTypes = exports.ColorScheme = exports.PortPaddingVertical = exports.PortPaddingHorizontal = exports.PortArrowSize = exports.junctionSize = exports.defaultFontSize = exports.defaultFontBold = exports.defaultFont = exports.displayUnits = exports.defaultFrameTitleTextSize = exports.CustomSymbolParamTextSize = exports.CustomSymbolRefDesSize = exports.CustomSymbolPinIdSize = exports.CustomSymbolPinTextSize = exports.defaultPageSpacingMM = exports.defaultPageMarginMM = exports.defaultPinIdTextSize = exports.defaultPinNameTextSize = exports.defaultWireLineWidth = exports.defaultSymbolLineWidth = exports.fontDisplayScale = exports.defaultZoomScale = exports.defaultGridSizeUnits = exports.portHeight = exports.portWidth = exports.PxToMM = exports.MMToPt = exports.MMToPx = exports.MilsToMM = exports.WireAutoDirection = exports.LengthUnit = exports.ValidPinSides = exports.SymbolPinSide = exports.LayoutDirection = exports.ParamKeys = exports.NoNetText = exports.GlobalNames = exports.DoubleDelimiter1 = exports.Delimiter1 = exports.TOOL_VERSION = void 0;
|
|
4
4
|
const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
|
|
5
5
|
exports.TOOL_VERSION = '0.1.5';
|
|
6
6
|
exports.Delimiter1 = '-';
|
|
@@ -15,6 +15,7 @@ var ParamKeys;
|
|
|
15
15
|
(function (ParamKeys) {
|
|
16
16
|
ParamKeys["priority"] = "priority";
|
|
17
17
|
ParamKeys["net_name"] = "net_name";
|
|
18
|
+
ParamKeys["net_type"] = "net_type";
|
|
18
19
|
ParamKeys["flip"] = "flip";
|
|
19
20
|
ParamKeys["flipX"] = "flipX";
|
|
20
21
|
ParamKeys["flipY"] = "flipY";
|
|
@@ -95,6 +96,7 @@ var ReferenceTypes;
|
|
|
95
96
|
ReferenceTypes["variable"] = "variable";
|
|
96
97
|
ReferenceTypes["instance"] = "instance";
|
|
97
98
|
ReferenceTypes["pinType"] = "pinType";
|
|
99
|
+
ReferenceTypes["unknown"] = "unknown";
|
|
98
100
|
})(ReferenceTypes || (exports.ReferenceTypes = ReferenceTypes = {}));
|
|
99
101
|
var BlockTypes;
|
|
100
102
|
(function (BlockTypes) {
|
|
@@ -126,3 +128,4 @@ exports.RenderFlags = {
|
|
|
126
128
|
ShowLabelOrigin: false,
|
|
127
129
|
};
|
|
128
130
|
exports.SymbolValidatorContext = '_sym';
|
|
131
|
+
exports.TrailerArrayIndex = 'index';
|