circuitscript 0.1.0 → 0.1.2

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.
Files changed (61) hide show
  1. package/dist/cjs/BaseVisitor.js +13 -8
  2. package/dist/cjs/antlr/CircuitScriptLexer.js +80 -80
  3. package/dist/cjs/antlr/CircuitScriptParser.js +599 -657
  4. package/dist/cjs/builtinMethods.js +27 -8
  5. package/dist/cjs/draw_symbols.js +314 -190
  6. package/dist/cjs/execute.js +113 -115
  7. package/dist/cjs/export.js +2 -4
  8. package/dist/cjs/geometry.js +52 -19
  9. package/dist/cjs/globals.js +12 -8
  10. package/dist/cjs/helpers.js +16 -3
  11. package/dist/cjs/layout.js +129 -125
  12. package/dist/cjs/logger.js +8 -1
  13. package/dist/cjs/objects/ClassComponent.js +22 -22
  14. package/dist/cjs/objects/ExecutionScope.js +10 -4
  15. package/dist/cjs/objects/Frame.js +2 -1
  16. package/dist/cjs/objects/ParamDefinition.js +120 -4
  17. package/dist/cjs/objects/PinDefinition.js +1 -4
  18. package/dist/cjs/render.js +40 -110
  19. package/dist/cjs/sizing.js +33 -7
  20. package/dist/cjs/utils.js +68 -2
  21. package/dist/cjs/visitor.js +214 -254
  22. package/dist/esm/BaseVisitor.mjs +15 -10
  23. package/dist/esm/antlr/CircuitScriptLexer.mjs +80 -80
  24. package/dist/esm/antlr/CircuitScriptParser.mjs +599 -657
  25. package/dist/esm/builtinMethods.mjs +24 -8
  26. package/dist/esm/draw_symbols.mjs +316 -193
  27. package/dist/esm/execute.mjs +115 -117
  28. package/dist/esm/export.mjs +2 -4
  29. package/dist/esm/geometry.mjs +52 -19
  30. package/dist/esm/globals.mjs +12 -8
  31. package/dist/esm/helpers.mjs +17 -4
  32. package/dist/esm/layout.mjs +131 -127
  33. package/dist/esm/logger.mjs +8 -1
  34. package/dist/esm/objects/ClassComponent.mjs +21 -26
  35. package/dist/esm/objects/ExecutionScope.mjs +10 -4
  36. package/dist/esm/objects/Frame.mjs +2 -1
  37. package/dist/esm/objects/ParamDefinition.mjs +119 -3
  38. package/dist/esm/objects/PinDefinition.mjs +0 -2
  39. package/dist/esm/render.mjs +42 -112
  40. package/dist/esm/sizing.mjs +34 -8
  41. package/dist/esm/utils.mjs +64 -1
  42. package/dist/esm/visitor.mjs +216 -256
  43. package/dist/types/BaseVisitor.d.ts +1 -1
  44. package/dist/types/antlr/CircuitScriptParser.d.ts +2 -3
  45. package/dist/types/draw_symbols.d.ts +71 -45
  46. package/dist/types/execute.d.ts +15 -10
  47. package/dist/types/geometry.d.ts +31 -19
  48. package/dist/types/globals.d.ts +14 -10
  49. package/dist/types/helpers.d.ts +2 -1
  50. package/dist/types/layout.d.ts +21 -21
  51. package/dist/types/logger.d.ts +1 -1
  52. package/dist/types/objects/ClassComponent.d.ts +19 -16
  53. package/dist/types/objects/ExecutionScope.d.ts +2 -1
  54. package/dist/types/objects/Frame.d.ts +2 -2
  55. package/dist/types/objects/ParamDefinition.d.ts +31 -2
  56. package/dist/types/objects/PinDefinition.d.ts +0 -2
  57. package/dist/types/render.d.ts +2 -1
  58. package/dist/types/utils.d.ts +6 -1
  59. package/dist/types/visitor.d.ts +4 -5
  60. package/libs/lib.cst +15 -3
  61. package/package.json +7 -3
@@ -17,9 +17,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
17
17
  super(...arguments);
18
18
  this.visitKeyword_assignment_expr = (ctx) => {
19
19
  const id = ctx.ID().getText();
20
- const ctxDataExpr = ctx.data_expr();
21
- this.visit(ctxDataExpr);
22
- const value = this.getResult(ctxDataExpr);
20
+ const value = this.visitResult(ctx.data_expr());
23
21
  this.setResult(ctx, [id, value]);
24
22
  };
25
23
  this.visitPin_select_expr = (ctx) => {
@@ -35,56 +33,48 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
35
33
  this.setResult(ctx, value);
36
34
  };
37
35
  this.visitAdd_component_expr = (ctx) => {
38
- const ctxDataWithAssignmentExpr = ctx.data_expr_with_assignment();
39
- this.visit(ctxDataWithAssignmentExpr);
40
- const [component, pinValue] = this.getResult(ctxDataWithAssignmentExpr);
36
+ const [component, pinValue] = this.visitResult(ctx.data_expr_with_assignment());
41
37
  this.getExecutor().addComponentExisting(component, pinValue);
42
38
  };
43
39
  this.visitAt_component_expr = (ctx) => {
44
- if (ctx.Point()) {
45
- this.getExecutor().atPointBlock();
46
- }
47
- else {
48
- const ctxComponentSelectExpr = ctx.component_select_expr();
49
- this.visit(ctxComponentSelectExpr);
50
- const [component, pin] = this.getResult(ctxComponentSelectExpr);
51
- this.getExecutor().atComponent(component, pin, {
52
- addSequence: true
53
- });
54
- }
40
+ const [component, pin] = this.visitResult(ctx.component_select_expr());
41
+ this.getExecutor().atComponent(component, pin, {
42
+ addSequence: true
43
+ });
55
44
  return this.getExecutor().getCurrentPoint();
56
45
  };
