46 return L
"double(" + std::to_wstring(
value.
decimal) + L
")";
64 return L
"short(" + std::to_wstring(
value.
shortV) + L
")";
79 r += operand.to_string();
87 std::tuple<IRValueType::valueType, yoi::indexT, yoi::indexT> implStructIndex,
88 const std::pair<yoi::indexT, yoi::indexT> &implInterfaceIndex,
89 const yoi::vec<std::shared_ptr<IRValueType>> &virtualMethods,
90 const std::map<yoi::wstr, yoi::indexT> &virtualMethodIndexMap)
91 : name(name), implStructIndex(implStructIndex), virtualMethods(virtualMethods), virtualMethodIndexMap(virtualMethodIndexMap),
92 implInterfaceIndex(implInterfaceIndex) {}
97 : name(name), functionOverloadIndexies(functionOverloadIndexies), methodMap(methodMap) {}
103 r += function.second->to_string(indent + 4);
106 r += structType.second->to_string(indent + 4);
109 r += interfaceType.second->to_string(indent + 4);
112 r += interfaceImpl.second->to_string(indent + 4);
119 std::shared_ptr<IRModule> currentModule,
120 std::shared_ptr<IRFunctionDefinition> currentFunction)
121 : compilerCtx(compilerCtx), currentModule(currentModule), currentFunction(currentFunction), currentCodeBlockIndex(0), currentDebugInfo() {}
148 if (insertionPoint == 0xffffffff) {
171 switch (valType->type) {
176 "Type mismatch in basicCast.");
184 "Type mismatch in basicCast.");
192 "Type mismatch in basicCast.");
200 "Type mismatch in basicCast.");
212 "Type mismatch in basicCast.");
220 "Type mismatch in basicCast.");
227 "Unsupported type for basicCast: " + std::string{magic_enum::enum_name<>(valType->type)});
251 "Type mismatch in arithmetic operation: " +
wstring2string(left->to_string()) +
" " + std::string{magic_enum::enum_name<>(op)} +
336 }
else if (moduleIndex == -1) {
384 const std::shared_ptr<IRValueType> &returnType,
385 bool externalInvocation,
400 const std::shared_ptr<IRValueType> &returnType,
402 bool externalInvocation,
405 for (
yoi::indexT i = 0; i < methodArgsCount + 1; i++) {
423 const std::shared_ptr<IRValueType> &returnType,
424 bool externalInvocation,
426 for (
yoi::indexT i = 0; i < methodArgsCount + 1; i++) {
440 if (returnWithNone) {
513 r +=
yoi::wstr(indent, L
' ') + ir.to_string() + L
"\n";
527 r += (*it)->to_string(
true) + L
", ";
531 r += L
") : " +
returnType->to_string(
true) + L
" {\n";
533 for (
auto idx = 0; idx <
codeBlock.size(); ++idx) {
534 r +=
yoi::wstr(indent + 4, L
' ') + L
"block#" + std::to_wstring(idx) + L
":\n";
535 r +=
codeBlock[idx]->to_string(indent + 8);
547 this->
name = interfaceName;
553 this->implStructIndex = implStructIndex;
559 this->implInterfaceIndex = implInterfaceIndex;
565 this->virtualMethods.emplace_back(methodType);
566 this->virtualMethodIndexMap[methodName] = this->virtualMethods.size() - 1;
572 std::move(
name), implStructIndex, implInterfaceIndex, std::move(virtualMethods), std::move(virtualMethodIndexMap)});
576 this->
name = interfaceName;
581 const yoi::wstr &methodNameOri,
const yoi::wstr &methodName,
const std::shared_ptr<IRFunctionDefinition> &methodSignature) {
582 this->functionOverloadIndexies[methodNameOri].push_back(this->methodMap.put_create(methodName, methodSignature));
587 return std::make_shared<IRInterfaceInstanceDefinition>(std::move(
name), std::move(functionOverloadIndexies), std::move(methodMap));
591 const std::shared_ptr<IRValueType> &argumentType) {
592 this->
argumentTypes.emplace_back(argumentName, argumentType);
607 const std::shared_ptr<IRValueType> &
returnType,
609 const std::set<FunctionAttrs> &
attrs,
624 : type(type), typeAffiliateModule(typeAffiliateModule), typeIndex(objectPrototypeIndex), dimensions() {}
665 res = L
"int_literal";
668 res = L
"deci_literal";
671 res = L
"bool_literal";
674 res = L
"short_literal";
677 res = L
"unsigned_literal";
716 res = L
"pointerObject";
725 res = L
"incomplete_template_type#" + std::to_wstring(
typeIndex);
740 res += L
"[" + std::to_wstring(d) + L
"]";
759 const std::map<yoi::wstr, nameInfo> &nameInfoMap,
760 const vec<std::shared_ptr<IRValueType>> &fieldTypes,
762 const yoi::vec<std::shared_ptr<IRValueType>> &storedTemplateArgs,
763 const std::map<yoi::wstr, yoi::structDefInnerPair *> &templateMethodDecls,
764 const std::map<yoi::wstr, yoi::implInnerPair *> &templateMethodDefs)
765 : name(name), nameIndexMap(nameInfoMap), fieldTypes(fieldTypes), templateParamNames(templateParamNames),
766 storedTemplateArgs(storedTemplateArgs), templateMethodDecls(templateMethodDecls), templateMethodDefs(templateMethodDefs) {}
773 r +=
yoi::wstr(indent + 4, L
' ') + i.first + L
" " +
fieldTypes[i.second.index]->to_string(
true) + L
"\n";
783 }
catch (std::out_of_range &e) {
805 const yoi::vec<std::shared_ptr<IRValueType>> &args) {
822 return std::make_shared<IRStructDefinition>(std::move(
name),
832 return pool.put(str);
840 for (
auto &it : std::ranges::reverse_view(variableNameIndexMap)) {
841 if (
auto item = it.find(
name); item != it.end()) {
849 variableNameIndexMap.emplace_back();
850 return (
yoi::indexT)variableNameIndexMap.size() - 1;
854 variableNameIndexMap.pop_back();
859 r +=
yoi::wstr(indent, L
' ') + L
"Variables {\n";
860 for (int64_t i = 0; i < variables.size(); ++i) {
861 r +=
yoi::wstr(indent + 4, L
' ') + L
"#" + std::to_wstring(i) + L
" " + reversedVariableNameMap[i] + L
"(scope#" +
862 std::to_wstring(variableScopeMap[i]) + L
") : " + variables[i]->to_string(
true) + L
"\n";
864 return r +
yoi::wstr(indent, L
' ') + L
"}\n";
868 return variables[index];
872 return variables[lookup(
name)];
876 variables.emplace_back(type);
877 variableNameIndexMap.back()[
name] = variables.size() - 1;
878 variableScopeMap[variables.size() - 1] = variableNameIndexMap.size() - 1;
879 reversedVariableNameMap[variables.size() - 1] =
name;
880 return variables.size() - 1;
884 : type(type),
name(
name), affiliateModule(affiliateModule), itemIndex(itemIndex) {}
936 r +=
yoi::wstr(indent, L
' ') + L
"interface " + name + L
" {\n";
937 for (
auto &i : methodMap) {
938 r += i.second->to_string(indent + 4) + L
"\n";
946 r +=
yoi::wstr(indent, L
' ') + L
"impl " + name + L
" for " +
948 std::to_wstring(std::get<1>(implStructIndex)) + L
"#" + std::to_wstring(std::get<2>(implStructIndex)) + L
" {\n";
950 for (
auto &i : virtualMethods) {
951 r +=
yoi::wstr(indent + 4, L
' ') + L
"virtual " + i->to_string() + L
"\n";
1001 const std::shared_ptr<IRInterfaceImplementationDefinition> &templateDefinition) {
1011 const std::shared_ptr<IRValueType> &templateType,
1018 const std::shared_ptr<IRFunctionTemplate> &methodTemplate) {
1020 templateMethods.put_create(methodName, methodTemplate);
1029 return reversedVariableNameMap;
1041 const std::shared_ptr<IRFunctionDefinition> &functionDefinition) {
1046 return importedLibraries[libraryName].importedFunctionTable.put(functionName, functionDefinition);
1052 const std::set<IRFunctionDefinition::FunctionAttrs> &attrs) {
1061 this->searchPaths = searchPaths;
1066 searchPaths.push_back(searchPath);
1073 const std::shared_ptr<IRValueType> &returnType) {
1075 tempVarStack.pop_back();
1077 tempVarStack.push_back(
managedPtr(compilerCtx->normalizeForeignBasicType(returnType)));
1089 return !dimensions.empty() && dimensions.back() !=
static_cast<yoi::indexT>(-1);
1096 : type(type), dimensions(dimensions), typeAffiliateModule(typeAffiliateModule), typeIndex(objectPrototypeIndex) {}
1099 : type(type), dimensions(dimensions), typeAffiliateModule(0), typeIndex(0) {}
1109 switch (elementType->type) {
1149 for (
auto &dim : dimensions) {
1153 for (
yoi::indexT i = 0; i < onstackElementCount; ++i) {
1178 "Invalid code block index");
1191 auto elementCount =
tempVarStack.back()->bracedTypes.size();
1217 auto rhs = tempVarStack.back();
1218 tempVarStack.pop_back();
1225 if (type->isArrayType() || type->isDynamicArrayType()) {
1227 for (
auto &dim : type->dimensions) {
1243 insert(
IR(op, operand, currentDebugInfo));
1256 if (type->isDynamicArrayType() || type->isArrayType()) {
1258 for (
auto &dim : type->dimensions) {
1266 insert(
IR(op, operand, currentDebugInfo));
1267 tempVarStack.pop_back();
1268 tempVarStack.push_back(type);
1278 tempVarStack.pop_back();
1285 switch (elementType->type) {
1318 panic(currentDebugInfo.line,
1319 currentDebugInfo.column,
1324 insert(
IR{op, operands, currentDebugInfo});
1325 for (
yoi::indexT i = 0; i <= initializerSize; i++) {
1326 tempVarStack.pop_back();
1328 tempVarStack.push_back(
managedPtr(elementType->getDynamicArrayType()));
1332 return {type, typeAffiliateModule, typeIndex, {
static_cast<yoi::indexT>(-1)}};
1336 return dimensions.size() == 1 && dimensions.back() ==
static_cast<yoi::indexT>(-1);
1340 tempVarStack.pop_back();
1341 tempVarStack.push_back(compilerCtx->getIntObjectType());
1346 tempVarStack.pop_back();
1347 tempVarStack.pop_back();
1348 tempVarStack.push_back(compilerCtx->getBoolObjectType());
1353 return attributes.count(attr) > 0;
1357 attributes.erase(attr);
1362 attributes.insert(attr);
1367 : type(type), typeAffiliateModule(typeAffiliateModule), typeIndex(objectPrototypeIndex), dimensions(), attributes(attributes) {}
1434 auto current = codeBlockInsertionStates.back();
1435 yoi_assert(currentCodeBlockIndex == std::get<0>(current), currentDebugInfo.line, currentDebugInfo.column,
"Invalid code block index");
1436 tempStateCodeBlock = std::vector<IR>(codeBlocks[currentCodeBlockIndex]->getIRArray().begin() + std::get<1>(current),
1437 codeBlocks[currentCodeBlockIndex]->getIRArray().end());
1438 tempStateTempVarStack = std::vector<std::shared_ptr<IRValueType>>(tempVarStack.begin() + std::get<2>(current), tempVarStack.end());
1440 codeBlocks[currentCodeBlockIndex]->getIRArray().resize(std::get<1>(current));
1441 tempVarStack.resize(std::get<2>(current));
1445 for (
auto &block : tempStateCodeBlock) {
1446 codeBlocks[currentCodeBlockIndex]->getIRArray().push_back(block);
1448 for (
auto &
type : tempStateTempVarStack) {
1449 tempVarStack.push_back(
type);
1451 tempStateCodeBlock.clear();
1452 tempStateTempVarStack.clear();
1457 while (codeBlockInsertionStates.size() > stateIndex) {
1463 if (!codeBlocks[currentCodeBlockIndex]->getIRArray().empty()) {
1464 switch (codeBlocks[currentCodeBlockIndex]->getIRArray().back().opcode) {
1477 marcos[name] =
value;
1482 return variableScopeMap[varIndex];
1486 loopContext.pop_back();
1490 yoi_assert(!loopContext.empty(), currentDebugInfo.line, currentDebugInfo.column,
"break statement outside a `while` or `for` loop");
1491 jumpOp(loopContext.back().breakTarget);
1495 yoi_assert(!loopContext.empty(), currentDebugInfo.line, currentDebugInfo.column,
"continue statement outside a `while` or `for` loop");
1496 jumpOp(loopContext.back().continueTarget);
1500 auto rhs = tempVarStack.back();
1501 tempVarStack.pop_back();
1502 for (
yoi::indexT i = 0; i < extractElementCount; i++) {
1503 tempVarStack.push_back(
managedPtr(rhs->getElementType()));
1512 auto rhs = tempVarStack.back();
1513 auto structDef = compilerCtx->getImportedModule(rhs->typeAffiliateModule)->structTable[rhs->typeIndex];
1514 yoi::indexT startPos = (extractType == ExtractType::First ? 0 : structDef->fieldTypes.size() - extractFieldCount);
1516 for (
auto curPos = startPos; curPos < startPos + extractFieldCount; curPos++) {
1517 tempVarStack.push_back(structDef->fieldTypes[curPos]);
1525 loopContext.push_back({breakTarget, continueTarget});
1532 const std::shared_ptr<IRValueType> &returnType,
1533 bool externalInvocation,
1552 : name(name), valueToIndexMap(valueToIndexMap) {}
1558 maxIndex = std::max(maxIndex, entry.second);
1560 if (maxIndex <= 255)
1562 else if (maxIndex <= 65535)
1579 if (metadata.count(key)) {
1580 metadata.erase(key);
1585 return metadata.find(key) != metadata.end();
1589 std::wstringstream ss;
1590 for (
auto &entry : metadata) {
1591 if (entry.first == L
"regressed_interface_impl") {
1592 auto &implIndex = getMetadata<std::pair<yoi::indexT, yoi::indexT>>(L
"regressed_interface_impl");
1593 ss << L
"!" << entry.first <<
"{" << implIndex.first <<
"," << implIndex.second <<
"}" <<
' ';
1594 }
else if (entry.first == L
"delayed_interface_impl") {
1595 auto &implIndex = getMetadata<std::pair<yoi::indexT, yoi::indexT>>(L
"delayed_interface_impl");
1596 ss << L
"!" << entry.first <<
"{" << implIndex.first <<
"," << implIndex.second <<
"}" <<
' ';
1597 }
else if (entry.first == L
"from_local") {
1598 auto localIndex = getMetadata<yoi::indexT>(L
"from_local");
1599 ss << L
"!" << entry.first <<
"{" << localIndex <<
"}" <<
' ';
1602 if (!ss.str().empty())
1626 if (dimensions.empty()) {
1630 for (
auto &dimension : dimensions) {
1637 const yoi::vec<std::shared_ptr<IRValueType>> &fieldTypes,
1638 const std::map<yoi::wstr, yoi::indexT> &fields,
1640 : name(name), fieldTypes(fieldTypes), fields(fields), linkedModuleId(linkedModuleId) {}
1648 const std::shared_ptr<IRValueType> &fieldType) {
1664 std::wstringstream ss;
1665 ss <<
yoi::wstr(indent, L
' ') << L
"datastruct " <<
name << L
" {\n";
1667 ss <<
yoi::wstr(indent + 4, L
' ') << field->to_string() << L
'\n';
1669 ss <<
yoi::wstr(indent, L
' ') << L
'}' << L
'\n';
1674 for (
yoi::indexT i = 0; i < parameterCount; i++) {
1675 popFromTempVarStack();
1681 const std::shared_ptr<IRValueType> &expectedType) {
1682 popFromTempVarStack();
1684 pushTempVar(expectedType);
1688 popFromTempVarStack();
1690 popFromTempVarStack();
1694 popFromTempVarStack();
1700 popFromTempVarStack();
1701 popFromTempVarStack();
1706 variables[index] = type;
void pushLoopContext(yoi::indexT breakTarget, yoi::indexT continueTarget)
std::vector< std::shared_ptr< IRCodeBlock > > codeBlocks
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.
std::shared_ptr< IRModule > currentModule
std::shared_ptr< IRValueType > & getLhsFromTempVarStack()
void newDataStructOp(yoi::indexT structIndex, bool isExternal=false, yoi::indexT moduleIndex=-1)
const IRDebugInfo & getCurrentDebugInfo()
std::shared_ptr< IRFunctionDefinition > currentFunction
void yieldOp(bool yieldNone=false)
void invokeVirtualOp(yoi::indexT funcIndex, yoi::indexT interfaceIndex, yoi::indexT methodArgsCount, const std::shared_ptr< IRValueType > &returnType, bool externalInvocation=false, yoi::indexT moduleIndex=-1)
void pushOp(IR::Opcode op, const yoi::IROperand &constV)
yoi::vec< std::tuple< yoi::indexT, yoi::indexT, yoi::indexT > > codeBlockInsertionStates
IRCodeBlock & getCodeBlock(yoi::indexT index)
void storeOp(IR::Opcode op, const yoi::IROperand &operand, yoi::indexT moduleIndex=-1)
void basicCast(const std::shared_ptr< IRValueType > &valType, yoi::indexT insertionPoint, bool lhs=false)
yoi::indexT createCodeBlock()
void constructInterfaceImplOp(const std::pair< yoi::indexT, yoi::indexT > &interfaceId, yoi::indexT interfaceImplIndex, bool isExternal=false, yoi::indexT moduleIndex=-1)
void loadFieldOp(yoi::vec< yoi::IROperand > &accessors, const std::shared_ptr< IRValueType > &expectedType)
std::shared_ptr< IRFunctionDefinition > irFuncDefinition()
void pushTempVar(const std::shared_ptr< IRValueType > &type)
void newArrayOp(const std::shared_ptr< IRValueType > &elementType, const yoi::vec< yoi::indexT > &dimensions, yoi::indexT onstackElementCount)
void loadOp(IR::Opcode op, const yoi::IROperand &source, const std::shared_ptr< IRValueType > &expectedType, yoi::indexT moduleIndex=-1)
void storeFieldOp(yoi::vec< yoi::IROperand > &accessors)
void invokeImportedOp(yoi::indexT libIndex, yoi::indexT funcIndex, yoi::indexT funcArgsCount, const std::shared_ptr< IRValueType > &returnType)
void newStructOp(yoi::indexT structIndex, bool isExternal=false, yoi::indexT moduleIndex=-1)
yoi::indexT currentCodeBlockIndex
yoi::indexT switchCodeBlock(yoi::indexT index)
void discardStateUntil(yoi::indexT stateIndex)
void bindElementsOp(yoi::indexT extractElementCount, ExtractType extractType)
void insert(const IR &ir, yoi::indexT insertionPoint=0xffffffff)
void invokeMethodOp(yoi::indexT funcIndex, yoi::indexT methodArgsCount, const std::shared_ptr< IRValueType > &returnType, bool isStatic, bool externalInvocation=false, yoi::indexT moduleIndex=-1)
void uniqueArithmeticOp(IR::Opcode op)
yoi::IROperand createLocalVar(const yoi::wstr &varName, const std::shared_ptr< IRValueType > &type)
void loadMemberOp(const yoi::IROperand &memberIndex, const std::shared_ptr< IRValueType > &memberType)
IRCodeBlock & getCurrentCodeBlock()
void initializeFieldsOp(yoi::indexT parameterCount)
void jumpOp(yoi::indexT target)
IRDebugInfo currentDebugInfo
void bindFieldsOp(yoi::indexT extractFieldCount, ExtractType extractType)
void jumpIfOp(IR::Opcode op, yoi::indexT target)
yoi::indexT getCurrentInsertionPoint()
void restoreStateTemporarily()
void invokeDanglingOp(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, but the last param will be taken as the first param.
void newDynamicArrayOp(const std::shared_ptr< IRValueType > &elementType, yoi::indexT initializerSize=0)
std::shared_ptr< compilerContext > compilerCtx
std::vector< std::shared_ptr< yoi::IRValueType > > tempVarStack
void popFromTempVarStack()
void storeMemberOp(const yoi::IROperand &memberIndex)
void arithmeticOp(IR::Opcode op)
yoi::indexT getCurrentCodeBlockIndex()
void dynCastOp(const std::shared_ptr< IRValueType > &type)
std::shared_ptr< IRValueType > & getRhsFromTempVarStack()
void retOp(bool returnWithNone=false)
void setDebugInfo(const IRDebugInfo &debugInfo)
yoi::vec< IR > & getIRArray()
void insert(const IR &ir)
yoi::wstr to_string(yoi::indexT indent=0)
yoi::vec< std::shared_ptr< IRValueType > > fieldTypes
std::map< yoi::wstr, yoi::indexT > fields
yoi::wstr to_string(yoi::indexT indent=0)
IRDataStructDefinition(const yoi::wstr &name, const yoi::vec< std::shared_ptr< IRValueType > > &fieldTypes, const std::map< yoi::wstr, yoi::indexT > &fields, yoi::indexT linkedModuleId)
yoi::indexT linkedModuleId
Builder & addValue(const yoi::wstr &valueName, yoi::indexT valueIndex)
std::shared_ptr< IREnumerationType > yield()
Builder & setName(const yoi::wstr &name)
UnderlyingType getUnderlyingType()
IREnumerationType(const yoi::wstr &name, const yoi::indexTable< yoi::wstr, yoi::indexT > &valueToIndexMap)
yoi::indexTable< yoi::wstr, yoi::indexT > valueToIndexMap
externType getExternType() const
enum yoi::IRExternEntry::externType type
ImportLibrary(const yoi::wstr &libraryPath)
void addForeignType(const yoi::wstr &foreignTypeName, const std::shared_ptr< IRValueType > &structType)
void addExportedFunction(const yoi::wstr &exportName, yoi::indexT moduleIndex, yoi::indexT functionIndex, const std::set< IRFunctionDefinition::FunctionAttrs > &attrs)
Add an exported function to the FFI table.
yoi::indexT addImportedFunction(const yoi::wstr &libraryName, const yoi::wstr &functionName, const std::shared_ptr< IRFunctionDefinition > &functionDefinition)
yoi::indexTable< yoi::wstr, std::tuple< yoi::indexT, yoi::indexT, std::set< IRFunctionDefinition::FunctionAttrs > > > exportedFunctionTable
yoi::indexTable< yoi::wstr, std::shared_ptr< IRValueType > > foreignTypeTable
yoi::indexTable< yoi::wstr, ImportLibrary > importedLibraries
yoi::vec< std::shared_ptr< IRValueType > > argumentTypes
std::shared_ptr< IRValueType > returnType
IRVariableTable variableTable
yoi::wstr to_string(yoi::indexT indent=0)
IRFunctionDefinition(const yoi::wstr &name, const yoi::vec< std::pair< yoi::wstr, std::shared_ptr< IRValueType > > > &argumentTypes, const std::shared_ptr< IRValueType > &returnType, const yoi::vec< std::shared_ptr< IRCodeBlock > > &codeBlock, const std::set< FunctionAttrs > &attrs, const IRDebugInfo &debugInfo)
bool hasAttribute(const FunctionAttrs &attr)
std::set< FunctionAttrs > attrs
IRVariableTable & getVariableTable()
std::shared_ptr< IRFunctionDefinition > templateDefinition
std::shared_ptr< IRFunctionTemplate > yield()
Builder & setTemplateDefinition(const std::shared_ptr< IRFunctionDefinition > &templateDefinition)
std::shared_ptr< IRFunctionDefinition > templateDefinition
yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > templateArguments
IRFunctionTemplate(const std::shared_ptr< IRFunctionDefinition > &templateDefinition, const yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > &templateArguments)
yoi::wstr to_string(yoi::indexT indent=0)
IRInterfaceImplementationDefinition(const yoi::wstr &name, std::tuple< IRValueType::valueType, yoi::indexT, yoi::indexT > implStructIndex, const std::pair< yoi::indexT, yoi::indexT > &implInterfaceIndex, const yoi::vec< std::shared_ptr< IRValueType > > &virtualMethods, const std::map< yoi::wstr, yoi::indexT > &virtualMethodIndexMap)
std::shared_ptr< IRInterfaceImplementationDefinition > templateDefinition
std::shared_ptr< IRInterfaceImplementationTemplate > yield()
Builder & setTemplateDefinition(const std::shared_ptr< IRInterfaceImplementationDefinition > &templateDefinition)
std::shared_ptr< IRInterfaceImplementationDefinition > templateDefinition
IRInterfaceImplementationTemplate(const std::shared_ptr< IRInterfaceImplementationDefinition > &templateDefinition, const yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > &templateArguments)
yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > templateArguments
yoi::wstr to_string(yoi::indexT indent=0)
IRInterfaceInstanceDefinition(const yoi::wstr &name, const std::map< yoi::wstr, yoi::vec< yoi::indexT > > &functionOverloadIndexies, const yoi::indexTable< yoi::wstr, std::shared_ptr< IRFunctionDefinition > > &methodMap)
std::shared_ptr< IRInterfaceInstanceTemplate > yield()
Builder & setTemplateDefinition(const std::shared_ptr< IRInterfaceInstanceDefinition > &templateDefinition)
std::shared_ptr< IRInterfaceInstanceDefinition > templateDefinition
yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > templateArguments
IRInterfaceInstanceTemplate(const std::shared_ptr< IRInterfaceInstanceDefinition > &templateDefinition, const yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > &templateArguments)
std::shared_ptr< IRInterfaceInstanceDefinition > templateDefinition
yoi::indexTable< yoi::wstr, std::shared_ptr< IRInterfaceInstanceDefinition > > interfaceTable
yoi::wstr to_string(yoi::indexT indent=0)
yoi::indexTable< yoi::wstr, std::shared_ptr< IRStructDefinition > > structTable
yoi::indexTable< yoi::wstr, std::shared_ptr< IRFunctionDefinition > > functionTable
yoi::indexTable< yoi::wstr, std::shared_ptr< IRInterfaceImplementationDefinition > > interfaceImplementationTable
enum yoi::IROperand::operandType type
std::shared_ptr< IRValueType > lvalueType
union yoi::IROperand::operandValue value
std::shared_ptr< IRValueType > getLvalueType()
yoi::wstr to_string() const
yoi::wstr & getStringLiteral(yoi::indexT index)
yoi::indexT addStringLiteral(const yoi::wstr &str)
yoi::vec< std::shared_ptr< IRValueType > > fieldTypes
IRStructDefinition(const yoi::wstr &name, const std::map< yoi::wstr, nameInfo > &nameIndexMap, const vec< std::shared_ptr< IRValueType > > &fieldTypes, const yoi::vec< yoi::wstr > &templateParamNames={}, const yoi::vec< std::shared_ptr< IRValueType > > &storedTemplateArgs={}, const std::map< yoi::wstr, yoi::structDefInnerPair * > &templateMethodDecls={}, const std::map< yoi::wstr, yoi::implInnerPair * > &templateMethodDefs={})
yoi::vec< std::shared_ptr< IRValueType > > storedTemplateArgs
yoi::wstr to_string(yoi::indexT indent=0)
const nameInfo & lookupName(const yoi::wstr &name)
Lookup a name in the struct definition, returning the index of the field or method and its type.
std::map< yoi::wstr, yoi::structDefInnerPair * > templateMethodDecls
std::map< yoi::wstr, nameInfo > nameIndexMap
std::map< yoi::wstr, yoi::implInnerPair * > templateMethodDefs
yoi::vec< yoi::wstr > templateParamNames
Builder & setTemplateDefinition(const std::shared_ptr< IRStructDefinition > &templateDefinition)
Builder & setTemplateMethod(const yoi::wstr &methodName, const std::shared_ptr< IRFunctionTemplate > &methodTemplate)
std::shared_ptr< IRStructTemplate > yield()
IRStructTemplate(const std::shared_ptr< IRStructDefinition > &templateDefinition, const yoi::indexTable< yoi::wstr, std::shared_ptr< IRFunctionTemplate > > &templateMethods, const yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > &templateArguments)
yoi::indexTable< yoi::wstr, Argument > templateArguments
IRTemplateBuilder & addTemplateArgument(const yoi::wstr &templateName, const std::shared_ptr< IRValueType > &templateType, const yoi::vec< externModuleAccessExpression * > &satisfyConditions={})
IRValueType getNormalizedForeignBasicType()
IRValueType getArrayType(const yoi::vec< yoi::indexT > &dimensions)
IRValueType getBasicRawType() const
bool isForeignBasicType() const
yoi::indexT calculateDimensionSize() const
IRValueType & removeAttribute(ValueAttr attr)
IRValueType getElementType()
enum yoi::IRValueType::valueType type
bool isDynamicArrayType() const
IRValueType getBasicObjectType() const
IRValueType getDynamicArrayType()
bool hasAttribute(ValueAttr attr) const
yoi::wstr to_string(bool showAttributes=false) const
std::set< ValueAttr > attributes
yoi::vec< yoi::indexT > dimensions
IRValueType & addAttribute(ValueAttr attr)
bool operator==(const yoi::IRValueType &rhs) const
bool isBasicRawType() const
yoi::indexT typeAffiliateModule
std::shared_ptr< IRValueType > operator[](const yoi::wstr &name)
void set(yoi::indexT index, const std::shared_ptr< IRValueType > &type)
yoi::indexT put(const yoi::wstr &name, const std::shared_ptr< IRValueType > &type)
std::shared_ptr< IRValueType > get(yoi::indexT index)
std::map< yoi::indexT, yoi::wstr > & getReversedVariableNameMap()
yoi::wstr to_string(yoi::indexT indent=0)
yoi::indexT createScope()
yoi::indexT lookup(const yoi::wstr &name)
Look up a variable by name in the current scope. If the variable is not found in the current scope,...
yoi::vec< std::shared_ptr< IRValueType > > & getVariables()
yoi::indexT scopeIndex(yoi::indexT varIndex)
@ typeid_object_non_stack
@ new_dynamic_array_short
@ new_dynamic_array_interface
@ new_dynamic_array_struct
@ new_dynamic_array_unsigned
@ construct_interface_impl
yoi::vec< IROperand > operands
enum yoi::IR::Opcode opcode
yoi::wstr to_string() const
yoi::indexT put_create(const A &a, const B &b)
constexpr auto enum_name() noexcept -> detail::enable_if_t< decltype(V), string_view >
std::string wstring2string(const std::wstring &v)
std::shared_ptr< T > managedPtr(const T &v)
std::wstring string2wstring(const std::string &v)
void yoi_assert(bool condition, yoi::indexT line, yoi::indexT col, const std::string &msg)
Asserts a condition that would be true and throws a runtime_error if it is false.
void set_current_file_path(const std::wstring &path)
void panic(yoi::indexT line, yoi::indexT col, const std::string &msg)
Builder & addSearchPath(const yoi::wstr &searchPath)
yoi::vec< yoi::wstr > additionalLinkingFiles
Builder & setImmediatelyClearupCache(bool immediatelyClearupCache)
Builder & setBuildType(BuildType buildType)
Builder & setBuildCachePath(const yoi::wstr &buildCachePath)
std::shared_ptr< IRBuildConfig > yield()
Builder & setAdditionalLinkingFiles(const yoi::vec< yoi::wstr > &additionalLinkingFiles)
Builder & setPreserveIntermediateFiles(bool preserveIntermediateFiles)
Builder & setBuildMode(BuildMode buildMode)
Builder & setBuildPlatform(const yoi::wstr &buildPlatform)
Builder & setBuildArch(const yoi::wstr &buildArch)
Builder & setSearchPaths(const yoi::vec< yoi::wstr > &searchPaths)
Builder & setMarco(const yoi::wstr &name, const yoi::wstr &value)
Builder & setUseObjectLinker(UseObjectLinker useObjectLinker)
enum yoi::IRBuildConfig::BuildMode buildMode
bool preserveIntermediateFiles
yoi::vec< yoi::wstr > additionalLinkingFiles
std::map< yoi::wstr, yoi::wstr > marcos
enum yoi::IRBuildConfig::BuildType buildType
enum yoi::IRBuildConfig::UseObjectLinker useObjectLinker
yoi::vec< yoi::wstr > searchPaths
bool immediatelyClearupCache
Builder & addField(const yoi::wstr &fieldName, const std::shared_ptr< IRValueType > &fieldType)
std::shared_ptr< IRDataStructDefinition > yield()
Builder & setLinkedModuleId(yoi::indexT linkedModuleId)
Builder & setName(const yoi::wstr &name)
Builder & setDebugInfo(const IRDebugInfo &debugInfo)
std::shared_ptr< IRFunctionDefinition > yield()
Builder & setName(const yoi::wstr &name)
Builder & addArgument(const yoi::wstr &argumentName, const std::shared_ptr< IRValueType > &argumentType)
Builder & setReturnType(const std::shared_ptr< IRValueType > &returnType)
Builder & addAttr(FunctionAttrs attr)
std::shared_ptr< IRInterfaceImplementationDefinition > yield()
Builder & setImplStructIndex(std::tuple< IRValueType::valueType, yoi::indexT, yoi::indexT > implStructIndex)
Builder & setImplInterfaceIndex(const std::pair< yoi::indexT, yoi::indexT > &implInterfaceIndex)
Builder & addVirtualMethod(const yoi::wstr &methodName, const std::shared_ptr< IRValueType > &methodType)
Builder & setName(const yoi::wstr &name)
std::shared_ptr< IRInterfaceInstanceDefinition > yield()
Builder & setName(const yoi::wstr &name)
Builder & addMethod(const yoi::wstr &methodNameOri, const yoi::wstr &methodName, const std::shared_ptr< IRFunctionDefinition > &methodSignature)
std::shared_ptr< IRStructDefinition > yield()
Builder & setStoredTemplateArgs(const yoi::vec< yoi::wstr > ¶mNames, const yoi::vec< std::shared_ptr< IRValueType > > &args)
Builder & addMethod(const yoi::wstr &methodName, yoi::indexT index)
Builder & addTemplateMethodDef(const yoi::wstr &name, yoi::implInnerPair *def)
Builder & addField(const yoi::wstr &fieldName, const std::shared_ptr< IRValueType > &fieldType)
Builder & addTemplateMethodDecl(const yoi::wstr &name, yoi::structDefInnerPair *decl)
Builder & setName(const yoi::wstr &name)
Argument(const std::shared_ptr< IRValueType > &templateType, const yoi::vec< externModuleAccessExpression * > &satisfyConditions)
yoi::indexT stringLiteralIndex
yoi::indexT codeBlockIndex