import { Expression, Metadata, Statement } from "../ir"; import { Machine, State } from "../vm"; import { Environment, World } from "../world"; import { CrochetValue, CrochetType } from "./0-core"; import { Meta } from "../ir"; export declare class ContractCondition { readonly meta: Meta; readonly tag: string; readonly expr: Expression; constructor(meta: Meta, tag: string, expr: Expression); is_valid(state: State): Machine; format_error(): string; } export declare class Contract { readonly pre: ContractCondition[]; readonly post: ContractCondition[]; constructor(pre: ContractCondition[], post: ContractCondition[]); check_pre(state: State, name: string, params: string[], args: CrochetValue[]): Machine; check_post(state0: State, name: string, params: string[], args: CrochetValue[], result: CrochetValue): Machine; } export interface IProcedure { location_message: string; documentation: string; contract: Contract; invoke(state: State, values: CrochetValue[]): Machine; } export declare class Procedure { readonly name: string; readonly arity: number; private branches; private versions; constructor(name: string, arity: number); select(values: CrochetValue[]): ProcedureBranch | null; add(types: CrochetType[], procedure: IProcedure): void; override(types: CrochetType[], procedure: IProcedure): void; rollback(version?: number): void; select_exact(types: CrochetType[], branches?: ProcedureBranch[]): Generator; select_subtype(types: CrochetType[], branches?: ProcedureBranch[]): Generator; select_matching(type: CrochetType, branches?: ProcedureBranch[]): ProcedureBranch[]; assert_no_duplicates(types: CrochetType[], branches?: ProcedureBranch[]): void; } export declare class ProcedureBranch { readonly types: CrochetType[]; readonly procedure: IProcedure; constructor(types: CrochetType[], procedure: IProcedure); compare(branch: ProcedureBranch): number; accepts(values: CrochetValue[]): boolean; get simple_repr(): string; get location_message(): string; get full_repr(): string; } export declare type NativeProcedureFn = (state: State, ...args: CrochetValue[]) => Machine; export declare class NativeProcedure implements IProcedure { readonly meta: Metadata; readonly env: Environment; readonly name: string; readonly parameter_names: string[]; readonly parameters: string[]; readonly foreign_name: string; readonly contract: Contract; constructor(meta: Metadata, env: Environment, name: string, parameter_names: string[], parameters: string[], foreign_name: string, contract: Contract); get full_name(): string; get location_message(): string; get documentation(): string; invoke(state0: State, values: CrochetValue[]): Machine; } export declare class CrochetProcedure implements IProcedure { readonly meta: Metadata; readonly env: Environment; readonly world: World; readonly name: string; readonly parameters: string[]; readonly body: Statement[]; readonly contract: Contract; constructor(meta: Metadata, env: Environment, world: World, name: string, parameters: string[], body: Statement[], contract: Contract); get full_name(): string; get location_message(): string; get documentation(): string; invoke(state0: State, values: CrochetValue[]): Generator; }