import { Node, ProcedureDeclaration, Program, ProcedureCall, IdentifierExpression, AssignDestination, VariableDeclarator, ProcedureParameter } from "@pseuco/lang"; import { PseucoError } from "./PseucoError"; import { Type } from "./typeCheck/types/Type"; import { TypeEnvironment } from "./typeCheck/environments/TypeEnvironment"; import { PseucoWarning } from "./PseucoWarning"; export declare class StaticSemantics { readonly program: Program; private typeCheckCoordinator; private typeCheckResult; /** * Get a mapping from all AST nodes to their inferred types. */ get allNodesAndTypes(): ReadonlyArray<[Node, Type]>; /** * * @param program The root AST node of the program for which the static semantics analysis shall be performed. */ constructor(program: Program); /** * Get a list of all type errors that occurred during type-checking. Returns `undefined` if the type analysis was not started yet (use `checkTypes()` in this case). */ get typeErrors(): ReadonlyArray | undefined; /** * Get a list of all type warning that occurred during type-checking. Returns `undefined` if the type analysis was not started yet (use `checkTypes()` in this case). */ get typeWarnings(): ReadonlyArray | undefined; /** * Checks if the program is well-typed. The result is cached, i.e., successive calls do not perform a full static analysis. * @returns true, if the program is well-typed, otherwise false */ checkTypes(): boolean; /** * Access the types inferred for AST nodes during the type-checking process. * @param node The AST node for which the type information is requested. * @returns The type inferred for this node, if the program is well-typed. */ typeForNode(node: Node): Type; /** * Access the type environment in which a node's types were checked. * @param node The AST node for which the type environment is requested. * @returns The type environment associated with the node. */ environmentForNode(node: Node): TypeEnvironment; /** * Get the procedure declaration of a called procedure. * @param node A procedure call in the AST. * @returns The procedure declaration of the called procedure. */ procedureDeclarationForProcedureCall(node: ProcedureCall): ProcedureDeclaration; /** * Get the AST node declaring a variable that gets assigned a new value. * @param node The AST node representing the left-hand side of an assignment. * @returns The declaration of the corresponding variable or procedure parameter declaration that defined the variable. */ variableDeclarationForAssignDestination(node: AssignDestination): VariableDeclarator | ProcedureParameter; /** * Get the AST node declaring a variable represented by an identifier expression. * @param node The AST node using the variable. * @returns The declaration of the corresponding variable or procedure parameter declaration that defined the variable. */ variableDeclarationForIdentifierExpression(node: IdentifierExpression): VariableDeclarator | ProcedureParameter; }