import { AstNode } from "langium"; import { AstNodeType, TFunction, TTypeDefNamed } from "./type.js"; export type AstNodeValue = VNumber | VString | VBoolean | VList | VStruct | VRef | VNamed | VCast | VFunctionCall | VNone; export interface VNamed { readonly $type: typeof VNamed.$type; readonly node?: AstNode; readonly definition: TTypeDefNamed; readonly inner: AstNodeValue; } export declare namespace VNamed { const $type = "named"; const create: (opts: Opts) => VNamed; const is: (item: AstNodeValue) => item is VNamed; } export interface VNone { readonly $type: typeof VNone.$type; readonly node?: AstNode; } export declare namespace VNone { const $type = "none"; const create: (opts: Opts) => VNone; const is: (item: AstNodeValue) => item is VNone; } export interface VBoolean { readonly $type: typeof VBoolean.$type; readonly node?: AstNode; readonly literal: boolean; } export declare namespace VBoolean { const $type = "bool"; const create: (opts: Opts) => VBoolean; const is: (item: AstNodeValue) => item is VBoolean; } export interface VString { readonly $type: typeof VString.$type; readonly node?: AstNode; readonly literal: string; } export declare namespace VString { const $type = "string"; const create: (opts: Opts) => VString; const is: (item: AstNodeValue) => item is VString; } export interface VNumber { readonly $type: typeof VNumber.$type; readonly node?: AstNode; readonly literal: number; } export declare namespace VNumber { const $type = "number"; const create: (opts: Opts) => VNumber; const is: (item: AstNodeValue) => item is VNumber; } export interface VStruct { readonly $type: typeof VStruct.$type; readonly node?: AstNode; readonly parameters: { [x: string]: VStructItem | undefined; }; } export declare namespace VStruct { const $type = "struct"; const create: (opts: Opts) => VStruct; const is: (item: AstNodeValue) => item is VStruct; } export interface VStructItem { readonly $type: typeof VStructItem.$type; readonly node?: AstNode; readonly value: AstNodeValue; } export declare namespace VStructItem { const $type = "struct-item"; const create: (opts: Opts) => VStructItem; } export type VList = { readonly $type: typeof VList.$type; readonly node?: AstNode; readonly items: VListItem[]; }; export declare namespace VList { const $type = "list"; const create: (opts: Opts) => VList; const is: (item: AstNodeValue) => item is VList; } export interface VListItem { readonly $type: typeof VListItem.$type; readonly node?: AstNode; readonly value: AstNodeValue; } export declare namespace VListItem { const $type = "list-item"; const create: (opts: Opts) => VListItem; } export interface VFunctionCall { readonly $type: typeof VFunctionCall.$type; readonly node?: AstNode; readonly definition: TFunction; readonly params: VParam[]; readonly result: AstNodeValue; } export declare namespace VFunctionCall { const $type = "function-call"; const create: (opts: Opts) => VFunctionCall; const is: (item: AstNodeValue) => item is VFunctionCall; } export interface VParam { readonly $type: typeof VParam.$type; readonly node?: AstNode; readonly name: string; readonly value: AstNodeValue; } export declare namespace VParam { const $type = "function-parameter"; const create: (opts: Opts) => VParam; } export interface VCast { readonly $type: typeof VCast.$type; readonly node?: AstNode; readonly to: AstNodeType; readonly from: AstNodeValue; readonly result: AstNodeValue; } export declare namespace VCast { const $type = "type-cast"; const create: (opts: Opts) => VCast; const is: (item: AstNodeValue) => item is VCast; } export interface VRef { readonly $type: typeof VRef.$type; readonly node?: AstNode; readonly ref: AstNodeValue; } export declare namespace VRef { const $type = "reference"; const create: (opts: Opts) => VRef; const is: (item: AstNodeValue) => item is VRef; const unwrap: (item: AstNodeValue) => AstNodeValue; const unwrapN: (item: AstNodeValue, limit: number) => readonly [AstNodeValue, number]; } export type VLiteral = VBoolean | VString | VNumber; declare const literals: readonly ["bool", "string", "number"]; export declare namespace VLiteral { type literal = (typeof literals)[number]; export const is: (item: AstNodeValue) => item is VLiteral; export const eq: (v: string) => v is literal; export {}; } export interface ValueError { readonly $type: typeof ValueError.$type; readonly node: AstNode; readonly message: string; } export declare namespace ValueError { const $type = "error"; const create: (opts: { node: AstNode; message: string; }) => ValueError; const is: (item: unknown) => item is ValueError; } export declare function ValueToString(item: AstNodeValue): string; export declare function clone(value: AstNodeValue): AstNodeValue; type Opts = T extends unknown ? Omit : never; export {};