| 620 | } |
| 621 | |
| 622 | bool Compiler::ImportModule(const char* bytecode, const char* pos, unsigned int number) |
| 623 | { |
| 624 | char errBuf[256]; |
| 625 | ByteCode *bCode = (ByteCode*)bytecode; |
| 626 | char *symbols = (char*)(bCode) + bCode->offsetToSymbols; |
| 627 | |
| 628 | typeRemap.clear(); |
| 629 | |
| 630 | #ifdef IMPORT_VERBOSE_DEBUG_OUTPUT |
| 631 | printf("Importing module %s\r\n", pos); |
| 632 | #endif |
| 633 | // Import types |
| 634 | ExternTypeInfo *tInfo = FindFirstType(bCode); |
| 635 | unsigned int *memberList = (unsigned int*)(tInfo + bCode->typeCount); |
| 636 | |
| 637 | unsigned int oldTypeCount = CodeInfo::typeInfo.size(); |
| 638 | |
| 639 | typeMap.clear(); |
| 640 | for(unsigned int n = 0; n < oldTypeCount; n++) |
| 641 | typeMap.insert(CodeInfo::typeInfo[n]->GetFullNameHash(), CodeInfo::typeInfo[n]); |
| 642 | |
| 643 | unsigned int lastTypeNum = CodeInfo::typeInfo.size(); |
| 644 | for(unsigned int i = 0; i < bCode->typeCount; i++, tInfo++) |
| 645 | { |
| 646 | TypeInfo **info = typeMap.find(tInfo->nameHash); |
| 647 | if(info) |
| 648 | typeRemap.push_back((*info)->typeIndex); |
| 649 | else |
| 650 | typeRemap.push_back(lastTypeNum++); |
| 651 | } |
| 652 | |
| 653 | // Import namespaces |
| 654 | struct NamespaceData |
| 655 | { |
| 656 | unsigned offsetToName; |
| 657 | unsigned parentHash; |
| 658 | }; |
| 659 | NamespaceData *namespaceList = (NamespaceData*)((char*)bCode + bCode->offsetToNamespaces); |
| 660 | for(unsigned i = 0; i < bCode->namespaceCount; i++) |
| 661 | { |
| 662 | NamespaceInfo *parent = NULL; |
| 663 | if(namespaceList->parentHash != ~0u) |
| 664 | { |
| 665 | for(unsigned k = 0; k < CodeInfo::namespaceInfo.size() && !parent; k++) |
| 666 | { |
| 667 | if(CodeInfo::namespaceInfo[k]->hash == namespaceList->parentHash) |
| 668 | parent = CodeInfo::namespaceInfo[k]; |
| 669 | } |
| 670 | } |
| 671 | CodeInfo::namespaceInfo.push_back(new NamespaceInfo(InplaceStr(symbols + namespaceList->offsetToName), GetStringHash(symbols + namespaceList->offsetToName), parent)); |
| 672 | namespaceList++; |
| 673 | } |
| 674 | |
| 675 | unsigned skipConstants = 0; |
| 676 | tInfo = FindFirstType(bCode); |
| 677 | for(unsigned int i = 0; i < bCode->typeCount; i++, tInfo++) |
| 678 | { |
| 679 | if(typeRemap[i] >= oldTypeCount) |
nothing calls this directly
no test coverage detected