hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
visitor Class Reference

#include <visitor.h>

Classes

struct  OverloadResult
 

Public Member Functions

 visitor (const std::shared_ptr< yoi::moduleContext > &moduleContext, const std::shared_ptr< yoi::IRModule > &irModule, yoi::indexT moduleIndex)
 
std::shared_ptr< yoi::IRModulevisit ()
 
yoi::indexT isModuleName (identifierWithTemplateArg *it, yoi::indexT currentModule) const
 check if the subscript expression is a module name
 
yoi::indexT isModuleName (identifier *it, yoi::indexT currentModule) const
 
yoi::IRExternEntry getExternEntry (yoi::indexT moduleIndex, const yoi::wstr &identifier) const
 search and return extern entry by identifier in target module
 
bool isVisitingGlobalScope () const
 
void emitBasicCastInBasicArithOpByLhsAndRhs (yoi::indexT lhs, yoi::indexT rhs)
 
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::wstr getFuncUniqueNameStr (const std::vector< std::shared_ptr< IRValueType > > &argumentTypes, bool whetherIgnoreFirstParam=false)
 
std::shared_ptr< IRValueTypegetIncompleteType (const yoi::wstr &typeName) const
 
yoi::indexTable< yoi::wstr, IRTemplateBuilder::ArgumentgetTemplateArgs (const yoi::defTemplateArg &templateArgs)
 
yoi::vec< std::shared_ptr< IRValueType > > parseTemplateArgs (const yoi::templateArg &templateArgs)
 
yoi::indexT specializeFunctionTemplate (yoi::funcDefStmt *astNode, const yoi::vec< std::shared_ptr< IRValueType > > &templateArgs, yoi::indexT moduleIndex)
 
yoi::indexT specializeStructTemplate (const yoi::wstr &templateName, const yoi::vec< std::shared_ptr< IRValueType > > &concreteTemplateArgs, yoi::implStmt *pureTemplateImplAst, yoi::indexT moduleIndex)
 
std::pair< yoi::indexT, yoi::wstrspecializeStructMethodDeclaration (IRTemplateBuilder &structTemplate, yoi::structDefInnerPair *methodAstNode, const yoi::wstr &specializedStructName, const yoi::vec< std::shared_ptr< IRValueType > > &concreteTemplateArgs, yoi::indexT moduleIndex)
 
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)
 
yoi::vec< yoi::wstrextractTemplateParamsFromTypeArgs (yoi::templateArg *templateArgs)
 
yoi::vec< yoi::wstrextractTemplateParamsFromTypeArgs (yoi::defTemplateArg *templateArgs)
 
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)
 
yoi::wstr getSpecializedMangledMethodName (yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > &templateArgs, const yoi::wstr &baseMethodName, const yoi::vec< std::shared_ptr< IRValueType > > &specializedArgTypes)
 
yoi::indexT specializeInterfaceTemplate (const yoi::wstr &templateName, const yoi::vec< std::shared_ptr< IRValueType > > &concreteTemplateArgs, yoi::indexT moduleIndex)
 
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)
 
yoi::wstr getMangledTemplateName (const yoi::wstr &baseName, const yoi::vec< std::shared_ptr< IRValueType > > &templateArgs)
 
void tryCastTo (const std::shared_ptr< IRValueType > &toType)
 
bool canCastTo (const std::shared_ptr< IRValueType > &fromType, const std::shared_ptr< IRValueType > &toType)
 
std::set< IRFunctionDefinition::FunctionAttrsgetFunctionAttributes (const yoi::vec< lexer::token > &attrs)
 
yoi::indexT generateNullInterfaceImplementation (const std::shared_ptr< IRValueType > &structType)
 
void visit (yoi::hoshiModule *module)
 
yoi::indexT visit (yoi::basicLiterals *basicLiterals)
 
yoi::indexT visit (yoi::bracedInitalizerList *bracedInitalizerList)
 
yoi::indexT visit (yoi::identifier *identifier, bool isStoreOp=false)
 
yoi::indexT visitExtern (yoi::identifier *identifier, yoi::indexT targetModule, bool isStoreOp=false)
 
yoi::indexT visit (yoi::identifierWithTemplateArg *identifierWithTemplateArg, bool isStoreOp=false)
 
yoi::indexT visitExtern (yoi::identifierWithTemplateArg *identifierWithTemplateArg, yoi::indexT targetModule, bool isStoreOp=false)
 
yoi::indexT visit (yoi::subscriptExpr *subscriptExpr, bool isStoreOp=false)
 
yoi::indexT visitExtern (yoi::subscriptExpr *subscriptExpr, yoi::indexT targetModule, bool isStoreOp=false)
 
yoi::indexT visit (yoi::memberExpr *memberExpr, bool isStoreOp=false)
 
yoi::indexT visit (yoi::primary *primary, bool isStoreOp=false)
 
yoi::indexT visit (yoi::abstractExpr *abstractExpr, bool isStoreOp=false)
 
