#include <translator_i.h>
Inheritance diagram for Translate_visitor:
Public Methods | |
Translate_visitor (Source *s) | |
virtual | ~Translate_visitor () |
Private Types | |
typedef Ptree_program_visitor< bool > | Super |
typedef hash_map< string, vrec > | Var_map |
enum | Func_what { Prologue, Epilogue } |
Private Methods | |
bool | visit_function (Ptree *storagespec, Ptree *returntype, PtreeDeclarator *decl, PtreeBlock *block) |
bool | visit_name_declaration (Ptree *storagespec, Ptree *type, Ptree *decllist) |
bool | visit_return (PtreeReturnStatement *exp) |
bool | visit_exprstatement (PtreeExprStatement *exp) |
bool | visit_assign (PtreeAssignExpr *exp) |
bool | visit_infix (PtreeInfixExpr *exp) |
bool | visit_postfix (PtreePostfixExpr *exp) |
bool | visit_funcall (PtreeFuncallExpr *exp) |
bool | visit_name (Ptree *exp) |
Variable expression. More... | |
bool | visit_leaf (Leaf *exp) |
void | new_value (const string &val) |
void | new_variable (const string &name, const string &initializer) |
void | new_function_prologue (const string &name, const string &rettype) |
void | new_function_epilogue (const string &name, const string &value) |
void | new_state (const string &func) |
void | push_lvalue () |
void | pop_lvalue () |
Private Attributes | |
Var_map | _var |
Variable array, indexed by encoded name. More... | |
Mangle | _sym |
Symbol table. More... | |
int | _value |
Current value index. More... | |
int | _number |
Next variable index. More... | |
string | _func |
Currently defined function. More... | |
string | _alloc |
Name of current allocator. More... | |
string | _last_alloc |
Name of current state's allocator. More... | |
bool | _expecting_lvalue |
Currently parsing an lvalue. More... | |
stack< bool > | _lvalue_stack |
Saved values of _expecting_lvalue. More... | |
ostringstream | _expr |
Where to save expression computation. More... | |
ostream * | out |
Current output stream. More... |
|
Reimplemented from Ptree_program_visitor< bool >. Definition at line 31 of file translator_i.h. |
|
Definition at line 32 of file translator_i.h. |
|
Definition at line 34 of file translator_i.h. |
|
Definition at line 23 of file translator.cc. |
|
Definition at line 39 of file translator.cc. |
|
Definition at line 499 of file translator.cc. References out. Referenced by new_variable(), and visit_function(). |
|
Definition at line 482 of file translator.cc. References out. Referenced by new_variable(), and visit_function(). |
|
Definition at line 512 of file translator.cc. References out. Referenced by new_variable(), visit_funcall(), and visit_name(). |
|
Definition at line 413 of file translator.cc. Referenced by visit_funcall(), visit_infix(), visit_leaf(), visit_name(), and visit_postfix(). |
|
Definition at line 421 of file translator.cc. References _last_alloc, _value, _var, new_function_epilogue(), new_function_prologue(), new_state(), and out. Referenced by visit_name_declaration(). |
|
Definition at line 532 of file translator.cc. References _expecting_lvalue, and _lvalue_stack. Referenced by visit_infix(), and visit_postfix(). |
|
Definition at line 523 of file translator.cc. References _expecting_lvalue, and _lvalue_stack. Referenced by visit_infix(), and visit_postfix(). |
|
Reimplemented from Ptree_visitor< bool >. Definition at line 228 of file translator.cc. References _expecting_lvalue, Ptree::First(), Ptree::Third(), Ptree::ToString(), and Ptree_visitor< bool >::visit(). |
|
Reimplemented from Ptree_visitor< bool >. Definition at line 218 of file translator.cc. References Ptree::First(), Ptree::Second(), Ptree::ToString(), and Ptree_visitor< bool >::visit(). |
|
Reimplemented from Ptree_visitor< bool >. Definition at line 316 of file translator.cc. References _sym, _var, Ptree::Car(), Mangle::lookup_global_name(), new_state(), new_value(), and out. |
|
Reimplemented from Ptree_program_visitor< bool >. Definition at line 50 of file translator.cc. References _alloc, _func, _last_alloc, _number, _sym, _var, Ptree::Car(), Mangle::enter_scope(), Ptree::First(), Mangle::insert(), NonLeaf::IsLeaf(), Mangle::leave_scope(), new_function_epilogue(), new_function_prologue(), Ptree::Second(), Ptree::Third(), Ptree::ToString(), and Ptree_visitor< bool >::visit(). |
|
Reimplemented from Ptree_visitor< bool >. Definition at line 249 of file translator.cc. References _value, Ptree::First(), new_value(), pop_lvalue(), push_lvalue(), Ptree::Second(), Ptree::Third(), Ptree::ToString(), and Ptree_visitor< bool >::visit(). |
|
Reimplemented from Ptree_visitor< bool >. Definition at line 386 of file translator.cc. References Leaf::IsLeaf(), new_value(), and Ptree::ToString(). Referenced by visit_name(). |
|
Variable expression. Semantics: If expecting an rvalue, read the typed value of the variable into a logic variable. If expecting an lvalue, write the previuosly computed rvalue to the variable. Reimplemented from Ptree_visitor< bool >. Definition at line 342 of file translator.cc. References _expecting_lvalue, _last_alloc, _sym, _value, _var, vrec::alloc, Ptree::IsLeaf(), Mangle::lookup_global_name(), vrec::name, new_state(), new_value(), Ptree::ToString(), and visit_leaf(). |
|
Reimplemented from Ptree_program_visitor< bool >. Definition at line 111 of file translator.cc. References _alloc, _expr, _number, _sym, _var, Ptree::Car(), Ptree::Cdr(), Ptree::First(), Mangle::insert(), Ptree::IsLeaf(), new_variable(), out, Ptree::ToString(), and Ptree_visitor< bool >::visit(). |
|
Reimplemented from Ptree_visitor< bool >. Definition at line 279 of file translator.cc. References _expecting_lvalue, _value, Ptree::First(), new_value(), pop_lvalue(), push_lvalue(), Ptree::Second(), Ptree::ToString(), and Ptree_visitor< bool >::visit(). |
|
Reimplemented from Ptree_visitor< bool >. Definition at line 187 of file translator.cc. References _func, _value, _var, Ptree::Length(), out, Ptree::Second(), and Ptree_visitor< bool >::visit(). |
|
Name of current allocator.
Definition at line 43 of file translator_i.h. Referenced by visit_function(), and visit_name_declaration(). |
|
Currently parsing an lvalue.
Definition at line 46 of file translator_i.h. Referenced by pop_lvalue(), push_lvalue(), visit_assign(), visit_name(), and visit_postfix(). |
|
Where to save expression computation.
Definition at line 50 of file translator_i.h. Referenced by visit_name_declaration(). |
|
Currently defined function.
Definition at line 42 of file translator_i.h. Referenced by visit_function(), and visit_return(). |
|
Name of current state's allocator.
Definition at line 44 of file translator_i.h. Referenced by new_variable(), visit_function(), and visit_name(). |
|
Saved values of _expecting_lvalue.
Definition at line 47 of file translator_i.h. Referenced by pop_lvalue(), and push_lvalue(). |
|
Next variable index.
Definition at line 40 of file translator_i.h. Referenced by visit_function(), and visit_name_declaration(). |
|
Symbol table.
Definition at line 37 of file translator_i.h. Referenced by visit_funcall(), visit_function(), visit_name(), and visit_name_declaration(). |
|
Current value index.
Definition at line 39 of file translator_i.h. Referenced by new_value(), new_variable(), visit_infix(), visit_name(), visit_postfix(), and visit_return(). |
|
Variable array, indexed by encoded name.
Definition at line 36 of file translator_i.h. Referenced by new_variable(), visit_funcall(), visit_function(), visit_name(), visit_name_declaration(), and visit_return(). |
|
Current output stream.
Definition at line 52 of file translator_i.h. Referenced by new_function_epilogue(), new_function_prologue(), new_state(), new_value(), new_variable(), visit_funcall(), visit_name_declaration(), and visit_return(). |