circuitscript 0.1.11 → 0.1.12
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 +78 -51
- package/dist/cjs/antlr/CircuitScriptParser.js +1059 -949
- package/dist/cjs/builtinMethods.js +5 -1
- package/dist/cjs/execute.js +43 -22
- package/dist/cjs/globals.js +7 -1
- package/dist/cjs/layout.js +50 -16
- package/dist/cjs/objects/ExecutionScope.js +3 -0
- package/dist/cjs/objects/Net.js +1 -0
- package/dist/cjs/objects/ParamDefinition.js +3 -0
- package/dist/cjs/objects/types.js +19 -10
- package/dist/cjs/render.js +48 -6
- package/dist/cjs/utils.js +16 -1
- package/dist/cjs/visitor.js +69 -52
- package/dist/esm/BaseVisitor.js +72 -45
- package/dist/esm/antlr/CircuitScriptParser.js +1052 -944
- package/dist/esm/antlr/CircuitScriptVisitor.js +4 -2
- package/dist/esm/builtinMethods.js +6 -2
- package/dist/esm/execute.js +43 -22
- package/dist/esm/globals.js +6 -0
- package/dist/esm/layout.js +53 -17
- package/dist/esm/objects/ExecutionScope.js +3 -0
- package/dist/esm/objects/Net.js +1 -0
- package/dist/esm/objects/ParamDefinition.js +4 -1
- package/dist/esm/objects/types.js +21 -15
- package/dist/esm/render.js +49 -7
- package/dist/esm/utils.js +13 -0
- package/dist/esm/visitor.js +57 -40
- package/dist/types/BaseVisitor.d.ts +2 -2
- package/dist/types/antlr/CircuitScriptParser.d.ts +99 -83
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +8 -4
- package/dist/types/execute.d.ts +1 -0
- package/dist/types/globals.d.ts +5 -0
- package/dist/types/layout.d.ts +16 -3
- package/dist/types/objects/ExecutionScope.d.ts +15 -3
- package/dist/types/objects/Net.d.ts +1 -0
- package/dist/types/objects/types.d.ts +25 -18
- package/dist/types/utils.d.ts +3 -1
- package/dist/types/visitor.d.ts +3 -2
- package/package.json +1 -1
- /package/dist/libs/{lib.cst → std.cst} +0 -0
- /package/libs/{lib.cst → std.cst} +0 -0
|
@@ -21,7 +21,10 @@ exports.buildInMethodNamesList = builtInMethods.map(item => item[0]);
|
|
|
21
21
|
function linkBuiltInMethods(context, visitor) {
|
|
22
22
|
context.createFunction('print', (params) => {
|
|
23
23
|
const args = getPositionParams(params);
|
|
24
|
-
const items = args.map(item =>
|
|
24
|
+
const items = args.map(item => {
|
|
25
|
+
const value = (0, utils_js_1.prepareValue)(item);
|
|
26
|
+
return toString(value);
|
|
27
|
+
});
|
|
25
28
|
if (visitor.printToConsole) {
|
|
26
29
|
console.log('::', ...items);
|
|
27
30
|
}
|
|
@@ -82,6 +85,7 @@ function toMils(value) {
|
|
|
82
85
|
return (0, utils_js_1.resolveToNumericValue)(bigValue);
|
|
83
86
|
}
|
|
84
87
|
function objectLength(obj) {
|
|
88
|
+
obj = (0, utils_js_1.prepareValue)(obj);
|
|
85
89
|
if (Array.isArray(obj)) {
|
|
86
90
|
return (0, ParamDefinition_js_1.numeric)(obj.length);
|
|
87
91
|
}
|
package/dist/cjs/execute.js
CHANGED
|
@@ -352,6 +352,10 @@ class ExecutionContext {
|
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
this.scope.setCurrent(component, usePinId);
|
|
355
|
+
if (!this.scope.hasNet(component, pinId)) {
|
|
356
|
+
const tmpNet = new Net_js_1.Net(this.netNamespace, this.getUniqueNetName());
|
|
357
|
+
this.scope.setNet(component, pinId, tmpNet);
|
|
358
|
+
}
|
|
355
359
|
this.scope.clearActive();
|
|
356
360
|
if (addSequence) {
|
|
357
361
|
this.scope.sequence.push([ExecutionScope_js_1.SequenceAction.At,
|
|
@@ -395,13 +399,14 @@ class ExecutionContext {
|
|
|
395
399
|
this.tmpPointId += 1;
|
|
396
400
|
}
|
|
397
401
|
this.scope.blockStack.set(this.scope.indentLevel, {
|
|
398
|
-
|
|
402
|
+
start_point: [
|
|
399
403
|
this.scope.currentComponent,
|
|
400
404
|
this.scope.currentPin,
|
|
401
405
|
this.scope.currentWireId
|
|
402
406
|
],
|
|
407
|
+
end_point: null,
|
|
403
408
|
inner_blocks: new Map(),
|
|
404
|
-
current_index:
|
|
409
|
+
current_index: 0,
|
|
405
410
|
type: blockType,
|
|
406
411
|
});
|
|
407
412
|
this.log('enter blocks');
|
|
@@ -410,7 +415,7 @@ class ExecutionContext {
|
|
|
410
415
|
const stackRef = this.scope.blockStack.get(this.scope.indentLevel);
|
|
411
416
|
const { type: blockType } = stackRef;
|
|
412
417
|
if (blockType === globals_js_1.BlockTypes.Join || blockType === globals_js_1.BlockTypes.Parallel) {
|
|
413
|
-
const {
|
|
418
|
+
const { end_point: finalPoint } = stackRef;
|
|
414
419
|
const [component, pin, wireId] = finalPoint;
|
|
415
420
|
this.scope.setCurrent(component, pin);
|
|
416
421
|
this.scope.currentWireId = wireId;
|
|
@@ -421,17 +426,22 @@ class ExecutionContext {
|
|
|
421
426
|
}
|
|
422
427
|
}
|
|
423
428
|
else if (blockType === globals_js_1.BlockTypes.Point) {
|
|
424
|
-
const {
|
|
429
|
+
const { start_point: [component, pin,] } = stackRef;
|
|
425
430
|
this.atComponent(component, pin, { addSequence: true });
|
|
426
431
|
}
|
|
432
|
+
this.scope.blockStack.delete(this.scope.indentLevel);
|
|
427
433
|
this.log('exit blocks');
|
|
428
434
|
}
|
|
435
|
+
closeAllBlocks() {
|
|
436
|
+
if (this.scope.blockStack.has(this.scope.indentLevel)) {
|
|
437
|
+
this.exitBlocks();
|
|
438
|
+
}
|
|
439
|
+
}
|
|
429
440
|
enterBlock(blockIndex) {
|
|
430
441
|
const stackRef = this.scope.blockStack.get(this.scope.indentLevel);
|
|
431
|
-
stackRef['block_index'] = blockIndex;
|
|
432
442
|
const { type: blockType } = stackRef;
|
|
433
443
|
const blockTypeName = (0, utils_js_1.getBlockTypeString)(blockType);
|
|
434
|
-
stackRef
|
|
444
|
+
stackRef.inner_blocks.set(blockIndex, {
|
|
435
445
|
last_net: null,
|
|
436
446
|
ignore_last_net: false,
|
|
437
447
|
});
|
|
@@ -440,7 +450,7 @@ class ExecutionContext {
|
|
|
440
450
|
this.scope.currentWireId = -1;
|
|
441
451
|
}
|
|
442
452
|
else if (blockType === globals_js_1.BlockTypes.Parallel) {
|
|
443
|
-
const {
|
|
453
|
+
const { start_point: [component, pin,] } = stackRef;
|
|
444
454
|
this.atComponent(component, pin, { addSequence: true });
|
|
445
455
|
}
|
|
446
456
|
this.log(`enter inner block of type (${blockTypeName}) >>>`);
|
|
@@ -449,17 +459,16 @@ class ExecutionContext {
|
|
|
449
459
|
exitBlock(blockIndex) {
|
|
450
460
|
const stackRef = this.scope.blockStack.get(this.scope.indentLevel - 1);
|
|
451
461
|
const { type: blockType } = stackRef;
|
|
452
|
-
const blockIndexRef = stackRef
|
|
453
|
-
blockIndexRef
|
|
462
|
+
const blockIndexRef = stackRef.inner_blocks.get(blockIndex);
|
|
463
|
+
blockIndexRef.last_net = [
|
|
454
464
|
this.scope.currentComponent,
|
|
455
465
|
this.scope.currentPin,
|
|
456
466
|
this.scope.currentWireId
|
|
457
467
|
];
|
|
458
|
-
stackRef['block_index'] = null;
|
|
459
468
|
this.scope.indentLevel -= 1;
|
|
460
469
|
this.log('exit inner block <<<');
|
|
461
470
|
if (blockType === globals_js_1.BlockTypes.Branch) {
|
|
462
|
-
const {
|
|
471
|
+
const { start_point: [component, pin, wireId] } = stackRef;
|
|
463
472
|
this.atComponent(component, pin, { addSequence: true });
|
|
464
473
|
if (wireId !== -1) {
|
|
465
474
|
this.scope.sequence.push([ExecutionScope_js_1.SequenceAction.WireJump, wireId, 1]);
|
|
@@ -470,14 +479,14 @@ class ExecutionContext {
|
|
|
470
479
|
const pointIdName = `${globals_js_1.Delimiter1}${(0, utils_js_1.getBlockTypeString)(blockType)}`;
|
|
471
480
|
this.addPoint(`${pointIdName}.${this.name}.${this.tmpPointId}`, false);
|
|
472
481
|
this.tmpPointId += 1;
|
|
473
|
-
stackRef
|
|
482
|
+
stackRef.end_point = [
|
|
474
483
|
this.scope.currentComponent,
|
|
475
484
|
this.scope.currentPin,
|
|
476
485
|
this.scope.currentWireId
|
|
477
486
|
];
|
|
478
487
|
}
|
|
479
488
|
else {
|
|
480
|
-
const {
|
|
489
|
+
const { end_point: finalPoint } = stackRef;
|
|
481
490
|
const [component, pin,] = finalPoint;
|
|
482
491
|
this.toComponent(component, pin, { addSequence: true });
|
|
483
492
|
}
|
|
@@ -499,10 +508,10 @@ class ExecutionContext {
|
|
|
499
508
|
this.log('get block point');
|
|
500
509
|
for (let i = 0; i < this.scope.indentLevel; i++) {
|
|
501
510
|
const stackRef = this.scope.blockStack.get(this.scope.indentLevel - 1 - i);
|
|
502
|
-
const {
|
|
503
|
-
const component =
|
|
511
|
+
const { start_point } = stackRef;
|
|
512
|
+
const component = start_point[0];
|
|
504
513
|
if (component.instanceName.startsWith(`${globals_js_1.Delimiter1}point.`)) {
|
|
505
|
-
return
|
|
514
|
+
return start_point;
|
|
506
515
|
}
|
|
507
516
|
}
|
|
508
517
|
this.log('did not find block point');
|
|
@@ -543,8 +552,8 @@ class ExecutionContext {
|
|
|
543
552
|
});
|
|
544
553
|
}
|
|
545
554
|
else {
|
|
546
|
-
|
|
547
|
-
|
|
555
|
+
let isVariable = context.scope.variables.has(idName);
|
|
556
|
+
let isComponentInstance = context.scope.instances.has(idName);
|
|
548
557
|
if (isVariable || isComponentInstance) {
|
|
549
558
|
const scopeList = isVariable ? context.scope.variables
|
|
550
559
|
: context.scope.instances;
|
|
@@ -553,11 +562,25 @@ class ExecutionContext {
|
|
|
553
562
|
if (trailers.length > 0) {
|
|
554
563
|
parentValue = useValue;
|
|
555
564
|
const trailersPath = trailers.join(".");
|
|
565
|
+
if (!isComponentInstance && (parentValue instanceof ClassComponent_js_1.ClassComponent)) {
|
|
566
|
+
isComponentInstance = true;
|
|
567
|
+
isVariable = false;
|
|
568
|
+
}
|
|
556
569
|
if (isVariable) {
|
|
557
570
|
useValue = parentValue[trailersPath];
|
|
558
571
|
}
|
|
559
572
|
else if (isComponentInstance) {
|
|
560
|
-
|
|
573
|
+
const tmpComponent = parentValue;
|
|
574
|
+
if (tmpComponent.typeProp === globals_js_1.ComponentTypes.net) {
|
|
575
|
+
const usedNet = this.scope.getNet(tmpComponent, 1);
|
|
576
|
+
if (usedNet) {
|
|
577
|
+
const trailerValue = trailers.join(".");
|
|
578
|
+
useValue = usedNet.params.get(trailerValue) ?? null;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
useValue = parentValue.parameters.get(trailersPath);
|
|
583
|
+
}
|
|
561
584
|
}
|
|
562
585
|
}
|
|
563
586
|
return new types_js_1.DeclaredReference({
|
|
@@ -613,9 +636,7 @@ class ExecutionContext {
|
|
|
613
636
|
}
|
|
614
637
|
mergeScope(childScope, namespace) {
|
|
615
638
|
this.log('-- merging scope to parent --');
|
|
616
|
-
const currentComponent = this.scope
|
|
617
|
-
const currentPin = this.scope.currentPin;
|
|
618
|
-
const currentWireId = this.scope.currentWireId;
|
|
639
|
+
const { currentComponent, currentPin, currentWireId } = this.scope;
|
|
619
640
|
const tmpInstances = childScope.instances;
|
|
620
641
|
const tmpNets = childScope.getNets();
|
|
621
642
|
for (const [instanceName, component] of tmpInstances) {
|
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.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.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 = '-';
|
|
@@ -103,6 +103,12 @@ var BlockTypes;
|
|
|
103
103
|
BlockTypes[BlockTypes["Parallel"] = 3] = "Parallel";
|
|
104
104
|
BlockTypes[BlockTypes["Point"] = 4] = "Point";
|
|
105
105
|
})(BlockTypes || (exports.BlockTypes = BlockTypes = {}));
|
|
106
|
+
var NetGraphicsParams;
|
|
107
|
+
(function (NetGraphicsParams) {
|
|
108
|
+
NetGraphicsParams["Color"] = "color";
|
|
109
|
+
NetGraphicsParams["Highight"] = "highlight";
|
|
110
|
+
NetGraphicsParams["LineWidth"] = "lineWidth";
|
|
111
|
+
})(NetGraphicsParams || (exports.NetGraphicsParams = NetGraphicsParams = {}));
|
|
106
112
|
var FrameType;
|
|
107
113
|
(function (FrameType) {
|
|
108
114
|
FrameType[FrameType["Frame"] = 1] = "Frame";
|
package/dist/cjs/layout.js
CHANGED
|
@@ -56,6 +56,7 @@ class LayoutEngine {
|
|
|
56
56
|
}
|
|
57
57
|
runLayout(sequence, nets) {
|
|
58
58
|
const logNodesAndEdges = true;
|
|
59
|
+
const renderNets = this.collectRenderNets(nets);
|
|
59
60
|
this.print('===== creating graph and populating with nodes =====');
|
|
60
61
|
const { graph, containerFrames } = this.generateLayoutGraph(sequence, nets);
|
|
61
62
|
this.print('===== done populating graph =====');
|
|
@@ -108,7 +109,7 @@ class LayoutEngine {
|
|
|
108
109
|
}
|
|
109
110
|
wireGroups.get(netName).push(wire);
|
|
110
111
|
});
|
|
111
|
-
const { junctions, mergedWires } = this.findJunctions(wireGroups);
|
|
112
|
+
const { junctions, mergedWires } = this.findJunctions(wireGroups, renderNets);
|
|
112
113
|
return {
|
|
113
114
|
frame: sheet,
|
|
114
115
|
frames,
|
|
@@ -116,11 +117,33 @@ class LayoutEngine {
|
|
|
116
117
|
wires,
|
|
117
118
|
textObjects,
|
|
118
119
|
junctions,
|
|
119
|
-
mergedWires
|
|
120
|
+
mergedWires
|
|
120
121
|
};
|
|
121
122
|
});
|
|
122
123
|
return sheetFrameObjects;
|
|
123
124
|
}
|
|
125
|
+
collectRenderNets(nets) {
|
|
126
|
+
const renderNets = new Map();
|
|
127
|
+
const uniqueNets = new Set(nets.map(([, , net]) => net));
|
|
128
|
+
uniqueNets.forEach(net => {
|
|
129
|
+
const renderNet = {
|
|
130
|
+
netName: net.toString(),
|
|
131
|
+
net,
|
|
132
|
+
};
|
|
133
|
+
if (net.params.has(globals_js_1.NetGraphicsParams.Color)) {
|
|
134
|
+
renderNet.color = net.params.get(globals_js_1.NetGraphicsParams.Color);
|
|
135
|
+
}
|
|
136
|
+
if (net.params.has(globals_js_1.NetGraphicsParams.LineWidth)) {
|
|
137
|
+
const value = net.params.get(globals_js_1.NetGraphicsParams.LineWidth);
|
|
138
|
+
renderNet.lineWidth = (0, helpers_js_1.milsToMM)(value).toNumber();
|
|
139
|
+
}
|
|
140
|
+
if (net.params.has(globals_js_1.NetGraphicsParams.Highight)) {
|
|
141
|
+
renderNet.highlight = net.params.get(globals_js_1.NetGraphicsParams.Highight);
|
|
142
|
+
}
|
|
143
|
+
renderNets.set(net.toString(), renderNet);
|
|
144
|
+
});
|
|
145
|
+
return renderNets;
|
|
146
|
+
}
|
|
124
147
|
flattenFrameItems(frame) {
|
|
125
148
|
const items = [];
|
|
126
149
|
frame.innerItems.forEach(item => {
|
|
@@ -132,11 +155,11 @@ class LayoutEngine {
|
|
|
132
155
|
});
|
|
133
156
|
return items;
|
|
134
157
|
}
|
|
135
|
-
findJunctions(wireGroups) {
|
|
158
|
+
findJunctions(wireGroups, nets) {
|
|
136
159
|
const junctions = [];
|
|
137
160
|
const mergedWires = [];
|
|
138
161
|
const debugSegments = false;
|
|
139
|
-
for (const [
|
|
162
|
+
for (const [netName, wires] of wireGroups) {
|
|
140
163
|
const allLines = wires.map(wire => {
|
|
141
164
|
return wire.points.map(pt => {
|
|
142
165
|
return {
|
|
@@ -145,6 +168,10 @@ class LayoutEngine {
|
|
|
145
168
|
};
|
|
146
169
|
});
|
|
147
170
|
});
|
|
171
|
+
let renderNet = null;
|
|
172
|
+
if (nets.has(netName)) {
|
|
173
|
+
renderNet = nets.get(netName);
|
|
174
|
+
}
|
|
148
175
|
if (debugSegments) {
|
|
149
176
|
const tmpSegments = [];
|
|
150
177
|
allLines.forEach(wire => {
|
|
@@ -158,20 +185,22 @@ class LayoutEngine {
|
|
|
158
185
|
}
|
|
159
186
|
});
|
|
160
187
|
mergedWires.push({
|
|
161
|
-
netName:
|
|
188
|
+
netName: netName,
|
|
162
189
|
segments: tmpSegments,
|
|
163
190
|
intersectPoints: [],
|
|
191
|
+
net: renderNet,
|
|
164
192
|
});
|
|
165
193
|
}
|
|
166
194
|
else {
|
|
167
195
|
const { intersectPoints, segments } = geometry_js_1.Geometry.mergeWires(allLines);
|
|
168
196
|
mergedWires.push({
|
|
169
|
-
netName:
|
|
197
|
+
netName: netName,
|
|
170
198
|
segments,
|
|
171
199
|
intersectPoints,
|
|
200
|
+
net: renderNet,
|
|
172
201
|
});
|
|
173
202
|
intersectPoints.forEach(([x, y]) => {
|
|
174
|
-
junctions.push(new RenderJunction((0, ParamDefinition_js_1.numeric)(x), (0, ParamDefinition_js_1.numeric)(y)));
|
|
203
|
+
junctions.push(new RenderJunction((0, ParamDefinition_js_1.numeric)(x), (0, ParamDefinition_js_1.numeric)(y), renderNet));
|
|
175
204
|
});
|
|
176
205
|
}
|
|
177
206
|
}
|
|
@@ -682,22 +711,25 @@ class LayoutEngine {
|
|
|
682
711
|
}
|
|
683
712
|
case ExecutionScope_js_1.SequenceAction.Wire: {
|
|
684
713
|
const [, wireId, wireSegments] = sequenceStep;
|
|
685
|
-
|
|
686
|
-
wire.id = wireId;
|
|
687
|
-
let useNetName = null;
|
|
714
|
+
let useNet;
|
|
688
715
|
if (previousNode !== null) {
|
|
689
716
|
const [prevNodeType, prevNodeItem] = graph.node(previousNode);
|
|
690
717
|
if (prevNodeType === RenderItemType.Component) {
|
|
691
718
|
const matchingItem = nets.find(([comp, pin]) => {
|
|
692
|
-
return comp.instanceName === previousNode
|
|
719
|
+
return comp.instanceName === previousNode
|
|
720
|
+
&& pin === previousPin;
|
|
693
721
|
});
|
|
694
|
-
|
|
722
|
+
if (matchingItem !== undefined) {
|
|
723
|
+
useNet = matchingItem[2];
|
|
724
|
+
}
|
|
695
725
|
}
|
|
696
726
|
else if (prevNodeType === RenderItemType.Wire) {
|
|
697
|
-
|
|
727
|
+
useNet = prevNodeItem.net;
|
|
698
728
|
}
|
|
699
729
|
}
|
|
700
|
-
wire
|
|
730
|
+
const wire = new RenderWire(useNet, (0, ParamDefinition_js_1.numeric)(0), (0, ParamDefinition_js_1.numeric)(0), wireSegments);
|
|
731
|
+
wire.id = wireId;
|
|
732
|
+
wire.netName = useNet.toString();
|
|
701
733
|
const wireName = getWireName(wire.id);
|
|
702
734
|
graph.setNode(wireName, [RenderItemType.Wire, wire, index]);
|
|
703
735
|
this.setGraphEdge(graph, previousNode, wireName, makeEdgeValue(previousNode, previousPin, wireName, 0, index));
|
|
@@ -1215,10 +1247,11 @@ class RenderObject {
|
|
|
1215
1247
|
}
|
|
1216
1248
|
exports.RenderObject = RenderObject;
|
|
1217
1249
|
class RenderWire extends RenderObject {
|
|
1218
|
-
constructor(x, y, segments) {
|
|
1250
|
+
constructor(net, x, y, segments) {
|
|
1219
1251
|
super();
|
|
1220
1252
|
this.segments = [];
|
|
1221
1253
|
this.points = [];
|
|
1254
|
+
this.net = net;
|
|
1222
1255
|
this.x = x;
|
|
1223
1256
|
this.y = y;
|
|
1224
1257
|
this.segments = segments;
|
|
@@ -1452,9 +1485,10 @@ var RenderFrameType;
|
|
|
1452
1485
|
RenderFrameType[RenderFrameType["Elements"] = 2] = "Elements";
|
|
1453
1486
|
})(RenderFrameType || (exports.RenderFrameType = RenderFrameType = {}));
|
|
1454
1487
|
class RenderJunction {
|
|
1455
|
-
constructor(x, y) {
|
|
1488
|
+
constructor(x, y, net) {
|
|
1456
1489
|
this.x = x;
|
|
1457
1490
|
this.y = y;
|
|
1491
|
+
this.net = net;
|
|
1458
1492
|
}
|
|
1459
1493
|
}
|
|
1460
1494
|
exports.RenderJunction = RenderJunction;
|
|
@@ -104,6 +104,9 @@ class ExecutionScope {
|
|
|
104
104
|
console.log(netName.padEnd(10), '=>', instanceName, pin);
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
+
setVariable(name, value) {
|
|
108
|
+
this.variables.set(name, value);
|
|
109
|
+
}
|
|
107
110
|
setActive(type, item) {
|
|
108
111
|
this.clearActive();
|
|
109
112
|
if (type === ActiveObject.Wire) {
|
package/dist/cjs/objects/Net.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Net = void 0;
|
|
4
4
|
class Net {
|
|
5
5
|
constructor(namespace, name, priority = 0, type = null) {
|
|
6
|
+
this.params = new Map();
|
|
6
7
|
if (namespace.indexOf(' ') !== -1) {
|
|
7
8
|
throw "Invalid net namespace provided";
|
|
8
9
|
}
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Direction = exports.ParseSymbolType = exports.DeclaredReference = exports.UndeclaredReference = void 0;
|
|
3
|
+
exports.Direction = exports.ParseSymbolType = exports.DeclaredReference = exports.UndeclaredReference = exports.AnyReference = void 0;
|
|
4
|
+
const utils_js_1 = require("../utils.js");
|
|
5
|
+
class AnyReference {
|
|
6
|
+
constructor(refType) {
|
|
7
|
+
this.found = false;
|
|
8
|
+
this.trailers = [];
|
|
9
|
+
if (refType.value instanceof AnyReference) {
|
|
10
|
+
throw new utils_js_1.RuntimeExecutionError("Nested reference types!");
|
|
11
|
+
}
|
|
12
|
+
this.found = refType.found;
|
|
13
|
+
this.name = refType.name;
|
|
14
|
+
this.trailers = refType.trailers;
|
|
15
|
+
this.type = refType.type;
|
|
16
|
+
this.value = refType.value;
|
|
17
|
+
this.parentValue = refType.parentValue;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.AnyReference = AnyReference;
|
|
4
21
|
class UndeclaredReference {
|
|
5
22
|
constructor(reference) {
|
|
6
23
|
this.reference = reference;
|
|
@@ -21,15 +38,7 @@ class UndeclaredReference {
|
|
|
21
38
|
}
|
|
22
39
|
}
|
|
23
40
|
exports.UndeclaredReference = UndeclaredReference;
|
|
24
|
-
class DeclaredReference {
|
|
25
|
-
constructor(refType) {
|
|
26
|
-
this.found = refType.found;
|
|
27
|
-
this.name = refType.name;
|
|
28
|
-
this.trailers = refType.trailers;
|
|
29
|
-
this.type = refType.type;
|
|
30
|
-
this.value = refType.value;
|
|
31
|
-
this.parentValue = refType.parentValue;
|
|
32
|
-
}
|
|
41
|
+
class DeclaredReference extends AnyReference {
|
|
33
42
|
toString() {
|
|
34
43
|
return `[DeclaredReference name: ${this.name} trailers:${this.trailers} found: ${this.found}]`;
|
|
35
44
|
}
|
package/dist/cjs/render.js
CHANGED
|
@@ -178,28 +178,70 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
|
|
|
178
178
|
.translate(wire.x.add(5).toNumber(), wire.y.add(5).toNumber());
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
|
+
const mergedWireHighlightGroup = canvas.group();
|
|
181
182
|
const mergedWireGroup = canvas.group();
|
|
182
183
|
mergedWires.forEach(tmpItem => {
|
|
183
|
-
const { segments, intersectPoints } = tmpItem;
|
|
184
|
+
const { segments, intersectPoints, net = null } = tmpItem;
|
|
185
|
+
let useJunctionColor = globals_js_1.ColorScheme.JunctionColor;
|
|
186
|
+
let useColor = globals_js_1.ColorScheme.WireColor;
|
|
187
|
+
let useLineWidth = globals_js_1.defaultWireLineWidth;
|
|
188
|
+
let displayHighlight = false;
|
|
189
|
+
let displayHighlightColor = null;
|
|
190
|
+
if (net !== null) {
|
|
191
|
+
useColor = net.color ?? globals_js_1.ColorScheme.WireColor;
|
|
192
|
+
useJunctionColor = net.color ?? globals_js_1.ColorScheme.JunctionColor;
|
|
193
|
+
useLineWidth = net.lineWidth ?? globals_js_1.defaultWireLineWidth;
|
|
194
|
+
if (net.highlight !== null) {
|
|
195
|
+
displayHighlight = true;
|
|
196
|
+
displayHighlightColor = net.highlight ?? null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const pathItems = [];
|
|
200
|
+
const highlightExtraSize = 5 * globals_js_1.MilsToMM;
|
|
184
201
|
segments.forEach(segment => {
|
|
185
202
|
const pt1 = segment[0];
|
|
186
203
|
const pt2 = segment[1];
|
|
187
|
-
|
|
204
|
+
pathItems.push(...[
|
|
205
|
+
'M', pt1[0], pt1[1],
|
|
206
|
+
'L', pt2[0], pt2[1]
|
|
207
|
+
]);
|
|
208
|
+
});
|
|
209
|
+
if (displayHighlight) {
|
|
210
|
+
mergedWireHighlightGroup.path(pathItems)
|
|
188
211
|
.stroke({
|
|
189
|
-
width:
|
|
190
|
-
color:
|
|
212
|
+
width: useLineWidth + highlightExtraSize,
|
|
213
|
+
color: displayHighlightColor,
|
|
214
|
+
opacity: 0.3,
|
|
191
215
|
linecap: 'square'
|
|
192
216
|
})
|
|
193
217
|
.fill('none');
|
|
194
|
-
}
|
|
218
|
+
}
|
|
219
|
+
mergedWireGroup.path(pathItems)
|
|
220
|
+
.stroke({
|
|
221
|
+
width: useLineWidth,
|
|
222
|
+
color: useColor,
|
|
223
|
+
linecap: 'square'
|
|
224
|
+
})
|
|
225
|
+
.fill('none');
|
|
195
226
|
const halfJunctionSize = globals_js_1.junctionSize.half();
|
|
227
|
+
const highlightJunctionSize = (0, ParamDefinition_js_1.numeric)(globals_js_1.junctionSize.toNumber() + highlightExtraSize);
|
|
228
|
+
const tmpHighlightExtraSize = highlightJunctionSize.half();
|
|
196
229
|
intersectPoints.forEach(point => {
|
|
197
230
|
const [x, y,] = point;
|
|
198
231
|
const translateX = (0, ParamDefinition_js_1.numeric)(x).sub(halfJunctionSize);
|
|
199
232
|
const translateY = (0, ParamDefinition_js_1.numeric)(y).sub(halfJunctionSize);
|
|
233
|
+
if (displayHighlight && displayHighlightColor !== null) {
|
|
234
|
+
const tmpTranslateX = (0, ParamDefinition_js_1.numeric)(x).sub(tmpHighlightExtraSize);
|
|
235
|
+
const tmpTranslateY = (0, ParamDefinition_js_1.numeric)(y).sub(tmpHighlightExtraSize);
|
|
236
|
+
mergedWireHighlightGroup.circle(highlightJunctionSize.toNumber())
|
|
237
|
+
.translate(tmpTranslateX.toNumber(), tmpTranslateY.toNumber())
|
|
238
|
+
.fill(displayHighlightColor)
|
|
239
|
+
.opacity(0.3)
|
|
240
|
+
.stroke('none');
|
|
241
|
+
}
|
|
200
242
|
mergedWireGroup.circle(globals_js_1.junctionSize.toNumber())
|
|
201
243
|
.translate(translateX.toNumber(), translateY.toNumber())
|
|
202
|
-
.fill(
|
|
244
|
+
.fill(useJunctionColor)
|
|
203
245
|
.stroke('none');
|
|
204
246
|
});
|
|
205
247
|
});
|
package/dist/cjs/utils.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printWarnings = exports.RenderError = exports.RuntimeExecutionError = exports.ParseError = exports.ParseSyntaxError = exports.getLinePositionAsString = exports.BaseError = exports.getBlockTypeString = exports.generateDebugSequenceAction = exports.sequenceActionString = exports.areasOverlap = exports.isPointWithinArea = exports.resolveToNumericValue = exports.getNumberExponentialText = exports.getNumberExponential = exports.combineMaps = exports.throwWithTokenRange = exports.throwWithToken = exports.throwWithContext = exports.roundValue = exports.getPortType = exports.getBoundsSize = exports.toNearestGrid = exports.resizeToNearestGrid = exports.printBounds = exports.resizeBounds = exports.SimpleStopwatch = void 0;
|
|
3
|
+
exports.isReference = exports.prepareValue = exports.printWarnings = exports.RenderError = exports.RuntimeExecutionError = exports.ParseError = exports.ParseSyntaxError = exports.getLinePositionAsString = exports.BaseError = exports.getBlockTypeString = exports.generateDebugSequenceAction = exports.sequenceActionString = exports.areasOverlap = exports.isPointWithinArea = exports.resolveToNumericValue = exports.getNumberExponentialText = exports.getNumberExponential = exports.combineMaps = exports.throwWithTokenRange = exports.throwWithToken = exports.throwWithContext = exports.roundValue = exports.getPortType = exports.getBoundsSize = exports.toNearestGrid = exports.resizeToNearestGrid = exports.printBounds = exports.resizeBounds = exports.SimpleStopwatch = void 0;
|
|
4
4
|
const big_js_1 = require("big.js");
|
|
5
5
|
const antlr4ng_1 = require("antlr4ng");
|
|
6
6
|
const ClassComponent_js_1 = require("./objects/ClassComponent.js");
|
|
7
7
|
const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
|
|
8
8
|
const ExecutionScope_js_1 = require("./objects/ExecutionScope.js");
|
|
9
9
|
const globals_js_1 = require("./globals.js");
|
|
10
|
+
const types_js_1 = require("./objects/types.js");
|
|
10
11
|
class SimpleStopwatch {
|
|
11
12
|
constructor() {
|
|
12
13
|
this.startTime = new Date();
|
|
@@ -358,3 +359,17 @@ function printWarnings(warnings) {
|
|
|
358
359
|
});
|
|
359
360
|
}
|
|
360
361
|
exports.printWarnings = printWarnings;
|
|
362
|
+
function prepareValue(value) {
|
|
363
|
+
if (isReference(value)) {
|
|
364
|
+
return value.value;
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
return value;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
exports.prepareValue = prepareValue;
|
|
371
|
+
function isReference(value) {
|
|
372
|
+
return (value instanceof types_js_1.AnyReference ||
|
|
373
|
+
value instanceof types_js_1.DeclaredReference);
|
|
374
|
+
}
|
|
375
|
+
exports.isReference = isReference;
|