yoi::indexT visit (yoi::uniqueExpr *uniqueExpr, bool isStoreOp=false)
 
yoi::indexT visit (yoi::leftExpr *leftExpr)
 
yoi::indexT visit (yoi::mulExpr *mulExpr)
 
yoi::indexT visit (yoi::addExpr *addExpr)
 
yoi::indexT visit (yoi::shiftExpr *shiftExpr)
 
yoi::indexT visit (yoi::relationalExpr *relationalExpr)
 
yoi::indexT visit (yoi::equalityExpr *equalityExpr)
 
yoi::indexT visit (yoi::andExpr *andExpr)
 
yoi::indexT visit (yoi::exclusiveExpr *exclusiveExpr)
 
yoi::indexT visit (yoi::inclusiveExpr *inclusiveExpr)
 
yoi::indexT visit (yoi::logicalAndExpr *logicalAndExpr)
 
yoi::indexT visit (yoi::logicalOrExpr *logicalOrExpr)
 
yoi::indexT visit (yoi::rExpr *rExpr)
 
yoi::indexT visit (yoi::typeIdExpression *typeIdExpression)
 
yoi::indexT visit (yoi::dynCastExpression *dynCastExpression)
 
yoi::indexT visit (yoi::newExpression *newExpression)
 
void visit (yoi::codeBlock *codeBlock, bool notEmitNewBlockInstruction=false)
 
yoi::indexT visit (yoi::useStmt *useStmt)
 
IRValueType parseTypeSpec (yoi::identifier *identifier)
 
IRValueType parseTypeSpec (yoi::identifierWithTemplateArg *identifierWithTemplateArg)
 
IRValueType parseTypeSpec (yoi::subscriptExpr *subscriptExpr)
 
IRValueType parseTypeSpecExtern (yoi::identifier *identifier, yoi::indexT targetModule)
 
IRValueType parseTypeSpecExtern (yoi::identifierWithTemplateArg *identifierWithTemplateArg, yoi::indexT targetModule)
 
IRValueType parseTypeSpecExtern (yoi::subscriptExpr *subscriptExpr, yoi::indexT targetModule)
 
IRValueType parseTypeSpec (yoi::funcTypeSpec *typeSpec)
 
IRValueType parseTypeSpec (yoi::typeSpec *typeSpec)
 
IRValueType parseTypeSpec (yoi::externModuleAccessExpression *emaExpression)
 
yoi::wstr parseIdentifierWithTemplateArg (yoi::identifierWithTemplateArg *identifierWithTemplateArg)
 
std::pair< std::pair< yoi::indexT, yoi::indexT >, std::shared_ptr< IRInterfaceInstanceDefinition > > parseInterfaceName (yoi::externModuleAccessExpression *structDef)
 
yoi::indexT visit (yoi::funcDefStmt *funcDefStmt)
 
yoi::indexT visit (yoi::interfaceDefStmt *interfaceDefStmt)
 
yoi::indexT visit (yoi::structDefStmt *structDefStmt)
 
yoi::indexT visit (yoi::implStmt *implStmt)
 
yoi::indexT visit (yoi::letStmt *letStmt)
 
yoi::indexT visit (yoi::exportDecl *exportDecl)
 
yoi::indexT visit (yoi::importDecl *importDecl)
 
void visit (yoi::typeAliasStmt *typeAlias)
 
void visit (yoi::globalStmt *globalStmt)
 
yoi::indexT visit (yoi::ifStmt *ifStmt)
 
yoi::indexT visit (yoi::whileStmt *whileStmt)
 
yoi::indexT visit (yoi::forStmt *forStmt)
 
void visit (yoi::forEachStmt *forEachStmt)
 
yoi::indexT visit (yoi::returnStmt *returnStmt)
 
yoi::indexT visit (yoi::continueStmt *continueStmt)
 
yoi::indexT visit (yoi::breakStmt *breakStmt)
 
void visit (yoi::inCodeBlockStmt *inCodeBlockStmt)
 
yoi::indexT visit (yoi::funcExpr *func)
 
yoi::indexT visit (yoi::yieldStmt *stmt)
 
void visit (yoi::conceptDefinition *conceptDefinition)
 
void visit (yoi::enumerationDefinition *enumerationDefinition)
 
void visit (yoi::dataStructDefStmt *dataStructDefStmt)
 
yoi::vec< std::shared_ptr< IRValueType > > evaluateArguments (yoi::invocationArguments *args)
 Visits a list of argument expressions and returns their types.
 
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.
 
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.
 
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.
 
template<typename T >
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 appropriate overloaded operator method.
 
yoi::indexT handleUnaryOperatorOverload (const yoi::wstr &overloadName)
 Handles unary operator overload function when the operand owns a appropriate overloaded operator method.
 
bool handleSubscript (yoi::vec< yoi::subscript * >::iterator &it, yoi::vec< yoi::subscript * >::iterator end, bool isStoreOp, bool isLastTerm)
 Handle subscript.
 
