circuitscript 0.1.15 → 0.1.16
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 +96 -34
- package/dist/cjs/antlr/CircuitScriptLexer.js +3 -3
- package/dist/cjs/antlr/CircuitScriptParser.js +868 -757
- package/dist/cjs/builtinMethods.js +11 -1
- package/dist/cjs/execute.js +18 -11
- package/dist/cjs/globals.js +3 -1
- package/dist/cjs/graph.js +298 -0
- package/dist/cjs/helpers.js +6 -2
- package/dist/cjs/layout.js +12 -258
- package/dist/cjs/objects/types.js +27 -6
- package/dist/cjs/visitor.js +32 -30
- package/dist/esm/BaseVisitor.js +96 -34
- package/dist/esm/antlr/CircuitScriptLexer.js +3 -3
- package/dist/esm/antlr/CircuitScriptParser.js +864 -755
- package/dist/esm/antlr/CircuitScriptVisitor.js +2 -0
- package/dist/esm/builtinMethods.js +11 -1
- package/dist/esm/execute.js +19 -12
- package/dist/esm/globals.js +2 -0
- package/dist/esm/graph.js +293 -0
- package/dist/esm/helpers.js +6 -2
- package/dist/esm/layout.js +8 -234
- package/dist/esm/objects/types.js +27 -6
- package/dist/esm/visitor.js +33 -31
- package/dist/types/BaseVisitor.d.ts +3 -1
- package/dist/types/antlr/CircuitScriptParser.d.ts +42 -26
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +4 -0
- package/dist/types/execute.d.ts +5 -5
- package/dist/types/globals.d.ts +3 -1
- package/dist/types/graph.d.ts +28 -0
- package/dist/types/layout.d.ts +2 -8
- package/dist/types/objects/ExecutionScope.d.ts +3 -3
- package/dist/types/objects/types.d.ts +16 -6
- package/package.json +1 -1
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 } from './objects/PinDefinition.js';
|
|
8
|
-
import { AnyReference, CFunction, CFunctionResult, CallableParameter, ComponentPin
|
|
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';
|
|
11
11
|
import { ParserRuleContext } from 'antlr4ng';
|
|
@@ -26,7 +26,7 @@ export declare class ExecutionContext {
|
|
|
26
26
|
returnValue: null;
|
|
27
27
|
silent: boolean;
|
|
28
28
|
logger: Logger;
|
|
29
|
-
__functionCache:
|
|
29
|
+
__functionCache: Map<string, CFunction>;
|
|
30
30
|
parentContext: ExecutionContext;
|
|
31
31
|
componentAngleFollowsWire: boolean;
|
|
32
32
|
warnings: ExecutionWarning[];
|
|
@@ -71,10 +71,10 @@ export declare class ExecutionContext {
|
|
|
71
71
|
addBreakContext(ctx: ParserRuleContext): void;
|
|
72
72
|
popBreakContext(): ParserRuleContext;
|
|
73
73
|
getBreakContext(): ParserRuleContext;
|
|
74
|
-
createFunction(functionName: string, __runFunc: CFunction): void;
|
|
74
|
+
createFunction(functionName: string, __runFunc: CFunction, source?: ParserRuleContext, uniqueId?: string): void;
|
|
75
75
|
hasFunction(functionName: string): boolean;
|
|
76
|
-
getFunction(functionName: string):
|
|
77
|
-
resolveVariable(executionStack: ExecutionContext[], idName: string, trailers?: string[]):
|
|
76
|
+
getFunction(functionName: string): CFunctionEntry;
|
|
77
|
+
resolveVariable(executionStack: ExecutionContext[], idName: string, trailers?: string[]): AnyReference;
|
|
78
78
|
resolveTrailers(type: ReferenceTypes, item: any, trailers?: string[]): AnyReference;
|
|
79
79
|
callFunction(functionName: string, functionParams: CallableParameter[], executionStack: ExecutionContext[], netNamespace: string): CFunctionResult;
|
|
80
80
|
mergeScope(childScope: ExecutionScope, namespace: string): void;
|
package/dist/types/globals.d.ts
CHANGED
|
@@ -80,7 +80,8 @@ export declare enum ReferenceTypes {
|
|
|
80
80
|
value = "value",
|
|
81
81
|
variable = "variable",
|
|
82
82
|
instance = "instance",
|
|
83
|
-
pinType = "pinType"
|
|
83
|
+
pinType = "pinType",
|
|
84
|
+
unknown = "unknown"
|
|
84
85
|
}
|
|
85
86
|
export declare enum BlockTypes {
|
|
86
87
|
Branch = 1,
|
|
@@ -109,3 +110,4 @@ export declare const RenderFlags: {
|
|
|
109
110
|
ShowLabelOrigin: boolean;
|
|
110
111
|
};
|
|
111
112
|
export declare const SymbolValidatorContext = "_sym";
|
|
113
|
+
export declare const TrailerArrayIndex = "index";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Graph } from "@dagrejs/graphlib";
|
|
2
|
+
import { SymbolPinDefintion } from "./draw_symbols.js";
|
|
3
|
+
import { RenderFrame } from "./layout.js";
|
|
4
|
+
import { ClassComponent } from "./objects/ClassComponent.js";
|
|
5
|
+
import { SequenceItem } from "./objects/ExecutionScope.js";
|
|
6
|
+
import { Net } from "./objects/Net.js";
|
|
7
|
+
import { Logger } from "./logger.js";
|
|
8
|
+
import { ComponentPinNetPair } from "./objects/types.js";
|
|
9
|
+
export declare class NetGraph {
|
|
10
|
+
logger: Logger;
|
|
11
|
+
constructor(logger: Logger);
|
|
12
|
+
generateLayoutGraph(sequence: SequenceItem[], nets: [ClassComponent, pin: number, net: Net][]): {
|
|
13
|
+
graph: Graph;
|
|
14
|
+
containerFrames: RenderFrame[];
|
|
15
|
+
};
|
|
16
|
+
private setGraphEdge;
|
|
17
|
+
protected print(...params: any[]): void;
|
|
18
|
+
generateNetGraph(nets: ComponentPinNetPair[]): void;
|
|
19
|
+
findNodePaths(graph: Graph, startNode: string, endNode: string, seenNodes?: string[]): string[][];
|
|
20
|
+
private getNetNodeName;
|
|
21
|
+
private getComponentName;
|
|
22
|
+
}
|
|
23
|
+
export declare function getWireName(wireId: number): string;
|
|
24
|
+
export declare function generateLayoutPinDefinition(component: ClassComponent): SymbolPinDefintion[];
|
|
25
|
+
export declare enum RenderItemType {
|
|
26
|
+
Wire = "wire",
|
|
27
|
+
Component = "component"
|
|
28
|
+
}
|
package/dist/types/layout.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Graph } from '@dagrejs/graphlib';
|
|
2
2
|
import { SymbolGraphic, SymbolText, SymbolDrawingCommands, SimplePoint } from "./draw_symbols.js";
|
|
3
3
|
import { ClassComponent } from "./objects/ClassComponent.js";
|
|
4
|
-
import { SequenceItem } from "./objects/ExecutionScope.js";
|
|
5
4
|
import { WireAutoDirection } from './globals.js';
|
|
6
5
|
import { WireSegment } from './objects/Wire.js';
|
|
7
6
|
import { Net } from './objects/Net.js';
|
|
@@ -14,13 +13,13 @@ export declare class LayoutEngine {
|
|
|
14
13
|
logger: Logger;
|
|
15
14
|
layoutWarnings: string[];
|
|
16
15
|
showBaseFrame: boolean;
|
|
17
|
-
constructor(options?: {
|
|
16
|
+
constructor(logger: Logger, options?: {
|
|
18
17
|
showBaseFrame: boolean;
|
|
19
18
|
});
|
|
20
19
|
protected print(...params: any[]): void;
|
|
21
20
|
protected printLevel(level: number, ...params: any[]): void;
|
|
22
21
|
protected padLevel(value: number): string;
|
|
23
|
-
runLayout(
|
|
22
|
+
runLayout(graph: Graph, containerFrames: RenderFrame[], nets: ComponentPinNetPair[]): SheetFrame[];
|
|
24
23
|
private collectRenderNets;
|
|
25
24
|
private flattenFrameItems;
|
|
26
25
|
private findJunctions;
|
|
@@ -31,11 +30,6 @@ export declare class LayoutEngine {
|
|
|
31
30
|
dumpFrame(frame: RenderFrame, level?: number): void;
|
|
32
31
|
private prepareFrames;
|
|
33
32
|
private checkAddFrameTitle;
|
|
34
|
-
generateLayoutGraph(sequence: SequenceItem[], nets: [ClassComponent, pin: number, net: Net][]): {
|
|
35
|
-
graph: Graph;
|
|
36
|
-
containerFrames: RenderFrame[];
|
|
37
|
-
};
|
|
38
|
-
private setGraphEdge;
|
|
39
33
|
private sizeSubGraphs;
|
|
40
34
|
private walkAndPlaceGraph;
|
|
41
35
|
private placeSubgraphV2;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClassComponent } from './ClassComponent.js';
|
|
2
2
|
import { Net } from './Net.js';
|
|
3
|
-
import {
|
|
3
|
+
import { CFunctionEntry, ComponentPinNet, ComponentPinNetPair, ComponentPinWireId, 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';
|
|
@@ -12,7 +12,7 @@ export declare class ExecutionScope {
|
|
|
12
12
|
scopeId: number;
|
|
13
13
|
private nets;
|
|
14
14
|
instances: Map<string, ClassComponent>;
|
|
15
|
-
functions: Map<string,
|
|
15
|
+
functions: Map<string, CFunctionEntry>;
|
|
16
16
|
variables: Map<string, ValueType | ClassComponent>;
|
|
17
17
|
symbols: Map<string, {
|
|
18
18
|
type: ParseSymbolType;
|
|
@@ -33,7 +33,7 @@ export declare class ExecutionScope {
|
|
|
33
33
|
componentRoot: ClassComponent | null;
|
|
34
34
|
copyIDs: Map<string, number>;
|
|
35
35
|
sequence: SequenceItem[];
|
|
36
|
-
constructor(
|
|
36
|
+
private constructor();
|
|
37
37
|
static scopeId: number;
|
|
38
38
|
static create(): ExecutionScope;
|
|
39
39
|
private findNet;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { Token } from 'antlr4ng';
|
|
1
|
+
import { 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
7
|
export type CFunction = (args: CallableParameter[], options?: CFunctionOptions) => CFunctionResult;
|
|
8
|
+
export declare class CFunctionEntry {
|
|
9
|
+
name: string;
|
|
10
|
+
execute: CFunction;
|
|
11
|
+
uniqueId?: string;
|
|
12
|
+
source?: ParserRuleContext;
|
|
13
|
+
constructor(name: string, execute: CFunction, source?: ParserRuleContext, uniqueId?: string);
|
|
14
|
+
toString(): string;
|
|
15
|
+
}
|
|
8
16
|
export type CFunctionOptions = {
|
|
9
17
|
netNamespace?: string;
|
|
10
18
|
};
|
|
@@ -50,20 +58,22 @@ export type FunctionDefinedParameter = [
|
|
|
50
58
|
export declare class AnyReference {
|
|
51
59
|
found: boolean;
|
|
52
60
|
name?: string;
|
|
53
|
-
trailers: string[];
|
|
54
|
-
type
|
|
61
|
+
trailers: (string | ['index', number])[];
|
|
62
|
+
type: ReferenceTypes;
|
|
55
63
|
value?: any;
|
|
56
64
|
parentValue?: any;
|
|
65
|
+
referenceName: string;
|
|
57
66
|
constructor(refType: {
|
|
58
67
|
found: boolean;
|
|
59
68
|
name?: string;
|
|
60
|
-
trailers?: string[];
|
|
69
|
+
trailers?: (string | ['index', number])[];
|
|
61
70
|
type?: ReferenceTypes;
|
|
62
71
|
value?: any;
|
|
63
72
|
parentValue?: any;
|
|
64
73
|
});
|
|
74
|
+
toString(): string;
|
|
65
75
|
}
|
|
66
|
-
export declare class UndeclaredReference {
|
|
76
|
+
export declare class UndeclaredReference extends AnyReference {
|
|
67
77
|
reference: AnyReference;
|
|
68
78
|
constructor(reference: AnyReference);
|
|
69
79
|
throwMessage(): string;
|
|
@@ -71,7 +81,7 @@ export declare class UndeclaredReference {
|
|
|
71
81
|
nameString(): string;
|
|
72
82
|
}
|
|
73
83
|
export declare class DeclaredReference extends AnyReference {
|
|
74
|
-
|
|
84
|
+
referenceName: string;
|
|
75
85
|
toDisplayString(): string;
|
|
76
86
|
}
|
|
77
87
|
export declare enum ParseSymbolType {
|