void* sysObjectMethod(int64_t *object, char *methodName) { if (object == NULL ) { wprintf(L"Error in invoking method from null point!\n"); exit(1); } ClassInfo *classInfo = *((ClassInfo**) object); return getMethodPtr(classInfo, methodName); }
static void* getMethodPtr(ClassInfo *classInfo, char *methodName) { char **methodNameTable = classInfo->methodNameTable; void **methodTable = classInfo->methodTable; uint64_t methodCount = classInfo->methodCount; for (uint64_t i = 0; i < methodCount; i++) { if (strcmp(methodName, methodNameTable[i]) == 0) { return methodTable[i]; } } if (classInfo->superClass != NULL ) { return getMethodPtr(classInfo->superClass, methodName); } return NULL ; }
* ResourceData, and RefData classes. */ static_assert(TYPE_TO_DESTR_IDX(KindOfString) == 1, "String destruct index"); static_assert(TYPE_TO_DESTR_IDX(KindOfArray) == 2, "Array destruct index"); static_assert(TYPE_TO_DESTR_IDX(KindOfObject) == 3, "Object destruct index"); static_assert(TYPE_TO_DESTR_IDX(KindOfResource) == 4, "Resource destruct index"); static_assert(TYPE_TO_DESTR_IDX(KindOfRef) == 5, "Ref destruct index"); static_assert(kDestrTableSize == 6, "size of g_destructors[] must be kDestrTableSize"); const RawDestructor g_destructors[] = { nullptr, (RawDestructor)getMethodPtr(&StringData::release), (RawDestructor)getMethodPtr(&ArrayData::release), (RawDestructor)getMethodPtr(&ObjectData::release), (RawDestructor)getMethodPtr(&ResourceData::release), (RawDestructor)getMethodPtr(&RefData::release), }; Variant::~Variant() { if (IS_REFCOUNTED_TYPE(m_type)) { tvDecRefHelper(m_type, uint64_t(m_data.pref)); } } void tvDecRefHelper(DataType type, uint64_t datum) { assert(type == KindOfString || type == KindOfArray || type == KindOfObject || type == KindOfResource ||
void tweak_variant_dtors() { if (RuntimeOption::EnableObjDestructCall) return; g_destructors[TYPE_TO_DESTR_IDX(KindOfObject)] = (RawDestructor)getMethodPtr(&ObjectData::releaseNoObjDestructCheck); }
* ResourceData, and RefData classes. */ static_assert(TYPE_TO_DESTR_IDX(KindOfString) == 1, "String destruct index"); static_assert(TYPE_TO_DESTR_IDX(KindOfArray) == 2, "Array destruct index"); static_assert(TYPE_TO_DESTR_IDX(KindOfObject) == 3, "Object destruct index"); static_assert(TYPE_TO_DESTR_IDX(KindOfResource) == 4, "Resource destruct index"); static_assert(TYPE_TO_DESTR_IDX(KindOfRef) == 5, "Ref destruct index"); static_assert(kDestrTableSize == 6, "size of g_destructors[] must be kDestrTableSize"); RawDestructor g_destructors[] = { nullptr, (RawDestructor)getMethodPtr(&StringData::release), (RawDestructor)getMethodPtr(&ArrayData::release), (RawDestructor)getMethodPtr(&ObjectData::release), // may replace at runtime (RawDestructor)getMethodPtr(&ResourceData::release), (RawDestructor)getMethodPtr(&RefData::release), }; void tweak_variant_dtors() { if (RuntimeOption::EnableObjDestructCall) return; g_destructors[TYPE_TO_DESTR_IDX(KindOfObject)] = (RawDestructor)getMethodPtr(&ObjectData::releaseNoObjDestructCheck); } Variant::~Variant() noexcept { tvRefcountedDecRef(asTypedValue()); if (debug) {