yoi::indexT createCallableInterface (const yoi::vec< std::shared_ptr< IRValueType > > &parameterTypes, const std::shared_ptr< IRValueType > &returnType)
 Create a Callable Interface object and return its index in the module's interface table.
 
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 callable implementation index in the module's implementation table.
 
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 and return its callable implementation index in the module's implementation table.
 
void createCallableInstanceForFunction (yoi::indexT implIndex, std::pair< yoi::indexT, yoi::indexT > callableInterfaceIndex, yoi::indexT moduleIndex, bool hasThis)
 Create a Callable Instance For Function object.
 
yoi::indexT createLambdaUnnamedStruct (yoi::lambdaExpr *lambdaExpr)
 Create a Lambda Unnamed Struct object.
 
bool checkMarcoSatisfaction (yoi::marcoDescriptor *desc)
 Check whether the marco satisfies the condition.
 
void constructDataStruct (yoi::indexT datastructIndex, yoi::indexT moduleIndex, yoi::invocationArguments *args)
 Construct data struct and initialize with given parameters.
 
std::shared_ptr< IRValueTypemapEnumTypeToBasicType (yoi::indexT targetModule, yoi::indexT targetEnumType)
 
std::shared_ptr< IRValueTypegetGeneratorContext (const yoi::wstr &funcName, const std::shared_ptr< IRValueType > &yieldType)
 Get or fetch generator context type for specific function.
 
void setupTemporaryConceptEvaluationEnvironment (yoi::indexT moduleIndex, const yoi::wstr &conceptName, const std::vector< std::shared_ptr< IRValueType > > &args)
 
std::pair< std::shared_ptr< IRConcept >, templateArg * > parseConceptName (yoi::externModuleAccessExpression *conceptName)
 
void evaluateConstraint (yoi::conceptStmt *stmt, const IRDebugInfo &currentDebugInfo)
 
void ejectTemporaryConceptEvaluationEnvironment ()
 
void checkConceptSatisfaction (yoi::externModuleAccessExpression *stmt, const yoi::wstr &paramName, const std::shared_ptr< IRValueType > &args)
 
void checkConceptSatisfaction (yoi::externModuleAccessExpression *stmt)
 

Static Public Member Functions

static yoi::wstr getInterfaceImplName (const std::pair< yoi::indexT, yoi::indexT > &interfaceSrc, const std::shared_ptr< IRValueType > &typeSrc)
 

Public Attributes

std::shared_ptr< yoi::moduleContextmoduleContext
 
std::shared_ptr< yoi::IRModuleirModule
 
yoi::indexT currentModuleIndex
 

Private Member Functions

void pushModuleContext (yoi::indexT moduleIndex)
 
void popModuleContext ()
 

Private Attributes

std::stack< std::pair< std::shared_ptr< yoi::moduleContext >, yoi::indexT > > moduleContextStack
 

Detailed Description

Definition at line 21 of file visitor.h.

Constructor & Destructor Documentation

◆ visitor()

visitor ( const std::shared_ptr< yoi::moduleContext > &  moduleContext,
const std::shared_ptr< yoi::IRModule > &  irModule,
yoi::indexT  moduleIndex 
)

Definition at line 28 of file visitor.cpp.

Member Function Documentation

◆ canCastTo()

bool canCastTo ( const std::shared_ptr< IRValueType > &  fromType,
const std::shared_ptr< IRValueType > &  toType 
)

Definition at line 3922 of file visitor.cpp.

References moduleContext::getCompilerContext(), and yoi::managedPtr().

Here is the call graph for this function:

◆ checkConceptSatisfaction() [1/2]

void checkConceptSatisfaction ( yoi::externModuleAccessExpression stmt)

Definition at line 5762 of file visitor.cpp.

References yoi::__current_file_path, AST::getColumn(), AST::getLine(), and yoi::managedPtr().

Here is the call graph for this function:

◆ checkConceptSatisfaction() [2/2]

void checkConceptSatisfaction ( yoi::externModuleAccessExpression stmt,
const yoi::wstr paramName,
const std::shared_ptr< IRValueType > &  args 
)

Definition at line 5784 of file visitor.cpp.

References IRTemplateBuilder::addTemplateArgument(), moduleContext::popTemplateBuilder(), and moduleContext::pushTemplateBuilder().

Here is the call graph for this function:

◆ checkMarcoSatisfaction()

bool checkMarcoSatisfaction ( yoi::marcoDescriptor desc)

Check whether the marco satisfies the condition.

Parameters
descThe marco descriptor
Returns
true The marco satisfies the condition
false The marco doesn't satisfy the condition

Definition at line 5093 of file visitor.cpp.

References lexer::token::basicVal, lexer::token::col, AST::getColumn(), moduleContext::getCompilerContext(), AST::getLine(), lexer::token::kind, lexer::token::line, marcoDescriptor::pairs, yoi::panic(), lexer::scan(), lexer::token::strVal, lexer::token::vBasicValue::vDeci, yoi::wstring2string(), and yoi::yoi_assert().

Here is the call graph for this function:

