UNPKG

zignet

Version:

MCP server for Zig — AI-powered code analysis, validation, and documentation with fine-tuned LLM

194 lines (192 loc) 3.71 kB
import { t as Program } from "./ast-DVcyx7L5.js"; //#region src/type-checker.d.ts /** * Type information */ interface Type { kind: 'primitive' | 'struct' | 'function' | 'void' | 'unknown'; name: string; fields?: Map<string, Type>; parameters?: Type[]; returnType?: Type; } /** * Symbol information */ interface Symbol { name: string; type: Type; kind: 'variable' | 'function' | 'parameter' | 'struct'; isConst: boolean; declared: boolean; } /** * Scope for symbol management */ declare class Scope { private parent?; private symbols; constructor(parent?: Scope | undefined); /** * Define a symbol in this scope */ define(name: string, symbol: Symbol): void; /** * Resolve a symbol by name (checks parent scopes) */ resolve(name: string): Symbol | undefined; /** * Check if symbol exists in current scope only */ has(name: string): boolean; /** * Get parent scope */ getParent(): Scope | undefined; } /** * Type error class */ declare class TypeError extends Error { line?: number | undefined; column?: number | undefined; constructor(message: string, line?: number | undefined, column?: number | undefined); toString(): string; } /** * Type Checker class */ declare class TypeChecker { private currentScope; private globalScope; private errors; private currentFunction?; constructor(); /** * Initialize built-in types */ private initializeBuiltinTypes; /** * Check the entire program */ check(program: Program): TypeError[]; /** * Collect declaration (first pass) */ private collectDeclaration; /** * Create function type */ private createFunctionType; /** * Create struct type */ private createStructType; /** * Convert type annotation to Type */ private typeAnnotationToType; /** * Check declaration (second pass) */ private checkDeclaration; /** * Check function declaration */ private checkFunctionDeclaration; /** * Check if block has a return statement */ private blockHasReturn; /** * Check if statement has a return */ private statementHasReturn; /** * Check variable declaration */ private checkVariableDeclaration; /** * Check block statement */ private checkBlockStatement; /** * Check statement */ private checkStatement; /** * Check return statement */ private checkReturnStatement; /** * Check if statement */ private checkIfStatement; /** * Check while statement */ private checkWhileStatement; /** * Check expression statement */ private checkExpressionStatement; /** * Check expression and return its type */ private checkExpression; /** * Check identifier */ private checkIdentifier; /** * Check binary expression */ private checkBinaryExpression; /** * Check unary expression */ private checkUnaryExpression; /** * Check call expression */ private checkCallExpression; /** * Check member expression */ private checkMemberExpression; /** * Check index expression */ private checkIndexExpression; /** * Check assignment expression */ private checkAssignmentExpression; /** * Check if types are compatible */ private typesCompatible; /** * Check if type is numeric */ private isNumericType; /** * Enter a new scope */ private enterScope; /** * Exit current scope */ private exitScope; /** * Add an error */ private addError; /** * Get all errors */ getErrors(): TypeError[]; } //#endregion export { Scope, Symbol, Type, TypeChecker, TypeError }; //# sourceMappingURL=type-checker.d.ts.map