ref_t ModuleScope :: loadClassInfo(ClassInfo& info, ident_t vmtName, bool headerOnly) { _Module* argModule = NULL; if (emptystr(vmtName)) return 0; if (isTemplateWeakReference(vmtName)) { // COMPILER MAGIC : try to find a template ref_t ref = loadClassInfo(info, resolveWeakTemplateReference(vmtName + TEMPLATE_PREFIX_NS_LEN), headerOnly); if (ref != 0 && info.header.classRef != 0) { if (module->resolveReference(info.header.classRef).endsWith(CLASSCLASS_POSTFIX)) { // HOTFIX : class class ref should be template weak reference as well IdentifierString classClassName(vmtName, CLASSCLASS_POSTFIX); info.header.classRef = module->mapReference(classClassName); } } return ref; } else { // load class meta data ref_t moduleRef = 0; if (isWeakReference(vmtName)) { // if it is a weak reference - do not need to resolve the module argModule = module; moduleRef = module->mapReference(vmtName); } else argModule = project->resolveModule(vmtName, moduleRef, true); if (argModule == NULL || moduleRef == 0) return 0; // load argument VMT meta data _Memory* metaData = argModule->mapSection(moduleRef | mskMetaRDataRef, true); if (metaData == NULL || metaData->Length() == sizeof(SymbolExpressionInfo)) return 0; MemoryReader reader(metaData); if (argModule != module) { ClassInfo copy; copy.load(&reader, headerOnly); importClassInfo(copy, info, argModule, headerOnly, false, false); } else info.load(&reader, headerOnly); if (argModule != module) { // import reference importReference(argModule, moduleRef, module); } return moduleRef; } }
bool loadClassInfo(_Module* module, ident_t reference, ClassInfo& info) { // find class meta data _Memory* data = findClassMetaData(module, reference); if (data == NULL) { printLine("Class not found:", reference); return false; } MemoryReader reader(data); info.load(&reader); return true; }
bool loadClassInfo(_Module* module, const wchar_t* className, ClassInfo& info) { // find class meta data ReferenceNs reference(module->Name(), className); _Memory* data = findClassMetaData(module, reference); if (data == NULL) { wprintf(_T("Class %s not found\n"), (const wchar_t*)reference); return false; } MemoryReader reader(data); info.load(&reader); return true; }