type RelationalOperator = "<" | "<=" | "!=" | "==" | ">=" | ">"; type ArithmeticOperator = "+" | "-" | "/" | "*" | "%"; type LogicalBinaryOperator = "&&" | "||"; type BitwiseBinaryOperator = ">>" | "<<" | "&" | "|" | "^"; type BinaryOperator = RelationalOperator | ArithmeticOperator | LogicalBinaryOperator | BitwiseBinaryOperator; type ArithemeticUnaryOperator = "++" | "--"; type PostfixOperator = ArithemeticUnaryOperator; type PrefixOperator = "!" | "~" | "-" | "+" | ArithemeticUnaryOperator; type PrimaryCDataType = IntegerDataType | FloatDataType; type IntegerDataType = SignedIntegerType | UnsignedIntegerType; type UnsignedIntegerType = "unsigned char" | "unsigned short" | "unsigned int" | "unsigned long"; type SignedIntegerType = "signed char" | "signed short" | "signed int" | "signed long"; type FloatDataType = "float" | "double"; type DataType = ScalarDataType | ArrayDataType | StructDataType | FunctionDataType | EnumDataType | VoidDataType; type ScalarDataType = PrimaryDataType | PointerDataType; interface DataTypeBase { isConst?: boolean; } interface PrimaryDataType extends DataTypeBase { type: "primary"; primaryDataType: PrimaryCDataType; } interface ArrayDataType extends DataTypeBase { type: "array"; elementDataType: DataType; numElements: Expression; } interface PointerDataType extends DataTypeBase { type: "pointer"; pointeeType: DataType; } interface FunctionDataType extends DataTypeBase { type: "function"; returnType: DataType; parameters: DataType[]; } interface StructDataType extends DataTypeBase { type: "struct"; tag: string | null; fields: StructField[]; } interface VoidDataType extends DataTypeBase { type: "void"; } interface EnumDataType extends DataTypeBase { type: "enum"; tag: string | null; } interface StructField { tag: string; dataType: DataType | StructSelfPointer; isConst?: boolean; } interface StructSelfPointer { type: "struct self pointer"; } type UnaryExpression = PostfixExpression | PrefixExpression | FunctionCall | StructMemberAccess | PointerDereference | AddressOfExpression | SizeOfExpression; interface UnaryExpressionBase extends CNodeBase { expr: Expression; } interface PostfixExpression extends UnaryExpressionBase { type: "PostfixExpression"; operator: PostfixOperator; } interface PrefixExpression extends UnaryExpressionBase { type: "PrefixExpression"; operator: PrefixOperator; } interface FunctionCall extends UnaryExpressionBase { type: "FunctionCall"; expr: Expression; args: Expression[]; } interface StructMemberAccess extends UnaryExpressionBase { type: "StructMemberAccess"; expr: Expression; fieldTag: string; } interface PointerDereference extends CNodeBase { type: "PointerDereference"; expr: Expression; } interface AddressOfExpression extends CNodeBase { type: "AddressOfExpression"; expr: Expression; } type SizeOfExpression = SizeOfExpressionExpression | SizeOfDataTypeExpression; interface SizeOfExpressionBase extends CNodeBase { type: "SizeOfExpression"; subtype: "expression" | "dataType"; } interface SizeOfExpressionExpression extends SizeOfExpressionBase { subtype: "expression"; expr: Expression; } interface SizeOfDataTypeExpression extends SizeOfExpressionBase { subtype: "dataType"; dataType: DataType; } interface Assignment extends CNodeBase { type: "Assignment"; lvalue: Expression; expr: Expression; } interface Point { line: number; offset: number; column: number; } interface Position { start: Point; end: Point; } interface BinaryExpression extends CNodeBase { type: "BinaryExpression"; leftExpr: Expression; rightExpr: Expression; operator: BinaryOperator; } type IntegerConstantSuffix = "u" | "l" | "ul"; type FloatConstantSuffix = "F" | "f"; type Constant = IntegerConstant | FloatConstant; interface IntegerConstant extends CNodeBase { type: "IntegerConstant"; value: bigint; suffix: IntegerConstantSuffix | null; } interface FloatConstant extends CNodeBase { type: "FloatConstant"; value: number; suffix: FloatConstantSuffix | null; } interface IdentifierExpression extends CNodeBase { type: "IdentifierExpression"; name: string; } interface ConditionalExpression extends CNodeBase { type: "ConditionalExpression"; condition: Expression; trueExpression: Expression; falseExpression: Expression; } interface StringLiteral extends CNodeBase { type: "StringLiteral"; chars: number[]; } interface CNodeBase { type: string; position: Position; } type Expression = Assignment | BinaryExpression | Constant | IdentifierExpression | UnaryExpression | CommaSeparatedExpressions | ConditionalExpression | StringLiteral; interface CommaSeparatedExpressions extends CNodeBase { type: "CommaSeparatedExpressions"; expressions: Expression[]; } interface MemoryBlock { address: number; size: number; } interface ModuleFunction { parentImportedObject: string; functionType: FunctionDataType; jsFunction: Function; } declare abstract class Module { memory: WebAssembly.Memory; functionTable: WebAssembly.Table; config: ModulesGlobalConfig; freeList: MemoryBlock[]; allocatedBlocks: Map; sharedWasmGlobalVariables: SharedWasmGlobalVariables; instantiate?: () => Promise; abstract moduleDeclaredStructs: StructDataType[]; abstract moduleFunctions: Record; constructor(memory: WebAssembly.Memory, functionTable: WebAssembly.Table, config: ModulesGlobalConfig, sharedWasmGlobalVariables: SharedWasmGlobalVariables); print(str: string): void; } declare const mathStdlibName = "math"; declare const pixAndFlixLibraryModuleImportName = "pix_n_flix"; declare const sourceStandardLibraryModuleImportName = "source_stdlib"; declare const utilityStdLibName = "utility"; interface ModulesGlobalConfig { printFunction: (str: string) => void; externalFunctions?: { [functionName: string]: Function; }; } interface SharedWasmGlobalVariables { stackPointer: WebAssembly.Global; heapPointer: WebAssembly.Global; basePointer: WebAssembly.Global; } type ModuleName = typeof sourceStandardLibraryModuleImportName | typeof pixAndFlixLibraryModuleImportName | typeof mathStdlibName | typeof utilityStdLibName; declare class ModuleRepository { memory: WebAssembly.Memory; functionTable: WebAssembly.Table; config: ModulesGlobalConfig; modules: Record; sharedWasmGlobalVariables: SharedWasmGlobalVariables; constructor(memory?: WebAssembly.Memory, functionTable?: WebAssembly.Table, config?: ModulesGlobalConfig); setStackPointerValue(value: number): void; setBasePointerValue(value: number): void; setHeapPointerValue(value: number): void; setMemory(numberOfPages: number): void; createWasmImportsObject(importedModules: ModuleName[]): Promise; } interface SuccessfulCompilationResult { status: "success"; wasm: Uint8Array; dataSegmentSize: number; functionTableSize: number; importedModules: ModuleName[]; warnings: string[]; } interface FailedCompilationResult { status: "failure"; errorMessage: string; } type CompilationResult = SuccessfulCompilationResult | FailedCompilationResult; interface SuccessfulWatCompilationResult { status: "success"; watOutput: string; warnings: string[]; } interface FailedWatCompilationResult { status: "failure"; errorMessage: string; } type WatCompilationResult = SuccessfulWatCompilationResult | FailedWatCompilationResult; export const defaultModuleRepository: ModuleRepository; export function compileToWat(program: string): WatCompilationResult; export function generate_WAT_AST(program: string): string; export function compile(program: string): Promise; export function compileAndRun(program: string, modulesConfig?: ModulesGlobalConfig): Promise; export function runWasm(wasm: Uint8Array, dataSegmentSize: number, functionTableSize: number, importedModules: ModuleName[], modulesConfig?: ModulesGlobalConfig): Promise; export function generate_processed_C_AST(program: string): string; export function generate_C_AST(program: string): string; //# sourceMappingURL=index.d.ts.map