◆ constructDataStruct()

void constructDataStruct ( yoi::indexT  datastructIndex,
yoi::indexT  moduleIndex,
yoi::invocationArguments args 
)

Construct data struct and initialize with given parameters.

Parameters
datastructIndexThe index of the data struct in the module's struct table.
moduleIndexThe index of the module where the struct will be created.
argsThe arguments to initialize the struct.

Definition at line 5554 of file visitor.cpp.

References invocationArguments::arg, AST::getColumn(), moduleContext::getCompilerContext(), moduleContext::getIRBuilder(), AST::getLine(), IRBuilder::initializeFieldsOp(), IRBuilder::newDataStructOp(), yoi::wstring2string(), and yoi::yoi_assert().

Here is the call graph for this function:

◆ createCallableImplementationForFunction()

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 and return its callable implementation index in the module's implementation table.

Parameters
funcThe function definition.
funcIndexThe index of the function in the module's function table.
moduleIndexThe index of the module where the implementation will be created.
Returns
std::pair<yoi::indexT, std::pair<yoi::indexT, yoi::indexT>>
Note
If hasThis is true, the function is a member function and has a this pointer, make sure the object has been pushed onto the stack before invoking the method.

Definition at line 5394 of file visitor.cpp.

References IRFunctionDefinition::Builder::addArgument(), IRFunctionDefinition::Builder::addAttr(), IRStructDefinition::Builder::addField(), IRStructDefinition::Builder::addMethod(), IRFunctionDefinition::Builder::argumentTypes, IRBuilder::createCodeBlock(), moduleContext::getCompilerContext(), IRBuilder::getCurrentDebugInfo(), moduleContext::getIRBuilder(), HOSHI_COMPILER_CTX_GLOB_ID_CONST, IRBuilder::invokeOp(), IRBuilder::loadOp(), yoi::managedPtr(), moduleContext::popIRBuilder(), moduleContext::pushIRBuilder(), IRBuilder::retOp(), IRFunctionDefinition::Builder::setDebugInfo(), IRFunctionDefinition::Builder::setName(), IRStructDefinition::Builder::setName(), IRFunctionDefinition::Builder::setReturnType(), IRBuilder::storeOp(), IRBuilder::switchCodeBlock(), IRFunctionDefinition::Builder::yield(), IRStructDefinition::Builder::yield(), and IRBuilder::yield().

Here is the call graph for this function:

◆ createCallableImplementationForLambda()

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 callable implementation index in the module's implementation table.

Parameters
lambdaThe lambda struct definition.
lambdaStructIndexThe index of the lambda struct in the module's struct table.
moduleIndexThe index of the module where the implementation will be created.
Returns
std::pair<yoi::indexT, std::pair<yoi::indexT, yoi::indexT>> The index of the created callable implementation in the module's implementation table and callable interface index.

Definition at line 5056 of file visitor.cpp.

References IRInterfaceImplementationDefinition::Builder::addVirtualMethod(), moduleContext::getCompilerContext(), moduleContext::getIRBuilder(), IRBuilder::getRhsFromTempVarStack(), HOSHI_COMPILER_CTX_GLOB_ID_CONST, yoi::managedPtr(), IRInterfaceImplementationDefinition::Builder::setImplInterfaceIndex(), IRInterfaceImplementationDefinition::Builder::setImplStructIndex(), and IRInterfaceImplementationDefinition::Builder::yield().

Here is the call graph for this function:

◆ createCallableInstanceForFunction()

void createCallableInstanceForFunction ( yoi::indexT  implIndex,
std::pair< yoi::indexT, yoi::indexT callableInterfaceIndex,
yoi::indexT  moduleIndex,
bool  hasThis 
)

Create a Callable Instance For Function object.

Parameters
implIndexThe index of the callable implementation in the module's implementation table.
callableInterfaceIndexThe index of the callable interface in the module's interface table.
moduleIndexThe index of the module where the implementation will be created.
hasThisThe index of the module where the implementation will be created.
Note
If hasThis is true, the action will pop the this pointer from the stack, and push the struct created into the stack.

Definition at line 5508 of file visitor.cpp.

References IRBuilder::constructInterfaceImplOp(), moduleContext::getCompilerContext(), moduleContext::getIRBuilder(), IRBuilder::getRhsFromTempVarStack(), IRBuilder::invokeDanglingOp(), and IRBuilder::newStructOp().

Here is the call graph for this function:

◆ createCallableInterface()

yoi::indexT createCallableInterface ( const yoi::vec< std::shared_ptr< IRValueType > > &  parameterTypes,
const std::shared_ptr< IRValueType > &  returnType 
)

Create a Callable Interface object and return its index in the module's interface table.

Parameters
parameterTypesThe parameter types of the callable interface.
returnTypeThe return type of the callable interface.
Returns
yoi::indexT The index of the created callable interface in the module's interface table.

Definition at line 4912 of file visitor.cpp.

