68 for (
const auto& modPair :
compilerCtx->getCompiledModules()) {
69 indexT modId = modPair.first;
70 const auto& srcModule = modPair.second;
73 for (
const auto& structPair : srcModule->structTable) {
74 indexT oldIdx = srcModule->structTable.getIndex(structPair.first);
75 auto newName =
mangleName(modId, structPair.second->name);
77 auto newIndex =
finalModule->structTable.put_create(newName, structPair.second);
79 finalModule->structTable[newIndex]->linkedModuleId = modId;
82 for (
const auto& ifacePair : srcModule->interfaceTable) {
83 indexT oldIdx = srcModule->interfaceTable.getIndex(ifacePair.first);
84 auto newName =
mangleName(modId, ifacePair.second->name);
86 finalModule->interfaceTable.put_create(newName, ifacePair.second);
87 auto newIndex =
finalModule->interfaceTable.getIndex(newName);
89 finalModule->interfaceTable[newIndex]->linkedModuleId = modId;
93 for (
const auto& modPair :
compilerCtx->getCompiledModules()) {
94 indexT modId = modPair.first;
95 const auto& srcModule = modPair.second;
97 for (
const auto& structPair : srcModule->structTable) {
98 indexT oldIdx = srcModule->structTable.getIndex(structPair.first);
99 auto newName =
mangleName(modId, structPair.second->name);
102 for (
auto &type :
finalModule->structTable[newIdx]->fieldTypes) {
108 for (
const auto& ifacePair : srcModule->interfaceTable) {
109 indexT oldIdx = srcModule->interfaceTable.getIndex(ifacePair.first);
110 auto newName =
mangleName(modId, ifacePair.second->name);
112 finalModule->interfaceTable[newIdx]->name = newName;
113 finalModule->interfaceTable[newIdx]->linkedModuleId = modId;
115 for (
auto &method :
finalModule->interfaceTable[newIdx]->methodMap) {
116 for (
auto ¶m : method.second->argumentTypes) {
119 for (
auto &ret : method.second->variableTable.getVariables()) {
122 method.second->returnType =
patchType(method.second->returnType);
129 for (
const auto& implPair : srcModule->interfaceImplementationTable) {
130 indexT oldIdx = srcModule->interfaceImplementationTable.getIndex(implPair.first);
131 auto newName =
mangleName(modId, implPair.second->name);
132 indexT newIdx =
finalModule->interfaceImplementationTable.put_create(newName, implPair.second);
135 finalModule->interfaceImplementationTable[newIdx]->name = newName;
136 finalModule->interfaceImplementationTable[newIdx]->linkedModuleId = modId;
143 for (
const auto& modPair :
compilerCtx->getCompiledModules()) {
144 indexT modId = modPair.first;
145 const auto& srcModule = modPair.second;
146 for (
const auto& globalPair : srcModule->globalVariables) {
147 indexT oldIdx = srcModule->globalVariables.getIndex(globalPair.first);
148 auto newName =
mangleName(modId, globalPair.first);
158 for (
const auto& modPair :
compilerCtx->getCompiledModules()) {
159 indexT modId = modPair.first;
160 const auto& srcModule = modPair.second;
161 for (
const auto& funcPair : srcModule->functionTable) {
162 indexT oldIdx = srcModule->functionTable.getIndex(funcPair.first);
163 auto newName =
mangleName(modId, funcPair.second->name);
166 auto newFuncDef = std::make_shared<IRFunctionDefinition>(*funcPair.second);
167 newFuncDef->name = newName;
168 newFuncDef->codeBlock.clear();
170 for (
auto &var : newFuncDef->variableTable.getVariables()) {
173 for (
auto ¶m : newFuncDef->argumentTypes) {
179 finalModule->functionTable[newIdx]->linkedModuleId = modId;
181 if (funcPair.first == L
"yoimiya_glob_initializer") {
188 for (
const auto& modPair :
compilerCtx->getCompiledModules()) {
189 indexT modId = modPair.first;
190 const auto& srcModule = modPair.second;
191 for (
const auto& funcPair : srcModule->functionTable) {
192 indexT oldIdx = srcModule->functionTable.getIndex(funcPair.first);
195 const auto& srcFunc = funcPair.second;
196 auto& destFunc =
finalModule->functionTable[newIdx];
199 destFunc->returnType =
patchType(srcFunc->returnType);
200 destFunc->variableTable = srcFunc->variableTable;
203 for (
const auto& srcBlock : srcFunc->codeBlock) {
204 auto newBlock = std::make_shared<IRCodeBlock>();
205 for (
const auto& srcInstr : srcBlock->getIRArray()) {
208 destFunc->codeBlock.push_back(newBlock);
297 std::shared_ptr<IRValueType> newType =
managedPtr(*oldType);
298 switch (oldType->type) {
300 auto newIndex =
structRemapping[oldType->typeAffiliateModule][oldType->typeIndex];
302 newType->typeIndex = newIndex;
308 newType->typeIndex = newIndex;
314 newType->typeIndex = newIndex;
318 auto newIndex =
functionRemapping[oldType->typeAffiliateModule][oldType->typeIndex];
320 newType->typeIndex = newIndex;
329 newType->metadata.setMetadata(L
"linkMetadata", std::make_pair(oldType->typeAffiliateModule, oldType->typeIndex));
367 for (
auto &funcPair :
compilerCtx->getIRFFITable()->exportedFunctionTable) {
370 for (
auto &libPair :
compilerCtx->getIRFFITable()->importedLibraries) {
371 for (
auto &funcPair : libPair.second.importedFunctionTable) {
372 funcPair.second->returnType =
patchType(funcPair.second->returnType);
373 for (
auto ¶m : funcPair.second->argumentTypes) {
376 for (
auto &ret : funcPair.second->variableTable.getVariables()) {
381 for (
auto &foreignTypePair :
compilerCtx->getIRFFITable()->foreignTypeTable) {
382 foreignTypePair.second =
patchType(foreignTypePair.second);
427 for (
const auto& modPair :
compilerCtx->getCompiledModules()) {
428 indexT modId = modPair.first;
429 const auto& srcModule = modPair.second;
430 for (
const auto& dataStructPair : srcModule->dataStructTable) {
431 auto &dataStruct = dataStructPair.second;
432 dataStruct->linkedModuleId = modId;
437 for (
auto &dataStructPair :
finalModule->dataStructTable) {
438 for (
auto &field : dataStructPair.second->fieldTypes) {
void invokeOp(yoi::indexT funcIndex, yoi::indexT funcArgsCount, const std::shared_ptr< IRValueType > &returnType, bool externalInvocation=false, yoi::indexT moduleIndex=-1)
Invoke a function with the given arguments.