Nearly CC
An educational compiler skeleton
Public Member Functions | List of all members
Function Class Reference

Function encapsulates all of the information needed to generate and optimize code for a function. More...

#include "function.h"

Public Member Functions

 Function (const std::string &name, Node *funcdef_ast, Symbol *symbol)
 Constructor. More...
 
std::string get_name () const
 Get the function name. More...
 
Nodeget_funcdef_ast () const
 Get the function definition AST. More...
 
Symbolget_symbol () const
 Get the function's symbol table entry. More...
 
std::shared_ptr< InstructionSequenceget_hl_iseq () const
 Get the high-level InstructionSequence. More...
 
void set_hl_iseq (const std::shared_ptr< InstructionSequence > &hl_iseq)
 Set the high-level InstructionSequence. More...
 
std::shared_ptr< InstructionSequenceget_ll_iseq () const
 Get the low-level InstructionSequence. More...
 
void set_ll_iseq (const std::shared_ptr< InstructionSequence > &ll_iseq)
 Set the low-level InstructionSequence. More...
 

Detailed Description

Function encapsulates all of the information needed to generate and optimize code for a function.

This includes (at a minimum) the function name, function definition AST, the symbol table entry, generated high-level code, and generated low-level code. However, you can add any additional fields that would be helpful. In particular, any information about a function that needs to be communicated between phases, such as storage allocation decisions, can also be collected in the Function object.

Constructor & Destructor Documentation

◆ Function()

Function::Function ( const std::string &  name,
Node funcdef_ast,
Symbol symbol 
)

Constructor.

Parameters
namethe name of the function
funcdef_astthe function definition AST
symbolthe function's symbol table entry

Member Function Documentation

◆ get_funcdef_ast()

Node * Function::get_funcdef_ast ( ) const

Get the function definition AST.

Returns
the function definition AST

◆ get_hl_iseq()

std::shared_ptr< InstructionSequence > Function::get_hl_iseq ( ) const

Get the high-level InstructionSequence.

Returns
shared poiner to the high-level InstructionSequence

◆ get_ll_iseq()

std::shared_ptr< InstructionSequence > Function::get_ll_iseq ( ) const

Get the low-level InstructionSequence.

Returns
shared pointer to the low-level InstructionSequence

◆ get_name()

std::string Function::get_name ( ) const

Get the function name.

Returns
the function name

◆ get_symbol()

Symbol * Function::get_symbol ( ) const

Get the function's symbol table entry.

Returns
the function's symbol table entry

◆ set_hl_iseq()

void Function::set_hl_iseq ( const std::shared_ptr< InstructionSequence > &  hl_iseq)

Set the high-level InstructionSequence.

Parameters
sharedpointer to the high-level InstructionSequence

◆ set_ll_iseq()

void Function::set_ll_iseq ( const std::shared_ptr< InstructionSequence > &  ll_iseq)

Set the low-level InstructionSequence.

Parameters
sharedpointer to the low-level InstructionSequence

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