References IRInterfaceInstanceDefinition::Builder::addMethod(), moduleContext::getCompilerContext(), HOSHI_COMPILER_CTX_GLOB_ID_CONST, yoi::managedPtr(), IRInterfaceInstanceDefinition::Builder::setName(), and IRInterfaceInstanceDefinition::Builder::yield().

Here is the call graph for this function:

◆ createLambdaUnnamedStruct()

◆ ejectTemporaryConceptEvaluationEnvironment()

void ejectTemporaryConceptEvaluationEnvironment ( )

Definition at line 5721 of file visitor.cpp.

References moduleContext::popIRBuilder(), and moduleContext::popTemplateBuilder().

Here is the call graph for this function:

◆ emitBasicCastInBasicArithOpByLhsAndRhs()

void emitBasicCastInBasicArithOpByLhsAndRhs ( yoi::indexT  lhs,
yoi::indexT  rhs 
)

◆ emitBasicCastTo()

void emitBasicCastTo ( const std::shared_ptr< IRValueType > &  toType)

Definition at line 3022 of file visitor.cpp.

References IRBuilder::basicCast(), IRBuilder::getCurrentInsertionPoint(), moduleContext::getIRBuilder(), and IRBuilder::getRhsFromTempVarStack().

Here is the call graph for this function:

◆ evaluateArguments()

yoi::vec< std::shared_ptr< IRValueType > > evaluateArguments ( yoi::invocationArguments args)

Visits a list of argument expressions and returns their types.

Parameters
argsThe AST node for the argument list.
Returns
A vector of shared pointers to the argument types.
Note
This function leaves the evaluated arguments on the IRBuilder's temporary stack.

Definition at line 4095 of file visitor.cpp.

References invocationArguments::get(), moduleContext::getIRBuilder(), and IRBuilder::getRhsFromTempVarStack().

Here is the call graph for this function:

◆ evaluateConstraint()

◆ extractTemplateParamsFromTypeArgs() [1/2]

yoi::vec< yoi::wstr > extractTemplateParamsFromTypeArgs ( yoi::defTemplateArg templateArgs)

Definition at line 3294 of file visitor.cpp.

References defTemplateArg::get().

Here is the call graph for this function:

◆ extractTemplateParamsFromTypeArgs() [2/2]

yoi::vec< yoi::wstr > extractTemplateParamsFromTypeArgs ( yoi::templateArg templateArgs)

Definition at line 3274 of file visitor.cpp.

References templateArg::get(), AST::getColumn(), AST::getLine(), externModuleAccessExpression::getTerms(), typeSpec::kind, typeSpec::member, and yoi::panic().

Here is the call graph for this function:

◆ generateNullInterfaceImplementation()

yoi::indexT generateNullInterfaceImplementation ( const std::shared_ptr< IRValueType > &  structType)

Definition at line 4002 of file visitor.cpp.

References moduleContext::getCompilerContext(), HOSHI_COMPILER_CTX_GLOB_ID_CONST, and yoi::managedPtr().

Here is the call graph for this function:

◆ getExternEntry()

yoi::IRExternEntry getExternEntry ( yoi::indexT  moduleIndex,
const yoi::wstr identifier 
) const

search and return extern entry by identifier in target module

Parameters
moduleIndexthe index of target module
identifierthe identifier to search
Returns
the extern entry
Exceptions
std::runtime_errorif identifier not found

Definition at line 2933 of file visitor.cpp.

References moduleContext::getCompilerContext(), and yoi::wstring2string().

Here is the call graph for this function:

◆ getFunctionAttributes()

std::set< IRFunctionDefinition::FunctionAttrs > getFunctionAttributes ( const yoi::vec< lexer::token > &  attrs)

Definition at line 4025 of file visitor.cpp.

◆ getFuncUniqueNameStr()

yoi::wstr getFuncUniqueNameStr ( const std::vector< std::shared_ptr< IRValueType > > &  argumentTypes,
bool  whetherIgnoreFirstParam = false 
)

Definition at line 3102 of file visitor.cpp.

◆ getGeneratorContext()

std::shared_ptr< IRValueType > getGeneratorContext ( const yoi::wstr funcName,
const std::shared_ptr< IRValueType > &  yieldType 
)

◆ getIncompleteType()

std::shared_ptr< IRValueType > getIncompleteType ( const yoi::wstr typeName) const

Definition at line 3155 of file visitor.cpp.

References moduleContext::getTemplateBuilders(), and yoi::wstring2string().

Here is the call graph for this function:

◆ getInterfaceImplName()

yoi::wstr getInterfaceImplName ( const std::pair< yoi::indexT, yoi::indexT > &  interfaceSrc,
const std::shared_ptr< IRValueType > &  typeSrc 
)
static

Definition at line 2898 of file visitor.cpp.

Referenced by IROptimizer::performInterfaceWrapperPass().

Here is the caller graph for this function:

◆ getInterfaceNameStr()

yoi::wstr getInterfaceNameStr ( const std::pair< yoi::indexT, yoi::indexT > &  interfaceSrc)

Definition at line 3032 of file visitor.cpp.

