5#ifndef HOSHI_LANG_VISITOR_H
6#define HOSHI_LANG_VISITOR_H
29 std::shared_ptr<IRFunctionDefinition>
function =
nullptr;
47 std::shared_ptr<yoi::IRModule>
visit();
90 const yoi::vec<std::shared_ptr<IRValueType>> &concreteTemplateArgs,
97 const yoi::vec<std::shared_ptr<IRValueType>> &concreteTemplateArgs,
101 const std::shared_ptr<IRStructDefinition> &specializedStruct,
104 const yoi::vec<std::shared_ptr<IRValueType>> &concreteTemplateArgs,
114 const yoi::vec<std::shared_ptr<IRValueType>> &methodTemplateArgs,
119 const yoi::vec<std::shared_ptr<IRValueType>> &specializedArgTypes);
122 const yoi::vec<std::shared_ptr<IRValueType>> &concreteTemplateArgs,
126 const std::shared_ptr<IRValueType> &concreteStructType,
128 const yoi::vec<std::shared_ptr<IRValueType>> &concreteTemplateArgs,
133 void tryCastTo(
const std::shared_ptr<IRValueType> &toType);
135 bool canCastTo(
const std::shared_ptr<IRValueType> &fromType,
const std::shared_ptr<IRValueType> &toType);
229 std::pair<std::pair<yoi::indexT, yoi::indexT>, std::shared_ptr<IRInterfaceInstanceDefinition>>
294 const yoi::vec<std::shared_ptr<IRValueType>> &argTypes,
296 const std::shared_ptr<IRInterfaceInstanceDefinition> &interfaceContext);
307 const yoi::vec<std::shared_ptr<IRValueType>> &argTypes,
309 const std::shared_ptr<IRStructDefinition> &structContext =
nullptr);
317 const std::shared_ptr<IRValueType> &structContext =
nullptr,
318 bool noThisCall =
false,
355 const std::shared_ptr<IRValueType> &returnType);
368 const std::shared_ptr<IRStructDefinition> &lambda,
yoi::indexT lambdaStructIndex,
yoi::indexT moduleIndex);
380 std::pair<yoi::indexT, std::pair<yoi::indexT, yoi::indexT>>
yoi::indexT handleBinaryOperatorOverload(const yoi::wstr &overloadName, T *rhsAST)
Generates a call to certain operator overload function when left hand side or right hand side owns a ...
yoi::indexT visitExtern(yoi::identifier *identifier, yoi::indexT targetModule, bool isStoreOp=false)
yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > getTemplateArgs(const yoi::defTemplateArg &templateArgs)
void emitBasicCastTo(const std::shared_ptr< IRValueType > &toType)
yoi::wstr getInterfaceNameStr(const std::pair< yoi::indexT, yoi::indexT > &interfaceSrc)
yoi::wstr getTypeSpecUniqueNameStr(const std::shared_ptr< IRValueType > &type)
yoi::indexT specializeStructMethodTemplate(const std::shared_ptr< IRStructDefinition > &structDef, yoi::structDefInnerPair *decl, yoi::implInnerPair *def, const yoi::wstr &baseMethodName, const yoi::vec< std::shared_ptr< IRValueType > > &methodTemplateArgs, yoi::indexT moduleIndex)
std::shared_ptr< IRValueType > mapEnumTypeToBasicType(yoi::indexT targetModule, yoi::indexT targetEnumType)
bool handleInvocationExtern(const yoi::wstr &baseName, yoi::invocationArguments *args, yoi::indexT targetModule, const std::shared_ptr< IRValueType > &structContext=nullptr, bool noThisCall=false, yoi::templateArg *templateArgs=nullptr)
Orchestrates an external function/method invocation IR generation.
std::pair< yoi::indexT, std::pair< yoi::indexT, yoi::indexT > > createCallableImplementationForFunction(const std::shared_ptr< IRFunctionDefinition > &func, yoi::indexT funcIndex, yoi::indexT moduleIndex, bool hasThis)
Create a Callable Implementation For Function object also create a unnamed struct for the function an...
yoi::wstr getFuncUniqueNameStr(const std::vector< std::shared_ptr< IRValueType > > &argumentTypes, bool whetherIgnoreFirstParam=false)
yoi::indexT handleUnaryOperatorOverload(const yoi::wstr &overloadName)
Handles unary operator overload function when the operand owns a appropriate overloaded operator meth...
void specializeStructMethodDefinition(IRTemplateBuilder &structTemplate, const std::shared_ptr< IRStructDefinition > &specializedStruct, yoi::implInnerPair *methodAstNode, const yoi::wstr &specializedStructName, const yoi::vec< std::shared_ptr< IRValueType > > &concreteTemplateArgs, yoi::indexT moduleIndex)
std::shared_ptr< yoi::IRModule > visit()
bool handleSubscript(yoi::vec< yoi::subscript * >::iterator &it, yoi::vec< yoi::subscript * >::iterator end, bool isStoreOp, bool isLastTerm)
Handle subscript.
std::pair< yoi::indexT, yoi::wstr > specializeStructMethodDeclaration(IRTemplateBuilder &structTemplate, yoi::structDefInnerPair *methodAstNode, const yoi::wstr &specializedStructName, const yoi::vec< std::shared_ptr< IRValueType > > &concreteTemplateArgs, yoi::indexT moduleIndex)
std::stack< std::pair< std::shared_ptr< yoi::moduleContext >, yoi::indexT > > moduleContextStack
visitor::OverloadResult resolveOverloadInterface(const yoi::wstr &baseName, const yoi::vec< std::shared_ptr< IRValueType > > &argTypes, yoi::indexT targetModule, const std::shared_ptr< IRInterfaceInstanceDefinition > &interfaceContext)
Resolves an function overload within the interface context.
yoi::indexT isModuleName(identifierWithTemplateArg *it, yoi::indexT currentModule) const
check if the subscript expression is a module name
static yoi::wstr getInterfaceImplName(const std::pair< yoi::indexT, yoi::indexT > &interfaceSrc, const std::shared_ptr< IRValueType > &typeSrc)
std::pair< yoi::indexT, std::pair< yoi::indexT, yoi::indexT > > createCallableImplementationForLambda(const std::shared_ptr< IRStructDefinition > &lambda, yoi::indexT lambdaStructIndex, yoi::indexT moduleIndex)
Create a Callable Implementation For Lambda object also create a struct for the lambda and return its...
yoi::indexT specializeStructTemplate(const yoi::wstr &templateName, const yoi::vec< std::shared_ptr< IRValueType > > &concreteTemplateArgs, yoi::implStmt *pureTemplateImplAst, yoi::indexT moduleIndex)
yoi::indexT specializeInterfaceTemplate(const yoi::wstr &templateName, const yoi::vec< std::shared_ptr< IRValueType > > &concreteTemplateArgs, yoi::indexT moduleIndex)
yoi::indexT createLambdaUnnamedStruct(yoi::lambdaExpr *lambdaExpr)
Create a Lambda Unnamed Struct object.
std::pair< std::shared_ptr< IRConcept >, templateArg * > parseConceptName(yoi::externModuleAccessExpression *conceptName)
yoi::wstr parseIdentifierWithTemplateArg(yoi::identifierWithTemplateArg *identifierWithTemplateArg)
void emitBasicCastInBasicArithOpByLhsAndRhs(yoi::indexT lhs, yoi::indexT rhs)
void pushModuleContext(yoi::indexT moduleIndex)
IRValueType parseTypeSpecExtern(yoi::identifier *identifier, yoi::indexT targetModule)
OverloadResult resolveOverloadExtern(const yoi::wstr &baseName, const yoi::vec< std::shared_ptr< IRValueType > > &argTypes, yoi::indexT targetModule, const std::shared_ptr< IRStructDefinition > &structContext=nullptr)
Resolves an external function overload within a target module.
yoi::wstr getMangledTemplateName(const yoi::wstr &baseName, const yoi::vec< std::shared_ptr< IRValueType > > &templateArgs)
bool checkMarcoSatisfaction(yoi::marcoDescriptor *desc)
Check whether the marco satisfies the condition.
std::shared_ptr< IRValueType > getIncompleteType(const yoi::wstr &typeName) const
std::set< IRFunctionDefinition::FunctionAttrs > getFunctionAttributes(const yoi::vec< lexer::token > &attrs)
void evaluateConstraint(yoi::conceptStmt *stmt, const IRDebugInfo ¤tDebugInfo)
std::pair< std::pair< yoi::indexT, yoi::indexT >, std::shared_ptr< IRInterfaceInstanceDefinition > > parseInterfaceName(yoi::externModuleAccessExpression *structDef)
yoi::indexT specializeFunctionTemplate(yoi::funcDefStmt *astNode, const yoi::vec< std::shared_ptr< IRValueType > > &templateArgs, yoi::indexT moduleIndex)
void createCallableInstanceForFunction(yoi::indexT implIndex, std::pair< yoi::indexT, yoi::indexT > callableInterfaceIndex, yoi::indexT moduleIndex, bool hasThis)
Create a Callable Instance For Function object.
void setupTemporaryConceptEvaluationEnvironment(yoi::indexT moduleIndex, const yoi::wstr &conceptName, const std::vector< std::shared_ptr< IRValueType > > &args)
yoi::vec< yoi::wstr > extractTemplateParamsFromTypeArgs(yoi::templateArg *templateArgs)
bool canCastTo(const std::shared_ptr< IRValueType > &fromType, const std::shared_ptr< IRValueType > &toType)
void specializeInterfaceImplementation(yoi::implStmt *implAst, const std::shared_ptr< IRValueType > &concreteStructType, const yoi::wstr &specializedStructName, const yoi::vec< std::shared_ptr< IRValueType > > &concreteTemplateArgs, yoi::indexT targetModule)
bool isVisitingGlobalScope() const
std::shared_ptr< yoi::moduleContext > moduleContext
yoi::indexT createCallableInterface(const yoi::vec< std::shared_ptr< IRValueType > > ¶meterTypes, const std::shared_ptr< IRValueType > &returnType)
Create a Callable Interface object and return its index in the module's interface table.
yoi::wstr getSpecializedMangledMethodName(yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > &templateArgs, const yoi::wstr &baseMethodName, const yoi::vec< std::shared_ptr< IRValueType > > &specializedArgTypes)
yoi::vec< std::shared_ptr< IRValueType > > evaluateArguments(yoi::invocationArguments *args)
Visits a list of argument expressions and returns their types.
yoi::vec< std::shared_ptr< IRValueType > > parseTemplateArgs(const yoi::templateArg &templateArgs)
yoi::IRExternEntry getExternEntry(yoi::indexT moduleIndex, const yoi::wstr &identifier) const
search and return extern entry by identifier in target module
void tryCastTo(const std::shared_ptr< IRValueType > &toType)
yoi::indexT currentModuleIndex
void constructDataStruct(yoi::indexT datastructIndex, yoi::indexT moduleIndex, yoi::invocationArguments *args)
Construct data struct and initialize with given parameters.
std::shared_ptr< yoi::IRModule > irModule
yoi::indexT generateNullInterfaceImplementation(const std::shared_ptr< IRValueType > &structType)
void ejectTemporaryConceptEvaluationEnvironment()
void checkConceptSatisfaction(yoi::externModuleAccessExpression *stmt, const yoi::wstr ¶mName, const std::shared_ptr< IRValueType > &args)
IRValueType parseTypeSpec(yoi::identifier *identifier)
std::shared_ptr< IRValueType > getGeneratorContext(const yoi::wstr &funcName, const std::shared_ptr< IRValueType > &yieldType)
Get or fetch generator context type for specific function.
yoi::indexT functionIndex
std::shared_ptr< IRValueType > variadicElementType
yoi::indexT fixedArgCount
std::shared_ptr< IRFunctionDefinition > function