LRDE Tiger Compiler
1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
|
Stack frames for languages with non local variables. More...
#include <level.hh>
Public Member Functions | |
Level (const misc::symbol &name, const Level *parent=nullptr, frame::bool_list_type formal_escapes=frame::bool_list_type()) | |
~Level () | |
tree::rExp | sl () const |
A Tree expression computing this level's static link. | |
tree::rExp | fp (const Level &use) const |
Return a Tree expression representing the frame pointer of this Level, but from the use level point of view (i.e., climbing the static links from use level to this Level). | |
std::ostream & | dump (std::ostream &o) const |
Report on stream o. | |
const Access * | local_alloc (bool escapes) |
Allocate a new local variable. | |
const Access * | formal_alloc (bool escapes) |
Similar to local_alloc () for formal arguments. | |
Accessors. | |
Level of the enclosing function. | |
const Level * | parent_get () const |
frame::Frame & | frame_get () |
Stack frame that we enhance with static link support. | |
const frame::Frame & | frame_get () const |
Stack frame that we enhance with static link support. | |
temp::Label | label_get () const |
Label of this function (from the Frame). | |
const access_list_type & | formals_get () const |
Accesses to the formals arguments. | |
int | frame_size_get () const |
Size of the Frame. |
Private Attributes | |
const Level * | parent_ |
Level of the enclosing function. | |
frame::Frame * | frame_ |
Stack frame that we enhance with static link support. | |
access_list_type | formals_ |
Accesses to the formal arguments. | |
access_list_type | locals_ |
Accesses to the local (automatic) variables. |
Stack frames for languages with non local variables.
frame::Frame holds the information on the function stack frame. translate::Level adds information on the parents of the current Level (which is used to fetch escaping variables), and also the list of the Access'es to the formals of the functions.
A frame::Frame is a frame::Access factory, and translate::Level is a translate::Access factory.
translate::Level::Level | ( | const misc::symbol & | name, |
const Level * | parent = nullptr , |
||
frame::bool_list_type | formal_escapes = frame::bool_list_type() |
||
) |
References formal_alloc().
translate::Level::~Level | ( | ) |
Destroy \a locals_ completely, but not \a formals_.
locals_ and formals_ are translate::Access binding some frame::Access. The frame::Frame keeps tracks of its formals, but not of its locals; hence it destroys by itself its locals and we must not do it here. As a result, we have to destroy the high level parts of both formals and locals, and the low level part (frame::Access) only for locals_.
References misc::deep_clear(), formals_, and locals_.
std::ostream & translate::Level::dump | ( | std::ostream & | o | ) | const |
Report on stream o.
References misc::decindent(), formals_, frame_, misc::incendl(), label_get(), and parent_.
Referenced by translate::operator<<().
const Access * translate::Level::formal_alloc | ( | bool | escapes | ) |
Similar to local_alloc () for formal arguments.
References frame::Frame::formal_alloc(), formals_, and frame_.
Referenced by Level().
|
inline |
Accesses to the formals arguments.
References formals_.
Referenced by sl(), and translate::Translator::visit_function_dec_body().
tree::rExp translate::Level::fp | ( | const Level & | use | ) | const |
Return a Tree expression representing the frame pointer of this Level, but from the use level point of view (i.e., climbing the static links from use level to this Level).
This is used in at least two places:
Referenced by translate::Access::exp().
|
inline |
Stack frame that we enhance with static link support.
References frame_.
Referenced by label_get(), sl(), and translate::Translator::visit_function_dec_body().
|
inline |
Stack frame that we enhance with static link support.
References frame_.
int translate::Level::frame_size_get | ( | ) | const |
Size of the Frame.
References frame_, and frame::Frame::get_current_frame_size().
temp::Label translate::Level::label_get | ( | ) | const |
Label of this function (from the Frame).
References frame_get(), and frame::Frame::label_get().
Referenced by dump(), and translate::operator<<().
const Access * translate::Level::local_alloc | ( | bool | escapes | ) |
Allocate a new local variable.
escapes | if true, make it frame resident. |
References frame_, frame::Frame::local_alloc(), and locals_.
Referenced by translate::Translator::operator()().
tree::rExp translate::Level::sl | ( | ) | const |
A Tree expression computing this level's static link.
References formals_get(), and frame_get().
|
private |
Accesses to the formal arguments.
Referenced by dump(), formal_alloc(), formals_get(), and ~Level().
|
private |
Stack frame that we enhance with static link support.
Referenced by dump(), formal_alloc(), frame_get(), frame_size_get(), and local_alloc().
|
private |
Accesses to the local (automatic) variables.
Referenced by local_alloc(), and ~Level().
|
private |
Level of the enclosing function.
Referenced by dump(), and parent_get().