Class: CheckedType
compiler.CheckedType
A wrapper class for a KipperType that is used to properly represent a type during type checking. This is primarily intended to check to handle invalid/undefined types and continue with type checking despite their existence.
This type may be used for a compilation if the field isCompilable is true.
Since
0.10.0
Hierarchy
-
↳
CheckedType
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• Private
new CheckedType(identifier
, kipperType
)
Parameters
Name | Type |
---|---|
identifier |
string |
kipperType |
KipperType |
Overrides
Defined in
kipper/core/src/compiler/analysis/type.ts:74
Properties
_identifier
• Protected
Readonly
_identifier: string
Inherited from
Defined in
kipper/core/src/compiler/analysis/type.ts:27
_isCompilable
• Protected
Readonly
_isCompilable: boolean
Defined in
kipper/core/src/compiler/analysis/type.ts:72
_kipperType
• Protected
Readonly
_kipperType: KipperType
Defined in
kipper/core/src/compiler/analysis/type.ts:71
Accessors
identifier
• get
identifier(): string
The identifier of this type.
If kipperType is of type UndefinedCustomType, then this will return the invalid type identifier of UndefinedCustomType.
Returns
string
Overrides
Type.identifier
Defined in
kipper/core/src/compiler/analysis/type.ts:107
isCompilable
• get
isCompilable(): boolean
Returns whether the type is compilable.
This function exists, since during type checking an undefined/invalid type may be encountered that should still be stored using this class though (but NOT compiled!).
Since
0.10.0
Returns
boolean
Defined in
kipper/core/src/compiler/analysis/type.ts:128
kipperType
• get
kipperType(): KipperType
The identifier in a KipperType format.
This mainly differentiates from identifier by possibly returning the class UndefinedCustomType, which represents an invalid type that should still be stored though.
Returns
Defined in
kipper/core/src/compiler/analysis/type.ts:117
Methods
getCompilableType
▸ getCompilableType(): KipperCompilableType
Gets the compilable type for this type.
This function throws an error instead of returning undefined, since it's intended to be used in circumstances, where only due to a bug the type is not compilable. As such, it makes sense to strictly assert it will be compilable, unless an error occurs.
Throws
UndefinedCustomType If the isCompilable is false, which should only occur if the identifier is of type UndefinedCustomType.
Since
0.10.0
Returns
Defined in
kipper/core/src/compiler/analysis/type.ts:142
fromCompilableType
▸ Static
fromCompilableType(kipperType
): CheckedType
Creates a new instance of this class using the given kipperType.
This instance will ALWAYS be compilable, since the type KipperCompilableType automatically excludes any undefined/invalid types to be stored in this class.
Parameters
Name | Type | Description |
---|---|---|
kipperType |
KipperCompilableType |
The type to use for the created of a checked type. |
Returns
Defined in
kipper/core/src/compiler/analysis/type.ts:97
fromKipperType
▸ Static
fromKipperType(kipperType
): CheckedType
Creates a new CheckedType instance based on the passed KipperType.
If the type is invalid, the function will still return a CheckedType, but the field isCompilable will be false and the instance WILL NOT be usable for a compilation.
Parameters
Name | Type |
---|---|
kipperType |
KipperType |
Returns
Defined in
kipper/core/src/compiler/analysis/type.ts:86