circuitscript 0.1.16 → 0.1.18
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 +2 -1
- package/dist/cjs/draw_symbols.js +18 -17
- package/dist/cjs/execute.js +45 -26
- package/dist/cjs/export.js +3 -3
- package/dist/cjs/globals.js +1 -0
- package/dist/cjs/graph.js +101 -27
- package/dist/cjs/helpers.js +55 -22
- package/dist/cjs/layout.js +6 -1
- package/dist/cjs/objects/ClassComponent.js +27 -20
- package/dist/cjs/objects/ExecutionScope.js +9 -4
- package/dist/cjs/objects/Net.js +2 -1
- package/dist/cjs/objects/PinDefinition.js +55 -3
- package/dist/cjs/objects/types.js +17 -1
- package/dist/cjs/visitor.js +78 -20
- package/dist/esm/BaseVisitor.js +2 -1
- package/dist/esm/draw_symbols.js +18 -17
- package/dist/esm/execute.js +46 -27
- package/dist/esm/export.js +1 -1
- package/dist/esm/globals.js +1 -0
- package/dist/esm/graph.js +79 -28
- package/dist/esm/helpers.js +46 -21
- package/dist/esm/layout.js +6 -1
- package/dist/esm/objects/ClassComponent.js +28 -21
- package/dist/esm/objects/ExecutionScope.js +9 -4
- package/dist/esm/objects/Net.js +2 -1
- package/dist/esm/objects/PinDefinition.js +53 -2
- package/dist/esm/objects/types.js +16 -0
- package/dist/esm/visitor.js +80 -22
- package/dist/libs/std.cst +3 -2
- package/dist/types/BaseVisitor.d.ts +2 -1
- package/dist/types/draw_symbols.d.ts +13 -7
- package/dist/types/execute.d.ts +7 -7
- package/dist/types/export.d.ts +2 -2
- package/dist/types/globals.d.ts +1 -0
- package/dist/types/graph.d.ts +2 -1
- package/dist/types/helpers.d.ts +15 -2
- package/dist/types/layout.d.ts +2 -1
- package/dist/types/objects/ClassComponent.d.ts +8 -8
- package/dist/types/objects/ExecutionScope.d.ts +7 -6
- package/dist/types/objects/Net.d.ts +3 -2
- package/dist/types/objects/PinDefinition.d.ts +17 -2
- package/dist/types/objects/types.d.ts +17 -2
- package/dist/types/visitor.d.ts +1 -0
- package/libs/std.cst +3 -2
- package/package.json +2 -1
|
@@ -1,4 +1,47 @@
|
|
|
1
|
+
import { RuntimeExecutionError } from '../utils.js';
|
|
2
|
+
import { NumericValue } from './ParamDefinition.js';
|
|
1
3
|
import { PinTypes } from './PinTypes.js';
|
|
4
|
+
export class PinId {
|
|
5
|
+
value;
|
|
6
|
+
type;
|
|
7
|
+
constructor(value) {
|
|
8
|
+
if (typeof value !== 'string' && typeof value !== 'number') {
|
|
9
|
+
throw new RuntimeExecutionError("Invalid value for PinId: " + value);
|
|
10
|
+
}
|
|
11
|
+
this.value = value;
|
|
12
|
+
this.type = typeof value === 'number' ? PinIdType.Int : PinIdType.Str;
|
|
13
|
+
}
|
|
14
|
+
getValue() {
|
|
15
|
+
return this.value;
|
|
16
|
+
}
|
|
17
|
+
getType() {
|
|
18
|
+
return this.type;
|
|
19
|
+
}
|
|
20
|
+
isNumeric() {
|
|
21
|
+
return this.type === PinIdType.Int;
|
|
22
|
+
}
|
|
23
|
+
isString() {
|
|
24
|
+
return this.type === PinIdType.Str;
|
|
25
|
+
}
|
|
26
|
+
toString() {
|
|
27
|
+
return this.value.toString();
|
|
28
|
+
}
|
|
29
|
+
equals(other) {
|
|
30
|
+
if (other instanceof PinId) {
|
|
31
|
+
return this.value === other.value;
|
|
32
|
+
}
|
|
33
|
+
return this.value === other;
|
|
34
|
+
}
|
|
35
|
+
static from(value) {
|
|
36
|
+
if (value instanceof NumericValue) {
|
|
37
|
+
return new PinId(value.toNumber());
|
|
38
|
+
}
|
|
39
|
+
return new PinId(value);
|
|
40
|
+
}
|
|
41
|
+
static isPinIdType(value) {
|
|
42
|
+
return (typeof value === 'number' || typeof value === 'string');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
2
45
|
export class PinDefinition {
|
|
3
46
|
id;
|
|
4
47
|
idType;
|
|
@@ -8,8 +51,8 @@ export class PinDefinition {
|
|
|
8
51
|
side = PortSide.EAST;
|
|
9
52
|
position = -1;
|
|
10
53
|
constructor(id, idType, name, pinType = PinTypes.Any, altNames = []) {
|
|
11
|
-
this.id = id;
|
|
12
|
-
this.idType =
|
|
54
|
+
this.id = id instanceof PinId ? id : new PinId(id);
|
|
55
|
+
this.idType = this.id.getType();
|
|
13
56
|
this.pinType = pinType;
|
|
14
57
|
this.name = name;
|
|
15
58
|
this.altNames = altNames;
|
|
@@ -27,3 +70,11 @@ export var PortSide;
|
|
|
27
70
|
PortSide["SOUTH"] = "SOUTH";
|
|
28
71
|
PortSide["NORTH"] = "NORTH";
|
|
29
72
|
})(PortSide || (PortSide = {}));
|
|
73
|
+
export function isPinId(item) {
|
|
74
|
+
return item instanceof PinId || (typeof item === 'number' || typeof item === 'string');
|
|
75
|
+
}
|
|
76
|
+
export function getPinDefinition(map, id) {
|
|
77
|
+
const keys = Array.from(map.keys());
|
|
78
|
+
const tmpKey = keys.find(item => item.equals(id));
|
|
79
|
+
return map.get(tmpKey);
|
|
80
|
+
}
|
|
@@ -106,3 +106,19 @@ export var Direction;
|
|
|
106
106
|
Direction["Down"] = "down";
|
|
107
107
|
Direction["Up"] = "up";
|
|
108
108
|
})(Direction || (Direction = {}));
|
|
109
|
+
export var TypeProps;
|
|
110
|
+
(function (TypeProps) {
|
|
111
|
+
TypeProps["Net"] = "net";
|
|
112
|
+
TypeProps["Port"] = "port";
|
|
113
|
+
TypeProps["Graphic"] = "graphic";
|
|
114
|
+
TypeProps["Module"] = "module";
|
|
115
|
+
TypeProps["Resistor"] = "res";
|
|
116
|
+
TypeProps["Capacitor"] = "cap";
|
|
117
|
+
TypeProps["Inductor"] = "ind";
|
|
118
|
+
TypeProps["Diode"] = "diode";
|
|
119
|
+
})(TypeProps || (TypeProps = {}));
|
|
120
|
+
export var NetTypes;
|
|
121
|
+
(function (NetTypes) {
|
|
122
|
+
NetTypes["Any"] = "any";
|
|
123
|
+
NetTypes["Source"] = "source";
|
|
124
|
+
})(NetTypes || (NetTypes = {}));
|
package/dist/esm/visitor.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClassComponent } from './objects/ClassComponent.js';
|
|
2
2
|
import { NumberOperator, numeric, NumericValue, ParamDefinition } from './objects/ParamDefinition.js';
|
|
3
|
-
import { PinDefinition, PinIdType } from './objects/PinDefinition.js';
|
|
3
|
+
import { PinDefinition, PinId, PinIdType } from './objects/PinDefinition.js';
|
|
4
4
|
import { PinTypes } from './objects/PinTypes.js';
|
|
5
|
-
import { AnyReference, DeclaredReference, UndeclaredReference } from './objects/types.js';
|
|
5
|
+
import { AnyReference, DeclaredReference, TypeProps, UndeclaredReference } from './objects/types.js';
|
|
6
6
|
import { BlockTypes, ComponentTypes, Delimiter1, FrameType, GlobalDocumentName, ModuleContainsKeyword, NoNetText, ParamKeys, ReferenceTypes, SymbolPinSide, ValidPinSides, WireAutoDirection } from './globals.js';
|
|
7
7
|
import { unwrapValue } from "./utils.js";
|
|
8
8
|
import { PlaceHolderCommands, SymbolDrawingCommands } from './draw_symbols.js';
|
|
@@ -17,19 +17,23 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
17
17
|
this.setResult(ctx, [id, value]);
|
|
18
18
|
};
|
|
19
19
|
visitPin_select_expr = (ctx) => {
|
|
20
|
-
let
|
|
20
|
+
let pinId = null;
|
|
21
21
|
const ctxData = ctx.data_expr();
|
|
22
22
|
const result = this.visitResult(ctxData);
|
|
23
|
+
let pinValue;
|
|
23
24
|
if (result instanceof NumericValue) {
|
|
24
|
-
|
|
25
|
+
pinValue = result.toNumber();
|
|
25
26
|
}
|
|
26
27
|
else if (typeof result === 'string') {
|
|
27
|
-
|
|
28
|
+
pinValue = result;
|
|
28
29
|
}
|
|
29
30
|
else {
|
|
30
|
-
throw new RuntimeExecutionError("Invalid
|
|
31
|
+
throw new RuntimeExecutionError("Invalid select pin: " + result, ctx);
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
if (pinValue !== undefined) {
|
|
34
|
+
pinId = new PinId(pinValue);
|
|
35
|
+
}
|
|
36
|
+
this.setResult(ctx, pinId);
|
|
33
37
|
};
|
|
34
38
|
visitAdd_component_expr = (ctx) => {
|
|
35
39
|
const [component, pinValue] = this.visitResult(ctx.data_expr_with_assignment());
|
|
@@ -216,11 +220,18 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
216
220
|
}
|
|
217
221
|
}
|
|
218
222
|
else {
|
|
219
|
-
if (!(value instanceof NumericValue)) {
|
|
223
|
+
if (!(value instanceof NumericValue) && !(typeof value === 'string')) {
|
|
220
224
|
throw new RuntimeExecutionError(`Invalid numeric value for arrange.${sideKeyName}`, ctx);
|
|
221
225
|
}
|
|
222
226
|
else {
|
|
223
|
-
|
|
227
|
+
let useValue;
|
|
228
|
+
if (value instanceof NumericValue) {
|
|
229
|
+
useValue = value.toNumber();
|
|
230
|
+
}
|
|
231
|
+
else if (typeof value === 'string') {
|
|
232
|
+
useValue = value;
|
|
233
|
+
}
|
|
234
|
+
value && checkPinExistsAndNotDuplicated(useValue, ctx);
|
|
224
235
|
}
|
|
225
236
|
}
|
|
226
237
|
}
|
|
@@ -260,7 +271,6 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
260
271
|
scope.exitContext();
|
|
261
272
|
scope.popOnPropertyHandler();
|
|
262
273
|
const properties = this.getPropertyExprList(ctx.property_expr());
|
|
263
|
-
const pins = this.parseCreateComponentPins(properties.get('pins'));
|
|
264
274
|
let instanceName = this.getExecutor().getUniqueInstanceName();
|
|
265
275
|
const propParams = properties.get('params');
|
|
266
276
|
const params = this.parseCreateComponentParams(propParams);
|
|
@@ -273,11 +283,11 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
273
283
|
}
|
|
274
284
|
instanceName += `${Delimiter1}${appendValue}`;
|
|
275
285
|
}
|
|
276
|
-
const
|
|
286
|
+
const arrangeProp = properties.has('arrange') ?
|
|
277
287
|
properties.get('arrange') : null;
|
|
278
|
-
const
|
|
288
|
+
const displayProp = properties.has('display') ?
|
|
279
289
|
properties.get('display') : null;
|
|
280
|
-
const
|
|
290
|
+
const typeProp = properties.has('type') ?
|
|
281
291
|
properties.get('type') : null;
|
|
282
292
|
const copy = properties.has('copy') ?
|
|
283
293
|
properties.get('copy') : false;
|
|
@@ -289,8 +299,29 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
289
299
|
properties.get(ParamKeys.angle) : null;
|
|
290
300
|
const followWireOrientation = properties.has('followWireOrientation') ?
|
|
291
301
|
properties.get('followWireOrientation') : true;
|
|
302
|
+
let pins = [];
|
|
303
|
+
if (displayProp !== null && arrangeProp === null
|
|
304
|
+
&& typeProp !== TypeProps.Graphic) {
|
|
305
|
+
const drawCommands = displayProp.getCommands();
|
|
306
|
+
drawCommands.forEach(command => {
|
|
307
|
+
const [commandValue,] = command;
|
|
308
|
+
if (commandValue === PlaceHolderCommands.vpin
|
|
309
|
+
|| commandValue === PlaceHolderCommands.hpin
|
|
310
|
+
|| commandValue === PlaceHolderCommands.pin) {
|
|
311
|
+
const id = PinId.from(command[1][0]);
|
|
312
|
+
const pinType = id.getType();
|
|
313
|
+
const pinName = id.toString();
|
|
314
|
+
pins.push(new PinDefinition(id, pinType, pinName, PinTypes.Any));
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
pins = this.parseCreateComponentPins(properties.get('pins'));
|
|
320
|
+
}
|
|
292
321
|
const props = {
|
|
293
|
-
arrange
|
|
322
|
+
arrange: arrangeProp,
|
|
323
|
+
display: displayProp,
|
|
324
|
+
type: typeProp, width, height, copy,
|
|
294
325
|
angle, followWireOrientation
|
|
295
326
|
};
|
|
296
327
|
try {
|
|
@@ -852,14 +883,21 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
852
883
|
visitPin_select_expr2 = (ctx) => {
|
|
853
884
|
const ctxStringValue = ctx.STRING_VALUE();
|
|
854
885
|
const ctxIntegerValue = ctx.INTEGER_VALUE();
|
|
855
|
-
let
|
|
886
|
+
let pinIdValue;
|
|
887
|
+
let pinId = null;
|
|
856
888
|
if (ctxStringValue) {
|
|
857
|
-
|
|
889
|
+
pinIdValue = this.prepareStringValue(ctxStringValue.getText());
|
|
858
890
|
}
|
|
859
891
|
else if (ctxIntegerValue) {
|
|
860
|
-
|
|
892
|
+
pinIdValue = Number(ctxIntegerValue.getText());
|
|
861
893
|
}
|
|
862
|
-
|
|
894
|
+
if (pinIdValue !== undefined) {
|
|
895
|
+
pinId = new PinId(pinIdValue);
|
|
896
|
+
}
|
|
897
|
+
else {
|
|
898
|
+
throw new RuntimeExecutionError("Invalid select pin", ctx);
|
|
899
|
+
}
|
|
900
|
+
this.setResult(ctx, pinId);
|
|
863
901
|
};
|
|
864
902
|
visitAt_block_pin_expr = (ctx) => {
|
|
865
903
|
const executor = this.getExecutor();
|
|
@@ -1200,7 +1238,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1200
1238
|
return item;
|
|
1201
1239
|
}
|
|
1202
1240
|
else {
|
|
1203
|
-
return
|
|
1241
|
+
return new PinId(nameToPinId.get(item));
|
|
1204
1242
|
}
|
|
1205
1243
|
});
|
|
1206
1244
|
if (items.length > 0) {
|
|
@@ -1291,7 +1329,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1291
1329
|
getGraph() {
|
|
1292
1330
|
const executor = this.getExecutor();
|
|
1293
1331
|
const fullSequence = executor.scope.sequence;
|
|
1294
|
-
const tmpNet = executor.scope.getNet(executor.scope.componentRoot, 1);
|
|
1332
|
+
const tmpNet = executor.scope.getNet(executor.scope.componentRoot, new PinId(1));
|
|
1295
1333
|
const sequence = (tmpNet === null)
|
|
1296
1334
|
? fullSequence.slice(1) : fullSequence;
|
|
1297
1335
|
const nets = executor.scope.getNets();
|
|
@@ -1336,8 +1374,28 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1336
1374
|
this.log('Failed to annotate:', instance.instanceName);
|
|
1337
1375
|
}
|
|
1338
1376
|
});
|
|
1339
|
-
this.log('===== annotate done =====');
|
|
1340
|
-
this.log('');
|
|
1377
|
+
this.log('===== annotate components done =====');
|
|
1378
|
+
this.log('===== rename nets =====');
|
|
1379
|
+
this.renameNetsWithRefdes();
|
|
1380
|
+
this.log('===== rename nets done =====');
|
|
1381
|
+
}
|
|
1382
|
+
renameNetsWithRefdes() {
|
|
1383
|
+
const nets = this.getScope().getNets();
|
|
1384
|
+
const seenNets = [];
|
|
1385
|
+
const uniqueNets = new Set(nets.map(([, , net]) => net));
|
|
1386
|
+
const fullNetNames = Array.from(uniqueNets).map(item => item.toString());
|
|
1387
|
+
nets.forEach(([component, pin, net]) => {
|
|
1388
|
+
if (net.priority === 0 && seenNets.indexOf(net) === -1
|
|
1389
|
+
&& component.typeProp !== TypeProps.Module
|
|
1390
|
+
&& component.typeProp !== TypeProps.Net) {
|
|
1391
|
+
net.name = net.baseName =
|
|
1392
|
+
`NET-(${component.assignedRefDes}-${pin.toString()})`;
|
|
1393
|
+
if (fullNetNames.indexOf(net.toString()) !== -1) {
|
|
1394
|
+
throw new RuntimeExecutionError('Net renaming failed due to clash: ' + net);
|
|
1395
|
+
}
|
|
1396
|
+
seenNets.push(net);
|
|
1397
|
+
}
|
|
1398
|
+
});
|
|
1341
1399
|
}
|
|
1342
1400
|
applySheetFrameComponent() {
|
|
1343
1401
|
const baseScope = this.getScope();
|
package/dist/libs/std.cst
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Circuitscript default lib
|
|
2
2
|
|
|
3
|
-
def net(net_name):
|
|
3
|
+
def net(net_name, net_type = "any"):
|
|
4
4
|
return create component:
|
|
5
5
|
pins: 1
|
|
6
6
|
copy: true
|
|
@@ -13,9 +13,10 @@ def net(net_name):
|
|
|
13
13
|
params:
|
|
14
14
|
net_name: net_name
|
|
15
15
|
priority: 10
|
|
16
|
+
net_type: net_type
|
|
16
17
|
|
|
17
18
|
def supply(net_name):
|
|
18
|
-
net_obj = net(net_name)
|
|
19
|
+
net_obj = net(net_name, "source")
|
|
19
20
|
return net_obj
|
|
20
21
|
|
|
21
22
|
def label(value, anchor="left"):
|
|
@@ -10,6 +10,7 @@ import { ExecutionWarning } from "./utils.js";
|
|
|
10
10
|
import { BaseError } from './utils.js';
|
|
11
11
|
import { ExecutionScope } from './objects/ExecutionScope.js';
|
|
12
12
|
import { NodeScriptEnvironment } from "./environment.js";
|
|
13
|
+
import { PinId } from './objects/PinDefinition.js';
|
|
13
14
|
export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyReference | any> {
|
|
14
15
|
indentLevel: number;
|
|
15
16
|
startingContext: ExecutionContext;
|
|
@@ -38,7 +39,7 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyR
|
|
|
38
39
|
found: boolean;
|
|
39
40
|
net?: Net;
|
|
40
41
|
};
|
|
41
|
-
createComponentPinNetResolver(executionStack: ExecutionContext[]): (component: ClassComponent, pin:
|
|
42
|
+
createComponentPinNetResolver(executionStack: ExecutionContext[]): (component: ClassComponent, pin: PinId) => Net | null;
|
|
42
43
|
log(...params: any[]): void;
|
|
43
44
|
log2(message: string): void;
|
|
44
45
|
visitAsync(ctx: ParserRuleContext): Promise<void>;
|
|
@@ -4,6 +4,7 @@ import { Logger } from "./logger.js";
|
|
|
4
4
|
import { PinTypes } from "./objects/PinTypes.js";
|
|
5
5
|
import { ParserRuleContext } from "antlr4ng";
|
|
6
6
|
import { NumericValue } from "./objects/ParamDefinition.js";
|
|
7
|
+
import { PinId } from "./objects/PinDefinition.js";
|
|
7
8
|
export declare abstract class SymbolGraphic {
|
|
8
9
|
drawPortsName: boolean;
|
|
9
10
|
displayBounds: boolean;
|
|
@@ -37,7 +38,7 @@ export declare abstract class SymbolGraphic {
|
|
|
37
38
|
drawPlaceRemove(group: G, extra?: {
|
|
38
39
|
place?: boolean;
|
|
39
40
|
}): void;
|
|
40
|
-
pinPosition(id:
|
|
41
|
+
pinPosition(id: PinId): {
|
|
41
42
|
x: NumericValue;
|
|
42
43
|
y: NumericValue;
|
|
43
44
|
angle: NumericValue;
|
|
@@ -131,7 +132,7 @@ export declare class SymbolCustomModule extends SymbolCustom {
|
|
|
131
132
|
}
|
|
132
133
|
export declare class SymbolDrawing {
|
|
133
134
|
items: (Feature | GeometryProp)[];
|
|
134
|
-
pins: [
|
|
135
|
+
pins: PinRenderInfo[];
|
|
135
136
|
angle: number;
|
|
136
137
|
flipX: number;
|
|
137
138
|
flipY: number;
|
|
@@ -141,8 +142,7 @@ export declare class SymbolDrawing {
|
|
|
141
142
|
clear(): void;
|
|
142
143
|
log(...params: any[]): void;
|
|
143
144
|
addLine(startX: NumericValue, startY: NumericValue, endX: NumericValue, endY: NumericValue): SymbolDrawing;
|
|
144
|
-
|
|
145
|
-
addPinMM(pinId: NumericValue, startXMM: NumericValue, startYMM: NumericValue, endXMM: NumericValue, endYMM: NumericValue, lineColor: string): SymbolDrawing;
|
|
145
|
+
addPinMM(pinId: PinId, startXMM: NumericValue, startYMM: NumericValue, endXMM: NumericValue, endYMM: NumericValue, lineColor: string): SymbolDrawing;
|
|
146
146
|
addVLine(startX: NumericValue, startY: NumericValue, value: NumericValue): SymbolDrawing;
|
|
147
147
|
addHLine(startX: NumericValue, startY: NumericValue, value: NumericValue): SymbolDrawing;
|
|
148
148
|
addRect(x: NumericValue, y: NumericValue, width: NumericValue, height: NumericValue): SymbolDrawing;
|
|
@@ -177,7 +177,7 @@ export declare class SymbolDrawing {
|
|
|
177
177
|
start: SimplePoint;
|
|
178
178
|
end: SimplePoint;
|
|
179
179
|
};
|
|
180
|
-
getPinPosition(pinId:
|
|
180
|
+
getPinPosition(pinId: PinId): {
|
|
181
181
|
start: [x: NumericValue, y: NumericValue];
|
|
182
182
|
end: [x: NumericValue, y: NumericValue];
|
|
183
183
|
angle: NumericValue;
|
|
@@ -191,7 +191,7 @@ export type GraphicExprCommand = [
|
|
|
191
191
|
];
|
|
192
192
|
export declare class SymbolDrawingCommands extends SymbolDrawing {
|
|
193
193
|
id: string;
|
|
194
|
-
|
|
194
|
+
protected commands: GraphicExprCommand[];
|
|
195
195
|
paramIds: string[];
|
|
196
196
|
callback: (variables: Map<string, any>) => GraphicExprCommand[];
|
|
197
197
|
constructor(callback: (variables: Map<string, any>) => GraphicExprCommand[]);
|
|
@@ -216,9 +216,15 @@ type SymbolPinLayout = {
|
|
|
216
216
|
};
|
|
217
217
|
export type SymbolPinDefintion = {
|
|
218
218
|
side: string;
|
|
219
|
-
pinId:
|
|
219
|
+
pinId: PinId;
|
|
220
220
|
text: string;
|
|
221
221
|
position: number;
|
|
222
222
|
pinType: PinTypes;
|
|
223
223
|
};
|
|
224
|
+
export type PinRenderInfo = [
|
|
225
|
+
PinId,
|
|
226
|
+
Feature,
|
|
227
|
+
angle: NumericValue,
|
|
228
|
+
lineColor: string
|
|
229
|
+
];
|
|
224
230
|
export {};
|
package/dist/types/execute.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ClassComponent } from './objects/ClassComponent.js';
|
|
|
4
4
|
import { ExecutionScope } from './objects/ExecutionScope.js';
|
|
5
5
|
import { Net } from './objects/Net.js';
|
|
6
6
|
import { NumericValue, ParamDefinition } from './objects/ParamDefinition.js';
|
|
7
|
-
import { PinDefinition } from './objects/PinDefinition.js';
|
|
7
|
+
import { PinDefinition, PinId } from './objects/PinDefinition.js';
|
|
8
8
|
import { AnyReference, CFunction, CFunctionEntry, CFunctionResult, CallableParameter, ComponentPin } from './objects/types.js';
|
|
9
9
|
import { Logger } from './logger.js';
|
|
10
10
|
import { UnitDimension } from './helpers.js';
|
|
@@ -21,7 +21,7 @@ export declare class ExecutionContext {
|
|
|
21
21
|
found: boolean;
|
|
22
22
|
net?: Net;
|
|
23
23
|
});
|
|
24
|
-
resolveComponentPinNet: (component: ClassComponent, pin:
|
|
24
|
+
resolveComponentPinNet: (component: ClassComponent, pin: PinId) => Net | null;
|
|
25
25
|
stopFurtherExpressions: boolean;
|
|
26
26
|
returnValue: null;
|
|
27
27
|
silent: boolean;
|
|
@@ -40,7 +40,7 @@ export declare class ExecutionContext {
|
|
|
40
40
|
private linkComponentPinNet;
|
|
41
41
|
private mergeNets;
|
|
42
42
|
createComponent(instanceName: string, pins: PinDefinition[], params: ParamDefinition[], props: {
|
|
43
|
-
arrange?: Map<string,
|
|
43
|
+
arrange?: Map<string, PinId[]>;
|
|
44
44
|
display?: SymbolDrawingCommands;
|
|
45
45
|
type?: string;
|
|
46
46
|
width?: number;
|
|
@@ -52,11 +52,11 @@ export declare class ExecutionContext {
|
|
|
52
52
|
private removeArrangePropDuplicates;
|
|
53
53
|
private getArrangePropPins;
|
|
54
54
|
printPoint(extra?: string): void;
|
|
55
|
-
addComponentExisting(component: ClassComponent, pin:
|
|
55
|
+
addComponentExisting(component: ClassComponent, pin: PinId): ComponentPin;
|
|
56
56
|
toComponent(component: ClassComponent, pinId: number | null, options?: {
|
|
57
57
|
addSequence?: boolean;
|
|
58
58
|
}): ComponentPin;
|
|
59
|
-
atComponent(component: ClassComponent, pinId:
|
|
59
|
+
atComponent(component: ClassComponent, pinId: PinId | null, options?: {
|
|
60
60
|
addSequence?: boolean;
|
|
61
61
|
}): ComponentPin;
|
|
62
62
|
copyComponent(component: ClassComponent): ClassComponent;
|
|
@@ -86,12 +86,12 @@ export declare class ExecutionContext {
|
|
|
86
86
|
enterFrame(frameType: FrameType): number;
|
|
87
87
|
exitFrame(frameId: number): void;
|
|
88
88
|
}
|
|
89
|
-
export declare function getPortSide(pins: Map<
|
|
89
|
+
export declare function getPortSide(pins: Map<PinId, PinDefinition>, arrangeProps: null | Map<string, number[]>): {
|
|
90
90
|
pins: PortSideItem[];
|
|
91
91
|
maxPositions: Map<string, number>;
|
|
92
92
|
};
|
|
93
93
|
type PortSideItem = {
|
|
94
|
-
pinId:
|
|
94
|
+
pinId: PinId;
|
|
95
95
|
side: string;
|
|
96
96
|
order: number;
|
|
97
97
|
position: number;
|
package/dist/types/export.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { NetListItem } from "./visitor.js";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function generateKiCadNetList(netlist: NetListItem[]): {
|
|
3
3
|
tree: SExp;
|
|
4
4
|
missingFootprints: {
|
|
5
5
|
refdes: string;
|
|
6
6
|
instanceName: string;
|
|
7
7
|
}[];
|
|
8
8
|
};
|
|
9
|
-
export declare function printTree(tree:
|
|
9
|
+
export declare function printTree(tree: any, level?: number): string;
|
|
10
10
|
export declare class IdObject {
|
|
11
11
|
keyName: string;
|
|
12
12
|
constructor(keyName: string);
|
package/dist/types/globals.d.ts
CHANGED
package/dist/types/graph.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ import { SequenceItem } from "./objects/ExecutionScope.js";
|
|
|
6
6
|
import { Net } from "./objects/Net.js";
|
|
7
7
|
import { Logger } from "./logger.js";
|
|
8
8
|
import { ComponentPinNetPair } from "./objects/types.js";
|
|
9
|
+
import { PinId } from "./objects/PinDefinition.js";
|
|
9
10
|
export declare class NetGraph {
|
|
10
11
|
logger: Logger;
|
|
11
12
|
constructor(logger: Logger);
|
|
12
|
-
generateLayoutGraph(sequence: SequenceItem[], nets: [ClassComponent, pin:
|
|
13
|
+
generateLayoutGraph(sequence: SequenceItem[], nets: [ClassComponent, pin: PinId, net: Net][]): {
|
|
13
14
|
graph: Graph;
|
|
14
15
|
containerFrames: RenderFrame[];
|
|
15
16
|
};
|
package/dist/types/helpers.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseError } from "./utils.js";
|
|
2
|
+
import { ParserVisitor } from "./visitor.js";
|
|
2
3
|
import { SymbolValidatorVisitor } from "./validate/SymbolValidatorVisitor.js";
|
|
3
4
|
import { CommonTokenStream, DefaultErrorStrategy, Parser } from "antlr4ng";
|
|
4
5
|
import { CircuitScriptParser } from "./antlr/CircuitScriptParser.js";
|
|
@@ -32,10 +33,21 @@ export declare class ParseErrorStrategy extends DefaultErrorStrategy {
|
|
|
32
33
|
reportUnwantedToken(recognizer: Parser): void;
|
|
33
34
|
}
|
|
34
35
|
export declare function validateScript(filePath: string, scriptData: string, options: ScriptOptions): Promise<SymbolValidatorVisitor>;
|
|
35
|
-
|
|
36
|
+
type RenderScriptReturn = {
|
|
36
37
|
svgOutput: string | null;
|
|
37
38
|
errors: BaseError[];
|
|
38
|
-
}
|
|
39
|
+
};
|
|
40
|
+
export declare function renderScript(scriptData: string, outputPath: string | null, options: ScriptOptions): Promise<RenderScriptReturn>;
|
|
41
|
+
export declare function renderScriptCustom(scriptData: string, outputPath: string | null, options: ScriptOptions, parseHandlers: ParseOutputHandler[]): Promise<RenderScriptReturn>;
|
|
42
|
+
export declare abstract class ParseOutputHandler {
|
|
43
|
+
beforeRender: boolean;
|
|
44
|
+
afterRender: boolean;
|
|
45
|
+
abstract parse(visitor: ParserVisitor, outputPath: string | null, fileExtension: string | null): boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare class KiCadNetListOutputHandler extends ParseOutputHandler {
|
|
48
|
+
beforeRender: boolean;
|
|
49
|
+
parse(visitor: ParserVisitor, outputPath: string | null, fileExtension: string | null): boolean;
|
|
50
|
+
}
|
|
39
51
|
export declare function detectJSModuleType(): JSModuleType;
|
|
40
52
|
export declare class UnitDimension {
|
|
41
53
|
type: LengthUnit;
|
|
@@ -60,3 +72,4 @@ export declare function getPaperSize(type: string, margin?: number): {
|
|
|
60
72
|
originalWidthMM: number;
|
|
61
73
|
originalHeightMM: number;
|
|
62
74
|
};
|
|
75
|
+
export {};
|
package/dist/types/layout.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Logger } from './logger.js';
|
|
|
8
8
|
import { Frame, FramePlotDirection } from './objects/Frame.js';
|
|
9
9
|
import { BoundBox } from './utils.js';
|
|
10
10
|
import { ComponentPinNetPair } from './objects/types.js';
|
|
11
|
+
import { PinId } from './objects/PinDefinition.js';
|
|
11
12
|
import { NumericValue } from './objects/ParamDefinition.js';
|
|
12
13
|
export declare class LayoutEngine {
|
|
13
14
|
logger: Logger;
|
|
@@ -35,7 +36,7 @@ export declare class LayoutEngine {
|
|
|
35
36
|
private placeSubgraphV2;
|
|
36
37
|
mergeOriginNodes(node1: RenderItem, pin1: number, node2: RenderItem, pin2: number, originNode1: string, originNode2: string, originNodes: RenderItem[], originNodeGroups: Map<string, RenderItem[]>): void;
|
|
37
38
|
translateNodeBy(offsetX: number, offsetY: number, item: RenderItem): void;
|
|
38
|
-
placeNodeAtPosition(fromX: NumericValue, fromY: NumericValue, item: RenderItem, pin:
|
|
39
|
+
placeNodeAtPosition(fromX: NumericValue, fromY: NumericValue, item: RenderItem, pin: PinId, depth?: number): void;
|
|
39
40
|
placeFloatingItems(graph: Graph, item: RenderItem, depth?: number): void;
|
|
40
41
|
printWarnings(): void;
|
|
41
42
|
}
|
|
@@ -9,8 +9,8 @@ export declare class ClassComponent {
|
|
|
9
9
|
instanceName: string;
|
|
10
10
|
numPins: number;
|
|
11
11
|
parameters: Map<string, number | string | NumericValue>;
|
|
12
|
-
pins: Map<
|
|
13
|
-
pinNets: Map<
|
|
12
|
+
pins: Map<PinId, PinDefinition>;
|
|
13
|
+
pinNets: Map<PinId, Net>;
|
|
14
14
|
pinWires: Map<number, WireSegment[]>;
|
|
15
15
|
pinsMaxPositions: Map<string, number>;
|
|
16
16
|
_cachedPins: string;
|
|
@@ -18,8 +18,8 @@ export declare class ClassComponent {
|
|
|
18
18
|
_copyID?: number;
|
|
19
19
|
_copyFrom?: ClassComponent;
|
|
20
20
|
_pointLinkComponent?: ClassComponent;
|
|
21
|
-
_unplacedPins:
|
|
22
|
-
arrangeProps: Map<string,
|
|
21
|
+
_unplacedPins: PinId[];
|
|
22
|
+
arrangeProps: Map<string, PinId[]> | null;
|
|
23
23
|
displayProp: SymbolDrawingCommands | null;
|
|
24
24
|
widthProp: number | null;
|
|
25
25
|
heightProp: number | null;
|
|
@@ -33,10 +33,10 @@ export declare class ClassComponent {
|
|
|
33
33
|
assignedRefDes: string | null;
|
|
34
34
|
constructor(instanceName: string, numPins: number);
|
|
35
35
|
setupPins(): void;
|
|
36
|
-
getDefaultPin():
|
|
37
|
-
hasPin(pinId:
|
|
38
|
-
getPin(pinId:
|
|
39
|
-
getNextPinAfter(pinIndex:
|
|
36
|
+
getDefaultPin(): PinId;
|
|
37
|
+
hasPin(pinId: PinId): boolean;
|
|
38
|
+
getPin(pinId: PinId): PinId;
|
|
39
|
+
getNextPinAfter(pinIndex: PinId): PinId;
|
|
40
40
|
setParam(key: string, value: number | string | NumericValue): void;
|
|
41
41
|
hasParam(key: string): boolean;
|
|
42
42
|
private refreshParamCache;
|
|
@@ -6,6 +6,7 @@ import { Wire, WireSegment } from './Wire.js';
|
|
|
6
6
|
import { Frame } from './Frame.js';
|
|
7
7
|
import { ParserRuleContext } from 'antlr4ng';
|
|
8
8
|
import { BaseVisitor } from 'src/BaseVisitor.js';
|
|
9
|
+
import { PinId } from './PinDefinition.js';
|
|
9
10
|
type OnPropertyHandler = (path: PropertyTreeKey[], value: any, valueContext: ParserRuleContext) => void;
|
|
10
11
|
export type PropertyTreeKey = [ctx: ParserRuleContext, value: any] | ['index', number];
|
|
11
12
|
export declare class ExecutionScope {
|
|
@@ -27,7 +28,7 @@ export declare class ExecutionScope {
|
|
|
27
28
|
netCounter: number;
|
|
28
29
|
unnamedCounter: number;
|
|
29
30
|
currentComponent: ClassComponent | null;
|
|
30
|
-
currentPin:
|
|
31
|
+
currentPin: PinId | null;
|
|
31
32
|
currentWireId: number;
|
|
32
33
|
currentFrameId: number;
|
|
33
34
|
componentRoot: ClassComponent | null;
|
|
@@ -39,17 +40,17 @@ export declare class ExecutionScope {
|
|
|
39
40
|
private findNet;
|
|
40
41
|
getNetWithName(name: string): Net;
|
|
41
42
|
getNetWithNamespacePath(namespace: string, name: string): Net | null;
|
|
42
|
-
hasNet(component: ClassComponent, pin:
|
|
43
|
-
getNet(component: ClassComponent, pin:
|
|
44
|
-
setNet(component: ClassComponent, pin:
|
|
45
|
-
removeNet(component: ClassComponent, pin:
|
|
43
|
+
hasNet(component: ClassComponent, pin: PinId): boolean;
|
|
44
|
+
getNet(component: ClassComponent, pin: PinId): Net | null;
|
|
45
|
+
setNet(component: ClassComponent, pin: PinId, net: Net): void;
|
|
46
|
+
removeNet(component: ClassComponent, pin: PinId): void;
|
|
46
47
|
getNets(): ComponentPinNetPair[];
|
|
47
48
|
dumpNets(): ComponentPinNet[];
|
|
48
49
|
printNets(): void;
|
|
49
50
|
setVariable(name: string, value: any): void;
|
|
50
51
|
setActive(type: ActiveObject, item: any): void;
|
|
51
52
|
clearActive(): void;
|
|
52
|
-
setCurrent(component: ClassComponent | null, pin?:
|
|
53
|
+
setCurrent(component: ClassComponent | null, pin?: PinId | null): void;
|
|
53
54
|
enterContext(context: ParserRuleContext): void;
|
|
54
55
|
exitContext(): ParserRuleContext;
|
|
55
56
|
private findPropertyKeyTree;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { NetTypes } from "./types.js";
|
|
1
2
|
export declare class Net {
|
|
2
3
|
name: string;
|
|
3
4
|
baseName: string;
|
|
4
5
|
namespace: string;
|
|
5
6
|
priority: number;
|
|
6
|
-
type:
|
|
7
|
+
type: NetTypes;
|
|
7
8
|
params: Map<string, any>;
|
|
8
|
-
constructor(namespace: string, name: string, priority?: number, type?:
|
|
9
|
+
constructor(namespace: string, name: string, priority?: number, type?: NetTypes);
|
|
9
10
|
toString(): string;
|
|
10
11
|
static isSame(netA: Net, netB: Net): boolean;
|
|
11
12
|
}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
import { NumericValue } from './ParamDefinition.js';
|
|
1
2
|
import { PinTypes } from './PinTypes.js';
|
|
2
|
-
export
|
|
3
|
+
export declare class PinId {
|
|
4
|
+
private value;
|
|
5
|
+
private type;
|
|
6
|
+
constructor(value: number | string);
|
|
7
|
+
getValue(): number | string;
|
|
8
|
+
getType(): PinIdType;
|
|
9
|
+
isNumeric(): boolean;
|
|
10
|
+
isString(): boolean;
|
|
11
|
+
toString(): string;
|
|
12
|
+
equals(other: PinId | number | string): boolean;
|
|
13
|
+
static from(value: number | string | NumericValue): PinId;
|
|
14
|
+
static isPinIdType(value: number | string): boolean;
|
|
15
|
+
}
|
|
3
16
|
export declare class PinDefinition {
|
|
4
17
|
id: PinId;
|
|
5
18
|
idType: PinIdType;
|
|
@@ -8,7 +21,7 @@ export declare class PinDefinition {
|
|
|
8
21
|
altNames: string[];
|
|
9
22
|
side: string;
|
|
10
23
|
position: number;
|
|
11
|
-
constructor(id: PinId, idType: PinIdType, name: string, pinType?: PinTypes, altNames?: never[]);
|
|
24
|
+
constructor(id: PinId | number | string, idType: PinIdType, name: string, pinType?: PinTypes, altNames?: never[]);
|
|
12
25
|
}
|
|
13
26
|
export declare enum PinIdType {
|
|
14
27
|
Int = "int",
|
|
@@ -20,3 +33,5 @@ export declare enum PortSide {
|
|
|
20
33
|
SOUTH = "SOUTH",
|
|
21
34
|
NORTH = "NORTH"
|
|
22
35
|
}
|
|
36
|
+
export declare function isPinId(item: any): boolean;
|
|
37
|
+
export declare function getPinDefinition(map: Map<PinId, PinDefinition>, id: PinId): PinDefinition;
|