circuitscript 0.1.29 → 0.1.32
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 +185 -22
- package/dist/cjs/RefdesAnnotationVisitor.js +27 -10
- package/dist/cjs/antlr/CircuitScriptLexer.js +241 -236
- package/dist/cjs/antlr/CircuitScriptParser.js +1197 -901
- package/dist/cjs/builtinMethods.js +6 -2
- package/dist/cjs/draw_symbols.js +38 -34
- package/dist/cjs/environment.js +28 -4
- package/dist/cjs/execute.js +195 -125
- package/dist/cjs/globals.js +6 -1
- package/dist/cjs/graph.js +14 -12
- package/dist/cjs/helpers.js +90 -17
- package/dist/cjs/layout.js +50 -25
- package/dist/cjs/main.js +16 -14
- package/dist/cjs/objects/ClassComponent.js +199 -30
- package/dist/cjs/objects/ExecutionScope.js +9 -0
- package/dist/cjs/objects/types.js +25 -2
- package/dist/cjs/parser.js +6 -2
- package/dist/cjs/regenerate-tests.js +3 -3
- package/dist/cjs/render.js +5 -3
- package/dist/cjs/rules-check/no-connect-on-connected-pin.js +9 -8
- package/dist/cjs/rules-check/rules.js +7 -2
- package/dist/cjs/rules-check/unconnected-pins.js +10 -8
- package/dist/cjs/utils.js +2 -1
- package/dist/cjs/validate/SymbolTable.js +7 -1
- package/dist/cjs/validate/SymbolValidatorVisitor.js +54 -17
- package/dist/cjs/visitor.js +299 -238
- package/dist/esm/BaseVisitor.js +187 -24
- package/dist/esm/RefdesAnnotationVisitor.js +27 -10
- package/dist/esm/antlr/CircuitScriptLexer.js +241 -236
- package/dist/esm/antlr/CircuitScriptParser.js +1196 -899
- package/dist/esm/antlr/CircuitScriptVisitor.js +4 -1
- package/dist/esm/builtinMethods.js +7 -3
- package/dist/esm/draw_symbols.js +38 -34
- package/dist/esm/environment.js +25 -1
- package/dist/esm/execute.js +197 -127
- package/dist/esm/globals.js +4 -0
- package/dist/esm/graph.js +14 -12
- package/dist/esm/helpers.js +91 -18
- package/dist/esm/layout.js +51 -26
- package/dist/esm/main.js +16 -14
- package/dist/esm/objects/ClassComponent.js +201 -30
- package/dist/esm/objects/ExecutionScope.js +9 -0
- package/dist/esm/objects/types.js +33 -1
- package/dist/esm/parser.js +6 -2
- package/dist/esm/regenerate-tests.js +3 -3
- package/dist/esm/render.js +5 -3
- package/dist/esm/rules-check/no-connect-on-connected-pin.js +9 -8
- package/dist/esm/rules-check/rules.js +7 -2
- package/dist/esm/rules-check/unconnected-pins.js +10 -8
- package/dist/esm/utils.js +2 -1
- package/dist/esm/validate/SymbolTable.js +5 -0
- package/dist/esm/validate/SymbolValidatorVisitor.js +53 -16
- package/dist/esm/visitor.js +201 -137
- package/dist/types/BaseVisitor.d.ts +27 -10
- package/dist/types/RefdesAnnotationVisitor.d.ts +2 -0
- package/dist/types/antlr/CircuitScriptLexer.d.ts +43 -42
- package/dist/types/antlr/CircuitScriptParser.d.ts +102 -58
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +8 -2
- package/dist/types/environment.d.ts +8 -1
- package/dist/types/execute.d.ts +6 -3
- package/dist/types/globals.d.ts +4 -0
- package/dist/types/graph.d.ts +2 -2
- package/dist/types/helpers.d.ts +2 -1
- package/dist/types/layout.d.ts +5 -4
- package/dist/types/objects/ClassComponent.d.ts +34 -9
- package/dist/types/objects/ExecutionScope.d.ts +3 -1
- package/dist/types/objects/types.d.ts +40 -3
- package/dist/types/validate/SymbolTable.d.ts +1 -0
- package/dist/types/validate/SymbolValidatorVisitor.d.ts +6 -6
- package/dist/types/visitor.d.ts +10 -2
- package/package.json +4 -1
|
@@ -25,48 +25,49 @@ export declare class CircuitScriptLexer extends antlr.Lexer {
|
|
|
25
25
|
static readonly Return = 23;
|
|
26
26
|
static readonly Define = 24;
|
|
27
27
|
static readonly Import = 25;
|
|
28
|
-
static readonly
|
|
29
|
-
static readonly
|
|
30
|
-
static readonly
|
|
31
|
-
static readonly
|
|
32
|
-
static readonly
|
|
33
|
-
static readonly
|
|
34
|
-
static readonly
|
|
35
|
-
static readonly
|
|
36
|
-
static readonly
|
|
37
|
-
static readonly
|
|
38
|
-
static readonly
|
|
39
|
-
static readonly
|
|
40
|
-
static readonly
|
|
41
|
-
static readonly
|
|
42
|
-
static readonly
|
|
43
|
-
static readonly
|
|
44
|
-
static readonly
|
|
45
|
-
static readonly
|
|
46
|
-
static readonly
|
|
47
|
-
static readonly
|
|
48
|
-
static readonly
|
|
49
|
-
static readonly
|
|
50
|
-
static readonly
|
|
51
|
-
static readonly
|
|
52
|
-
static readonly
|
|
53
|
-
static readonly
|
|
54
|
-
static readonly
|
|
55
|
-
static readonly
|
|
56
|
-
static readonly
|
|
57
|
-
static readonly
|
|
58
|
-
static readonly
|
|
59
|
-
static readonly
|
|
60
|
-
static readonly
|
|
61
|
-
static readonly
|
|
62
|
-
static readonly
|
|
63
|
-
static readonly
|
|
64
|
-
static readonly
|
|
65
|
-
static readonly
|
|
66
|
-
static readonly
|
|
67
|
-
static readonly
|
|
68
|
-
static readonly
|
|
69
|
-
static readonly
|
|
28
|
+
static readonly From = 26;
|
|
29
|
+
static readonly For = 27;
|
|
30
|
+
static readonly In = 28;
|
|
31
|
+
static readonly While = 29;
|
|
32
|
+
static readonly Continue = 30;
|
|
33
|
+
static readonly If = 31;
|
|
34
|
+
static readonly Else = 32;
|
|
35
|
+
static readonly Not = 33;
|
|
36
|
+
static readonly Frame = 34;
|
|
37
|
+
static readonly Sheet = 35;
|
|
38
|
+
static readonly Equals = 36;
|
|
39
|
+
static readonly NotEquals = 37;
|
|
40
|
+
static readonly GreaterThan = 38;
|
|
41
|
+
static readonly GreatOrEqualThan = 39;
|
|
42
|
+
static readonly LessThan = 40;
|
|
43
|
+
static readonly LessOrEqualThan = 41;
|
|
44
|
+
static readonly LogicalAnd = 42;
|
|
45
|
+
static readonly LogicalOr = 43;
|
|
46
|
+
static readonly Addition = 44;
|
|
47
|
+
static readonly Minus = 45;
|
|
48
|
+
static readonly Divide = 46;
|
|
49
|
+
static readonly Multiply = 47;
|
|
50
|
+
static readonly Modulus = 48;
|
|
51
|
+
static readonly AdditionAssign = 49;
|
|
52
|
+
static readonly MinusAssign = 50;
|
|
53
|
+
static readonly DivideAssign = 51;
|
|
54
|
+
static readonly MultiplyAssign = 52;
|
|
55
|
+
static readonly ModulusAssign = 53;
|
|
56
|
+
static readonly ANNOTATION_START = 54;
|
|
57
|
+
static readonly OPEN_PAREN = 55;
|
|
58
|
+
static readonly CLOSE_PAREN = 56;
|
|
59
|
+
static readonly NOT_CONNECTED = 57;
|
|
60
|
+
static readonly BOOLEAN_VALUE = 58;
|
|
61
|
+
static readonly ID = 59;
|
|
62
|
+
static readonly INTEGER_VALUE = 60;
|
|
63
|
+
static readonly DECIMAL_VALUE = 61;
|
|
64
|
+
static readonly NUMERIC_VALUE = 62;
|
|
65
|
+
static readonly STRING_VALUE = 63;
|
|
66
|
+
static readonly PERCENTAGE_VALUE = 64;
|
|
67
|
+
static readonly ALPHA_NUMERIC = 65;
|
|
68
|
+
static readonly WS = 66;
|
|
69
|
+
static readonly NEWLINE = 67;
|
|
70
|
+
static readonly COMMENT = 68;
|
|
70
71
|
static readonly channelNames: string[];
|
|
71
72
|
static readonly literalNames: (string | null)[];
|
|
72
73
|
static readonly symbolicNames: (string | null)[];
|
|
@@ -27,50 +27,51 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
27
27
|
static readonly Return = 23;
|
|
28
28
|
static readonly Define = 24;
|
|
29
29
|
static readonly Import = 25;
|
|
30
|
-
static readonly
|
|
31
|
-
static readonly
|
|
32
|
-
static readonly
|
|
33
|
-
static readonly
|
|
34
|
-
static readonly
|
|
35
|
-
static readonly
|
|
36
|
-
static readonly
|
|
37
|
-
static readonly
|
|
38
|
-
static readonly
|
|
39
|
-
static readonly
|
|
40
|
-
static readonly
|
|
41
|
-
static readonly
|
|
42
|
-
static readonly
|
|
43
|
-
static readonly
|
|
44
|
-
static readonly
|
|
45
|
-
static readonly
|
|
46
|
-
static readonly
|
|
47
|
-
static readonly
|
|
48
|
-
static readonly
|
|
49
|
-
static readonly
|
|
50
|
-
static readonly
|
|
51
|
-
static readonly
|
|
52
|
-
static readonly
|
|
53
|
-
static readonly
|
|
54
|
-
static readonly
|
|
55
|
-
static readonly
|
|
56
|
-
static readonly
|
|
57
|
-
static readonly
|
|
58
|
-
static readonly
|
|
59
|
-
static readonly
|
|
60
|
-
static readonly
|
|
61
|
-
static readonly
|
|
62
|
-
static readonly
|
|
63
|
-
static readonly
|
|
64
|
-
static readonly
|
|
65
|
-
static readonly
|
|
66
|
-
static readonly
|
|
67
|
-
static readonly
|
|
68
|
-
static readonly
|
|
69
|
-
static readonly
|
|
70
|
-
static readonly
|
|
71
|
-
static readonly
|
|
72
|
-
static readonly
|
|
73
|
-
static readonly
|
|
30
|
+
static readonly From = 26;
|
|
31
|
+
static readonly For = 27;
|
|
32
|
+
static readonly In = 28;
|
|
33
|
+
static readonly While = 29;
|
|
34
|
+
static readonly Continue = 30;
|
|
35
|
+
static readonly If = 31;
|
|
36
|
+
static readonly Else = 32;
|
|
37
|
+
static readonly Not = 33;
|
|
38
|
+
static readonly Frame = 34;
|
|
39
|
+
static readonly Sheet = 35;
|
|
40
|
+
static readonly Equals = 36;
|
|
41
|
+
static readonly NotEquals = 37;
|
|
42
|
+
static readonly GreaterThan = 38;
|
|
43
|
+
static readonly GreatOrEqualThan = 39;
|
|
44
|
+
static readonly LessThan = 40;
|
|
45
|
+
static readonly LessOrEqualThan = 41;
|
|
46
|
+
static readonly LogicalAnd = 42;
|
|
47
|
+
static readonly LogicalOr = 43;
|
|
48
|
+
static readonly Addition = 44;
|
|
49
|
+
static readonly Minus = 45;
|
|
50
|
+
static readonly Divide = 46;
|
|
51
|
+
static readonly Multiply = 47;
|
|
52
|
+
static readonly Modulus = 48;
|
|
53
|
+
static readonly AdditionAssign = 49;
|
|
54
|
+
static readonly MinusAssign = 50;
|
|
55
|
+
static readonly DivideAssign = 51;
|
|
56
|
+
static readonly MultiplyAssign = 52;
|
|
57
|
+
static readonly ModulusAssign = 53;
|
|
58
|
+
static readonly ANNOTATION_START = 54;
|
|
59
|
+
static readonly OPEN_PAREN = 55;
|
|
60
|
+
static readonly CLOSE_PAREN = 56;
|
|
61
|
+
static readonly NOT_CONNECTED = 57;
|
|
62
|
+
static readonly BOOLEAN_VALUE = 58;
|
|
63
|
+
static readonly ID = 59;
|
|
64
|
+
static readonly INTEGER_VALUE = 60;
|
|
65
|
+
static readonly DECIMAL_VALUE = 61;
|
|
66
|
+
static readonly NUMERIC_VALUE = 62;
|
|
67
|
+
static readonly STRING_VALUE = 63;
|
|
68
|
+
static readonly PERCENTAGE_VALUE = 64;
|
|
69
|
+
static readonly ALPHA_NUMERIC = 65;
|
|
70
|
+
static readonly WS = 66;
|
|
71
|
+
static readonly NEWLINE = 67;
|
|
72
|
+
static readonly COMMENT = 68;
|
|
73
|
+
static readonly INDENT = 69;
|
|
74
|
+
static readonly DEDENT = 70;
|
|
74
75
|
static readonly RULE_script = 0;
|
|
75
76
|
static readonly RULE_expression = 1;
|
|
76
77
|
static readonly RULE_flow_expressions = 2;
|
|
@@ -131,20 +132,21 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
131
132
|
static readonly RULE_array_expr = 57;
|
|
132
133
|
static readonly RULE_point_expr = 58;
|
|
133
134
|
static readonly RULE_import_expr = 59;
|
|
134
|
-
static readonly
|
|
135
|
-
static readonly
|
|
136
|
-
static readonly
|
|
137
|
-
static readonly
|
|
138
|
-
static readonly
|
|
139
|
-
static readonly
|
|
140
|
-
static readonly
|
|
141
|
-
static readonly
|
|
142
|
-
static readonly
|
|
143
|
-
static readonly
|
|
144
|
-
static readonly
|
|
145
|
-
static readonly
|
|
146
|
-
static readonly
|
|
147
|
-
static readonly
|
|
135
|
+
static readonly RULE_import_annotation_expr = 60;
|
|
136
|
+
static readonly RULE_frame_expr = 61;
|
|
137
|
+
static readonly RULE_if_expr = 62;
|
|
138
|
+
static readonly RULE_if_inner_expr = 63;
|
|
139
|
+
static readonly RULE_else_expr = 64;
|
|
140
|
+
static readonly RULE_while_expr = 65;
|
|
141
|
+
static readonly RULE_for_expr = 66;
|
|
142
|
+
static readonly RULE_part_set_expr = 67;
|
|
143
|
+
static readonly RULE_part_set_key = 68;
|
|
144
|
+
static readonly RULE_part_match_block = 69;
|
|
145
|
+
static readonly RULE_part_sub_expr = 70;
|
|
146
|
+
static readonly RULE_part_condition_expr = 71;
|
|
147
|
+
static readonly RULE_part_condition_key_only_expr = 72;
|
|
148
|
+
static readonly RULE_part_value_expr = 73;
|
|
149
|
+
static readonly RULE_annotation_comment_expr = 74;
|
|
148
150
|
static readonly literalNames: (string | null)[];
|
|
149
151
|
static readonly symbolicNames: (string | null)[];
|
|
150
152
|
static readonly ruleNames: string[];
|
|
@@ -216,6 +218,7 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
216
218
|
array_expr(): Array_exprContext;
|
|
217
219
|
point_expr(): Point_exprContext;
|
|
218
220
|
import_expr(): Import_exprContext;
|
|
221
|
+
import_annotation_expr(): Import_annotation_exprContext;
|
|
219
222
|
frame_expr(): Frame_exprContext;
|
|
220
223
|
if_expr(): If_exprContext;
|
|
221
224
|
if_inner_expr(): If_inner_exprContext;
|
|
@@ -813,9 +816,12 @@ export declare class GraphicForExprContext extends Graphic_exprContext {
|
|
|
813
816
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
814
817
|
}
|
|
815
818
|
export declare class Property_exprContext extends antlr.ParserRuleContext {
|
|
819
|
+
_extra?: Token | null;
|
|
816
820
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
817
821
|
property_key_expr(): Property_key_exprContext;
|
|
818
822
|
property_value_expr(): Property_value_exprContext;
|
|
823
|
+
STRING_VALUE(): antlr.TerminalNode[];
|
|
824
|
+
STRING_VALUE(i: number): antlr.TerminalNode | null;
|
|
819
825
|
get ruleIndex(): number;
|
|
820
826
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
821
827
|
}
|
|
@@ -885,8 +891,46 @@ export declare class Point_exprContext extends antlr.ParserRuleContext {
|
|
|
885
891
|
}
|
|
886
892
|
export declare class Import_exprContext extends antlr.ParserRuleContext {
|
|
887
893
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
894
|
+
get ruleIndex(): number;
|
|
895
|
+
copyFrom(ctx: Import_exprContext): void;
|
|
896
|
+
}
|
|
897
|
+
export declare class Import_specificContext extends Import_exprContext {
|
|
898
|
+
_moduleName?: Token | null;
|
|
899
|
+
_ID?: Token | null;
|
|
900
|
+
_funcNames: antlr.Token[];
|
|
901
|
+
constructor(ctx: Import_exprContext);
|
|
902
|
+
From(): antlr.TerminalNode;
|
|
888
903
|
Import(): antlr.TerminalNode;
|
|
904
|
+
ID(): antlr.TerminalNode[];
|
|
905
|
+
ID(i: number): antlr.TerminalNode | null;
|
|
906
|
+
import_annotation_expr(): Import_annotation_exprContext | null;
|
|
907
|
+
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
908
|
+
}
|
|
909
|
+
export declare class Import_all_simpleContext extends Import_exprContext {
|
|
910
|
+
_moduleName?: Token | null;
|
|
911
|
+
constructor(ctx: Import_exprContext);
|
|
912
|
+
From(): antlr.TerminalNode;
|
|
913
|
+
Import(): antlr.TerminalNode;
|
|
914
|
+
Multiply(): antlr.TerminalNode;
|
|
889
915
|
ID(): antlr.TerminalNode;
|
|
916
|
+
import_annotation_expr(): Import_annotation_exprContext | null;
|
|
917
|
+
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
918
|
+
}
|
|
919
|
+
export declare class Import_simpleContext extends Import_exprContext {
|
|
920
|
+
_moduleName?: Token | null;
|
|
921
|
+
constructor(ctx: Import_exprContext);
|
|
922
|
+
Import(): antlr.TerminalNode;
|
|
923
|
+
ID(): antlr.TerminalNode;
|
|
924
|
+
import_annotation_expr(): Import_annotation_exprContext | null;
|
|
925
|
+
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
926
|
+
}
|
|
927
|
+
export declare class Import_annotation_exprContext extends antlr.ParserRuleContext {
|
|
928
|
+
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
929
|
+
ANNOTATION_START(): antlr.TerminalNode;
|
|
930
|
+
ID(): antlr.TerminalNode[];
|
|
931
|
+
ID(i: number): antlr.TerminalNode | null;
|
|
932
|
+
Minus(): antlr.TerminalNode[];
|
|
933
|
+
Minus(i: number): antlr.TerminalNode | null;
|
|
890
934
|
get ruleIndex(): number;
|
|
891
935
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
892
936
|
}
|
|
@@ -71,7 +71,10 @@ import { Wire_expr_direction_onlyContext } from "./CircuitScriptParser.js";
|
|
|
71
71
|
import { Wire_exprContext } from "./CircuitScriptParser.js";
|
|
72
72
|
import { Array_exprContext } from "./CircuitScriptParser.js";
|
|
73
73
|
import { Point_exprContext } from "./CircuitScriptParser.js";
|
|
74
|
-
import {
|
|
74
|
+
import { Import_simpleContext } from "./CircuitScriptParser.js";
|
|
75
|
+
import { Import_all_simpleContext } from "./CircuitScriptParser.js";
|
|
76
|
+
import { Import_specificContext } from "./CircuitScriptParser.js";
|
|
77
|
+
import { Import_annotation_exprContext } from "./CircuitScriptParser.js";
|
|
75
78
|
import { Frame_exprContext } from "./CircuitScriptParser.js";
|
|
76
79
|
import { If_exprContext } from "./CircuitScriptParser.js";
|
|
77
80
|
import { If_inner_exprContext } from "./CircuitScriptParser.js";
|
|
@@ -159,7 +162,10 @@ export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisit
|
|
|
159
162
|
visitWire_expr?: (ctx: Wire_exprContext) => Result;
|
|
160
163
|
visitArray_expr?: (ctx: Array_exprContext) => Result;
|
|
161
164
|
visitPoint_expr?: (ctx: Point_exprContext) => Result;
|
|
162
|
-
|
|
165
|
+
visitImport_simple?: (ctx: Import_simpleContext) => Result;
|
|
166
|
+
visitImport_all_simple?: (ctx: Import_all_simpleContext) => Result;
|
|
167
|
+
visitImport_specific?: (ctx: Import_specificContext) => Result;
|
|
168
|
+
visitImport_annotation_expr?: (ctx: Import_annotation_exprContext) => Result;
|
|
163
169
|
visitFrame_expr?: (ctx: Frame_exprContext) => Result;
|
|
164
170
|
visitIf_expr?: (ctx: If_exprContext) => Result;
|
|
165
171
|
visitIf_inner_expr?: (ctx: If_inner_exprContext) => Result;
|
|
@@ -28,11 +28,18 @@ export declare class NodeScriptEnvironment {
|
|
|
28
28
|
textMeasurementCanvas: Dom | undefined;
|
|
29
29
|
getCanvasWindow(): Dom;
|
|
30
30
|
prepareSVGEnvironment(): Promise<void>;
|
|
31
|
-
readFile(path: PathOrFileDescriptor, options
|
|
31
|
+
readFile(path: PathOrFileDescriptor, options?: any): Promise<string>;
|
|
32
|
+
writeFileSync(path: PathOrFileDescriptor, data: string): void;
|
|
32
33
|
getAbsolutePath(filePath: string): string;
|
|
33
34
|
getDirPath(filePath: string): string;
|
|
34
35
|
setCurrentFile(filePath: string): string;
|
|
35
36
|
getCurrentFile(): string;
|
|
36
37
|
getRelativeToCurrentFolder(filePath: string): string;
|
|
37
38
|
exists(path: PathLike): Promise<boolean>;
|
|
39
|
+
hashStringSHA256(value: string): string;
|
|
40
|
+
dirname(filePath: string): string;
|
|
41
|
+
extname(filePath: string): string;
|
|
42
|
+
basename(filePath: string, ext: string): string;
|
|
43
|
+
join(...paths: string[]): string;
|
|
44
|
+
relative(from: string, to: string): string;
|
|
38
45
|
}
|
package/dist/types/execute.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ExecutionScope } from './objects/ExecutionScope.js';
|
|
|
5
5
|
import { Net } from './objects/Net.js';
|
|
6
6
|
import { NumericValue, ParamDefinition } from './objects/ParamDefinition.js';
|
|
7
7
|
import { PinDefinition, PinId } from './objects/PinDefinition.js';
|
|
8
|
-
import { AnyReference, CFunction, CFunctionEntry, CFunctionResult, CallableParameter, ComponentPin } from './objects/types.js';
|
|
8
|
+
import { AnyReference, CFunction, CFunctionEntry, CFunctionResult, CallableParameter, ComponentPin, ComponentUnitDefinition } from './objects/types.js';
|
|
9
9
|
import { Wire } from './objects/Wire.js';
|
|
10
10
|
import { Logger } from './logger.js';
|
|
11
11
|
import { UnitDimension } from './helpers.js';
|
|
@@ -53,7 +53,10 @@ export declare class ExecutionContext {
|
|
|
53
53
|
copy: boolean;
|
|
54
54
|
angle?: NumericValue;
|
|
55
55
|
followWireOrientation: boolean;
|
|
56
|
+
units: [string, ComponentUnitDefinition][];
|
|
56
57
|
}, isModule?: boolean): ClassComponent;
|
|
58
|
+
private extractPinsFromUnits;
|
|
59
|
+
private generateComponentUnits;
|
|
57
60
|
private removeArrangePropDuplicates;
|
|
58
61
|
private getArrangePropPins;
|
|
59
62
|
printPoint(extra?: string): void;
|
|
@@ -79,12 +82,12 @@ export declare class ExecutionContext {
|
|
|
79
82
|
resetBreakContextFunctionCalls(): void;
|
|
80
83
|
popBreakContext(): ParserRuleContext;
|
|
81
84
|
getBreakContext(): ParserRuleContext;
|
|
82
|
-
createFunction(functionName: string, __runFunc: CFunction, source?: ParserRuleContext, uniqueId?: string): void;
|
|
85
|
+
createFunction(namespace: string, functionName: string, __runFunc: CFunction, source?: ParserRuleContext, uniqueId?: string): void;
|
|
83
86
|
hasFunction(functionName: string): boolean;
|
|
84
87
|
getFunction(functionName: string): CFunctionEntry;
|
|
85
88
|
resolveVariable(executionStack: ExecutionContext[], idName: string, trailers?: string[]): AnyReference;
|
|
86
89
|
resolveTrailers(type: ReferenceTypes, item: any, trailers?: string[]): AnyReference;
|
|
87
|
-
callFunction(
|
|
90
|
+
callFunction(functionReference: AnyReference, functionParams: CallableParameter[], executionStack: ExecutionContext[], netNamespace: string): CFunctionResult;
|
|
88
91
|
mergeScope(childScope: ExecutionScope, namespace: string): ClassComponent[];
|
|
89
92
|
addWire(segments: [string, (number | UnitDimension)?][]): Wire;
|
|
90
93
|
addPoint(pointId: string, userDefined?: boolean): ComponentPin;
|
package/dist/types/globals.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const TOOL_VERSION = "0.1.5";
|
|
2
2
|
export declare const Delimiter1 = "-";
|
|
3
3
|
export declare const DoubleDelimiter1 = "--";
|
|
4
|
+
export declare const BaseNamespace = "--.";
|
|
5
|
+
export declare const RefdesFileSuffix = ".refdes.json";
|
|
4
6
|
export declare enum GlobalNames {
|
|
5
7
|
__root = "--root",
|
|
6
8
|
symbol = "symbol"
|
|
@@ -82,6 +84,7 @@ export declare enum ReferenceTypes {
|
|
|
82
84
|
variable = "variable",
|
|
83
85
|
instance = "instance",
|
|
84
86
|
pinType = "pinType",
|
|
87
|
+
module = "module",
|
|
85
88
|
unknown = "unknown"
|
|
86
89
|
}
|
|
87
90
|
export declare enum BlockTypes {
|
|
@@ -112,3 +115,4 @@ export declare const RenderFlags: {
|
|
|
112
115
|
};
|
|
113
116
|
export declare const SymbolValidatorContext = "_sym";
|
|
114
117
|
export declare const TrailerArrayIndex = "index";
|
|
118
|
+
export declare const DefaultComponentUnit = "__default";
|
package/dist/types/graph.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Graph } from "@dagrejs/graphlib";
|
|
2
2
|
import { SymbolPinDefintion } from "./draw_symbols.js";
|
|
3
3
|
import { RenderFrame, RenderComponent, RenderWire } from "./layout.js";
|
|
4
|
-
import { ClassComponent } from "./objects/ClassComponent.js";
|
|
4
|
+
import { ClassComponent, ComponentUnit } from "./objects/ClassComponent.js";
|
|
5
5
|
import { SequenceItem } from "./objects/ExecutionScope.js";
|
|
6
6
|
import { Net } from "./objects/Net.js";
|
|
7
7
|
import { Logger } from "./logger.js";
|
|
@@ -22,7 +22,7 @@ export declare class NetGraph {
|
|
|
22
22
|
private getComponentName;
|
|
23
23
|
}
|
|
24
24
|
export declare function getWireName(wireId: number): string;
|
|
25
|
-
export declare function generateLayoutPinDefinition(
|
|
25
|
+
export declare function generateLayoutPinDefinition(componentUnit: ComponentUnit): SymbolPinDefintion[];
|
|
26
26
|
export declare enum RenderItemType {
|
|
27
27
|
Wire = "wire",
|
|
28
28
|
Component = "component"
|
package/dist/types/helpers.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type SVGWindow = any;
|
|
|
11
11
|
import { NumericValue } from "./objects/ParamDefinition.js";
|
|
12
12
|
import { NodeScriptEnvironment } from "./environment.js";
|
|
13
13
|
import { ClassComponent } from "./objects/ClassComponent.js";
|
|
14
|
+
import { ImportedModule } from "./objects/types.js";
|
|
14
15
|
export declare enum JSModuleType {
|
|
15
16
|
CommonJs = "cjs",
|
|
16
17
|
ESM = "mjs"
|
|
@@ -46,7 +47,7 @@ type RenderScriptReturn = {
|
|
|
46
47
|
errors: BaseError[];
|
|
47
48
|
};
|
|
48
49
|
export declare function renderScript(scriptData: string, outputPath: string | null, options: ScriptOptions): Promise<RenderScriptReturn>;
|
|
49
|
-
export declare function renderScriptCustom(scriptData: string, outputPath: string | null, options: ScriptOptions, parseHandlers: ParseOutputHandler[], postAnnotationCallbacks: ((options: ScriptOptions, scriptData: string, tree: ScriptContext, tokens: CommonTokenStream, componentLinks: Map<ParserRuleContext, ClassComponent
|
|
50
|
+
export declare function renderScriptCustom(scriptData: string, outputPath: string | null, options: ScriptOptions, parseHandlers: ParseOutputHandler[], postAnnotationCallbacks: ((options: ScriptOptions, scriptData: string, tree: ScriptContext, tokens: CommonTokenStream, componentLinks: Map<ParserRuleContext, ClassComponent>, importedModule: ImportedModule[], environment: NodeScriptEnvironment) => void)[]): Promise<RenderScriptReturn>;
|
|
50
51
|
export declare abstract class ParseOutputHandler {
|
|
51
52
|
beforeRender: boolean;
|
|
52
53
|
afterRender: boolean;
|
package/dist/types/layout.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Graph } from '@dagrejs/graphlib';
|
|
2
2
|
import { SymbolGraphic, SymbolText, SymbolDrawingCommands, SimplePoint } from "./draw_symbols.js";
|
|
3
|
-
import { ClassComponent } from "./objects/ClassComponent.js";
|
|
3
|
+
import { ClassComponent, ComponentUnit } from "./objects/ClassComponent.js";
|
|
4
4
|
import { WireAutoDirection } from './globals.js';
|
|
5
5
|
import { Wire, WireSegment } from './objects/Wire.js';
|
|
6
6
|
import { Net } from './objects/Net.js';
|
|
@@ -41,7 +41,7 @@ export declare class LayoutEngine {
|
|
|
41
41
|
printWarnings(): void;
|
|
42
42
|
}
|
|
43
43
|
type RenderItem = RenderComponent | RenderWire | RenderText;
|
|
44
|
-
export declare function applyComponentParamsToSymbol(
|
|
44
|
+
export declare function applyComponentParamsToSymbol(componentUnit: ComponentUnit, symbol: SymbolGraphic): void;
|
|
45
45
|
export declare function getBounds(components: (RenderComponent | RenderText)[], wires: RenderWire[], junctions: RenderJunction[], frames: RenderFrame[]): BoundBox;
|
|
46
46
|
export declare class RenderObject {
|
|
47
47
|
x: NumericValue;
|
|
@@ -89,11 +89,12 @@ export type MergedWire = {
|
|
|
89
89
|
};
|
|
90
90
|
export declare class RenderComponent extends RenderObject {
|
|
91
91
|
component: ClassComponent;
|
|
92
|
+
unitId: string;
|
|
92
93
|
symbol: SymbolGraphic;
|
|
93
94
|
width: number;
|
|
94
95
|
height: number;
|
|
95
96
|
displaySymbol: string | null;
|
|
96
|
-
constructor(component: ClassComponent, width: number, height: number);
|
|
97
|
+
constructor(component: ClassComponent, unitId: string, width: number, height: number);
|
|
97
98
|
doesOverlap(other: RenderComponent): boolean;
|
|
98
99
|
toString(): string;
|
|
99
100
|
}
|
|
@@ -146,7 +147,7 @@ export type SheetFrame = {
|
|
|
146
147
|
junctions: RenderJunction[];
|
|
147
148
|
mergedWires: MergedWire[];
|
|
148
149
|
};
|
|
149
|
-
export declare function CalculatePinPositions(
|
|
150
|
+
export declare function CalculatePinPositions(unit: ComponentUnit): Map<number, {
|
|
150
151
|
x: NumericValue;
|
|
151
152
|
y: NumericValue;
|
|
152
153
|
angle: NumericValue;
|
|
@@ -6,6 +6,32 @@ import { PinDefinition, PinId } from './PinDefinition.js';
|
|
|
6
6
|
import { WireSegment } from './Wire.js';
|
|
7
7
|
import { ExecutionContext } from '../execute.js';
|
|
8
8
|
import { NumericValue } from './ParamDefinition.js';
|
|
9
|
+
export declare class ComponentUnit {
|
|
10
|
+
parent: ClassComponent;
|
|
11
|
+
unitId: string;
|
|
12
|
+
refdesSuffix: string;
|
|
13
|
+
suffix: string | null;
|
|
14
|
+
get instanceName(): string;
|
|
15
|
+
parameters: Map<string, number | string | NumericValue>;
|
|
16
|
+
numPins: number;
|
|
17
|
+
pins: Map<PinId, PinDefinition>;
|
|
18
|
+
pinsFlat: PinDefinition[];
|
|
19
|
+
pinsMaxPositions: Map<string, number>;
|
|
20
|
+
arrangeProps: Map<string, PinId[]> | null;
|
|
21
|
+
displayProp: SymbolDrawingCommands | null;
|
|
22
|
+
widthProp: number | null;
|
|
23
|
+
heightProp: number | null;
|
|
24
|
+
angleProp: number;
|
|
25
|
+
followWireOrientationProp: boolean;
|
|
26
|
+
wireOrientationAngle: number;
|
|
27
|
+
useWireOrientationAngle: boolean;
|
|
28
|
+
didSetWireOrientationAngle: boolean;
|
|
29
|
+
_unplacedPins: PinId[];
|
|
30
|
+
constructor(unitId: string, parent: ClassComponent);
|
|
31
|
+
clone(): ComponentUnit;
|
|
32
|
+
setParam(key: string, value: number | string | NumericValue): void;
|
|
33
|
+
isEqual(other: ComponentUnit): boolean;
|
|
34
|
+
}
|
|
9
35
|
export declare class ClassComponent {
|
|
10
36
|
instanceName: string;
|
|
11
37
|
numPins: number;
|
|
@@ -14,27 +40,21 @@ export declare class ClassComponent {
|
|
|
14
40
|
pinNets: Map<PinId, Net>;
|
|
15
41
|
pinWires: Map<number, WireSegment[]>;
|
|
16
42
|
pinsMaxPositions: Map<string, number>;
|
|
43
|
+
units: ComponentUnit[];
|
|
17
44
|
_cachedPins: string;
|
|
18
45
|
_cachedParams: string;
|
|
19
46
|
_copyID?: number;
|
|
20
47
|
_copyFrom?: ClassComponent;
|
|
21
48
|
_pointLinkComponent?: ClassComponent;
|
|
22
49
|
_unplacedPins: PinId[];
|
|
23
|
-
arrangeProps: Map<string, PinId[]> | null;
|
|
24
|
-
displayProp: SymbolDrawingCommands | null;
|
|
25
|
-
widthProp: number | null;
|
|
26
|
-
heightProp: number | null;
|
|
27
50
|
typeProp: string | null;
|
|
28
51
|
copyProp: boolean;
|
|
29
|
-
angleProp: number;
|
|
30
|
-
followWireOrientationProp: boolean;
|
|
31
|
-
wireOrientationAngle: number;
|
|
32
|
-
useWireOrientationAngle: boolean;
|
|
33
|
-
didSetWireOrientationAngle: boolean;
|
|
34
52
|
assignedRefDes: string | null;
|
|
35
53
|
placeHolderRefDes: string | null;
|
|
54
|
+
forceSaveRefdesAnnotation: boolean;
|
|
36
55
|
ctxReferences: CtxReference[];
|
|
37
56
|
_creationIndex: number;
|
|
57
|
+
pinUnitMap: Map<PinId, ComponentUnit>;
|
|
38
58
|
constructor(instanceName: string, numPins: number);
|
|
39
59
|
setupPins(): void;
|
|
40
60
|
getDefaultPin(): PinId;
|
|
@@ -51,6 +71,10 @@ export declare class ClassComponent {
|
|
|
51
71
|
static simple(instanceName: string, numPins: number): ClassComponent;
|
|
52
72
|
isEqual(other: ClassComponent): boolean;
|
|
53
73
|
clone(): ClassComponent;
|
|
74
|
+
getUnit(unitId?: string | null): ComponentUnit;
|
|
75
|
+
addDefaultUnit(displayProp: SymbolDrawingCommands): void;
|
|
76
|
+
refreshPinUnitMap(): void;
|
|
77
|
+
getUnitForPin(pinId: PinId): ComponentUnit;
|
|
54
78
|
}
|
|
55
79
|
export declare class ModuleComponent extends ClassComponent {
|
|
56
80
|
moduleContainsExpressions?: Expressions_blockContext;
|
|
@@ -63,4 +87,5 @@ export type CtxReference = {
|
|
|
63
87
|
ctx: ParserRuleContext;
|
|
64
88
|
indexedStack: [ParserRuleContext, number][];
|
|
65
89
|
creationFlag: boolean;
|
|
90
|
+
filePath: string;
|
|
66
91
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClassComponent } from './ClassComponent.js';
|
|
2
2
|
import { Net } from './Net.js';
|
|
3
|
-
import { CFunction, CFunctionEntry, ComponentPinNet, ComponentPinNetPair, ComponentPinWireId, ParseSymbolType, ValueType } from './types.js';
|
|
3
|
+
import { CFunction, CFunctionEntry, ComponentPinNet, ComponentPinNetPair, ComponentPinWireId, ImportedModule, ParseSymbolType, ValueType } from './types.js';
|
|
4
4
|
import { BlockTypes, LayoutDirection } from '../globals.js';
|
|
5
5
|
import { Wire, WireSegment } from './Wire.js';
|
|
6
6
|
import { Frame } from './Frame.js';
|
|
@@ -19,6 +19,7 @@ export declare class ExecutionScope {
|
|
|
19
19
|
symbols: Map<string, {
|
|
20
20
|
type: ParseSymbolType;
|
|
21
21
|
}>;
|
|
22
|
+
modules: Map<string, ImportedModule>;
|
|
22
23
|
blockStack: Map<number, BlockStackEntry>;
|
|
23
24
|
contextStack: ParserRuleContext[];
|
|
24
25
|
onPropertyHandler: OnPropertyHandler[];
|
|
@@ -59,6 +60,7 @@ export declare class ExecutionScope {
|
|
|
59
60
|
popOnPropertyHandler(): OnPropertyHandler;
|
|
60
61
|
triggerPropertyHandler(visitor: BaseVisitor, value: any, valueCtx: ParserRuleContext): void;
|
|
61
62
|
getInstances(): ClassComponent[];
|
|
63
|
+
copyTo(scope: ExecutionScope): void;
|
|
62
64
|
}
|
|
63
65
|
export declare enum SequenceAction {
|
|
64
66
|
To = "to",
|
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import { ParserRuleContext, Token } from 'antlr4ng';
|
|
1
|
+
import { CommonTokenStream, ParserRuleContext, Token } from 'antlr4ng';
|
|
2
2
|
import { ExecutionContext } from '../execute.js';
|
|
3
3
|
import { ClassComponent } from './ClassComponent.js';
|
|
4
4
|
import { Net } from './Net.js';
|
|
5
5
|
import { NumericValue, PercentageValue } from './ParamDefinition.js';
|
|
6
6
|
import { ReferenceTypes } from '../globals.js';
|
|
7
|
-
import { PinId } from './PinDefinition.js';
|
|
7
|
+
import { PinDefinition, PinId } from './PinDefinition.js';
|
|
8
|
+
import { ScriptContext } from 'src/antlr/CircuitScriptParser.js';
|
|
9
|
+
import { SymbolDrawingCommands } from 'src/draw_symbols.js';
|
|
8
10
|
export type CFunction = (args: CallableParameter[], options?: CFunctionOptions) => CFunctionResult;
|
|
9
11
|
export declare class CFunctionEntry {
|
|
10
12
|
name: string;
|
|
13
|
+
namespace: string;
|
|
14
|
+
originalNamespace: string;
|
|
11
15
|
execute: CFunction;
|
|
12
16
|
uniqueId?: string;
|
|
13
17
|
source?: ParserRuleContext;
|
|
14
|
-
constructor(name: string, execute: CFunction, source?: ParserRuleContext, uniqueId?: string);
|
|
18
|
+
constructor(namespace: string, name: string, execute: CFunction, source?: ParserRuleContext, uniqueId?: string);
|
|
15
19
|
toString(): string;
|
|
16
20
|
}
|
|
17
21
|
export type CFunctionOptions = {
|
|
18
22
|
netNamespace?: string;
|
|
19
23
|
functionCallIndex: number;
|
|
20
24
|
};
|
|
25
|
+
export type NewContextOptions = {
|
|
26
|
+
netNamespace?: string;
|
|
27
|
+
namespace?: string;
|
|
28
|
+
functionCallIndex: number;
|
|
29
|
+
};
|
|
21
30
|
export type CFunctionResult = [
|
|
22
31
|
executionContext: ExecutionContext,
|
|
23
32
|
result: ValueType | ClassComponent | null
|
|
@@ -113,3 +122,31 @@ export declare enum NetTypes {
|
|
|
113
122
|
Any = "any",
|
|
114
123
|
Source = "source"
|
|
115
124
|
}
|
|
125
|
+
export declare class ImportedModule {
|
|
126
|
+
moduleName: string;
|
|
127
|
+
context: ExecutionContext;
|
|
128
|
+
importHandlingFlag: ImportFunctionHandling;
|
|
129
|
+
specifiedImports: string[];
|
|
130
|
+
moduleNamespace: string;
|
|
131
|
+
moduleFilePath: string;
|
|
132
|
+
enableRefdesAnnotation: boolean;
|
|
133
|
+
enableRefdesAnnotationFile: boolean;
|
|
134
|
+
tree: ScriptContext;
|
|
135
|
+
tokens: CommonTokenStream;
|
|
136
|
+
constructor(moduleName: string, moduleNamespace: string, moduleFilePath: string, tree: ScriptContext, tokens: CommonTokenStream, context: ExecutionContext, flag: ImportFunctionHandling, specifiedImports: string[]);
|
|
137
|
+
}
|
|
138
|
+
export declare enum ImportFunctionHandling {
|
|
139
|
+
AllWithNamespace = "all-with-namespace",
|
|
140
|
+
AllMergeIntoNamespace = "all-merge-into-namespace",
|
|
141
|
+
SpecificMergeIntoNamespace = "specific-merge-into-namespace"
|
|
142
|
+
}
|
|
143
|
+
export type ComponentUnitDefinition = {
|
|
144
|
+
width: NumericValue | null;
|
|
145
|
+
height: NumericValue | null;
|
|
146
|
+
angle: NumericValue | null;
|
|
147
|
+
followWireOrientation: boolean | null;
|
|
148
|
+
pins: PinDefinition[];
|
|
149
|
+
display: SymbolDrawingCommands | null;
|
|
150
|
+
arrange: any | null;
|
|
151
|
+
suffix: string | null;
|
|
152
|
+
};
|
|
@@ -18,6 +18,7 @@ export declare class SymbolTable {
|
|
|
18
18
|
searchParentContext(executionContext: ExecutionContext, id: string): ExecutionContext | null;
|
|
19
19
|
clearUndefined(): void;
|
|
20
20
|
}
|
|
21
|
+
export declare function cloneSymbol(symbol: SymbolTableItemDefined): SymbolTableItemDefined;
|
|
21
22
|
export type SymbolTableItemDefined = {
|
|
22
23
|
id: string;
|
|
23
24
|
type: ParseSymbolType;
|