VM_Data_Type type_info_get_type(Type_Info_Handle tih) { assert(tih); TypeDesc* td = (TypeDesc*)tih; switch (td->get_kind()) { case K_S1: return VM_DATA_TYPE_INT8; case K_S2: return VM_DATA_TYPE_INT16; case K_S4: return VM_DATA_TYPE_INT32; case K_S8: return VM_DATA_TYPE_INT64; case K_Sp: return VM_DATA_TYPE_INTPTR; case K_U1: return VM_DATA_TYPE_UINT8; case K_U2: return VM_DATA_TYPE_UINT16; case K_U4: return VM_DATA_TYPE_UINT32; case K_U8: return VM_DATA_TYPE_UINT64; case K_Up: return VM_DATA_TYPE_UINTPTR; case K_F4: return VM_DATA_TYPE_F4; case K_F8: return VM_DATA_TYPE_F8; case K_Char: return VM_DATA_TYPE_CHAR; case K_Boolean: return VM_DATA_TYPE_BOOLEAN; case K_Void: return VM_DATA_TYPE_VOID; case K_Object: return VM_DATA_TYPE_CLASS; case K_Vector: return VM_DATA_TYPE_ARRAY; case K_UnboxedValue: return VM_DATA_TYPE_VALUE; case K_UnmanagedPointer: return VM_DATA_TYPE_UP; case K_ManagedPointer: return VM_DATA_TYPE_MP; // The rest are not implemented in the VM_Data_Type scheme case K_Array: case K_MethodPointer: case K_TypedRef: default: DIE(("Invalid vm data type")); return VM_DATA_TYPE_INVALID; } } //type_info_get_type
BOOLEAN type_info_is_resolved(Type_Info_Handle tih) { TypeDesc* td = (TypeDesc*)tih; switch (td->get_kind()) { case K_Vector: if (td->get_element_type()->is_primitive()) { return true; } return type_info_is_resolved(td->get_element_type()); case K_Object: return td->is_loaded(); default: LDIE(73, "Unexpected kind"); return 0; } }
U_32 type_info_get_num_array_dimensions(Type_Info_Handle tih) { TypeDesc* td = (TypeDesc*)tih; if (td->get_kind() == K_Vector) { const String* name = td->get_type_name(); U_32 res = 0; if (name == NULL) { res = 1 + type_info_get_num_array_dimensions(td->get_element_type()); } else { res = countLeadingChars(name->bytes, '['); } assert(res<=255); return res; } return 0; }
Type_Info_Handle type_info_get_type_info(Type_Info_Handle tih) { TypeDesc* td = (TypeDesc*)tih; assert(td); switch (td->get_kind()) { case K_Vector: case K_Array: return td->get_element_type(); case K_ManagedPointer: case K_UnmanagedPointer: return td->get_pointed_to_type(); default: LDIE(73, "Unexpected kind"); return 0; } } //type_info_get_type_info
BOOLEAN type_info_is_void(Type_Info_Handle tih) { TypeDesc* td = (TypeDesc*)tih; assert(td); return td->get_kind()==K_Void; } //type_info_is_void
BOOLEAN type_info_is_reference(Type_Info_Handle tih) { TypeDesc* td = (TypeDesc*)tih; assert(td); return td->get_kind()==K_Object; } //type_info_is_reference