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

#include <IR.h>

Public Member Functions

 IRVariableTable ()=default
 
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, look it up in the parent scope.
 
std::shared_ptr< IRValueTypeget (yoi::indexT index)
 
std::shared_ptr< IRValueTypeoperator[] (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)
 
void popScope ()
 
yoi::wstr to_string (yoi::indexT indent=0)
 
yoi::vec< std::shared_ptr< IRValueType > > & getVariables ()
 
std::map< yoi::indexT, yoi::wstr > & getReversedVariableNameMap ()
 
yoi::indexT scopeIndex (yoi::indexT varIndex)
 

Private Attributes

yoi::vec< std::shared_ptr< IRValueType > > variables
 
yoi::vec< std::map< yoi::wstr, yoi::indexT > > variableNameIndexMap
 
std::map< yoi::indexT, yoi::indexTvariableScopeMap
 
std::map< yoi::indexT, yoi::wstrreversedVariableNameMap
 

Detailed Description

Definition at line 430 of file IR.h.

Constructor & Destructor Documentation

◆ IRVariableTable()

IRVariableTable ( )
default

Member Function Documentation

◆ createScope()

yoi::indexT createScope ( )

Definition at line 848 of file IR.cpp.

Referenced by IRFunctionDefinition::IRFunctionDefinition().

Here is the caller graph for this function:

◆ get()

std::shared_ptr< IRValueType > get ( yoi::indexT  index)

Definition at line 867 of file IR.cpp.

◆ getReversedVariableNameMap()

std::map< yoi::indexT, yoi::wstr > & getReversedVariableNameMap ( )

Definition at line 1030 of file IR.cpp.

◆ getVariables()

yoi::vec< std::shared_ptr< IRValueType > > & getVariables ( )

Definition at line 1026 of file IR.cpp.

Referenced by LLVMCodegen::generateFunction().

Here is the caller graph for this function:

◆ lookup()

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, look it up in the parent scope.

Parameters
nameThe name of the variable to look up.
Returns
The index of the variable in the variable table.
Exceptions
std::runtime_errorpanics if the variable is not found in any scope.

Definition at line 839 of file IR.cpp.

References IRStructDefinition::name, and yoi::wstring2string().

Here is the call graph for this function:

◆ operator[]()

std::shared_ptr< IRValueType > operator[] ( const yoi::wstr name)

Definition at line 871 of file IR.cpp.

References IRStructDefinition::name.

◆ popScope()

void popScope ( )

Definition at line 853 of file IR.cpp.

◆ put()

yoi::indexT put ( const yoi::wstr name,
const std::shared_ptr< IRValueType > &  type 
)

Definition at line 875 of file IR.cpp.

References IRStructDefinition::name.

Referenced by IRFunctionDefinition::IRFunctionDefinition().

Here is the caller graph for this function:

◆ scopeIndex()

yoi::indexT scopeIndex ( yoi::indexT  varIndex)

Definition at line 1483 of file IR.cpp.

◆ set()

void set ( yoi::indexT  index,
const std::shared_ptr< IRValueType > &  type 
)

Definition at line 1712 of file IR.cpp.

◆ to_string()

yoi::wstr to_string ( yoi::indexT  indent = 0)

Definition at line 857 of file IR.cpp.

Referenced by IRFunctionDefinition::to_string().

Here is the caller graph for this function:

Member Data Documentation

◆ reversedVariableNameMap

std::map<yoi::indexT, yoi::wstr> reversedVariableNameMap
private

Definition at line 434 of file IR.h.

◆ variableNameIndexMap

yoi::vec<std::map<yoi::wstr, yoi::indexT> > variableNameIndexMap
private

Definition at line 432 of file IR.h.

◆ variables

yoi::vec<std::shared_ptr<IRValueType> > variables
private

Definition at line 431 of file IR.h.

◆ variableScopeMap

std::map<yoi::indexT, yoi::indexT> variableScopeMap
private

Definition at line 433 of file IR.h.


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