diff --git a/plugins/ets/runtime/ets_coroutine.h b/plugins/ets/runtime/ets_coroutine.h index 778d8445d54da1ed355c224af28de9634565d7c4..103d9bfd2683642b47396cc42044c8d63d8d5d16 100644 --- a/plugins/ets/runtime/ets_coroutine.h +++ b/plugins/ets/runtime/ets_coroutine.h @@ -21,6 +21,7 @@ namespace panda::ets { class PandaEtsVM; +class EtsObjectArray; /** * \brief The eTS coroutine. It is aware of the native interface and reference storage existance. @@ -70,6 +71,11 @@ public: promise_class_ptr_ = promise_class; } + void SetTypeParams(EtsObjectArray * type_class) + { + type_params_ = type_class; + } + static constexpr uint32_t GetTlsPromiseClassPointerOffset() { return MEMBER_OFFSET(EtsCoroutine, promise_class_ptr_); @@ -82,6 +88,10 @@ public: return ets_napi_env_.get(); } + EtsObjectArray * GetTypeParams() const { + return type_params_; + } + void Initialize() override; void RequestCompletion(Value return_value) override; void FreeInternalMemory() override; @@ -97,6 +107,7 @@ private: std::unique_ptr ets_napi_env_; void *promise_class_ptr_ {nullptr}; + EtsObjectArray* type_params_; // Allocator calls our protected ctor friend class mem::Allocator; diff --git a/plugins/ets/runtime/ets_libbase_runtime.yaml b/plugins/ets/runtime/ets_libbase_runtime.yaml index 86427db288dfae9a7558d797bcf1aa0d91f1a7df..57d2cac9891f6a9bb22e7fa3cf5072fed5d6003a 100644 --- a/plugins/ets/runtime/ets_libbase_runtime.yaml +++ b/plugins/ets/runtime/ets_libbase_runtime.yaml @@ -1291,7 +1291,7 @@ intrinsics: ret: void args: [ std.core.Object ] impl: panda::ets::intrinsics::StdGCUnpinObject - + - name: StdGetFreeHeapSize space: ets class_name: std.core.GC @@ -1301,7 +1301,7 @@ intrinsics: ret: i64 args: [ ] impl: panda::ets::intrinsics::StdGetFreeHeapSize - + - name: StdGetUsedHeapSize space: ets class_name: std.core.GC @@ -1311,7 +1311,7 @@ intrinsics: ret: i64 args: [ ] impl: panda::ets::intrinsics::StdGetUsedHeapSize - + - name: StdGetReservedHeapSize space: ets class_name: std.core.GC @@ -1611,6 +1611,40 @@ intrinsics: ret: std.core.String args: [ std.core.String ] impl: panda::ets::intrinsics::TypeAPIGetBaseType + clear_flags: [ ] + + - name: StdCoreTypeStoreTypeParamDescriptors + space: ets + class_name: std.core.ETSGLOBAL + method_name: StoreTypeParamDescriptors + static: true + signature: + ret: void + args: [ 'std.core.String[]' ] + impl: panda::ets::intrinsics::TypeAPIStoreTypeParamDescriptors + clear_flags: [ ] + + - name: StdCoreTypeLoadTypeParamDescriptors + space: ets + class_name: std.core.ETSGLOBAL + method_name: LoadTypeParamDescriptors + static: true + signature: + ret: std.core.String[] + args: [] + impl: panda::ets::intrinsics::TypeAPILoadTypeParamDescriptors + clear_flags: [ ] + + - name: StdCoreTypeGetGenericTypeDesc + space: ets + class_name: std.core.ETSGLOBAL + method_name: GetGenericTypeDesc + static: true + signature: + ret: std.core.String + args: [] + impl: panda::ets::intrinsics::TypeAPIGetGenericTypeDesc + clear_flags: [ ] ################# # std.core.Char # @@ -1694,7 +1728,7 @@ intrinsics: args: [ std.core.Object, i64 ] impl: panda::ets::intrinsics::ValueAPIGetFieldByte clear_flags: [ ] - + - name: ValueAPIGetFieldChar space: ets class_name: std.core.ETSGLOBAL @@ -1705,7 +1739,7 @@ intrinsics: args: [ std.core.Object, i64 ] impl: panda::ets::intrinsics::ValueAPIGetFieldChar clear_flags: [ ] - + - name: ValueAPIGetFieldShort space: ets class_name: std.core.ETSGLOBAL diff --git a/plugins/ets/runtime/intrinsics/std_core_Type.cpp b/plugins/ets/runtime/intrinsics/std_core_Type.cpp index 560c903686f6fd9456f766926790cdd734871af7..5ea23a79a0fb4e6a906b6285128aac95d68ca195 100644 --- a/plugins/ets/runtime/intrinsics/std_core_Type.cpp +++ b/plugins/ets/runtime/intrinsics/std_core_Type.cpp @@ -22,6 +22,9 @@ #include "intrinsics.h" #include "mem/mem.h" #include "mem/vm_handle.h" +#include "ets_coroutine.h" +#include "ets_vm.h" +#include "macros.h" #include "plugins/ets/runtime/types/ets_object.h" #include "plugins/ets/runtime/types/ets_string.h" #include "plugins/ets/runtime/ets_panda_file_items.h" @@ -34,6 +37,8 @@ #include "types/ets_typeapi_feature.h" #include "types/ets_typeapi_field.h" #include "types/ets_typeapi_method.h" +#include "plugins/ets/runtime/napi/ets_scoped_objects_fix.h" +#include "runtime/handle_scope-inl.h" namespace panda::ets::intrinsics { @@ -351,4 +356,28 @@ EtsString *TypeAPIGetBaseType(EtsString *td) } return EtsString::CreateFromMUtf8(base_class->GetDescriptor()); } + +void TypeAPIStoreTypeParamDescriptors(ObjectHeader *obj) +{ + auto arr = EtsObjectArray::FromCoreType(obj); + EtsCoroutine::GetCurrent()->SetTypeParams(arr); +} + +ObjectHeader *TypeAPILoadTypeParamDescriptors() +{ + return EtsCoroutine::GetCurrent()->GetTypeParams()->GetCoreType(); +} + +EtsString *TypeAPIGetGenericTypeDesc() +{ + auto params = EtsCoroutine::GetCurrent()->GetTypeParams(); + ASSERT(params->GetLength() == 1); + PandaString assembler_type; + auto type = EtsString::FromEtsObject(params->Get(0)); + assembler_type += CLASS_TYPE_PREFIX; + assembler_type += type->GetMutf8(); + assembler_type += TYPE_DESC_DELIMITER; + return EtsString::CreateFromMUtf8(assembler_type.c_str()); +} + } // namespace panda::ets::intrinsics diff --git a/plugins/ets/stdlib/std/core/Field.ets b/plugins/ets/stdlib/std/core/Field.ets index 441dc2cd141af2c3953cc468711089d82847c6cd..bb101b70db2aad35f3126e61f9260963005432fc 100644 --- a/plugins/ets/stdlib/std/core/Field.ets +++ b/plugins/ets/stdlib/std/core/Field.ets @@ -16,11 +16,10 @@ package std.core; export final class Field extends Object { - private td: string - private name: string - private accessMod: byte + private td: string + private name: string private attributes: int - + private accessMod: byte public getType(): Type { return Type.resolve(this.td) @@ -29,4 +28,4 @@ export final class Field extends Object { public getName(): String { return this.name } -} \ No newline at end of file +} diff --git a/plugins/ets/stdlib/std/core/Type.ets b/plugins/ets/stdlib/std/core/Type.ets index 2c022d53af85a2af5fdea1847144709c1316a95f..f7f888beaff4065bcd8fe308a9f1151cf89f5187 100644 --- a/plugins/ets/stdlib/std/core/Type.ets +++ b/plugins/ets/stdlib/std/core/Type.ets @@ -15,7 +15,7 @@ package std.core; -type TypeDesc = string +type TypeDesc = string native function TypeAPIGetTypeDescriptor(o: Object): string @@ -47,8 +47,18 @@ native function TypeAPIMakeArrayInstance(td: TypeDesc, len: long): Object native function TypeAPIGetBaseType(td: TypeDesc): TypeDesc +native function StoreTypeParamDescriptors(typ: string[]): void + +native function LoadTypeParamDescriptors(): TypeDesc[] + +native function GetGenericTypeDesc(): TypeDesc + +export function GetGenericType(): Type { + return Type.resolve(GetGenericTypeDesc()) +} + // TODO(shumilov-petr): replace to enum, enum not available now -export type TypeKind = byte +export type TypeKind = byte const NoneKind: TypeKind = 0x0 const VoidKind: TypeKind = 0x1 @@ -61,10 +71,10 @@ const IntKind: TypeKind = 0x6 const LongKind: TypeKind = 0x7 const FloatKind: TypeKind = 0x8 const DoubleKind: TypeKind = 0x9 - + const ClassKind: TypeKind = 0xA const StringKind: TypeKind = 0xB -const InterfaceKind: TypeKind = 0xC +const InterfaceKind: TypeKind = 0xC const ArrayKind: TypeKind = 0xD const FunctionKind: TypeKind = 0xE const UnionKind: TypeKind = 0xF @@ -98,7 +108,7 @@ export abstract class Type extends Object { switch (kind) { case VoidKind: return VoidType.getInstance() - + case CharKind: return CharType.getInstance(td) case BooleanKind: @@ -174,7 +184,7 @@ export abstract class Type extends Object { } // ----- - + public static of(o: Object | null): Type { if (o == null) { return NullType.getInstance() @@ -184,7 +194,7 @@ export abstract class Type extends Object { } // ----- - + public static of(v: Boolean): Type { return BooleanType.getInstance(TypeAPIGetTypeDescriptor(v)) } @@ -262,24 +272,24 @@ export abstract class Type extends Object { public static of(v: Object[]): Type { return ArrayType.getInstance(TypeAPIGetTypeDescriptor(v)) } - + public abstract isPrimitive(): boolean // Or Composite public abstract isReference(): boolean // Or Value - public abstract hasName(): boolean + public abstract hasName(): boolean public getId(): long { return TypeAPIGetTypeId(this.td); } - public abstract getName(): string + public abstract getName(): string public abstract getLiteral(): string - + public override toString(): string { if (this.hasName()) { - return this.getName() + return this.getName() } return this.getLiteral() } @@ -287,28 +297,28 @@ export abstract class Type extends Object { export final class UndefinedType extends Type { private static instance: UndefinedType | null = null - + private constructor() { - this.td = UndefinedTD + this.td = UndefinedTD } public static getInstance(): UndefinedType { if (UndefinedType.instance == null) { UndefinedType.instance = new UndefinedType() - } + } return UndefinedType.instance } public override isPrimitive(): boolean { - return true + return true } public override isReference(): boolean { - return true + return true } public override hasName(): boolean { - return true + return true } public override getName(): string { @@ -327,15 +337,15 @@ export final class UndefinedType extends Type { export final class VoidType extends Type { private static instance: VoidType | null = null - + private constructor() { - this.td = VoidTD + this.td = VoidTD } public static getInstance(): VoidType { if (VoidType.instance == null) { VoidType.instance = new VoidType() - } + } return VoidType.instance } @@ -344,11 +354,11 @@ export final class VoidType extends Type { } public override isReference(): boolean { - return true + return true } public override hasName(): boolean { - return true + return true } public override getName(): string { @@ -368,25 +378,25 @@ export final class VoidType extends Type { export final class CharType extends Type { private static refInst: CharType | null = null private static valInst: CharType | null = null - - private isValue: boolean + + private isValue: boolean private constructor(td: TypeDesc, isValue: boolean) { this.td = td - this.isValue = isValue + this.isValue = isValue } public static getInstance(td: TypeDesc): CharType { if (TypeAPIIsValueType(td)) { - CharType.valInst = (CharType.valInst == null) ? new CharType(td, true) : CharType.valInst + CharType.valInst = (CharType.valInst == null) ? new CharType(td, true) : CharType.valInst return CharType.valInst! - } + } CharType.refInst = (CharType.refInst == null) ? new CharType(td, false) : CharType.refInst return CharType.refInst! } public override isPrimitive(): boolean { - return true + return true } public override isReference(): boolean { @@ -394,7 +404,7 @@ export final class CharType extends Type { } public override hasName(): boolean { - return !this.isValue + return !this.isValue } public override getName(): string { @@ -412,7 +422,7 @@ export final class CharType extends Type { } public override equals(to: Object): boolean { - return to instanceof CharType && this.isValue != (to as CharType).isReference() + return to instanceof CharType && this.isValue != (to as CharType).isReference() } } @@ -420,19 +430,19 @@ export final class CharType extends Type { export final class BooleanType extends Type { private static refInst: BooleanType | null = null private static valInst: BooleanType | null = null - - private isValue: boolean + + private isValue: boolean private constructor(td: TypeDesc, isValue: boolean) { this.td = td - this.isValue = isValue + this.isValue = isValue } public static getInstance(td: TypeDesc): BooleanType { if (TypeAPIIsValueType(td)) { - BooleanType.valInst = (BooleanType.valInst == null) ? new BooleanType(td, true) : BooleanType.valInst + BooleanType.valInst = (BooleanType.valInst == null) ? new BooleanType(td, true) : BooleanType.valInst return BooleanType.valInst! - } + } BooleanType.refInst =(BooleanType.refInst == null) ? new BooleanType(td, false) : BooleanType.refInst return BooleanType.refInst! } @@ -446,7 +456,7 @@ export final class BooleanType extends Type { } public override hasName(): boolean { - return !this.isValue + return !this.isValue } public override getName(): string { @@ -464,7 +474,7 @@ export final class BooleanType extends Type { } public override equals(to: Object): boolean { - return to instanceof BooleanType && this.isValue != (to as BooleanType).isReference() + return to instanceof BooleanType && this.isValue != (to as BooleanType).isReference() } } @@ -472,19 +482,19 @@ export final class BooleanType extends Type { export final class ByteType extends Type { private static refInst: ByteType | null = null private static valInst: ByteType | null = null - - private isValue: boolean + + private isValue: boolean private constructor(td: TypeDesc, isValue: boolean) { this.td = td - this.isValue = isValue + this.isValue = isValue } public static getInstance(td: TypeDesc): ByteType { if (TypeAPIIsValueType(td)) { - ByteType.valInst = (ByteType.valInst == null) ? new ByteType(td, true) : ByteType.valInst + ByteType.valInst = (ByteType.valInst == null) ? new ByteType(td, true) : ByteType.valInst return ByteType.valInst! - } + } ByteType.refInst = (ByteType.refInst == null) ? new ByteType(td, false) : ByteType.refInst return ByteType.refInst! } @@ -498,7 +508,7 @@ export final class ByteType extends Type { } public override hasName(): boolean { - return !this.isValue + return !this.isValue } public override getName(): string { @@ -516,7 +526,7 @@ export final class ByteType extends Type { } public override equals(to: Object): boolean { - return to instanceof ByteType && this.isValue != (to as ByteType).isReference() + return to instanceof ByteType && this.isValue != (to as ByteType).isReference() } } @@ -524,19 +534,19 @@ export final class ByteType extends Type { export final class ShortType extends Type { private static refInst: ShortType | null = null private static valInst: ShortType | null = null - - private isValue: boolean + + private isValue: boolean private constructor(td: TypeDesc, isValue: boolean) { this.td = td - this.isValue = isValue + this.isValue = isValue } public static getInstance(td: TypeDesc): ShortType { if (TypeAPIIsValueType(td)) { - ShortType.valInst = (ShortType.valInst == null) ? new ShortType(td, true) : ShortType.valInst + ShortType.valInst = (ShortType.valInst == null) ? new ShortType(td, true) : ShortType.valInst return ShortType.valInst! - } + } ShortType.refInst = (ShortType.refInst == null) ? new ShortType(td, false) : ShortType.refInst return ShortType.refInst! } @@ -550,7 +560,7 @@ export final class ShortType extends Type { } public override hasName(): boolean { - return !this.isValue + return !this.isValue } public override getName(): string { @@ -576,19 +586,19 @@ export final class ShortType extends Type { export final class IntType extends Type { private static refInst: IntType | null = null private static valInst: IntType | null = null - - private isValue: boolean + + private isValue: boolean private constructor(td: TypeDesc, isValue: boolean) { this.td = td - this.isValue = isValue + this.isValue = isValue } public static getInstance(td: TypeDesc): IntType { if (TypeAPIIsValueType(td)) { - IntType.valInst = (IntType.valInst == null) ? new IntType(td, true) : IntType.valInst + IntType.valInst = (IntType.valInst == null) ? new IntType(td, true) : IntType.valInst return IntType.valInst! - } + } IntType.refInst = (IntType.refInst == null) ? new IntType(td, false) : IntType.refInst return IntType.refInst! } @@ -602,7 +612,7 @@ export final class IntType extends Type { } public override hasName(): boolean { - return !this.isValue + return !this.isValue } public override getName(): string { @@ -628,19 +638,19 @@ export final class IntType extends Type { export final class LongType extends Type { private static refInst: LongType | null = null private static valInst: LongType | null = null - - private isValue: boolean + + private isValue: boolean private constructor(td: TypeDesc, isValue: boolean) { this.td = td - this.isValue = isValue + this.isValue = isValue } public static getInstance(td: TypeDesc): LongType { if (TypeAPIIsValueType(td)) { - LongType.valInst = (LongType.valInst == null) ? new LongType(td, true) : LongType.valInst + LongType.valInst = (LongType.valInst == null) ? new LongType(td, true) : LongType.valInst return LongType.valInst! - } + } LongType.refInst = (LongType.refInst == null) ? new LongType(td, false) : LongType.refInst return LongType.refInst! } @@ -654,7 +664,7 @@ export final class LongType extends Type { } public override hasName(): boolean { - return !this.isValue + return !this.isValue } public override getName(): string { @@ -680,19 +690,19 @@ export final class LongType extends Type { export final class FloatType extends Type { private static refInst: FloatType | null = null private static valInst: FloatType | null = null - - private isValue: boolean + + private isValue: boolean private constructor(td: TypeDesc, isValue: boolean) { this.td = td - this.isValue = isValue + this.isValue = isValue } public static getInstance(td: TypeDesc): FloatType { if (TypeAPIIsValueType(td)) { - FloatType.valInst = (FloatType.valInst == null) ? new FloatType(td, true) : FloatType.valInst + FloatType.valInst = (FloatType.valInst == null) ? new FloatType(td, true) : FloatType.valInst return FloatType.valInst! - } + } FloatType.refInst = (FloatType.refInst == null) ? new FloatType(td, false) : FloatType.refInst return FloatType.refInst! } @@ -706,7 +716,7 @@ export final class FloatType extends Type { } public override hasName(): boolean { - return !this.isValue + return !this.isValue } public override getName(): string { @@ -732,19 +742,19 @@ export final class FloatType extends Type { export final class DoubleType extends Type { private static refInst: DoubleType | null = null private static valInst: DoubleType | null = null - - private isValue: boolean + + private isValue: boolean private constructor(td: TypeDesc, isValue: boolean) { this.td = td - this.isValue = isValue + this.isValue = isValue } public static getInstance(td: TypeDesc): DoubleType { if (TypeAPIIsValueType(td)) { - DoubleType.valInst = (DoubleType.valInst == null) ? new DoubleType(td, true) : DoubleType.valInst + DoubleType.valInst = (DoubleType.valInst == null) ? new DoubleType(td, true) : DoubleType.valInst return DoubleType.valInst! - } + } DoubleType.refInst = (DoubleType.refInst == null) ? new DoubleType(td, false) : DoubleType.refInst return DoubleType.refInst! } @@ -758,7 +768,7 @@ export final class DoubleType extends Type { } public override hasName(): boolean { - return !this.isValue + return !this.isValue } public override getName(): string { @@ -783,7 +793,7 @@ export final class DoubleType extends Type { export final class ClassType extends Type { public constructor(td: TypeDesc) { - this.td = td + this.td = td } public override isPrimitive(): boolean { @@ -795,7 +805,7 @@ export final class ClassType extends Type { } public override hasName(): boolean { - return true + return true } public override getName(): string { @@ -809,7 +819,7 @@ export final class ClassType extends Type { public override equals(to: Object): boolean { // TODO(shumilov-petr): not implemented - return false + return false } public hasEmptyConstructor(): boolean { @@ -824,7 +834,7 @@ export final class ClassType extends Type { } public getBaseType(): Type { - // TODO(mitkin-kirill): discuss necessity of getBaseTypes + // TODO(mitkin-kirill): discuss necessity of getBaseTypes return Type.resolve(TypeAPIGetBaseType(this.td)) } @@ -919,7 +929,7 @@ export final class ClassType extends Type { export final class InterfaceType extends Type { public constructor(td: TypeDesc) { - this.td = td + this.td = td } public override isPrimitive(): boolean { @@ -931,7 +941,7 @@ export final class InterfaceType extends Type { } public override hasName(): boolean { - return true + return true } public override getName(): string { @@ -945,7 +955,7 @@ export final class InterfaceType extends Type { public override equals(to: Object): boolean { // TODO(shumilov-petr): not implemented - return false + return false } public getBaseTypesNum(): long { @@ -1017,7 +1027,7 @@ export final class InterfaceType extends Type { export final class ArrayType extends Type { private elemTD: TypeDesc - + private static booleanInst: ArrayType | null = null private static charInst: ArrayType | null = null private static byteInst: ArrayType | null = null @@ -1026,7 +1036,7 @@ export final class ArrayType extends Type { private static longInst: ArrayType | null = null private static floatInst: ArrayType | null = null private static doubleInst: ArrayType | null = null - + private constructor(td: TypeDesc, elemTD: TypeDesc) { this.td = td this.elemTD = elemTD @@ -1036,28 +1046,28 @@ export final class ArrayType extends Type { let ek = TypeAPIGetTypeKind(elemTD) & TypeKindMask switch (ek) { case BooleanKind: - ArrayType.booleanInst = (ArrayType.booleanInst == null) ? new ArrayType(td, elemTD) : ArrayType.booleanInst + ArrayType.booleanInst = (ArrayType.booleanInst == null) ? new ArrayType(td, elemTD) : ArrayType.booleanInst return ArrayType.booleanInst! case CharKind: - ArrayType.charInst = (ArrayType.charInst == null) ? new ArrayType(td, elemTD) : ArrayType.charInst + ArrayType.charInst = (ArrayType.charInst == null) ? new ArrayType(td, elemTD) : ArrayType.charInst return ArrayType.charInst! case ByteKind: - ArrayType.byteInst = (ArrayType.byteInst == null) ? new ArrayType(td, elemTD) : ArrayType.byteInst + ArrayType.byteInst = (ArrayType.byteInst == null) ? new ArrayType(td, elemTD) : ArrayType.byteInst return ArrayType.byteInst! case ShortKind: - ArrayType.shortInst = (ArrayType.shortInst == null) ? new ArrayType(td, elemTD) : ArrayType.shortInst + ArrayType.shortInst = (ArrayType.shortInst == null) ? new ArrayType(td, elemTD) : ArrayType.shortInst return ArrayType.shortInst! case IntKind: - ArrayType.intInst = (ArrayType.intInst == null) ? new ArrayType(td, elemTD) : ArrayType.intInst + ArrayType.intInst = (ArrayType.intInst == null) ? new ArrayType(td, elemTD) : ArrayType.intInst return ArrayType.intInst! case LongKind: - ArrayType.longInst = (ArrayType.longInst == null) ? new ArrayType(td, elemTD) : ArrayType.longInst + ArrayType.longInst = (ArrayType.longInst == null) ? new ArrayType(td, elemTD) : ArrayType.longInst return ArrayType.longInst! case FloatKind: - ArrayType.floatInst = (ArrayType.floatInst == null) ? new ArrayType(td, elemTD) : ArrayType.floatInst + ArrayType.floatInst = (ArrayType.floatInst == null) ? new ArrayType(td, elemTD) : ArrayType.floatInst return ArrayType.floatInst! case DoubleKind: - ArrayType.doubleInst = (ArrayType.doubleInst == null) ? new ArrayType(td, elemTD) : ArrayType.doubleInst + ArrayType.doubleInst = (ArrayType.doubleInst == null) ? new ArrayType(td, elemTD) : ArrayType.doubleInst return ArrayType.doubleInst! case ClassKind: case StringKind: @@ -1067,7 +1077,7 @@ export final class ArrayType extends Type { case UnionKind: return new ArrayType(td, elemTD) default: - // TODO(shumilov-petr): need throw exception + // TODO(shumilov-petr): need throw exception assert(false) } } @@ -1085,7 +1095,7 @@ export final class ArrayType extends Type { } public override hasName(): boolean { - return false + return false } public override getName(): string { @@ -1098,7 +1108,7 @@ export final class ArrayType extends Type { public override equals(to: Object): boolean { // TODO(shumilov-petr): not implemented - return false + return false } public getElementType(): Type { @@ -1122,16 +1132,16 @@ export final class ArrayType extends Type { export final class FunctionType extends Type { - private isThrowabl: boolean - private isNativ: boolean - private isAsyn: boolean - + private isThrowabl: boolean + private isNativ: boolean + private isAsyn: boolean + constructor(td: TypeDesc) { this.td = td // TODO(shumilov-petr): not implemented - this.isThrowabl = false + this.isThrowabl = false this.isNativ = false - this.isAsyn = false + this.isAsyn = false } public override isPrimitive(): boolean { @@ -1143,7 +1153,7 @@ export final class FunctionType extends Type { } public override hasName(): boolean { - return false + return false } public isThrowable(): boolean { @@ -1196,7 +1206,7 @@ export final class FunctionType extends Type { // TODO(shumilov-petr): not implemented throw new Error("Not implemented") } - + public static create(): FunctionType { // TODO(shumilov-petr): not implemented throw new Error("Not implemented") @@ -1228,12 +1238,11 @@ export final class FunctionType extends Type { } } - export final class StringType extends Type { private static inst: StringType | null = null constructor() { - this.td = TypeAPIGetTypeDescriptor("") + this.td = TypeAPIGetTypeDescriptor("") } public static getInstance(): StringType { @@ -1250,7 +1259,7 @@ export final class StringType extends Type { } public override hasName(): boolean { - return false + return false } public override getName(): string { @@ -1272,7 +1281,7 @@ export final class StringType extends Type { export final class EnumType extends Type { constructor(td: TypeDesc) { - this.td = td + this.td = td } public override isPrimitive(): boolean { @@ -1284,7 +1293,7 @@ export final class EnumType extends Type { } public override hasName(): boolean { - return false + return false } public override getName(): string { @@ -1306,7 +1315,7 @@ export final class EnumType extends Type { export final class UnionType extends Type { constructor(td: TypeDesc) { - this.td = td + this.td = td } public override isPrimitive(): boolean { @@ -1318,7 +1327,7 @@ export final class UnionType extends Type { } public override hasName(): boolean { - return false + return false } public override getName(): string { @@ -1339,15 +1348,15 @@ export final class UnionType extends Type { export final class NullType extends Type { private static instance: NullType | null = null - + private constructor() { - this.td = NullTD + this.td = NullTD } public static getInstance(): NullType { if (NullType.instance == null) { NullType.instance = new NullType() - } + } return NullType.instance! } @@ -1375,4 +1384,3 @@ export final class NullType extends Type { return (to instanceof NullType); } } -