Skip to content

Commit

Permalink
Added Basic types
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrylR committed Apr 4, 2024
1 parent c2dd8db commit ac63495
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 0 deletions.
126 changes: 126 additions & 0 deletions src/types/ast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// Helper types

export type SignalType = "Output" | "Input" | "Intermediate";

// Compiler and Definitions

export interface CompilerConfig {
meta: Meta;
compiler_version: number[];
custom_gates: boolean;
custom_gates_declared: boolean;
includes: string[];
definitions: Definition[];
main_component?: MainComponent;
}

export type MainComponent = [string[], Call];

export interface Call {
meta: Meta;
id: string;
args: any[];
}

export type Definition = {
Template?: Template;
};

export interface Template {
meta: Meta;
name: string;
args: string[];
arg_location: Location;
body: Body;
parallel: boolean;
is_custom_gate: boolean;
}

export interface Body {
Block: Block;
}

export interface Block {
meta: Meta;
stmts: Stmt[];
}

export type Stmt = {
InitializationBlock?: InitializationBlock;
Substitution?: Substitution;
};

export interface InitializationBlock {
meta: Meta;
xtype: XType;
initializations: Initialization[];
}

export type Initialization = {
Declaration: Declaration;
};

export interface Declaration {
meta: Meta;
xtype: XType;
name: string;
dimensions: any[];
is_constant: boolean;
}

export interface Substitution {
meta: Meta;
var: string;
access: any[];
op: string;
rhe: Rhe;
}

export interface Rhe {
InfixOp: InfixOp;
}

export interface InfixOp {
meta: Meta;
lhe: Variable;
infix_op: string;
rhe: Variable;
}

export interface Variable {
meta: Meta;
name: string;
access: any[];
}

export type XType = {
Signal: [string, any[]];
};

// Base Types

export interface Meta {
elem_id: number;
start: number;
end: number;
location: Location;
file_id?: string;
component_inference?: string;
type_knowledge: TypeKnowledge;
memory_knowledge: MemoryKnowledge;
}

export interface Location {
start: number;
end: number;
}

export interface TypeKnowledge {
reduces_to?: string;
}

export interface MemoryKnowledge {
concrete_dimensions?: string;
full_length?: string;
abstract_memory_address?: string;
}
14 changes: 14 additions & 0 deletions src/types/circuitArtifact.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { SignalType } from "./ast";

export interface CircuitArtifact {
_format: string;
circuitName: string;
sourceName: string;
signals: Signal[];
}

export interface Signal {
name: string;
type: SignalType;
internalType: string;
}

0 comments on commit ac63495

Please sign in to comment.