circuitscript 0.4.0 → 0.5.0
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 +16 -10
- package/dist/cjs/BomGeneration.js +3 -3
- package/dist/cjs/ComponentMatchConditions.js +2 -2
- package/dist/cjs/annotate/RefdesAnnotationVisitor.js +4 -0
- package/dist/cjs/builtinMethods.js +10 -10
- package/dist/cjs/execute.js +25 -23
- package/dist/cjs/globals.js +7 -14
- package/dist/cjs/helpers.js +4 -3
- package/dist/cjs/index.js +6 -2
- package/dist/cjs/lexer.js +8 -4
- package/dist/cjs/objects/BlockTypes.js +10 -0
- package/dist/cjs/objects/NumericValue.js +196 -0
- package/dist/cjs/objects/ParamDefinition.js +1 -149
- package/dist/cjs/objects/PercentageValue.js +15 -0
- package/dist/cjs/objects/PinDefinition.js +2 -2
- package/dist/cjs/objects/WrappedNumber.js +15 -0
- package/dist/cjs/pipeline.js +2 -2
- package/dist/cjs/render/draw_symbols.js +78 -78
- package/dist/cjs/render/export.js +2 -2
- package/dist/cjs/render/geometry.js +11 -12
- package/dist/cjs/render/graph.js +2 -2
- package/dist/cjs/render/layout.js +46 -46
- package/dist/cjs/render/render.js +19 -19
- package/dist/cjs/semantic-tokens/SemanticTokenVisitor.js +59 -59
- package/dist/cjs/utils.js +21 -83
- package/dist/cjs/visitor.js +45 -31
- package/dist/esm/BaseVisitor.js +8 -2
- package/dist/esm/BomGeneration.js +1 -1
- package/dist/esm/ComponentMatchConditions.js +1 -1
- package/dist/esm/annotate/RefdesAnnotationVisitor.js +4 -0
- package/dist/esm/builtinMethods.js +2 -2
- package/dist/esm/execute.js +4 -2
- package/dist/esm/globals.js +1 -8
- package/dist/esm/helpers.js +3 -2
- package/dist/esm/index.js +6 -2
- package/dist/esm/lexer.js +8 -4
- package/dist/esm/objects/BlockTypes.js +7 -0
- package/dist/esm/objects/NumericValue.js +189 -0
- package/dist/esm/objects/ParamDefinition.js +0 -148
- package/dist/esm/objects/PercentageValue.js +12 -0
- package/dist/esm/objects/PinDefinition.js +1 -1
- package/dist/esm/objects/WrappedNumber.js +12 -0
- package/dist/esm/pipeline.js +2 -2
- package/dist/esm/render/draw_symbols.js +2 -2
- package/dist/esm/render/export.js +1 -1
- package/dist/esm/render/geometry.js +1 -2
- package/dist/esm/render/graph.js +1 -1
- package/dist/esm/render/layout.js +2 -2
- package/dist/esm/render/render.js +1 -1
- package/dist/esm/semantic-tokens/SemanticTokenVisitor.js +58 -58
- package/dist/esm/utils.js +16 -74
- package/dist/esm/visitor.js +17 -3
- package/dist/types/ComponentMatchConditions.d.ts +1 -1
- package/dist/types/annotate/RefdesAnnotationVisitor.d.ts +3 -1
- package/dist/types/execute.d.ts +4 -2
- package/dist/types/globals.d.ts +1 -7
- package/dist/types/helpers.d.ts +2 -2
- package/dist/types/index.d.ts +6 -2
- package/dist/types/lexer.d.ts +1 -0
- package/dist/types/objects/BlockTypes.d.ts +6 -0
- package/dist/types/objects/ClassComponent.d.ts +1 -1
- package/dist/types/objects/ExecutionScope.d.ts +2 -1
- package/dist/types/objects/NumericValue.d.ts +35 -0
- package/dist/types/objects/ParamDefinition.d.ts +0 -41
- package/dist/types/objects/PercentageValue.d.ts +6 -0
- package/dist/types/objects/PinDefinition.d.ts +1 -1
- package/dist/types/objects/WrappedNumber.d.ts +6 -0
- package/dist/types/objects/types.d.ts +2 -1
- package/dist/types/render/draw_symbols.d.ts +1 -1
- package/dist/types/render/geometry.d.ts +1 -1
- package/dist/types/render/layout.d.ts +1 -1
- package/dist/types/semantic-tokens/SemanticTokenVisitor.d.ts +3 -4
- package/dist/types/utils.d.ts +1 -7
- package/package.json +1 -1
package/dist/cjs/BaseVisitor.js
CHANGED
|
@@ -7,7 +7,8 @@ const CircuitScriptParserVisitor_js_1 = require("./antlr/CircuitScriptParserVisi
|
|
|
7
7
|
const execute_js_1 = require("./execute.js");
|
|
8
8
|
const logger_js_1 = require("./logger.js");
|
|
9
9
|
const ClassComponent_js_1 = require("./objects/ClassComponent.js");
|
|
10
|
-
const
|
|
10
|
+
const NumericValue_js_1 = require("./objects/NumericValue.js");
|
|
11
|
+
const PercentageValue_js_1 = require("./objects/PercentageValue.js");
|
|
11
12
|
const types_js_1 = require("./objects/types.js");
|
|
12
13
|
const globals_js_1 = require("./globals.js");
|
|
13
14
|
const utils_js_1 = require("./utils.js");
|
|
@@ -101,6 +102,11 @@ class BaseVisitor extends CircuitScriptParserVisitor_js_1.CircuitScriptParserVis
|
|
|
101
102
|
currentReference = this.visitResult(ctxTrailer);
|
|
102
103
|
});
|
|
103
104
|
}
|
|
105
|
+
else {
|
|
106
|
+
if (ctx.trailer().length > 0 && ctx.trailer(0).LParen()) {
|
|
107
|
+
this.throwWithContext(ctx, `Function not found: ${ctx.getText()}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
104
110
|
let resultValue = currentReference;
|
|
105
111
|
if (!keepReference) {
|
|
106
112
|
if (currentReference.type !== globals_js_1.ReferenceTypes.pinType) {
|
|
@@ -128,7 +134,7 @@ class BaseVisitor extends CircuitScriptParserVisitor_js_1.CircuitScriptParserVis
|
|
|
128
134
|
}
|
|
129
135
|
else if (ctxDataExpr) {
|
|
130
136
|
const arrayIndex = this.visitResult(ctxDataExpr);
|
|
131
|
-
if (arrayIndex instanceof
|
|
137
|
+
if (arrayIndex instanceof NumericValue_js_1.NumericValue) {
|
|
132
138
|
const arrayIndexValue = arrayIndex.toNumber();
|
|
133
139
|
const foundValue = useValue[arrayIndexValue];
|
|
134
140
|
const refType = foundValue instanceof ClassComponent_js_1.ClassComponent
|
|
@@ -242,7 +248,7 @@ class BaseVisitor extends CircuitScriptParserVisitor_js_1.CircuitScriptParserVis
|
|
|
242
248
|
this.throwWithContext(ctx, 'Operator assignment failed: could not get value');
|
|
243
249
|
}
|
|
244
250
|
let newValue = 0;
|
|
245
|
-
const operator = new
|
|
251
|
+
const operator = new NumericValue_js_1.NumberOperator();
|
|
246
252
|
if (ctx.AdditionAssign()) {
|
|
247
253
|
newValue = operator.addition(currentValue, value);
|
|
248
254
|
}
|
|
@@ -292,7 +298,7 @@ class BaseVisitor extends CircuitScriptParserVisitor_js_1.CircuitScriptParserVis
|
|
|
292
298
|
}
|
|
293
299
|
else if (ctxDataExpr) {
|
|
294
300
|
const arrayIndex = this.visitResult(ctxDataExpr);
|
|
295
|
-
if (arrayIndex instanceof
|
|
301
|
+
if (arrayIndex instanceof NumericValue_js_1.NumericValue) {
|
|
296
302
|
const arrayIndexValue = arrayIndex.toNumber();
|
|
297
303
|
const foundValue = useValue[arrayIndexValue];
|
|
298
304
|
const refType = foundValue instanceof ClassComponent_js_1.ClassComponent
|
|
@@ -345,14 +351,14 @@ class BaseVisitor extends CircuitScriptParserVisitor_js_1.CircuitScriptParserVis
|
|
|
345
351
|
let result = null;
|
|
346
352
|
if (ctxIntegerValue || ctxDecimalValue || ctxNumericValue) {
|
|
347
353
|
if (ctxIntegerValue) {
|
|
348
|
-
result = (0,
|
|
354
|
+
result = (0, NumericValue_js_1.resolveToNumericValue)((new big_js_1.Big(ctxIntegerValue.getText())).mul(new big_js_1.Big(sign)));
|
|
349
355
|
}
|
|
350
356
|
else if (ctxDecimalValue) {
|
|
351
|
-
result = (0,
|
|
357
|
+
result = (0, NumericValue_js_1.resolveToNumericValue)((new big_js_1.Big(ctxDecimalValue.getText())).mul(new big_js_1.Big(sign)));
|
|
352
358
|
}
|
|
353
359
|
else if (ctxNumericValue) {
|
|
354
360
|
const textExtra = ctx.Minus() ? '-' : '';
|
|
355
|
-
result = new
|
|
361
|
+
result = new NumericValue_js_1.NumericValue(textExtra + ctxNumericValue.getText());
|
|
356
362
|
}
|
|
357
363
|
}
|
|
358
364
|
else {
|
|
@@ -373,7 +379,7 @@ class BaseVisitor extends CircuitScriptParserVisitor_js_1.CircuitScriptParserVis
|
|
|
373
379
|
result = this.prepareStringValue(ctxStringValue.getText());
|
|
374
380
|
}
|
|
375
381
|
else if (ctxPercentageValue) {
|
|
376
|
-
result = new
|
|
382
|
+
result = new PercentageValue_js_1.PercentageValue(ctxPercentageValue.getText());
|
|
377
383
|
}
|
|
378
384
|
this.setResult(ctx, result);
|
|
379
385
|
};
|
|
@@ -490,7 +496,7 @@ class BaseVisitor extends CircuitScriptParserVisitor_js_1.CircuitScriptParserVis
|
|
|
490
496
|
if (!Array.isArray(arrayItem)) {
|
|
491
497
|
throw new utils_js_2.RuntimeExecutionError("Invalid array", ctxArray);
|
|
492
498
|
}
|
|
493
|
-
if (!(indexValue instanceof
|
|
499
|
+
if (!(indexValue instanceof NumericValue_js_1.NumericValue)) {
|
|
494
500
|
throw new utils_js_2.RuntimeExecutionError("Invalid index value", ctxArrayIndex);
|
|
495
501
|
}
|
|
496
502
|
const indexValueNumber = indexValue.toNumber();
|
|
@@ -1092,7 +1098,7 @@ class BaseVisitor extends CircuitScriptParserVisitor_js_1.CircuitScriptParserVis
|
|
|
1092
1098
|
}
|
|
1093
1099
|
validateNumeric(value, context) {
|
|
1094
1100
|
this.validateType(value, context, (val) => {
|
|
1095
|
-
return (val instanceof
|
|
1101
|
+
return (val instanceof NumericValue_js_1.NumericValue);
|
|
1096
1102
|
}, 'numeric value');
|
|
1097
1103
|
}
|
|
1098
1104
|
enterFile(filePath) {
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.saveBomOutputCsv = exports.generateBomCSV = exports.groupComponents = exports.generateBom = void 0;
|
|
27
27
|
const csv = __importStar(require("@fast-csv/format"));
|
|
28
|
-
const
|
|
28
|
+
const NumericValue_js_1 = require("./objects/NumericValue.js");
|
|
29
29
|
const TypeSortOrder = {
|
|
30
30
|
"res": 1,
|
|
31
31
|
"cap": 2,
|
|
@@ -94,7 +94,7 @@ function extractComponentValuesForBom(bomConfig, instances) {
|
|
|
94
94
|
if (typeof useValue === 'string') {
|
|
95
95
|
useValue = resolveValuesInTemplate(instance, useValue);
|
|
96
96
|
}
|
|
97
|
-
else if (useValue instanceof
|
|
97
|
+
else if (useValue instanceof NumericValue_js_1.NumericValue) {
|
|
98
98
|
useValue = useValue.toDisplayString();
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -110,7 +110,7 @@ function resolveValuesInTemplate(instance, templateString) {
|
|
|
110
110
|
return templateString.replace(/\{(\w+)\}/g, (match, paramName) => {
|
|
111
111
|
if (instance.hasParam(paramName)) {
|
|
112
112
|
const paramValue = instance.getParam(paramName);
|
|
113
|
-
if (paramValue instanceof
|
|
113
|
+
if (paramValue instanceof NumericValue_js_1.NumericValue) {
|
|
114
114
|
return paramValue.toDisplayString();
|
|
115
115
|
}
|
|
116
116
|
return instance.getParam(paramName);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.applyPartConditions = exports.partMatchesConditions = exports.extractPartConditions = exports.flattenConditionNodes = void 0;
|
|
4
4
|
const globals_js_1 = require("./globals.js");
|
|
5
|
-
const
|
|
5
|
+
const NumericValue_js_1 = require("./objects/NumericValue.js");
|
|
6
6
|
function flattenConditionNodes(conditionNodes, level = 0) {
|
|
7
7
|
const conditionBranches = [];
|
|
8
8
|
conditionNodes.forEach(node => {
|
|
@@ -84,7 +84,7 @@ function partMatchesConditions(instance, partConditions) {
|
|
|
84
84
|
if (typeof compareValue === "string") {
|
|
85
85
|
return (compareValue !== paramValue);
|
|
86
86
|
}
|
|
87
|
-
else if (compareValue instanceof
|
|
87
|
+
else if (compareValue instanceof NumericValue_js_1.NumericValue) {
|
|
88
88
|
return !compareValue.eq(paramValue);
|
|
89
89
|
}
|
|
90
90
|
else if (typeof compareValue === 'number') {
|
|
@@ -14,6 +14,10 @@ class RefdesAnnotationVisitor extends BaseVisitor_js_1.BaseVisitor {
|
|
|
14
14
|
this.getExecutor().closeOpenPathBlocks();
|
|
15
15
|
this.resultText = (0, utils_js_1.generateModifiedSourceText)(this.modifications, this.tokenStream.getTokens(), this.sourceText);
|
|
16
16
|
};
|
|
17
|
+
this.visitCallable_expr = (ctx) => {
|
|
18
|
+
};
|
|
19
|
+
this.visitAssignment_expr = (ctx) => {
|
|
20
|
+
};
|
|
17
21
|
this.visitAdd_component_expr = (ctx) => {
|
|
18
22
|
this.addRefdesAnnotationComment(ctx);
|
|
19
23
|
};
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
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
|
-
const
|
|
8
|
+
const NumericValue_js_1 = require("./objects/NumericValue.js");
|
|
9
9
|
const types_js_1 = require("./objects/types.js");
|
|
10
10
|
const utils_js_1 = require("./utils.js");
|
|
11
11
|
const globals_js_1 = require("./globals.js");
|
|
@@ -45,8 +45,8 @@ function linkBuiltInMethods(context, visitor) {
|
|
|
45
45
|
}
|
|
46
46
|
exports.linkBuiltInMethods = linkBuiltInMethods;
|
|
47
47
|
function range(...args) {
|
|
48
|
-
let startValue = (0,
|
|
49
|
-
let endValue = (0,
|
|
48
|
+
let startValue = (0, NumericValue_js_1.numeric)(0);
|
|
49
|
+
let endValue = (0, NumericValue_js_1.numeric)(0);
|
|
50
50
|
if (args.length === 1) {
|
|
51
51
|
endValue = args[0];
|
|
52
52
|
}
|
|
@@ -73,7 +73,7 @@ function enumerate(array) {
|
|
|
73
73
|
}
|
|
74
74
|
function toMils(value) {
|
|
75
75
|
let bigValue;
|
|
76
|
-
if (value instanceof
|
|
76
|
+
if (value instanceof NumericValue_js_1.NumericValue) {
|
|
77
77
|
bigValue = value.toBigNumber();
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
@@ -83,16 +83,16 @@ function toMils(value) {
|
|
|
83
83
|
bigValue = new big_js_1.default(value);
|
|
84
84
|
}
|
|
85
85
|
bigValue = bigValue.div(new big_js_1.default(25.4 / 1000));
|
|
86
|
-
return (0,
|
|
86
|
+
return (0, NumericValue_js_1.resolveToNumericValue)(bigValue);
|
|
87
87
|
}
|
|
88
88
|
function objectLength(obj) {
|
|
89
89
|
obj = (0, utils_js_1.unwrapValue)(obj);
|
|
90
90
|
if (Array.isArray(obj)) {
|
|
91
|
-
return (0,
|
|
91
|
+
return (0, NumericValue_js_1.numeric)(obj.length);
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
94
|
if (obj.length) {
|
|
95
|
-
return (0,
|
|
95
|
+
return (0, NumericValue_js_1.numeric)(obj.length);
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
98
98
|
throw "Could not get length of object: " + obj;
|
|
@@ -111,7 +111,7 @@ function arrayGet(arrayObject, index) {
|
|
|
111
111
|
throw "Invalid array object to get";
|
|
112
112
|
}
|
|
113
113
|
let useValue;
|
|
114
|
-
if (index instanceof
|
|
114
|
+
if (index instanceof NumericValue_js_1.NumericValue) {
|
|
115
115
|
useValue = index.toNumber();
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
@@ -127,7 +127,7 @@ function arraySet(arrayObject, index, setValue) {
|
|
|
127
127
|
throw "Invalid array object";
|
|
128
128
|
}
|
|
129
129
|
let useValue;
|
|
130
|
-
if (index instanceof
|
|
130
|
+
if (index instanceof NumericValue_js_1.NumericValue) {
|
|
131
131
|
useValue = index.toNumber();
|
|
132
132
|
}
|
|
133
133
|
else {
|
|
@@ -150,7 +150,7 @@ function toString(obj) {
|
|
|
150
150
|
const inner = obj.map(item => toString(item)).join(", ");
|
|
151
151
|
return "[" + inner + "]";
|
|
152
152
|
}
|
|
153
|
-
else if (obj instanceof
|
|
153
|
+
else if (obj instanceof NumericValue_js_1.NumericValue) {
|
|
154
154
|
return obj.toBigNumber().toString();
|
|
155
155
|
}
|
|
156
156
|
else if (obj instanceof types_js_1.CFunctionEntry) {
|
package/dist/cjs/execute.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPortSide = exports.ExecutionContext = void 0;
|
|
4
4
|
const globals_js_1 = require("./globals.js");
|
|
5
|
+
const BlockTypes_js_1 = require("./objects/BlockTypes.js");
|
|
5
6
|
const ClassComponent_js_1 = require("./objects/ClassComponent.js");
|
|
6
7
|
const ExecutionScope_js_1 = require("./objects/ExecutionScope.js");
|
|
7
8
|
const Net_js_1 = require("./objects/Net.js");
|
|
8
|
-
const
|
|
9
|
+
const NumericValue_js_1 = require("./objects/NumericValue.js");
|
|
10
|
+
const NumericValue_js_2 = require("./objects/NumericValue.js");
|
|
9
11
|
const PinDefinition_js_1 = require("./objects/PinDefinition.js");
|
|
10
12
|
const types_js_1 = require("./objects/types.js");
|
|
11
13
|
const Wire_js_1 = require("./objects/Wire.js");
|
|
@@ -259,7 +261,7 @@ class ExecutionContext {
|
|
|
259
261
|
items = [items];
|
|
260
262
|
}
|
|
261
263
|
items = items.map(item => {
|
|
262
|
-
if (item instanceof
|
|
264
|
+
if (item instanceof NumericValue_js_1.NumericValue) {
|
|
263
265
|
item = item.toNumber();
|
|
264
266
|
}
|
|
265
267
|
if (item instanceof PinDefinition_js_1.PinId) {
|
|
@@ -440,9 +442,9 @@ class ExecutionContext {
|
|
|
440
442
|
return componentCopy;
|
|
441
443
|
}
|
|
442
444
|
enterBlocks(blockType) {
|
|
443
|
-
if (blockType ===
|
|
444
|
-
|| blockType ===
|
|
445
|
-
|| blockType ===
|
|
445
|
+
if (blockType === BlockTypes_js_1.BlockTypes.Point
|
|
446
|
+
|| blockType === BlockTypes_js_1.BlockTypes.Parallel
|
|
447
|
+
|| blockType === BlockTypes_js_1.BlockTypes.Branch) {
|
|
446
448
|
const key = (0, utils_js_1.getBlockTypeString)(blockType);
|
|
447
449
|
this.addPoint(`${globals_js_1.Delimiter1}${key}.${this.name}.${this.tmpPointId}`, false);
|
|
448
450
|
this.tmpPointId += 1;
|
|
@@ -466,7 +468,7 @@ class ExecutionContext {
|
|
|
466
468
|
}
|
|
467
469
|
const stackRef = this.scope.blockStack.get(scopeLevel);
|
|
468
470
|
const { type: blockType } = stackRef;
|
|
469
|
-
if (blockType ===
|
|
471
|
+
if (blockType === BlockTypes_js_1.BlockTypes.Join || blockType === BlockTypes_js_1.BlockTypes.Parallel) {
|
|
470
472
|
const { end_point: finalPoint } = stackRef;
|
|
471
473
|
const [component, pin, wireId] = finalPoint;
|
|
472
474
|
this.scope.setCurrent(component, pin);
|
|
@@ -477,7 +479,7 @@ class ExecutionContext {
|
|
|
477
479
|
]);
|
|
478
480
|
}
|
|
479
481
|
}
|
|
480
|
-
else if (blockType ===
|
|
482
|
+
else if (blockType === BlockTypes_js_1.BlockTypes.Point) {
|
|
481
483
|
const { start_point: [component, pin,] } = stackRef;
|
|
482
484
|
this.atComponent(component, pin, { addSequence: true });
|
|
483
485
|
}
|
|
@@ -499,11 +501,11 @@ class ExecutionContext {
|
|
|
499
501
|
last_net: null,
|
|
500
502
|
ignore_last_net: false,
|
|
501
503
|
});
|
|
502
|
-
if (blockType ===
|
|
504
|
+
if (blockType === BlockTypes_js_1.BlockTypes.Join || blockType === BlockTypes_js_1.BlockTypes.Point) {
|
|
503
505
|
this.scope.setCurrent(null);
|
|
504
506
|
this.scope.currentWireId = -1;
|
|
505
507
|
}
|
|
506
|
-
else if (blockType ===
|
|
508
|
+
else if (blockType === BlockTypes_js_1.BlockTypes.Parallel) {
|
|
507
509
|
const { start_point: [component, pin,] } = stackRef;
|
|
508
510
|
this.atComponent(component, pin, { addSequence: true });
|
|
509
511
|
}
|
|
@@ -521,7 +523,7 @@ class ExecutionContext {
|
|
|
521
523
|
];
|
|
522
524
|
this.scope.scopeLevel -= 1;
|
|
523
525
|
this.log('exit inner block <<<');
|
|
524
|
-
if (blockType ===
|
|
526
|
+
if (blockType === BlockTypes_js_1.BlockTypes.Branch) {
|
|
525
527
|
const { start_point: [component, pin, wireId] } = stackRef;
|
|
526
528
|
this.atComponent(component, pin, { addSequence: true });
|
|
527
529
|
if (wireId !== -1) {
|
|
@@ -530,7 +532,7 @@ class ExecutionContext {
|
|
|
530
532
|
wireId, PinDefinition_js_1.PinId.from(1), wireObject]);
|
|
531
533
|
}
|
|
532
534
|
}
|
|
533
|
-
else if (blockType ===
|
|
535
|
+
else if (blockType === BlockTypes_js_1.BlockTypes.Join || blockType === BlockTypes_js_1.BlockTypes.Parallel) {
|
|
534
536
|
if (blockIndex === 0) {
|
|
535
537
|
const pointIdName = `${globals_js_1.Delimiter1}${(0, utils_js_1.getBlockTypeString)(blockType)}`;
|
|
536
538
|
this.addPoint(`${pointIdName}.${this.name}.${this.tmpPointId}`, false);
|
|
@@ -971,8 +973,8 @@ class ExecutionContext {
|
|
|
971
973
|
getPointSymbol(name = "") {
|
|
972
974
|
const commands = [
|
|
973
975
|
[draw_symbols_js_1.PlaceHolderCommands.pin,
|
|
974
|
-
[(0,
|
|
975
|
-
(0,
|
|
976
|
+
[(0, NumericValue_js_2.numeric)(1), (0, NumericValue_js_2.numeric)(0), (0, NumericValue_js_2.numeric)(0),
|
|
977
|
+
(0, NumericValue_js_2.numeric)(0), (0, NumericValue_js_2.numeric)(0)],
|
|
976
978
|
new Map([
|
|
977
979
|
["display_id", false]
|
|
978
980
|
]),
|
|
@@ -986,25 +988,25 @@ class ExecutionContext {
|
|
|
986
988
|
new Map(), null
|
|
987
989
|
],
|
|
988
990
|
[draw_symbols_js_1.PlaceHolderCommands.hline,
|
|
989
|
-
[(0,
|
|
991
|
+
[(0, NumericValue_js_2.numeric)(-25), (0, NumericValue_js_2.numeric)(0), (0, NumericValue_js_2.numeric)(50)],
|
|
990
992
|
new Map(),
|
|
991
993
|
null
|
|
992
994
|
],
|
|
993
995
|
[draw_symbols_js_1.PlaceHolderCommands.vline,
|
|
994
|
-
[(0,
|
|
996
|
+
[(0, NumericValue_js_2.numeric)(0), (0, NumericValue_js_2.numeric)(-25), (0, NumericValue_js_2.numeric)(50)],
|
|
995
997
|
new Map(),
|
|
996
998
|
null
|
|
997
999
|
],
|
|
998
1000
|
[draw_symbols_js_1.PlaceHolderCommands.hline,
|
|
999
|
-
[(0,
|
|
1000
|
-
(0,
|
|
1001
|
+
[(0, NumericValue_js_2.numeric)(0), (0, NumericValue_js_2.numeric)(0),
|
|
1002
|
+
(0, NumericValue_js_2.numeric)(10)],
|
|
1001
1003
|
new Map([]), null
|
|
1002
1004
|
],
|
|
1003
1005
|
[draw_symbols_js_1.PlaceHolderCommands.text,
|
|
1004
1006
|
[],
|
|
1005
1007
|
new Map([
|
|
1006
1008
|
["content", name],
|
|
1007
|
-
["fontSize", (0,
|
|
1009
|
+
["fontSize", (0, NumericValue_js_2.numeric)(10)],
|
|
1008
1010
|
]),
|
|
1009
1011
|
null
|
|
1010
1012
|
]
|
|
@@ -1046,7 +1048,7 @@ class ExecutionContext {
|
|
|
1046
1048
|
if (unitModifiers.indexOf(paramName) !== -1) {
|
|
1047
1049
|
if (paramName === globals_js_1.ParamKeys.flipX || paramName == globals_js_1.ParamKeys.flipY) {
|
|
1048
1050
|
if (typeof value === "boolean") {
|
|
1049
|
-
value = value ? (0,
|
|
1051
|
+
value = value ? (0, NumericValue_js_2.numeric)(1) : (0, NumericValue_js_2.numeric)(0);
|
|
1050
1052
|
}
|
|
1051
1053
|
}
|
|
1052
1054
|
component.getUnit().setParam(paramName, value);
|
|
@@ -1117,18 +1119,18 @@ class ExecutionContext {
|
|
|
1117
1119
|
useAngle += 360;
|
|
1118
1120
|
}
|
|
1119
1121
|
if (useAngle === 90) {
|
|
1120
|
-
targetUnit.setParam(globals_js_1.ParamKeys.angle, (0,
|
|
1122
|
+
targetUnit.setParam(globals_js_1.ParamKeys.angle, (0, NumericValue_js_2.numeric)(90));
|
|
1121
1123
|
}
|
|
1122
1124
|
else if (useAngle === 180) {
|
|
1123
1125
|
if (pinAngle == 90 || pinAngle == 270) {
|
|
1124
|
-
targetUnit.setParam(globals_js_1.ParamKeys.flipY, (0,
|
|
1126
|
+
targetUnit.setParam(globals_js_1.ParamKeys.flipY, (0, NumericValue_js_2.numeric)(1));
|
|
1125
1127
|
}
|
|
1126
1128
|
else if (pinAngle == 0 || pinAngle == 180) {
|
|
1127
|
-
targetUnit.setParam(globals_js_1.ParamKeys.flipX, (0,
|
|
1129
|
+
targetUnit.setParam(globals_js_1.ParamKeys.flipX, (0, NumericValue_js_2.numeric)(1));
|
|
1128
1130
|
}
|
|
1129
1131
|
}
|
|
1130
1132
|
else if (useAngle === 270) {
|
|
1131
|
-
targetUnit.setParam(globals_js_1.ParamKeys.angle, (0,
|
|
1133
|
+
targetUnit.setParam(globals_js_1.ParamKeys.angle, (0, NumericValue_js_2.numeric)(270));
|
|
1132
1134
|
}
|
|
1133
1135
|
targetUnit.wireOrientationAngle = useAngle;
|
|
1134
1136
|
targetUnit.didSetWireOrientationAngle = true;
|
package/dist/cjs/globals.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RenderFlags = exports.GlobalDocumentName = exports.ModuleContainsKeyword = exports.FrameType = exports.NetGraphicsParams = exports.
|
|
4
|
-
exports.PinTypesList = exports.DefaultComponentUnit = exports.TrailerArrayIndex =
|
|
5
|
-
const
|
|
3
|
+
exports.SymbolValidatorContext = exports.RenderFlags = exports.GlobalDocumentName = exports.ModuleContainsKeyword = exports.FrameType = exports.NetGraphicsParams = 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.RefdesFileSuffix = exports.BaseNamespace = exports.DoubleDelimiter1 = exports.Delimiter1 = exports.TOOL_VERSION = void 0;
|
|
4
|
+
exports.PinTypesList = exports.DefaultComponentUnit = exports.TrailerArrayIndex = void 0;
|
|
5
|
+
const NumericValue_js_1 = require("./objects/NumericValue.js");
|
|
6
6
|
const PinTypes_js_1 = require("./objects/PinTypes.js");
|
|
7
7
|
exports.TOOL_VERSION = '0.1.5';
|
|
8
8
|
exports.Delimiter1 = '-';
|
|
@@ -57,11 +57,11 @@ exports.MMToPt = 2.8346456693;
|
|
|
57
57
|
exports.PxToMM = 0.2645833;
|
|
58
58
|
exports.portWidth = 20;
|
|
59
59
|
exports.portHeight = 2;
|
|
60
|
-
exports.defaultGridSizeUnits = (0,
|
|
60
|
+
exports.defaultGridSizeUnits = (0, NumericValue_js_1.numeric)(exports.MilsToMM).mul(100).toNumber();
|
|
61
61
|
exports.defaultZoomScale = 2.5;
|
|
62
62
|
exports.fontDisplayScale = 0.032;
|
|
63
|
-
exports.defaultSymbolLineWidth = (0,
|
|
64
|
-
exports.defaultWireLineWidth = (0,
|
|
63
|
+
exports.defaultSymbolLineWidth = (0, NumericValue_js_1.numeric)(exports.MilsToMM).mul(6).toNumber();
|
|
64
|
+
exports.defaultWireLineWidth = (0, NumericValue_js_1.numeric)(exports.MilsToMM).mul(6).toNumber();
|
|
65
65
|
exports.defaultPinNameTextSize = 40;
|
|
66
66
|
exports.defaultPinIdTextSize = 30;
|
|
67
67
|
exports.defaultPageMarginMM = 10;
|
|
@@ -75,7 +75,7 @@ exports.displayUnits = LengthUnit.mils;
|
|
|
75
75
|
exports.defaultFont = 'Arial';
|
|
76
76
|
exports.defaultFontBold = 'Arial';
|
|
77
77
|
exports.defaultFontSize = 10;
|
|
78
|
-
exports.junctionSize = (0,
|
|
78
|
+
exports.junctionSize = (0, NumericValue_js_1.numeric)(exports.MilsToMM).mul(20);
|
|
79
79
|
exports.PortArrowSize = exports.MilsToMM * 50;
|
|
80
80
|
exports.PortPaddingHorizontal = exports.MilsToMM * 10;
|
|
81
81
|
exports.PortPaddingVertical = exports.MilsToMM * 10;
|
|
@@ -104,13 +104,6 @@ var ReferenceTypes;
|
|
|
104
104
|
ReferenceTypes["library"] = "library";
|
|
105
105
|
ReferenceTypes["unknown"] = "unknown";
|
|
106
106
|
})(ReferenceTypes || (exports.ReferenceTypes = ReferenceTypes = {}));
|
|
107
|
-
var BlockTypes;
|
|
108
|
-
(function (BlockTypes) {
|
|
109
|
-
BlockTypes[BlockTypes["Branch"] = 1] = "Branch";
|
|
110
|
-
BlockTypes[BlockTypes["Join"] = 2] = "Join";
|
|
111
|
-
BlockTypes[BlockTypes["Parallel"] = 3] = "Parallel";
|
|
112
|
-
BlockTypes[BlockTypes["Point"] = 4] = "Point";
|
|
113
|
-
})(BlockTypes || (exports.BlockTypes = BlockTypes = {}));
|
|
114
107
|
var NetGraphicsParams;
|
|
115
108
|
(function (NetGraphicsParams) {
|
|
116
109
|
NetGraphicsParams["Color"] = "color";
|
package/dist/cjs/helpers.js
CHANGED
|
@@ -4,12 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.milsToMM = exports.UnitDimension = exports.detectJSModuleType = exports.RefdesOutputType = exports.ParseErrorStrategy = exports.TokenErrorListener = exports.prepareFile = exports.JSModuleType = void 0;
|
|
7
|
+
const big_js_1 = __importDefault(require("big.js"));
|
|
7
8
|
const utils_js_1 = require("./utils.js");
|
|
8
9
|
const antlr4ng_1 = require("antlr4ng");
|
|
9
10
|
const lexer_js_1 = require("./lexer.js");
|
|
10
11
|
const CircuitScriptParser_js_1 = require("./antlr/CircuitScriptParser.js");
|
|
11
12
|
const globals_js_1 = require("./globals.js");
|
|
12
|
-
const
|
|
13
|
+
const NumericValue_js_1 = require("./objects/NumericValue.js");
|
|
13
14
|
var JSModuleType;
|
|
14
15
|
(function (JSModuleType) {
|
|
15
16
|
JSModuleType["CommonJs"] = "cjs";
|
|
@@ -95,8 +96,8 @@ class UnitDimension {
|
|
|
95
96
|
exports.UnitDimension = UnitDimension;
|
|
96
97
|
function milsToMM(value) {
|
|
97
98
|
if (typeof value === 'number') {
|
|
98
|
-
value = (0,
|
|
99
|
+
value = (0, NumericValue_js_1.resolveToNumericValue)(new big_js_1.default(value));
|
|
99
100
|
}
|
|
100
|
-
return (0,
|
|
101
|
+
return (0, NumericValue_js_1.resolveToNumericValue)(value.toBigNumber().mul(new big_js_1.default(globals_js_1.MilsToMM)).round(6));
|
|
101
102
|
}
|
|
102
103
|
exports.milsToMM = milsToMM;
|
package/dist/cjs/index.js
CHANGED
|
@@ -16,16 +16,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./render/draw_symbols.js"), exports);
|
|
18
18
|
__exportStar(require("./execute.js"), exports);
|
|
19
|
-
__exportStar(require("./export.js"), exports);
|
|
19
|
+
__exportStar(require("./render/export.js"), exports);
|
|
20
20
|
__exportStar(require("./render/geometry.js"), exports);
|
|
21
|
+
__exportStar(require("./pipeline.js"), exports);
|
|
21
22
|
__exportStar(require("./globals.js"), exports);
|
|
22
23
|
__exportStar(require("./helpers.js"), exports);
|
|
23
24
|
__exportStar(require("./render/layout.js"), exports);
|
|
25
|
+
__exportStar(require("./render/render.js"), exports);
|
|
26
|
+
__exportStar(require("./render/KiCadNetListOutputHandler.js"), exports);
|
|
24
27
|
__exportStar(require("./lexer.js"), exports);
|
|
25
28
|
__exportStar(require("./LexerDiagnosticListener.js"), exports);
|
|
26
29
|
__exportStar(require("./logger.js"), exports);
|
|
27
30
|
__exportStar(require("./parser.js"), exports);
|
|
28
|
-
__exportStar(require("./render/render.js"), exports);
|
|
29
31
|
__exportStar(require("./utils.js"), exports);
|
|
30
32
|
__exportStar(require("./visitor.js"), exports);
|
|
31
33
|
__exportStar(require("./sizing.js"), exports);
|
|
@@ -34,5 +36,7 @@ __exportStar(require("./builtinMethods.js"), exports);
|
|
|
34
36
|
__exportStar(require("./validate/SymbolTable.js"), exports);
|
|
35
37
|
__exportStar(require("./validate/SymbolValidatorResolveVisitor.js"), exports);
|
|
36
38
|
__exportStar(require("./validate/SymbolValidatorVisitor.js"), exports);
|
|
39
|
+
__exportStar(require("./validate/validateScript.js"), exports);
|
|
37
40
|
__exportStar(require("./environment/environment.js"), exports);
|
|
38
41
|
__exportStar(require("./annotate/RefdesAnnotationVisitor.js"), exports);
|
|
42
|
+
__exportStar(require("./semantic-tokens/getSemanticTokens.js"), exports);
|
package/dist/cjs/lexer.js
CHANGED
|
@@ -8,13 +8,17 @@ const LexerDiagnosticListener_js_1 = require("./LexerDiagnosticListener.js");
|
|
|
8
8
|
class MainLexer extends CircuitScriptLexer_js_1.CircuitScriptLexer {
|
|
9
9
|
constructor(input, enableDiagnostics = false) {
|
|
10
10
|
super(input);
|
|
11
|
+
this.enableDiagnostics = false;
|
|
11
12
|
this.tokens = [];
|
|
12
13
|
this.tokensHead = 0;
|
|
13
14
|
this.indents = [];
|
|
14
15
|
this.opened = 0;
|
|
15
16
|
this.lineOffset = 0;
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
17
|
+
this.enableDiagnostics = enableDiagnostics;
|
|
18
|
+
if (this.enableDiagnostics) {
|
|
19
|
+
this.diagnosticCollector = new LexerDiagnosticListener_js_1.LexerDiagnosticCollector();
|
|
20
|
+
this.diagnosticCollector.setEnabled(enableDiagnostics);
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
23
|
reset() {
|
|
20
24
|
this.tokens = [];
|
|
@@ -24,10 +28,10 @@ class MainLexer extends CircuitScriptLexer_js_1.CircuitScriptLexer {
|
|
|
24
28
|
super.reset();
|
|
25
29
|
}
|
|
26
30
|
emitToken(token) {
|
|
27
|
-
this.diagnosticCollector.onTokenStart();
|
|
31
|
+
this.enableDiagnostics && this.diagnosticCollector.onTokenStart();
|
|
28
32
|
super.emitToken(token);
|
|
29
33
|
this.tokens.push(token);
|
|
30
|
-
this.diagnosticCollector.onTokenGenerated(token, this.tokens.length - this.tokensHead);
|
|
34
|
+
this.enableDiagnostics && this.diagnosticCollector.onTokenGenerated(token, this.tokens.length - this.tokensHead);
|
|
31
35
|
}
|
|
32
36
|
nextToken() {
|
|
33
37
|
if (this.inputStream.LA(1) === CircuitScriptParser_js_1.CircuitScriptParser.EOF && this.indents.length) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlockTypes = void 0;
|
|
4
|
+
var BlockTypes;
|
|
5
|
+
(function (BlockTypes) {
|
|
6
|
+
BlockTypes[BlockTypes["Branch"] = 1] = "Branch";
|
|
7
|
+
BlockTypes[BlockTypes["Join"] = 2] = "Join";
|
|
8
|
+
BlockTypes[BlockTypes["Parallel"] = 3] = "Parallel";
|
|
9
|
+
BlockTypes[BlockTypes["Point"] = 4] = "Point";
|
|
10
|
+
})(BlockTypes || (exports.BlockTypes = BlockTypes = {}));
|