typir
Version:
General purpose type checking library
122 lines • 6.08 kB
TypeScript
/******************************************************************************
* Copyright 2025 TypeFox GmbH
* This program and the accompanying materials are made available under the
* terms of the MIT License, which is available in the project root.
******************************************************************************/
import { Module } from '../utils/dependency-injection.js';
import { DefaultLanguageService } from '../services/language.js';
import { InferOperatorWithMultipleOperands } from '../services/operator.js';
import { DefaultTypeConflictPrinter } from '../services/printing.js';
import { TypirSpecifics, TypirServices, PartialTypirServices, DeepPartial } from '../typir.js';
/**
* Base class for all language nodes,
* which are predefined for test cases.
*/
export declare abstract class TestLanguageNode {
constructor();
print(): string;
protected printObject(obj: unknown): string;
}
export declare abstract class TestExpressionNode extends TestLanguageNode {
}
export declare abstract class TestStatementNode extends TestLanguageNode {
}
export declare class IntegerLiteral extends TestExpressionNode {
value: number;
constructor(value: number);
}
export declare class DoubleLiteral extends TestExpressionNode {
value: number;
constructor(value: number);
}
export declare class BooleanLiteral extends TestExpressionNode {
value: boolean;
constructor(value: boolean);
}
export declare class StringLiteral extends TestExpressionNode {
value: string;
constructor(value: string);
}
export declare const integer2: IntegerLiteral;
export declare const integer3: IntegerLiteral;
export declare const integer123: IntegerLiteral;
export declare const integer456: IntegerLiteral;
export declare const double123_0: DoubleLiteral;
export declare const double456_0: DoubleLiteral;
export declare const double2_0: DoubleLiteral;
export declare const double3_0: DoubleLiteral;
export declare const booleanTrue: BooleanLiteral;
export declare const booleanFalse: BooleanLiteral;
export declare const string123: StringLiteral;
export declare const string456: StringLiteral;
export declare const string2: StringLiteral;
export declare const string3: StringLiteral;
export declare const stringHello: StringLiteral;
export declare const stringWorld: StringLiteral;
export declare class ClassConstructorCall extends TestExpressionNode {
className: string;
constructor(className: string);
}
export declare class ClassFieldAccess extends TestExpressionNode {
classVariable: Variable;
fieldName: string;
constructor(classVariable: Variable, fieldName: string);
}
export declare class BinaryExpression extends TestExpressionNode {
left: TestExpressionNode;
operator: string;
right: TestExpressionNode;
constructor(left: TestExpressionNode, operator: string, right: TestExpressionNode);
}
export declare class Variable extends TestLanguageNode {
name: string;
initialValue: TestExpressionNode;
constructor(name: string, initialValue: TestExpressionNode);
}
export declare class AssignmentStatement extends TestStatementNode {
left: Variable;
right: TestExpressionNode;
constructor(left: Variable, right: TestExpressionNode);
}
export declare class StatementBlock extends TestStatementNode {
statements: TestLanguageNode[];
constructor(statements: TestLanguageNode[]);
}
export declare const InferenceRuleBinaryExpression: InferOperatorWithMultipleOperands<TestingSpecifics, BinaryExpression>;
export declare class TestProblemPrinter extends DefaultTypeConflictPrinter<TestingSpecifics> {
printLanguageNode(languageNode: TestLanguageNode, sentenceBegin?: boolean | undefined): string;
}
export declare class TestLanguageService extends DefaultLanguageService<TestingSpecifics> {
protected subKeys: Map<string, string[]>;
protected superKeys: Map<string, string[]>;
constructor(subSuper?: Array<{
superKey: string;
subKey: string;
}>);
getLanguageNodeKey(languageNode: TestLanguageNode): string | undefined;
protected registerSubSuperRelationship(superKey: string, subKey: string): void;
protected addKeyValue(key: string, value: string, map: Map<string, string[]>): void;
getAllSubKeys(languageKey: string): string[];
getAllSuperKeys(languageKey: string): string[];
protected getTransitiveKeys(languageKey: string, map: Map<string, string[]>): string[];
isLanguageNode(node: TestLanguageNode): node is TestLanguageNode;
}
export interface TestingSpecifics extends TypirSpecifics {
LanguageType: TestLanguageNode;
}
/**
* Creates TypirServices dedicated for testing purposes,
* with the default module containing the default implements for Typir, which might be exchanged by the given optional customized module.
* @param customizationForTesting specific customizations for the current test case
* @returns a Typir instance, i.e. the TypirServices with implementations
*/
export declare function createTypirServicesForTesting(customizationForTesting?: Module<TypirServices<TestingSpecifics>, PartialTypirServices<TestingSpecifics>>): TypirServices<TestingSpecifics>;
/**
* Creates TypirServices dedicated for testing purposes,
* with the default module containing the default implements for Typir, which might be exchanged by the given optional customized module.
* @param moduleForAdditionalServices required implementations for the additional services
* @param customizationForTesting specific customizations for the current test case
* @returns a Typir instance, i.e. the TypirServices with implementations
*/
export declare function createTypirServicesForTestingWithAdditionalServices<AdditionalServices>(moduleForAdditionalServices: Module<TypirServices<TestingSpecifics> & AdditionalServices, AdditionalServices>, customizationForTesting?: Module<TypirServices<TestingSpecifics> & AdditionalServices, DeepPartial<TypirServices<TestingSpecifics> & AdditionalServices>>): TypirServices<TestingSpecifics> & AdditionalServices;
//# sourceMappingURL=predefined-language-nodes.d.ts.map