Design decisions:

  • features of types are realized/determined by their kinds
  • Identifiers of types must be unique!

Hierarchy (View Summary)

Constructors

Properties

associatedLanguageNode: unknown

A node from the language might be associated with the current type, e.g. the declaration node in the AST (e.g. a FunctionDeclarationNode is associated with the corresponding FunctionType) This language node is not used for managing the lifecycles of this type, since it should be usable for any domain-specific purpose. Therefore, the use and update of this feature is under the responsibility of the user of Typir.

edgesIncoming: Map<string, TypeEdge[]> = ...
edgesOutgoing: Map<string, TypeEdge[]> = ...
functionName: string
identifier: undefined | string
initializationState: TypeInitializationState = 'Invalid'
inputParameters: ParameterDetails[]
onCompletion: () => void
onIdentification: () => void
onInvalidation: () => void
outputParameter: undefined | ParameterDetails
stateListeners: TypeStateListener[] = []

Methods

  • Analyzes, whether there is a sub type-relationship between two types. The difference between sub type-relationships and super type-relationships are only switched types. If both types are the same, no problems will be reported, since a type is considered as sub-type of itself (by definition).

    Parameters

    • superType: Type

      the super type, while the current type is the sub type

    Returns TypirProblem[]

    an empty array, if the relationship exists, otherwise some problems which might point to violations of the investigated relationship. These problems are presented to users in order to support them with useful information about the result of this analysis.

  • Analyzes, whether there is a super type-relationship between two types. The difference between sub type-relationships and super type-relationships are only switched types. If both types are the same, no problems will be reported, since a type is considered as sub-type of itself (by definition).

    Parameters

    • subType: Type

      the sub type, while the current type is super type

    Returns TypirProblem[]

    an empty array, if the relationship exists, otherwise some problems which might point to violations of the investigated relationship. These problems are presented to users in order to support them with useful information about the result of this analysis.

  • Analyzes, whether two types are equal.

    Parameters

    • otherType: Type

      to be compared with the current type

    Returns TypirProblem[]

    an empty array, if both types are equal, otherwise some problems which might point to found differences/conflicts between the two types. These problems are presented to users in order to support them with useful information about the result of this analysis.

  • Use this method to specify, how THIS new type should be initialized.

    This method has(!) to be called at the end(!) of the constructor of each specific Type implementation, even if nothing has to be specified, since calling this method starts the initialization process! If you forget the call this method, the new type remains invalid and invisible for Typir and you will not be informed about this problem!

    Parameters

    • preconditions: {
          onCompleted?: () => void;
          onIdentifiable?: () => void;
          onInvalidated?: () => void;
          preconditionsForCompleted?: PreconditionsForInitializationState;
          preconditionsForIdentifiable?: PreconditionsForInitializationState;
          referencesRelevantForInvalidation?: TypeReference<Type>[];
      }

      all possible options for the initialization process

      • OptionalonCompleted?: () => void

        typical use cases: do some internal checks for the completed properties

      • OptionalonIdentifiable?: () => void

        typical use cases: calculate the identifier, register inference rules for the type object already now!

      • OptionalonInvalidated?: () => void
      • OptionalpreconditionsForCompleted?: PreconditionsForInitializationState

        Contains only those TypeReferences which are required to do the completion. TypeReferences which are required only for the initialization, but not for the completion, don't need to be repeated here, since the completion is done only after the initialization.

      • OptionalpreconditionsForIdentifiable?: PreconditionsForInitializationState

        Contains only those TypeReferences which are required to do the initialization.

      • OptionalreferencesRelevantForInvalidation?: TypeReference<Type>[]

        Must contain all(!) TypeReferences of a type.

    Returns void

  • Identifiers must be unique and stable for all types known in a single Typir instance, since they are used as key to store types in maps. Identifiers might have a naming schema for calculatable values.

    Returns string

  • Returns a string value containing a short representation of the type to be shown to users of the type-checked language nodes. This value don't need to be unique for all types. This name should be quite short. Services should not call this function directly, but typir.printer.printTypeName(...) instead.

    Returns string

    a short string value to show to the user

  • Calculates a string value which might be shown to users of the type-checked language nodes. This value don't need to be unique for all types. This representation might be longer and show lots of details of the type. Services should not call this function directly, but typir.printer.printTypeUserRepresentation(...) instead.

    Returns string

    a longer string value to show to the user

  • This is an internal method to ignore some types during the initialization process in order to prevent dependency cycles. Usually there is no need to call this method on your own.

    Parameters

    • additionalTypesToIgnore: Set<Type>

      the new types to ignore during

    Returns void