◆ getMangledTemplateName()

yoi::wstr getMangledTemplateName ( const yoi::wstr baseName,
const yoi::vec< std::shared_ptr< IRValueType > > &  templateArgs 
)

Definition at line 3262 of file visitor.cpp.

◆ getSpecializedMangledMethodName()

yoi::wstr getSpecializedMangledMethodName ( yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > &  templateArgs,
const yoi::wstr baseMethodName,
const yoi::vec< std::shared_ptr< IRValueType > > &  specializedArgTypes 
)

Definition at line 3720 of file visitor.cpp.

References replace_all().

Here is the call graph for this function:

◆ getTemplateArgs()

yoi::indexTable< yoi::wstr, IRTemplateBuilder::Argument > getTemplateArgs ( const yoi::defTemplateArg templateArgs)

Definition at line 3168 of file visitor.cpp.

References yoi::managedPtr(), indexTable< A, B >::put_create(), and defTemplateArg::spec.

Here is the call graph for this function:

◆ getTypeSpecUniqueNameStr()

yoi::wstr getTypeSpecUniqueNameStr ( const std::shared_ptr< IRValueType > &  type)

Definition at line 3036 of file visitor.cpp.

References IRDebugInfo::column, IRBuilder::getCurrentDebugInfo(), moduleContext::getIRBuilder(), IRDebugInfo::line, and yoi::panic().

Here is the call graph for this function:

◆ handleBinaryOperatorOverload()

template<typename T >
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 appropriate overloaded operator method.

Parameters
overloadNamethe name of the operator overload method
rhsASTthe right hand side AST expression, will be used when the cast is required when resolving overload method
Returns
yoi::indexT current insertion point after the invocation
Note
Make sure the builder state is saved before calling this helper function.

Definition at line 4373 of file visitor.cpp.

References IRDebugInfo::column, IRBuilder::discardState(), moduleContext::getCompilerContext(), IRBuilder::getCurrentDebugInfo(), IRBuilder::getCurrentInsertionPoint(), moduleContext::getIRBuilder(), IRBuilder::getLhsFromTempVarStack(), IRBuilder::getRhsFromTempVarStack(), IRBuilder::invokeMethodOp(), IRBuilder::invokeVirtualOp(), IRDebugInfo::line, IRBuilder::restoreState(), yoi::wstring2string(), and yoi::yoi_assert().

Here is the call graph for this function:

◆ handleInvocationExtern()

◆ handleSubscript()

bool handleSubscript ( yoi::vec< yoi::subscript * >::iterator &  it,
yoi::vec< yoi::subscript * >::iterator  end,
bool  isStoreOp,
bool  isLastTerm 
)

◆ handleUnaryOperatorOverload()

yoi::indexT handleUnaryOperatorOverload ( const yoi::wstr overloadName)

Handles unary operator overload function when the operand owns a appropriate overloaded operator method.

Parameters
overloadNamethe name of the operator overload method
Returns
yoi::indexT current insertion point after the invocation

Definition at line 4481 of file visitor.cpp.

References IRDebugInfo::column, moduleContext::getCompilerContext(), IRBuilder::getCurrentDebugInfo(), IRBuilder::getCurrentInsertionPoint(), moduleContext::getIRBuilder(), IRBuilder::getRhsFromTempVarStack(), IRBuilder::invokeMethodOp(), IRBuilder::invokeVirtualOp(), IRDebugInfo::line, yoi::wstring2string(), and yoi::yoi_assert().

Here is the call graph for this function:

◆ isModuleName() [1/2]

yoi::indexT isModuleName ( identifier it,
yoi::indexT  currentModule 
) const

Definition at line 4066 of file visitor.cpp.

References moduleContext::getCompilerContext(), identifier::node, and lexer::token::strVal.

Here is the call graph for this function:

◆ isModuleName() [2/2]

yoi::indexT isModuleName ( identifierWithTemplateArg it,
yoi::indexT  currentModule 
) const

check if the subscript expression is a module name

Parameters
itThe subscript expression being checked
currentModuleThe current module being checked, -1 if not in a module
Returns
-1 if not a module name, otherwise the index of the module in the module table

Definition at line 2925 of file visitor.cpp.

References identifierWithTemplateArg::hasTemplateArg(), and identifierWithTemplateArg::id.

Here is the call graph for this function:

◆ isVisitingGlobalScope()

bool isVisitingGlobalScope ( ) const

Definition at line 2969 of file visitor.cpp.

References moduleContext::getIRBuilder(), and IRBuilder::irFuncDefinition().

Here is the call graph for this function:

◆ mapEnumTypeToBasicType()

std::shared_ptr< IRValueType > mapEnumTypeToBasicType ( yoi::indexT  targetModule,
yoi::indexT  targetEnumType 
)

Definition at line 5243 of file visitor.cpp.

References moduleContext::getCompilerContext().

Here is the call graph for this function:

◆ parseConceptName()

