17 class structDefInnerPair;
29 std::map<yoi::wstr, yoi::wstr>
marcos;
42 std::map<yoi::wstr, yoi::wstr>
marcos;
44 (std::filesystem::temp_directory_path() /
45 (L
"zyy-" + std::to_wstring(std::chrono::system_clock::now().time_since_epoch().count()))).wstring()};
74 std::shared_ptr<IRBuildConfig>
yield();
88 return *std::any_cast<T>(&
metadata.at(key));
92 return *std::any_cast<T>(&
metadata.at(key));
381 std::shared_ptr<IRValueType>
type;
405 std::shared_ptr<IREnumerationType>
yield();
446 void set(
yoi::indexT index,
const std::shared_ptr<IRValueType> &type);
491 const std::shared_ptr<IRValueType> &
returnType,
493 const std::set<FunctionAttrs> &
attrs,
521 std::shared_ptr<IRFunctionDefinition>
yield();
542 const std::shared_ptr<IRValueType> &templateType,
562 std::shared_ptr<IRFunctionTemplate>
yield();
577 const std::map<yoi::wstr, yoi::indexT> &
fields,
596 std::shared_ptr<IRDataStructDefinition>
yield();
661 std::shared_ptr<IRStructDefinition>
yield();
686 std::shared_ptr<IRStructTemplate>
yield();
701 std::tuple<IRValueType::valueType, yoi::indexT, yoi::indexT>
implStructIndex,
726 std::shared_ptr<IRInterfaceImplementationDefinition>
yield();
755 addMethod(
const yoi::wstr &methodNameOri,
const yoi::wstr &methodName,
const std::shared_ptr<IRFunctionDefinition> &methodSignature);
757 std::shared_ptr<IRInterfaceInstanceDefinition>
yield();
774 std::shared_ptr<IRInterfaceInstanceTemplate>
yield();
795 std::shared_ptr<IRInterfaceImplementationTemplate>
yield();
842 class IRModule : std::enable_shared_from_this<IRModule> {
866 std::map<yoi::wstr, std::shared_ptr<IRConcept>>
concepts;
917 void pushTempVar(
const std::shared_ptr<IRValueType> &type);
948 void basicCast(
const std::shared_ptr<IRValueType> &valType,
yoi::indexT insertionPoint,
bool lhs =
false);
985 const std::shared_ptr<IRValueType> &returnType,
986 bool externalInvocation =
false,
1000 const std::shared_ptr<IRValueType> &returnType,
1001 bool externalInvocation =
false,
1006 const std::shared_ptr<IRValueType> &returnType,
1008 bool externalInvocation =
false,
1014 const std::shared_ptr<IRValueType> &returnType,
1015 bool externalInvocation =
false,
1020 void retOp(
bool returnWithNone =
false);
1032 bool isExternal =
false,
1043 void typeIdOp(
const std::shared_ptr<IRValueType> &type);
1047 void dynCastOp(
const std::shared_ptr<IRValueType> &type);
1075 void yieldOp(
bool yieldNone =
false);
1114 const std::shared_ptr<IRFunctionDefinition> &functionDefinition);
1130 const std::set<IRFunctionDefinition::FunctionAttrs> &attrs);
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
IRValueType getLocalVar(yoi::indexT index)
std::shared_ptr< IRValueType > & getLhsFromTempVarStack()
void newDataStructOp(yoi::indexT structIndex, bool isExternal=false, yoi::indexT moduleIndex=-1)
const IRDebugInfo & getCurrentDebugInfo()
yoi::vec< std::shared_ptr< yoi::IRValueType > > tempStateTempVarStack
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 newInterfaceOp(yoi::indexT interfaceIndex, bool isExternal=false, yoi::indexT moduleIndex=-1)
void bindElementsOp(yoi::indexT extractElementCount, ExtractType extractType)
void insert(const IR &ir, yoi::indexT insertionPoint=0xffffffff)
yoi::vec< IR > tempStateCodeBlock
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()
yoi::vec< LoopContext > loopContext
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::indexT affiliateModule
yoi::vec< std::shared_ptr< IRValueType > > fieldTypes
std::map< yoi::wstr, yoi::indexT > fields
yoi::wstr to_string(yoi::indexT indent=0)
yoi::indexT linkedModuleId
Builder & addValue(const yoi::wstr &valueName, yoi::indexT valueIndex)
std::shared_ptr< IREnumerationType > yield()
yoi::indexTable< yoi::wstr, yoi::indexT > valueToIndexMap
Builder & setName(const yoi::wstr &name)
UnderlyingType getUnderlyingType()
yoi::indexTable< yoi::wstr, yoi::indexT > valueToIndexMap
externType getExternType() const
yoi::indexT affiliateModule
enum yoi::IRExternEntry::externType type
yoi::indexTable< yoi::wstr, std::shared_ptr< IRFunctionDefinition > > importedFunctionTable
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)
yoi::vec< std::shared_ptr< IRCodeBlock > > codeBlock
@ NoRawAndNullOptimization
yoi::indexT linkedModuleId
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
yoi::wstr to_string(yoi::indexT indent=0)
std::pair< yoi::indexT, yoi::indexT > implInterfaceIndex
std::map< yoi::wstr, yoi::indexT > virtualMethodIndexMap
yoi::indexT linkedModuleId
std::tuple< IRValueType::valueType, yoi::indexT, yoi::indexT > implStructIndex
yoi::vec< std::shared_ptr< IRValueType > > virtualMethods
std::shared_ptr< IRInterfaceImplementationDefinition > templateDefinition
yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > templateArguments
std::shared_ptr< IRInterfaceImplementationTemplate > yield()
Builder & setTemplateDefinition(const std::shared_ptr< IRInterfaceImplementationDefinition > &templateDefinition)
std::shared_ptr< IRInterfaceImplementationDefinition > templateDefinition
yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > templateArguments
std::map< yoi::wstr, yoi::vec< yoi::indexT > > functionOverloadIndexies
yoi::vec< std::tuple< IRValueType::valueType, yoi::indexT, yoi::indexT > > implementations
yoi::wstr to_string(yoi::indexT indent=0)
yoi::indexTable< yoi::wstr, std::shared_ptr< IRFunctionDefinition > > methodMap
yoi::indexT linkedModuleId
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
std::shared_ptr< IRInterfaceInstanceDefinition > templateDefinition
std::map< yoi::wstr, yoi::implStmt * > templateImplAsts
std::map< yoi::wstr, yoi::vec< yoi::indexT > > functionOverloadIndexies
std::set< yoi::indexT > dependentModules
std::map< yoi::wstr, yoi::structDefStmt * > structTemplateAsts
yoi::indexTable< yoi::wstr, std::shared_ptr< IRInterfaceInstanceDefinition > > interfaceTable
std::map< yoi::wstr, std::shared_ptr< IRConcept > > concepts
std::map< yoi::wstr, yoi::vec< yoi::implStmt * > > templateInterfaceImplAsts
yoi::indexTable< yoi::wstr, std::shared_ptr< IRValueType > > globalVariables
yoi::wstr to_string(yoi::indexT indent=0)
std::map< yoi::wstr, yoi::interfaceDefStmt * > templateInterfaceAsts
yoi::indexTable< yoi::wstr, std::shared_ptr< IRStructDefinition > > structTable
IRStringLiteralPool stringLiteralPool
std::map< yoi::wstr, yoi::funcDefStmt * > funcTemplateAsts
yoi::indexTable< yoi::wstr, std::shared_ptr< IRFunctionDefinition > > functionTable
yoi::indexTable< yoi::wstr, std::shared_ptr< IRInterfaceImplementationDefinition > > interfaceImplementationTable
std::map< yoi::wstr, IRValueType > typeAliases
std::map< yoi::wstr, yoi::typeAliasStmt * > typeAliasTemplateAsts
std::map< yoi::wstr, yoi::indexT > moduleImports
yoi::indexTable< yoi::wstr, std::shared_ptr< IRDataStructDefinition > > dataStructTable
yoi::indexTable< yoi::wstr, std::shared_ptr< IREnumerationType > > enumerationTable
yoi::indexTable< yoi::wstr, std::shared_ptr< IRExternEntry > > externTable
std::shared_ptr< IRModule > compiledModule
enum yoi::IROperand::operandType type
std::shared_ptr< IRValueType > lvalueType
static enum_range< operandType > IROperandTypeEnumRange
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::indexPool< yoi::wstr > pool
yoi::vec< std::shared_ptr< IRValueType > > fieldTypes
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::indexT linkedModuleId
yoi::vec< yoi::wstr > templateParamNames
Builder & setTemplateDefinition(const std::shared_ptr< IRStructDefinition > &templateDefinition)
std::shared_ptr< IRStructDefinition > templateDefinition
Builder & setTemplateMethod(const yoi::wstr &methodName, const std::shared_ptr< IRFunctionTemplate > &methodTemplate)
std::shared_ptr< IRStructTemplate > yield()
yoi::indexTable< yoi::wstr, std::shared_ptr< IRFunctionTemplate > > templateMethods
std::shared_ptr< IRStructDefinition > templateDefinition
yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > templateArguments
yoi::indexTable< yoi::wstr, std::shared_ptr< IRFunctionTemplate > > templateMethods
IRTemplateBuilder()=default
yoi::indexTable< yoi::wstr, Argument > templateArguments
IRTemplateBuilder & addTemplateArgument(const yoi::wstr &templateName, const std::shared_ptr< IRValueType > &templateType, const yoi::vec< externModuleAccessExpression * > &satisfyConditions={})
std::shared_ptr< IRValueType > type
yoi::vec< IRValueType > bracedTypes
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
@ PermanentInCurrentScope
IRValueType & addAttribute(ValueAttr attr)
bool operator==(const yoi::IRValueType &rhs) const
bool isBasicRawType() const
yoi::indexT typeAffiliateModule
yoi::vec< std::map< yoi::wstr, yoi::indexT > > variableNameIndexMap
IRVariableTable()=default
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 > > variables
std::map< yoi::indexT, yoi::wstr > reversedVariableNameMap
std::map< yoi::indexT, yoi::indexT > variableScopeMap
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
static enum_range< Opcode > IROpCodeEnumRange
yoi::vec< IROperand > operands
enum yoi::IR::Opcode opcode
yoi::wstr to_string() const
Builder & addSearchPath(const yoi::wstr &searchPath)
bool preserveIntermediateFiles
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)
UseObjectLinker useObjectLinker
std::map< yoi::wstr, yoi::wstr > marcos
yoi::vec< yoi::wstr > searchPaths
Builder & setSearchPaths(const yoi::vec< yoi::wstr > &searchPaths)
bool immediatelyClearupCache
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
yoi::indexT continueTarget
yoi::vec< std::shared_ptr< IRValueType > > fieldTypes
std::map< yoi::wstr, yoi::indexT > fields
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)
yoi::indexT linkedModuleId
std::shared_ptr< IRValueType > returnType
Builder & setDebugInfo(const IRDebugInfo &debugInfo)
yoi::vec< std::pair< yoi::wstr, std::shared_ptr< IRValueType > > > argumentTypes
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::set< FunctionAttrs > attrs
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)
std::pair< yoi::indexT, yoi::indexT > implInterfaceIndex
std::map< yoi::wstr, yoi::indexT > virtualMethodIndexMap
Builder & setName(const yoi::wstr &name)
std::tuple< IRValueType::valueType, yoi::indexT, yoi::indexT > implStructIndex
yoi::vec< std::shared_ptr< IRValueType > > virtualMethods
std::map< yoi::wstr, yoi::vec< yoi::indexT > > functionOverloadIndexies
std::shared_ptr< IRInterfaceInstanceDefinition > yield()
yoi::indexTable< yoi::wstr, std::shared_ptr< IRFunctionDefinition > > methodMap
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)
yoi::vec< std::shared_ptr< IRValueType > > fieldTypes
Builder & addMethod(const yoi::wstr &methodName, yoi::indexT index)
yoi::vec< std::shared_ptr< IRValueType > > storedTemplateArgs
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)
std::map< yoi::wstr, yoi::structDefInnerPair * > templateMethodDecls
std::map< yoi::wstr, nameInfo > nameIndexMap
std::map< yoi::wstr, yoi::implInnerPair * > templateMethodDefs
Builder & setName(const yoi::wstr &name)
yoi::vec< yoi::wstr > templateParamNames
enum yoi::IRStructDefinition::nameInfo::nameType type
std::shared_ptr< IRValueType > templateType
yoi::vec< externModuleAccessExpression * > satisfyCondition
yoi::indexT stringLiteralIndex
yoi::indexT codeBlockIndex