57
46
  this.visitTo_component_expr = (ctx) => {
58
- if (ctx.Point()) {
59
- this.getExecutor().toPointBlock();
60
- }
61
- else {
62
- ctx.component_select_expr().forEach(item => {
63
- this.visit(item);
64
- const [component, pin] = this.getResult(item);
65
- this.getExecutor().toComponent(component, pin, {
66
- addSequence: true
67
- });
47
+ ctx.component_select_expr().forEach(item => {
48
+ const [component, pin] = this.visitResult(item);
49
+ this.getExecutor().toComponent(component, pin, {
50
+ addSequence: true
68
51
  });
69
- }
52
+ });
70
53
  return this.getExecutor().getCurrentPoint();
71
54
  };
72
55
  this.visitComponent_select_expr = (ctx) => {
73
56
  const ctxDataExprWithAssigment = ctx.data_expr_with_assignment();
74
- if (ctxDataExprWithAssigment) {
75
- this.visit(ctxDataExprWithAssigment);
76
- this.setResult(ctx, this.getResult(ctxDataExprWithAssigment));
57
+ let componentPin = null;
58
+ if (ctx.Point()) {
59
+ const [component, pin,] = this.getExecutor().getPointBlockLocation();
60
+ componentPin = [component, pin];
61
+ }
62
+ else if (ctxDataExprWithAssigment) {
63
+ componentPin = this.visitResult(ctxDataExprWithAssigment);
77
64
  }
78
65
  else {
79
66
  const component = this.getExecutor().scope.currentComponent;
80
67
  let pinId = null;
81
68
  const ctxPinSelectExpr = ctx.pin_select_expr();
82
69
  if (ctxPinSelectExpr) {
83
- this.visit(ctxPinSelectExpr);
84
- pinId = this.getResult(ctxPinSelectExpr);
70
+ pinId = this.visitResult(ctxPinSelectExpr);
71
+ }
72
+ if (pinId === null) {
73
+ this.throwWithContext(ctx, "Could not resolve pin");
85
74
  }
86
- this.setResult(ctx, [component, pinId]);
75
+ componentPin = [component, pinId];
87
76
  }
77
+ this.setResult(ctx, componentPin);
88
78
  };
89
79
  this.visitPath_blocks = (ctx) => {
90
80
  const blocks = ctx.path_block_inner();
@@ -123,7 +113,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
123
113
  this.visitCreate_component_expr = (ctx) => {
124
114
  const properties = this.getPropertyExprList(ctx.property_expr());
125
115
  const pins = this.parseCreateComponentPins(properties.get('pins'));
126
- let instanceName = this.getExecutor().getUniqueInstanceName('');
116
+ let instanceName = this.getExecutor().getUniqueInstanceName();
127
117
  const propParams = properties.get('params');
128
118
  const params = this.parseCreateComponentParams(propParams);
129
119
  if (params.length > 0) {
@@ -145,12 +135,14 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
145
135
  properties.get('copy') : false;
146
136
  const width = properties.has('width') ?
147
137
  properties.get('width') : null;
148
- const angle = properties.has('angle') ?
149
- properties.get('angle') : null;
138
+ const height = properties.has('height') ?
139
+ properties.get('height') : null;
140
+ const angle = properties.has(globals_js_1.ParamKeys.angle) ?
141
+ properties.get(globals_js_1.ParamKeys.angle) : null;
150
142
  const followWireOrientation = properties.has('followWireOrientation') ?
151
143
  properties.get('followWireOrientation') : true;
152
144
  const props = {
153
- arrange, display, type, width, copy,
145
+ arrange, display, type, width, height, copy,
154
146
  angle, followWireOrientation
155
147
  };
156
148
  const createdComponent = this.getExecutor().createComponent(instanceName, pins, params, props);
@@ -177,8 +169,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
177
169
  const currentStack = this.executionStack.splice(0);
178
170
  this.executionStack.push(...stack);
179
171
  const graphicsExpressionsCtx = ctx.graphic_expressions_block();
180
- this.visit(graphicsExpressionsCtx);
181
- const commands = this.getResult(graphicsExpressionsCtx);
172
+ const commands = this.visitResult(graphicsExpressionsCtx);
182
173
  this.executionStack.splice(0);
183
174
  this.executionStack.push(...currentStack);
184
175
  return commands;
@@ -188,8 +179,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
188
179
  };
189
180
  this.visitGraphic_expressions_block = (ctx) => {
190
181
  const commands = ctx.graphic_expr().reduce((accum, item) => {
191
- this.visit(item);
192
- const [commandName, parameters] = this.getResult(item);
182
+ const [commandName, parameters] = this.visitResult(item);
193
183
  if (commandName === draw_symbols_js_1.PlaceHolderCommands.for) {
194
184
  accum = accum.concat(parameters);
195
185
  }
@@ -222,18 +212,15 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
222
212
  let parameters = [];
223
213
  const ctxNestedProperties = ctx.nested_properties_inner();
224
214
  if (ctxNestedProperties) {
225
- this.visit(ctxNestedProperties);
226
- const nestedKeyValues = this.getResult(ctxNestedProperties);
215
+ const nestedKeyValues = this.visitResult(ctxNestedProperties);
227
216
  nestedKeyValues.forEach((value, key) => {
228
217
  parameters.push(['keyword', key, value]);
229
218
  });
230
219
  }
231
220
  else {
232
- const ctxParameters = ctx.parameters();
233
- this.visit(ctxParameters);
234
- parameters = this.getResult(ctxParameters);
221
+ parameters = this.visitResult(ctx.parameters());
235
222
  }
236
- if (commandName === 'label') {
223
+ if (commandName === draw_symbols_js_1.PlaceHolderCommands.label) {
237
224
  parameters.forEach(item => {
238
225
  if (item[0] == 'keyword' && item[1] === 'portType') {
239
226
  if (item[2] === 'in') {
@@ -249,9 +236,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
249
236
  };
250
237
  this.visitGraphicForExpr = (ctx) => {
251
238
  const forVariableNames = ctx.ID().map(item => item.getText());
252
- const ctxDataExpr = ctx.data_expr();
253
- this.visit(ctxDataExpr);
254
- const listItems = this.getResult(ctxDataExpr);
239
+ const listItems = this.visitResult(ctx.data_expr());
255
240
  let keepLooping = true;
256
241
  let counter = 0;
257
242
  let allCommands = [];
@@ -264,9 +249,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
264
249
  useValueArray.forEach((value, index) => {
265
250
  this.getExecutor().scope.variables.set(forVariableNames[index], value);
266
251
  });
267
- const graphicsExpressionsCtx = ctx.graphic_expressions_block();
268
- this.visit(graphicsExpressionsCtx);
269
- const commands = this.getResult(graphicsExpressionsCtx);
252
+ const commands = this.visitResult(ctx.graphic_expressions_block());
270
253
  allCommands = allCommands.concat(commands);
271
254
  counter += 1;
272
255
  }
@@ -278,8 +261,10 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
278
261
  };
279
262
  this.visitCreate_module_expr = (ctx) => {
280
263
  const properties = this.getPropertyExprList(ctx.property_expr());
281
- const { left: leftPorts, right: rightPorts } = this.parseCreateModulePorts(properties.get('ports'));
282
- const allPorts = [...leftPorts, ...rightPorts].filter(item => {
264
+ const modulePorts = this.parseCreateModulePorts(properties.get('ports'));
265
+ const { [globals_js_1.SymbolPinSide.Left]: leftPorts, [globals_js_1.SymbolPinSide.Right]: rightPorts, [globals_js_1.SymbolPinSide.Top]: topPorts, [globals_js_1.SymbolPinSide.Bottom]: bottomPorts } = modulePorts;
266
+ const allPorts = [...leftPorts, ...rightPorts,
267
+ ...topPorts, ...bottomPorts].filter(item => {
283
268
  return !(Array.isArray(item));
284
269
  });
285
270
  const nameToPinId = new Map();
@@ -287,64 +272,42 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
287
272
  nameToPinId.set(portName, index + 1);
288
273
  return new PinDefinition_js_1.PinDefinition(index + 1, PinDefinition_js_1.PinIdType.Int, portName, PinTypes_js_1.PinTypes.Any);
289
274
  });
290
- const arrangeLeftItems = leftPorts.map(item => {
291
- if (Array.isArray(item)) {
292
- return item;
293
- }
294
- else {
295
- return nameToPinId.get(item);
296
- }
297
- });
298
- const arrangeRightItems = rightPorts.map(item => {
299
- if (Array.isArray(item)) {
300
- return item;
301
- }
302
- else {
303
- return nameToPinId.get(item);
304
- }
305
- });
306
- const arrange = new Map();
307
- if (arrangeLeftItems.length > 0) {
308
- arrange.set('left', arrangeLeftItems);
309
- }
310
- if (arrangeRightItems.length > 0) {
311
- arrange.set('right', arrangeRightItems);
312
- }
275
+ const arrange = this.getArrangePropFromModulePorts(modulePorts, nameToPinId);
313
276
  const width = properties.has('width') ?
314
277
  properties.get('width') : null;
278
+ const height = properties.has('height') ?
279
+ properties.get('height') : null;
315
280
  const blankParams = [];
316
281
  const props = {
317
- arrange, width
282
+ arrange, width, height,
283
+ copy: false,
284
+ followWireOrientation: true,
318
285
  };
319
- const moduleInstanceName = this.getExecutor().getUniqueInstanceName('');
320
- const createdComponent = this.getExecutor().createComponent(moduleInstanceName, tmpPorts, blankParams, props);
321
- createdComponent.typeProp = 'module';
286
+ const moduleInstanceName = this.getExecutor().getUniqueInstanceName();
287
+ const moduleComponent = this.getExecutor().createComponent(moduleInstanceName, tmpPorts, blankParams, props, true);
288
+ moduleComponent.typeProp = globals_js_1.ComponentTypes.module;
322
289
  const ctxPropertyBlock = ctx.property_block_expr();
323
290
  if (ctxPropertyBlock) {
324
291
  const [firstBlock] = ctxPropertyBlock;
325
- this.visit(firstBlock);
326
- const [keyName, expressionsBlock] = this.getResult(firstBlock);
292
+ const [keyName, expressionsBlock] = this.visitResult(firstBlock);
327
293
  if (keyName === globals_js_1.ModuleContainsKeyword) {
328
- createdComponent.moduleContainsExpressions = expressionsBlock;
329
- this.expandModuleContains(createdComponent, this.getExecutor().netNamespace);
294
+ moduleComponent.moduleContainsExpressions = expressionsBlock;
295
+ this.expandModuleContains(moduleComponent, this.getExecutor().netNamespace);
330
296
  }
331
297
  }
332
- this.setResult(ctx, createdComponent);
298
+ if (moduleComponent.moduleContainsExpressions === undefined) {
299
+ throw 'Module has no `contains` block defined!';
300
+ }
301
+ this.setResult(ctx, moduleComponent);
333
302
  };
334
303
  this.visitProperty_block_expr = (ctx) => {
335
- const tmpCtx = ctx.property_key_expr();
336
- this.visit(tmpCtx);
337
- const keyName = this.getResult(tmpCtx);
304
+ const keyName = this.visitResult(ctx.property_key_expr());
338
305
  const expressionsBlock = ctx.expressions_block();
339
306
  this.setResult(ctx, [keyName, expressionsBlock]);
340
307
  };
341
308
  this.visitProperty_expr = (ctx) => {
342
- const ctxPropertyKeyExpr = ctx.property_key_expr();
343
- const ctxPropertyValueExpr = ctx.property_value_expr();
344
- this.visit(ctxPropertyKeyExpr);
345
- this.visit(ctxPropertyValueExpr);
346
- const keyName = this.getResult(ctxPropertyKeyExpr);
347
- const value = this.getResult(ctxPropertyValueExpr);
309
+ const keyName = this.visitResult(ctx.property_key_expr());
310
+ const value = this.visitResult(ctx.property_value_expr());
348
311
  if (value instanceof types_js_1.UndeclaredReference && (value.reference.parentValue === undefined
349
312
  && value.reference.value === undefined)) {
350
313
  throw value.throwMessage();
@@ -356,14 +319,11 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
356
319
  this.visitSingle_line_property = (ctx) => {
357
320
  let value;
358
321
  if (ctx.data_expr().length === 1) {
359
- const ctxFirst = ctx.data_expr(0);
360
- this.visit(ctxFirst);
361
- value = this.getResult(ctxFirst);
322
+ value = this.visitResult(ctx.data_expr(0));
362
323
  }
363
324
  else {
364
325
  value = ctx.data_expr().map(item => {
365
- this.visit(item);
366
- return this.getResult(item);
326
+ return this.visitResult(item);
367
327
  });
368
328
  }
369
329
  this.setResult(ctx, value);
@@ -371,8 +331,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
371
331
  this.visitNested_properties_inner = (ctx) => {
372
332
  const result = new Map();
373
333
  ctx.property_expr().forEach((item) => {
374
- this.visit(item);
375
- const property = this.getResult(item);
334
+ const property = this.visitResult(item);
376
335
  for (const [key, value] of property) {
377
336
  result.set(key, value);
378
337
  }
@@ -380,9 +339,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
380
339
  this.setResult(ctx, result);
381
340
  };
382
341
  this.visitNested_properties = (ctx) => {
383
- const ctxNested = ctx.nested_properties_inner();
384
- this.visit(ctxNested);
385
- this.setResult(ctx, this.getResult(ctxNested));
342
+ this.setResult(ctx, this.visitResult(ctx.nested_properties_inner()));
386
343
  };
387
344
  this.visitProperty_key_expr = (ctx) => {
388
345
  const ctxID = ctx.ID();
@@ -406,16 +363,14 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
406
363
  const ctxDataExpr = ctx.data_expr();
407
364
  const ctxAssignmentExpr = ctx.assignment_expr();
408
365
  if (ctxDataExpr) {
409
- this.visit(ctxDataExpr);
410
- component = this.getResult(ctxDataExpr);
366
+ component = this.visitResult(ctxDataExpr);
411
367
  componentCtx = ctxDataExpr;
412
368
  if (component === null || component === undefined) {
413
369
  this.throwWithContext(ctxDataExpr, "Could not find component: " + ctxDataExpr.getText());
414
370
  }
415
371
  }
416
372
  else if (ctxAssignmentExpr) {
417
- this.visit(ctxAssignmentExpr);
418
- component = this.getResult(ctxAssignmentExpr);
373
+ component = this.visitResult(ctxAssignmentExpr);
419
374
  componentCtx = ctxAssignmentExpr;
420
375
  }
421
376
  if (component instanceof ClassComponent_js_1.ClassComponent
@@ -439,27 +394,25 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
439
394
  const ctxID2 = modifier.ID(1);
440
395
  let result = null;
441
396
  if (ctxValueExpr) {
442
- this.visit(ctxValueExpr);
443
- result = this.getResult(ctxValueExpr);
397
+ result = this.visitResult(ctxValueExpr);
444
398
  }
445
399
  else if (ctxID2) {
446
400
  result = ctxID2.getText();
447
401
  }
448
402
  let shouldIgnoreWireOrientation = false;
449
- if (modifierText === 'flip') {
403
+ if (modifierText === globals_js_1.ParamKeys.flip) {
450
404
  const flipValue = result;
451
405
  if (flipValue.indexOf('x') !== -1) {
452
- component.setParam('flipX', 1);
406
+ component.setParam(globals_js_1.ParamKeys.flipX, 1);
453
407
  shouldIgnoreWireOrientation = true;
454
408
  }
455
409
  if (flipValue.indexOf('y') !== -1) {
456
- component.setParam('flipY', 1);
410
+ component.setParam(globals_js_1.ParamKeys.flipY, 1);
457
411
  shouldIgnoreWireOrientation = true;
458
412
  }
459
413
  }
460
- else if (modifierText === 'angle') {
461
- const angleValue = Number(result);
462
- component.setParam('angle', angleValue);
414
+ else if (modifierText === globals_js_1.ParamKeys.angle) {
415
+ component.setParam(globals_js_1.ParamKeys.angle, result);
463
416
  shouldIgnoreWireOrientation = true;
464
417
  }
465
418
  else if (modifierText === 'anchor') {
@@ -473,8 +426,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
473
426
  let pinValue = null;
474
427
  const ctxPinSelectExpr = ctx.pin_select_expr();
475
428
  if (ctxPinSelectExpr) {
476
- this.visit(ctxPinSelectExpr);
477
- pinValue = this.getResult(ctxPinSelectExpr);
429
+ pinValue = this.visitResult(ctxPinSelectExpr);
478
430
  }
479
431
  else {
480
432
  if (component instanceof ClassComponent_js_1.ClassComponent) {
@@ -488,24 +440,23 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
488
440
  this.setResult(ctx, [component, pinValue]);
489
441
  };
490
442
  this.visitUnaryOperatorExpr = (ctx) => {
491
- this.visit(ctx.data_expr());
492
- let value = this.getResult(ctx.data_expr());
443
+ let value = this.visitResult(ctx.data_expr());
493
444
  const unaryOp = ctx.unary_operator();
494
445
  if (unaryOp) {
495
446
  if (unaryOp.Not()) {
496
447
  if (typeof value === "boolean") {
497
448
  value = !value;
498
449
  }
499
- else if (typeof value === "number") {
500
- value = (value === 0) ? false : true;
450
+ else if (value instanceof ParamDefinition_js_1.NumericValue) {
451
+ value = (value.toNumber() === 0) ? true : false;
501
452
  }
502
453
  else {
503
454
  throw "Failed to do Not operator";
504
455
  }
505
456
  }
506
457
  else if (unaryOp.Minus()) {
507
- if (typeof value === 'number') {
508
- value = -value;
458
+ if (value instanceof ParamDefinition_js_1.NumericValue) {
459
+ value = value.neg();
509
460
  }
510
461
  else {
511
462
  throw "Failed to do Negation operator";
@@ -520,16 +471,13 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
520
471
  const ctxCreateGraphicExpr = ctx.create_graphic_expr();
521
472
  const ctxCreateModuleExpr = ctx.create_module_expr();
522
473
  if (ctxCreateComponentExpr) {
523
- this.visit(ctxCreateComponentExpr);
524
- value = this.getResult(ctxCreateComponentExpr);
474
+ value = this.visitResult(ctxCreateComponentExpr);
525
475
  }
526
476
  else if (ctxCreateGraphicExpr) {
527
- this.visit(ctxCreateGraphicExpr);
528
- value = this.getResult(ctxCreateGraphicExpr);
477
+ value = this.visitResult(ctxCreateGraphicExpr);
529
478
  }
530
479
  else if (ctxCreateModuleExpr) {
531
- this.visit(ctxCreateModuleExpr);
532
- value = this.getResult(ctxCreateModuleExpr);
480
+ value = this.visitResult(ctxCreateModuleExpr);
533
481
  }
534
482
  else {
535
483
  throw "Invalid data expression";
@@ -539,10 +487,14 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
539
487
  this.visitBinaryOperatorExpr = (ctx) => {
540
488
  const ctx0 = ctx.data_expr(0);
541
489
  const ctx1 = ctx.data_expr(1);
542
- this.visit(ctx0);
543
- this.visit(ctx1);
544
- const value1 = this.getResult(ctx0);
545
- const value2 = this.getResult(ctx1);
490
+ let value1 = this.visitResult(ctx0);
491
+ let value2 = this.visitResult(ctx1);
492
+ if (value1 instanceof ParamDefinition_js_1.NumericValue) {
493
+ value1 = value1.toNumber();
494
+ }
495
+ if (value2 instanceof ParamDefinition_js_1.NumericValue) {
496
+ value2 = value2.toNumber();
497
+ }
546
498
  const binaryOperatorType = ctx.binary_operator();
547
499
  let result = null;
548
500
  if (binaryOperatorType.Equals()) {
@@ -568,60 +520,87 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
568
520
  this.visitLogicalOperatorExpr = (ctx) => {
569
521
  const ctx0 = ctx.data_expr(0);
570
522
  const ctx1 = ctx.data_expr(1);
571
- this.visit(ctx0);
572
- const value1 = this.getResult(ctx0);
523
+ let value1 = this.visitResult(ctx0);
524
+ if (value1 instanceof ParamDefinition_js_1.NumericValue) {
525
+ value1 = value1.toNumber();
526
+ }
573
527
  let value2 = false;
574
528
  let skipNext = false;
575
- if (ctx.LogicalOr() && value1) {
529
+ const isLogicalOr = ctx.LogicalOr();
530
+ if (isLogicalOr && value1) {
576
531
  skipNext = true;
577
532
  }
578
533
  if (!skipNext) {
579
- this.visit(ctx1);
580
- value2 = this.getResult(ctx1);
534
+ value2 = this.visitResult(ctx1);
535
+ if (value2 instanceof ParamDefinition_js_1.NumericValue) {
536
+ value2 = value2.toNumber();
537
+ }
581
538
  }
582
539
  let result = null;
583
540
  if (ctx.LogicalAnd()) {
584
541
  result = value1 && value2;
585
542
  }
586
- else if (ctx.LogicalOr()) {
543
+ else if (isLogicalOr) {
587
544
  result = value1 || value2;
588
545
  }
546
+ if (typeof result === "number") {
547
+ result = (0, ParamDefinition_js_1.numeric)(result);
548
+ }
589
549
  this.setResult(ctx, result);
590
550
  };
591
551
  this.visitMultiplyExpr = (ctx) => {
592
552
  const value1 = this.resolveDataExpr(ctx.data_expr(0));
593
553
  const value2 = this.resolveDataExpr(ctx.data_expr(1));
554
+ const operator = new ParamDefinition_js_1.NumberOperator();
555
+ const tmpValue1 = operator.prepare(value1);
556
+ const tmpValue2 = operator.prepare(value2);
594
557
  let result = null;
595
558
  if (ctx.Multiply()) {
596
- result = value1 * value2;
559
+ result = operator.multiply(tmpValue1, tmpValue2);
597
560
  }
598
561
  else if (ctx.Divide()) {
599
- result = value1 / value2;
562
+ result = operator.divide(tmpValue1, tmpValue2);
600
563
  }
601
564
  else if (ctx.Modulus()) {
602
- result = value1 % value2;
565
+ result = operator.modulus(tmpValue1, tmpValue2);
603
566
  }
604
567
  this.setResult(ctx, result);
605
568
  };
606
569
  this.visitAdditionExpr = (ctx) => {
607
570
  const value1 = this.resolveDataExpr(ctx.data_expr(0));
608
571
  const value2 = this.resolveDataExpr(ctx.data_expr(1));
609
- let result = null;
610
- if (ctx.Addition()) {
611
- result = value1 + value2;
572
+ if (ctx.Addition() && (typeof value1 === 'string' || typeof value2 === 'string')) {
573
+ let tmpValue1 = value1;
574
+ if (value1 instanceof ParamDefinition_js_1.NumericValue) {
575
+ tmpValue1 = value1.toDisplayString();
576
+ }
577
+ let tmpValue2 = value2;
578
+ if (value2 instanceof ParamDefinition_js_1.NumericValue) {
579
+ tmpValue2 = value2.toDisplayString();
580
+ }
581
+ const result = tmpValue1 + tmpValue2;
582
+ this.setResult(ctx, result);
612
583
  }
613
- else if (ctx.Minus()) {
614
- result = value1 - value2;
584
+ else {
585
+ const operator = new ParamDefinition_js_1.NumberOperator();
586
+ const tmpValue1 = operator.prepare(value1);
587
+ const tmpValue2 = operator.prepare(value2);
588
+ let result = null;
589
+ if (ctx.Addition()) {
590
+ result = operator.addition(tmpValue1, tmpValue2);
591
+ }
592
+ else if (ctx.Minus()) {
593
+ result = operator.subtraction(tmpValue1, tmpValue2);
594
+ }
595
+ this.setResult(ctx, result);
615
596
  }
616
- this.setResult(ctx, result);
617
597
  };
618
598
  this.visitFunction_def_expr = (ctx) => {
619
599
  const functionName = ctx.ID().getText();
620
600
  let funcDefinedParameters = [];
621
601
  const ctxFunctionArgsExpr = ctx.function_args_expr();
622
602
  if (ctxFunctionArgsExpr) {
623
- this.visit(ctxFunctionArgsExpr);
624
- funcDefinedParameters = this.getResult(ctxFunctionArgsExpr);
603
+ funcDefinedParameters = this.visitResult(ctxFunctionArgsExpr);
625
604
  }
626
605
  const executionStack = this.executionStack;
627
606
  const functionCounter = { counter: 0 };
@@ -652,12 +631,9 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
652
631
  this.setResult(ctx, result);
653
632
  };
654
633
  this.visitAt_block_pin_expr = (ctx) => {
655
- const ctxPinSelectExpr2 = ctx.pin_select_expr2();
656
- this.visit(ctxPinSelectExpr2);
657
- const atPin = this.getResult(ctxPinSelectExpr2);
634
+ const atPin = this.visitResult(ctx.pin_select_expr2());
658
635
  const executor = this.getExecutor();
659
- const currentComponent = executor.scope.currentComponent;
660
- const currentPin = executor.scope.currentPin;
636
+ const [currentComponent, currentPin] = executor.getCurrentPoint();
661
637
  executor.atComponent(currentComponent, atPin, {
662
638
  addSequence: true
663
639
  });
@@ -719,8 +695,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
719
695
  useValue = Number(ctxIntegerValue);
720
696
  }
721
697
  else if (ctxDataExpr) {
722
- this.visit(ctxDataExpr);
723
- useValue = this.getResult(ctxDataExpr);
698
+ useValue = this.visitResult(ctxDataExpr);
724
699
  }
725
700
  if (useValue !== null) {
726
701
  this.setResult(ctx, [direction, new helpers_js_1.UnitDimension(useValue)]);
@@ -732,8 +707,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
732
707
  this.visitWire_expr = (ctx) => {
733
708
  const wireAtomExpr = ctx.wire_atom_expr();
734
709
  const segments = wireAtomExpr.map(wireSegment => {
735
- this.visit(wireSegment);
736
- return this.getResult(wireSegment);
710
+ return this.visitResult(wireSegment);
737
711
  });
738
712
  this.getExecutor().addWire(segments);
739
713
  };
@@ -742,18 +716,12 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
742
716
  return this.getExecutor().addPoint(ID.getText());
743
717
  };
744
718
  this.visitProperty_set_expr = (ctx) => {
745
- const ctxDataExpr = ctx.data_expr();
746
- this.visit(ctxDataExpr);
747
- const result = this.getResult(ctxDataExpr);
748
- const ctxAtomExpr = ctx.atom_expr();
749
- this.visit(ctxAtomExpr);
750
- const resolvedProperty = this.getResult(ctxAtomExpr);
719
+ const result = this.visitResult(ctx.data_expr());
720
+ const resolvedProperty = this.visitResult(ctx.atom_expr());
751
721
  this.getExecutor().setProperty(resolvedProperty, result);
752
722
  };
753
723
  this.visitDouble_dot_property_set_expr = (ctx) => {
754
- const ctxDataExpr = ctx.data_expr();
755
- this.visit(ctxDataExpr);
756
- const result = this.getResult(ctxDataExpr);
724
+ const result = this.visitResult(ctx.data_expr());
757
725
  const propertyName = ctx.ID().getText();
758
726
  this.getExecutor().setProperty('..' + propertyName, result);
759
727
  };
@@ -775,8 +743,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
775
743
  const hasPlus = ctx.Addition();
776
744
  const ctxDataExpr = ctx.data_expr();
777
745
  if (ctxDataExpr) {
778
- this.visit(ctxDataExpr);
779
- dataValue = this.getResult(ctxDataExpr);
746
+ dataValue = this.visitResult(ctxDataExpr);
780
747
  if (dataValue instanceof types_js_1.UndeclaredReference) {
781
748
  netNamespace = "/" + dataValue.reference.name;
782
749
  }
@@ -793,9 +760,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
793
760
  this.setResult(ctx, (hasPlus ? "+" : "") + netNamespace);
794
761
  };
795
762
  this.visitIf_expr = (ctx) => {
796
- const ctxDataExpr = ctx.data_expr();
797
- this.visit(ctxDataExpr);
798
- const result = this.getResult(ctxDataExpr);
763
+ const result = this.visitResult(ctx.data_expr());
799
764
  let resultValue = result;
800
765
  if (result instanceof types_js_1.UndeclaredReference) {
801
766
  resultValue = false;
@@ -807,9 +772,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
807
772
  const ctxInnerIfExprs = ctx.if_inner_expr();
808
773
  let innerIfWasTrue = false;
809
774
  for (let i = 0; i < ctxInnerIfExprs.length; i++) {
810
- const tmpCtx = ctxInnerIfExprs[i];
811
- this.visit(tmpCtx);
812
- const innerResult = this.getResult(tmpCtx);
775
+ const innerResult = this.visitResult(ctxInnerIfExprs[i]);
813
776
  if (innerResult) {
814
777
  innerIfWasTrue = true;
815
778
  break;
@@ -824,9 +787,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
824
787
  }
825
788
  };
826
789
  this.visitIf_inner_expr = (ctx) => {
827
- const ctxDataExpr = ctx.data_expr();
828
- this.visit(ctxDataExpr);
829
- const result = this.getResult(ctxDataExpr);
790
+ const result = this.visitResult(ctx.data_expr());
830
791
  if (result) {
831
792
  this.visit(ctx.expressions_block());
832
793
  }
@@ -838,8 +799,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
838
799
  this.log('enter while loop');
839
800
  this.getExecutor().addBreakContext(ctx);
840
801
  while (keepLooping) {
841
- this.visit(dataExpr);
842
- const result = this.getResult(dataExpr);
802
+ const result = this.visitResult(dataExpr);
843
803
  if (result) {
844
804
  this.visit(ctx.expressions_block());
845
805
  keepLooping = true;
@@ -864,10 +824,9 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
864
824
  this.log('exit while loop');
865
825
  };
866
826
  this.visitFor_expr = (ctx) => {
827
+ this.log('in for loop');
867
828
  const forVariableNames = ctx.ID().map(item => item.getText());
868
- const ctxDataExpr = ctx.data_expr();
869
- this.visit(ctxDataExpr);
870
- const listItems = this.getResult(ctxDataExpr);
829
+ const listItems = this.visitResult(ctx.data_expr());
871
830
  this.getExecutor().addBreakContext(ctx);
872
831
  let keepLooping = true;
873
832
  let counter = 0;
@@ -884,6 +843,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
884
843
  keepLooping = true;
885
844
  const currentResult = this.getResult(ctx) ?? {};
886
845
  const { breakSignal = false, continueSignal = false } = currentResult;
846
+ this.log('condition result: ', breakSignal, continueSignal);
887
847
  if (breakSignal && !continueSignal) {
888
848
  keepLooping = false;
889
849
  }
@@ -914,11 +874,12 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
914
874
  this.getExecutor().log('expanding module `contains`');
915
875
  const executionStack = this.executionStack;
916
876
  const resolveNet = this.createNetResolver(executionStack);
917
- const executionContextName = this.getExecutor().namespace + "_"
877
+ const executor = this.getExecutor();
878
+ const executionContextName = executor.namespace + "_"
918
879
  + component.instanceName
919
880
  + '_' + component.moduleCounter;
920
881
  const tmpNamespace = this.getNetNamespace(netNamespace, "+/" + component.instanceName + "_" + component.moduleCounter);
921
- const newExecutor = this.enterNewChildContext(executionStack, this.getExecutor(), executionContextName, { netNamespace: tmpNamespace }, [], []);
882
+ const newExecutor = this.enterNewChildContext(executionStack, executor, executionContextName, { netNamespace: tmpNamespace }, [], []);
922
883
  component.moduleCounter += 1;
923
884
  newExecutor.resolveNet = resolveNet;
924
885
  this.visit(component.moduleContainsExpressions);
@@ -936,9 +897,9 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
936
897
  });
937
898
  const pinIdToPortMap = new Map();
938
899
  moduleComponent.modulePinIdToPortMap = pinIdToPortMap;
939
- for (const [key, component] of executionContext.scope.instances) {
940
- if (component._copyID !== null && component.typeProp === 'port') {
941
- const portName = component.parameters.get('net_name');
900
+ for (const [, component] of executionContext.scope.instances) {
901
+ if (component._copyID !== null && component.typeProp === globals_js_1.ComponentTypes.port) {
902
+ const portName = component.parameters.get(globals_js_1.ParamKeys.net_name);
942
903
  const modulePinId = modulePinMapping.get(portName);
943
904
  pinIdToPortMap.set(modulePinId, component);
944
905
  const portType = (0, utils_js_1.getPortType)(component);
@@ -948,7 +909,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
948
909
  }
949
910
  }
950
911
  placeModuleContains(moduleComponent) {
951
- if (moduleComponent.typeProp === 'module'
912
+ if (moduleComponent.typeProp === globals_js_1.ComponentTypes.module
952
913
  && moduleComponent.moduleContainsExpressions) {
953
914
  this.log('place module `contains`');
954
915
  this.getExecutor().mergeScope(moduleComponent.moduleExecutionContext.scope, moduleComponent.moduleExecutionContextName);
@@ -960,8 +921,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
960
921
  }
961
922
  }
962
923
  resolveDataExpr(data_expr) {
963
- this.visit(data_expr);
964
- const value = this.getResult(data_expr);
924
+ const value = this.visitResult(data_expr);
965
925
  if (value instanceof types_js_1.UndeclaredReference) {
966
926
  this.throwWithContext(data_expr, value.throwMessage());
967
927
  }
@@ -981,8 +941,8 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
981
941
  }
982
942
  parseCreateComponentPins(pinData) {
983
943
  const pins = [];
984
- if (typeof pinData === 'number') {
985
- const lastPin = pinData;
944
+ if (pinData instanceof ParamDefinition_js_1.NumericValue) {
945
+ const lastPin = pinData.toNumber();
986
946
  for (let i = 0; i < lastPin; i++) {
987
947
  const pinId = i + 1;
988
948
  pins.push(new PinDefinition_js_1.PinDefinition(pinId, PinDefinition_js_1.PinIdType.Int, pinId.toString()));
@@ -1018,30 +978,49 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
1018
978
  else {
1019
979
  pinName = pinDef;
1020
980
  }
981
+ this.log('pins', pinId, pinIdType, pinName, pinType, altPinNames);
1021
982
  pins.push(new PinDefinition_js_1.PinDefinition(pinId, pinIdType, pinName, pinType, altPinNames));
1022
983
  }
1023
984
  }
1024
985
  return pins;
1025
986
  }
1026
987
  parseCreateModulePorts(portsDefinition) {
1027
- let leftItems = [];
1028
- let rightItems = [];
1029
- if (portsDefinition.has('left')) {
1030
- leftItems = portsDefinition.get('left');
1031
- if (!Array.isArray(leftItems)) {
1032
- leftItems = [leftItems];
988
+ return {
989
+ left: this.getPortItems(portsDefinition, globals_js_1.SymbolPinSide.Left),
990
+ right: this.getPortItems(portsDefinition, globals_js_1.SymbolPinSide.Right),
991
+ top: this.getPortItems(portsDefinition, globals_js_1.SymbolPinSide.Top),
992
+ bottom: this.getPortItems(portsDefinition, globals_js_1.SymbolPinSide.Bottom),
993
+ };
994
+ }
995
+ getArrangePropFromModulePorts(modulePorts, nameToPinId) {
996
+ const keys = [globals_js_1.SymbolPinSide.Left, globals_js_1.SymbolPinSide.Right, globals_js_1.SymbolPinSide.Top, globals_js_1.SymbolPinSide.Bottom];
997
+ const arrangeProp = new Map();
998
+ keys.forEach(key => {
999
+ if (modulePorts[key]) {
1000
+ const items = modulePorts[key].map(item => {
1001
+ if (Array.isArray(item)) {
1002
+ return item;
1003
+ }
1004
+ else {
1005
+ return (0, ParamDefinition_js_1.numeric)(nameToPinId.get(item));
1006
+ }
1007
+ });
1008
+ if (items.length > 0) {
1009
+ arrangeProp.set(key, items);
1010
+ }
1033
1011
  }
1034
- }
1035
- if (portsDefinition.has('right')) {
1036
- rightItems = portsDefinition.get('right');
1037
- if (!Array.isArray(rightItems)) {
1038
- rightItems = [rightItems];
1012
+ });
1013
+ return arrangeProp;
1014
+ }
1015
+ getPortItems(portsDefinition, key) {
1016
+ let tmpItems = [];
1017
+ if (portsDefinition.has(key)) {
1018
+ tmpItems = portsDefinition.get(key);
1019
+ if (!Array.isArray(tmpItems)) {
1020
+ tmpItems = [tmpItems];
1039
1021
  }
1040
1022
  }
1041
- return {
1042
- left: leftItems,
1043
- right: rightItems
1044
- };
1023
+ return tmpItems;
1045
1024
  }
1046
1025
  parseCreateComponentParams(params) {
1047
1026
  const result = [];
@@ -1120,8 +1099,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
1120
1099
  const nets = executor.scope.getNets();
1121
1100
  return {
1122
1101
  sequence,
1123
- nets,
1124
- components: Array.from(executor.scope.instances.values())
1102
+ nets
1125
1103
  };
1126
1104
  }
1127
1105
  annotateComponents() {
@@ -1130,16 +1108,11 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
1130
1108
  const instances = this.getExecutor().scope.instances;
1131
1109
  const toAnnotate = [];
1132
1110
  for (const [, instance] of instances) {
1111
+ if (instance.typeProp === globals_js_1.ComponentTypes.net
1112
+ || instance.typeProp == globals_js_1.ComponentTypes.graphic) {
1113
+ continue;
1114
+ }
1133
1115
  if (instance.assignedRefDes === null) {
1134
- if (instance.typeProp === globals_js_1.ComponentTypes.label ||
1135
- instance.typeProp === globals_js_1.ComponentTypes.net ||
1136
- instance.typeProp === globals_js_1.ComponentTypes.point) {
1137
- continue;
1138
- }
1139
- if (instance.typeProp === null) {
1140
- this.log('Instance has no type:', instance.instanceName, ' assuming connector');
1141
- instance.typeProp = 'conn';
1142
- }
1143
1116
  if (instance.parameters.has('refdes')) {
1144
1117
  const refdes = instance.parameters.get('refdes');
1145
1118
  if (refdes) {
@@ -1153,7 +1126,10 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
1153
1126
  }
1154
1127
  }
1155
1128
  toAnnotate.forEach(instance => {
1156
- const newRefDes = annotater.getAnnotation(instance.typeProp);
1129
+ const useTypeProp = instance.typeProp ?? 'conn';
1130
+ instance.typeProp === null
1131
+ && this.log('Instance has no type:', instance.instanceName, ' assuming connector');
1132
+ const newRefDes = annotater.getAnnotation(useTypeProp);
1157
1133
  if (newRefDes !== null) {
1158
1134
  instance.assignedRefDes = newRefDes;
1159
1135
  this.log(newRefDes, '-', instance.instanceName);
@@ -1176,9 +1152,9 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
1176
1152
  });
1177
1153
  const totalSheets = sheets.length;
1178
1154
  sheets.forEach((item, index) => {
1179
- item.parameters.set(Frame_js_1.FrameParamKeys.SheetType, frameComponent);
1180
- item.parameters.set(Frame_js_1.FrameParamKeys.SheetNumber, index + 1);
1181
- item.parameters.set(Frame_js_1.FrameParamKeys.SheetTotal, totalSheets);
1155
+ item.parameters.set(Frame_js_1.FrameParamKeys.SheetType, frameComponent)
1156
+ .set(Frame_js_1.FrameParamKeys.SheetNumber, index + 1)
1157
+ .set(Frame_js_1.FrameParamKeys.SheetTotal, totalSheets);
1182
1158
  });
1183
1159
  }
1184
1160
  return {
@@ -1203,25 +1179,10 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
1203
1179
  }
1204
1180
  return result;
1205
1181
  }
1206
- setComponentOrientation(component, pin, orientation) {
1207
- if (this.acceptedDirections.indexOf(orientation) !== -1) {
1208
- component.setParam('_addDirection', orientation);
1209
- component.setParam('_addPin', pin);
1210
- }
1211
- else {
1212
- throw "Invalid modifier for orientation";
1213
- }
1214
- }
1215
- setComponentFlip(component, flipValue) {
1216
- if (this.acceptedFlip.indexOf(flipValue) !== -1) {
1217
- component.setParam(flipValue, 1);
1218
- }
1219
- }
1220
1182
  getPropertyExprList(items) {
1221
1183
  const properties = new Map();
1222
1184
  items.forEach((item) => {
1223
- this.visit(item);
1224
- const result = this.getResult(item);
1185
+ const result = this.visitResult(item);
1225
1186
  for (const [key, value] of result) {
1226
1187
  properties.set(key, value);
1227
1188
  }
@@ -1231,14 +1192,14 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
1231
1192
  }
1232
1193
  exports.ParserVisitor = ParserVisitor;
1233
1194
  const ComponentRefDesPrefixes = {
1234
- 'res': 'R',
1235
- 'cap': 'C',
1236
- 'ind': 'L',
1237
- 'diode': 'D',
1238
- 'conn': 'J',
1239
- 'transistor': 'Q',
1240
- 'relay': 'K',
1241
- 'ic': 'U',
1195
+ res: 'R',
1196
+ cap: 'C',
1197
+ ind: 'L',
1198
+ diode: 'D',
1199
+ conn: 'J',
1200
+ transistor: 'Q',
1201
+ relay: 'K',
1202
+ ic: 'U',
1242
1203
  '?': '?',
1243
1204
  };
1244
1205
  class ComponentAnnotater {
@@ -1248,7 +1209,6 @@ class ComponentAnnotater {
1248
1209
  for (const key in ComponentRefDesPrefixes) {
1249
1210
  this.counter[key] = 1;
1250
1211
  }
1251
- this.counter['?'] = 1;
1252
1212
  }
1253
1213
  getAnnotation(type) {
1254
1214
  if (this.counter[type] === undefined && type.length <= 2) {
@@ -1266,7 +1226,7 @@ class ComponentAnnotater {
1266
1226
  return null;
1267
1227
  }
1268
1228
  let attempts = 100;
1269
- let proposedName;
1229
+ let proposedName = "";
1270
1230
  while (attempts >= 0) {
1271
1231
  proposedName = ComponentRefDesPrefixes[type] + this.counter[type];
1272
1232
  this.counter[type]++;