std::pair< std::shared_ptr< IRConcept >, templateArg * > parseConceptName ( yoi::externModuleAccessExpression conceptName)

Definition at line 5745 of file visitor.cpp.

References AST::getColumn(), moduleContext::getCompilerContext(), AST::getLine(), externModuleAccessExpression::getTerms(), and yoi::yoi_assert().

Here is the call graph for this function:

◆ parseIdentifierWithTemplateArg()

yoi::wstr parseIdentifierWithTemplateArg ( yoi::identifierWithTemplateArg identifierWithTemplateArg)

◆ parseInterfaceName()

std::pair< std::pair< yoi::indexT, yoi::indexT >, std::shared_ptr< IRInterfaceInstanceDefinition > > parseInterfaceName ( yoi::externModuleAccessExpression structDef)

◆ parseTemplateArgs()

yoi::vec< std::shared_ptr< IRValueType > > parseTemplateArgs ( const yoi::templateArg templateArgs)

Definition at line 3178 of file visitor.cpp.

References yoi::managedPtr(), and templateArg::spec.

Here is the call graph for this function:

◆ parseTypeSpec() [1/6]

IRValueType parseTypeSpec ( yoi::externModuleAccessExpression emaExpression)

Definition at line 4076 of file visitor.cpp.

References externModuleAccessExpression::getTerms().

Here is the call graph for this function:

◆ parseTypeSpec() [2/6]

IRValueType parseTypeSpec ( yoi::funcTypeSpec typeSpec)

Definition at line 4902 of file visitor.cpp.

References HOSHI_COMPILER_CTX_GLOB_ID_CONST, and yoi::managedPtr().

Here is the call graph for this function:

◆ parseTypeSpec() [3/6]

IRValueType parseTypeSpec ( yoi::identifier identifier)

Definition at line 1893 of file visitor.cpp.

References AST::getColumn(), moduleContext::getCompilerContext(), AST::getLine(), identifier::node, yoi::panic(), lexer::token::strVal, and yoi::wstring2string().

Here is the call graph for this function:

◆ parseTypeSpec() [4/6]

◆ parseTypeSpec() [5/6]

IRValueType parseTypeSpec ( yoi::subscriptExpr subscriptExpr)

Definition at line 2752 of file visitor.cpp.

References subscriptExpr::getSubscript(), subscriptExpr::id, and yoi::yoi_assert().

Here is the call graph for this function:

◆ parseTypeSpec() [6/6]

◆ parseTypeSpecExtern() [1/3]

IRValueType parseTypeSpecExtern ( yoi::identifier identifier,
yoi::indexT  targetModule 
)

◆ parseTypeSpecExtern() [2/3]

◆ parseTypeSpecExtern() [3/3]

IRValueType parseTypeSpecExtern ( yoi::subscriptExpr subscriptExpr,
yoi::indexT  targetModule 
)

Definition at line 2814 of file visitor.cpp.

References AST::getColumn(), AST::getLine(), subscriptExpr::getSubscript(), subscriptExpr::id, and yoi::panic().

Here is the call graph for this function:

◆ popModuleContext()

void popModuleContext ( )
private

Definition at line 4802 of file visitor.cpp.

References moduleContext::getCompilerContext().

Here is the call graph for this function:

◆ pushModuleContext()

void pushModuleContext ( yoi::indexT  moduleIndex)
private

Definition at line 4794 of file visitor.cpp.

References moduleContext::getCompilerContext().

Here is the call graph for this function:

◆ resolveOverloadExtern()

visitor::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.

Parameters
baseNameThe base name of the function (e.g., "println" or "constructor").
argTypesThe types of the arguments provided at the call site.
targetModuleThe index of the module being looked into.
structContextOptional. If not null, searches for a method within this external struct.
Returns
An OverloadResult struct with the resolution details.

Definition at line 4104 of file visitor.cpp.

References visitor::OverloadResult::fixedArgCount, visitor::OverloadResult::function, visitor::OverloadResult::functionIndex, moduleContext::getCompilerContext(), visitor::OverloadResult::isCastRequired, visitor::OverloadResult::isVariadic, yoi::managedPtr(), visitor::OverloadResult::variadicElementType, and yoi::wstring2string().

Here is the call graph for this function:

◆ resolveOverloadInterface()

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.

Parameters
baseNameThe base name of the function (e.g., "println" or "constructor").
argTypesThe types of the arguments provided at the call site.
targetModuleThe index of the module being looked into.
interfaceContextThe interface context where the function is being called.
Returns
visitor::OverloadResult with the resolution details.

Definition at line 4716 of file visitor.cpp.

References visitor::OverloadResult::fixedArgCount, visitor::OverloadResult::function, visitor::OverloadResult::functionIndex, moduleContext::getCompilerContext(), visitor::OverloadResult::isCastRequired, visitor::OverloadResult::isVariadic, visitor::OverloadResult::isVirtual, yoi::managedPtr(), and visitor::OverloadResult::variadicElementType.

Here is the call graph for this function:

◆ setupTemporaryConceptEvaluationEnvironment()

