Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Translate_visitor Class Reference

#include <translator_i.h>

Inheritance diagram for Translate_visitor:

Inheritance graph
[legend]
Collaboration diagram for Translate_visitor:

Collaboration graph
[legend]
List of all members.

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


Member Typedef Documentation

typedef Ptree_program_visitor<bool> Translate_visitor::Super [private]
 

Reimplemented from Ptree_program_visitor< bool >.

Definition at line 31 of file translator_i.h.

typedef hash_map<string,vrec> Translate_visitor::Var_map [private]
 

Definition at line 32 of file translator_i.h.


Member Enumeration Documentation

enum Translate_visitor::Func_what [private]
 

Enumeration values:
Prologue 
Epilogue 

Definition at line 34 of file translator_i.h.


Constructor & Destructor Documentation

Translate_visitor::Translate_visitor Source   s
 

Definition at line 23 of file translator.cc.

Translate_visitor::~Translate_visitor   [virtual]
 

Definition at line 39 of file translator.cc.


Member Function Documentation

void Translate_visitor::new_function_epilogue const string &    name,
const string &    value
[private]
 

Definition at line 499 of file translator.cc.

References out.

Referenced by new_variable(), and visit_function().

void Translate_visitor::new_function_prologue const string &    name,
const string &    rettype
[private]
 

Definition at line 482 of file translator.cc.

References out.

Referenced by new_variable(), and visit_function().

void Translate_visitor::new_state const string &    func [private]
 

Definition at line 512 of file translator.cc.

References out.

Referenced by new_variable(), visit_funcall(), and visit_name().

void Translate_visitor::new_value const string &    val [private]
 

Definition at line 413 of file translator.cc.

References _value, and out.

Referenced by visit_funcall(), visit_infix(), visit_leaf(), visit_name(), and visit_postfix().

void Translate_visitor::new_variable const string &    name,
const string &    initializer
[private]
 

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().

void Translate_visitor::pop_lvalue   [private]
 

Definition at line 532 of file translator.cc.

References _expecting_lvalue, and _lvalue_stack.

Referenced by visit_infix(), and visit_postfix().

void Translate_visitor::push_lvalue   [private]
 

Definition at line 523 of file translator.cc.

References _expecting_lvalue, and _lvalue_stack.

Referenced by visit_infix(), and visit_postfix().

bool Translate_visitor::visit_assign PtreeAssignExpr   exp [private, virtual]
 

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().

bool Translate_visitor::visit_exprstatement PtreeExprStatement   exp [private, virtual]
 

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().

bool Translate_visitor::visit_funcall PtreeFuncallExpr   exp [private, virtual]
 

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.

bool Translate_visitor::visit_function Ptree   storagespec,
Ptree   returntype,
PtreeDeclarator   decl,
PtreeBlock   block
[private, virtual]
 

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().

bool Translate_visitor::visit_infix PtreeInfixExpr   exp [private, virtual]
 

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().

bool Translate_visitor::visit_leaf Leaf   exp [private, virtual]
 

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().

bool Translate_visitor::visit_name Ptree   exp [private, virtual]
 

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().

bool Translate_visitor::visit_name_declaration Ptree   storagespec,
Ptree   type,
Ptree   decllist
[private, virtual]
 

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().

bool Translate_visitor::visit_postfix PtreePostfixExpr   exp [private, virtual]
 

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().

bool Translate_visitor::visit_return PtreeReturnStatement   exp [private, virtual]
 

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().


Member Data Documentation

string Translate_visitor::_alloc [private]
 

Name of current allocator.

Definition at line 43 of file translator_i.h.

Referenced by visit_function(), and visit_name_declaration().

bool Translate_visitor::_expecting_lvalue [private]
 

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().

ostringstream Translate_visitor::_expr [private]
 

Where to save expression computation.

Definition at line 50 of file translator_i.h.

Referenced by visit_name_declaration().

string Translate_visitor::_func [private]
 

Currently defined function.

Definition at line 42 of file translator_i.h.

Referenced by visit_function(), and visit_return().

string Translate_visitor::_last_alloc [private]
 

Name of current state's allocator.

Definition at line 44 of file translator_i.h.

Referenced by new_variable(), visit_function(), and visit_name().

stack<bool> Translate_visitor::_lvalue_stack [private]
 

Saved values of _expecting_lvalue.

Definition at line 47 of file translator_i.h.

Referenced by pop_lvalue(), and push_lvalue().

int Translate_visitor::_number [private]
 

Next variable index.

Definition at line 40 of file translator_i.h.

Referenced by visit_function(), and visit_name_declaration().

Mangle Translate_visitor::_sym [private]
 

Symbol table.

Definition at line 37 of file translator_i.h.

Referenced by visit_funcall(), visit_function(), visit_name(), and visit_name_declaration().

int Translate_visitor::_value [private]
 

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().

Var_map Translate_visitor::_var [private]
 

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().

ostream* Translate_visitor::out [private]
 

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().


The documentation for this class was generated from the following files:
Generated on Mon Feb 10 17:36:47 2003 for VFiasco Semantics Compiler by doxygen1.2.15