void setupTemporaryConceptEvaluationEnvironment ( yoi::indexT  moduleIndex,
const yoi::wstr conceptName,
const std::vector< std::shared_ptr< IRValueType > > &  args 
)

◆ specializeFunctionTemplate()

◆ specializeInterfaceImplementation()

◆ specializeInterfaceTemplate()

◆ specializeStructMethodDeclaration()

◆ specializeStructMethodDefinition()

◆ specializeStructMethodTemplate()

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 
)

◆ specializeStructTemplate()

◆ tryCastTo()

◆ visit() [1/50]

◆ visit() [2/50]

◆ visit() [3/50]

◆ visit() [4/50]

◆ visit() [5/50]

◆ visit() [6/50]

◆ visit() [7/50]

yoi::indexT visit ( yoi::breakStmt breakStmt)

Definition at line 2721 of file visitor.cpp.

References IRBuilder::breakOp(), IRBuilder::getCurrentInsertionPoint(), and moduleContext::getIRBuilder().

Here is the call graph for this function:

◆ visit() [8/50]

void visit ( yoi::codeBlock codeBlock,
bool  notEmitNewBlockInstruction = false 
)

◆ visit() [9/50]

void visit ( yoi::conceptDefinition conceptDefinition)

Definition at line 5670 of file visitor.cpp.

References yoi::managedPtr(), conceptDefinition::name, and lexer::token::strVal.

Here is the call graph for this function:

◆ visit() [10/50]

yoi::indexT visit ( yoi::continueStmt continueStmt)

Definition at line 2716 of file visitor.cpp.

References IRBuilder::continueOp(), IRBuilder::getCurrentInsertionPoint(), and moduleContext::getIRBuilder().

Here is the call graph for this function:

◆ visit() [11/50]

◆ visit() [12/50]

◆ visit() [13/50]

◆ visit() [14/50]

◆ visit() [15/50]

◆ visit() [16/50]

◆ visit() [17/50]

void visit ( yoi::forEachStmt forEachStmt)

Definition at line 2693 of file visitor.cpp.

References AST::getColumn(), AST::getLine(), and yoi::panic().

Here is the call graph for this function:

◆ visit() [18/50]

◆ visit() [19/50]

◆ visit() [20/50]

◆ visit() [21/50]

◆ visit() [22/50]

void visit ( yoi::hoshiModule module)

Visitor methods These methods received a pointer to the corresponding AST node and return an index of the current position in IR array.

Definition at line 52 of file visitor.cpp.

◆ visit() [23/50]

◆ visit() [24/50]

yoi::indexT visit ( yoi::identifierWithTemplateArg identifierWithTemplateArg,
bool  isStoreOp = false 
)

Definition at line 1877 of file visitor.cpp.

References AST::getColumn(), AST::getLine(), identifierWithTemplateArg::hasTemplateArg(), identifierWithTemplateArg::id, and yoi::panic().

Here is the call graph for this function:

◆ visit() [25/50]

◆ visit() [26/50]

◆ visit() [27/50]

◆ visit() [28/50]

◆ visit() [29/50]

◆ visit() [30/50]

◆ visit() [31/50]

◆ visit() [32/50]

◆ visit() [33/50]

◆ visit() [34/50]

◆ visit() [35/50]

◆ visit() [36/50]

◆ visit() [37/50]

◆ visit() [38/50]

◆ visit() [39/50]

◆ visit() [40/50]

◆ visit() [41/50]

yoi::indexT visit ( yoi::rExpr rExpr)

Definition at line 883 of file visitor.cpp.

References rExpr::getExpr().

Here is the call graph for this function:

◆ visit() [42/50]

◆ visit() [43/50]

◆ visit() [44/50]

◆ visit() [45/50]

◆ visit() [46/50]

◆ visit() [47/50]

◆ visit() [48/50]

◆ visit() [49/50]

◆ visit() [50/50]

◆ visitExtern() [1/3]

◆ visitExtern() [2/3]

yoi::indexT visitExtern ( yoi::identifierWithTemplateArg identifierWithTemplateArg,
yoi::indexT  targetModule,
bool  isStoreOp = false 
)

Definition at line 3145 of file visitor.cpp.

References AST::getColumn(), AST::getLine(), identifierWithTemplateArg::hasTemplateArg(), identifierWithTemplateArg::id, and yoi::panic().

Here is the call graph for this function:

◆ visitExtern() [3/3]

Member Data Documentation

◆ currentModuleIndex

yoi::indexT currentModuleIndex

Definition at line 43 of file visitor.h.

◆ irModule

std::shared_ptr<yoi::IRModule> irModule

Definition at line 42 of file visitor.h.

Referenced by visitor::visit().

◆ moduleContext

Definition at line 41 of file visitor.h.

◆ moduleContextStack

std::stack<std::pair<std::shared_ptr<yoi::moduleContext>, yoi::indexT> > moduleContextStack
private

Definition at line 34 of file visitor.h.


The documentation for this class was generated from the following files: