#include <codegen/chllcode.h>
Inheritance diagram for CHLLCode:
Definition at line 84 of file chllcode.h.
Public Member Functions | |
virtual void | AddAssignmentStatement (int indLevel, Assign *asgn) |
Prints an assignment expression. | |
virtual void | AddBreak (int indLevel) |
Adds: break;. | |
virtual void | AddCallStatement (int indLevel, Proc *proc, const char *name, StatementList &args, StatementList *results) |
Adds a call to proc. | |
virtual void | AddCaseCondElse (int indLevel) |
Adds: default:. | |
virtual void | AddCaseCondEnd (int indLevel) |
Adds: }. | |
virtual void | AddCaseCondHeader (int indLevel, Exp *cond) |
Adds: switch(cond) {. | |
virtual void | AddCaseCondOption (int indLevel, Exp *opt) |
Adds: case opt :. | |
virtual void | AddCaseCondOptionEnd (int indLevel) |
Adds: break;. | |
virtual void | AddContinue (int indLevel) |
Adds: continue;. | |
virtual void | AddEndlessLoopEnd (int indLevel) |
Adds: }. | |
virtual void | AddEndlessLoopHeader (int indLevel) |
Adds: for(;;) {. | |
virtual void | AddGlobal (const char *name, Type *type, Exp *init=NULL) |
Add the declaration for a global. | |
virtual void | AddGoto (int indLevel, int ord) |
Adds: goto L ord. | |
virtual void | AddIfCondEnd (int indLevel) |
Adds: }. | |
virtual void | AddIfCondHeader (int indLevel, Exp *cond) |
Adds: if(cond) {. | |
virtual void | AddIfElseCondEnd (int indLevel) |
Adds: }. | |
virtual void | AddIfElseCondHeader (int indLevel, Exp *cond) |
Adds: if(cond) {. | |
virtual void | AddIfElseCondOption (int indLevel) |
Adds: } else {. | |
virtual void | AddIndCallStatement (int indLevel, Exp *exp, StatementList &args, StatementList *results) |
Adds an indirect call to exp. | |
virtual void | AddLabel (int indLevel, int ord) |
Adds: L ord :. | |
virtual void | AddLineComment (char *cmt) |
Adds one line of comment to the code. | |
virtual void | AddLocal (const char *name, Type *type, bool last=false) |
Declare a local variable. | |
virtual void | AddPosttestedLoopEnd (int indLevel, Exp *cond) |
Adds: } while (cond);. | |
virtual void | AddPosttestedLoopHeader (int indLevel) |
Adds: do {. | |
virtual void | AddPretestedLoopEnd (int indLevel) |
Adds: }. | |
virtual void | AddPretestedLoopHeader (int indLevel, Exp *cond) |
Adds: while( cond) {. | |
virtual void | AddProcEnd () |
Adds: }. | |
virtual void | AddProcStart (UserProc *proc) |
Print the start of a function, and also as a comment its address. | |
virtual void | AddPrototype (UserProc *proc) |
Add a prototype (for forward declaration). | |
virtual void | AddReturnStatement (int indLevel, StatementList *rets) |
Adds a return statement and returns the first expression in rets. | |
CHLLCode (UserProc *p) | |
Empty constructor, calls HLLCode(p). | |
CHLLCode () | |
Empty constructor, calls HLLCode(). | |
virtual void | print (std::ostream &os) |
Dump all generated code to os. | |
virtual void | RemoveLabel (int ord) |
Search for the label L ord and remove it from the generated code. | |
virtual void | RemoveUnusedLabels (int maxOrd) |
Removes labels from the code which are not in usedLabels. | |
virtual void | reset () |
Remove all generated code. | |
virtual | ~CHLLCode () |
Empty destructor. | |
Private Member Functions | |
void | AddProcDec (UserProc *proc, bool open) |
Print the declaration of a function. | |
void | appendExp (std::ostringstream &str, Exp *exp, PREC curPrec, bool uns=false) |
void | appendLine (const std::string &s) |
void | appendLine (const std::ostringstream &ostr) |
void | appendType (std::ostringstream &str, Type *typ) |
Print the type represented by typ to str. | |
void | appendTypeIdent (std::ostringstream &str, Type *typ, const char *ident) |
Print the indented type to str. | |
void | closeParen (std::ostringstream &str, PREC outer, PREC inner) |
Adds: ). | |
void | indent (std::ostringstream &str, int indLevel) |
Output 4 * indLevel spaces to str. | |
void | openParen (std::ostringstream &str, PREC outer, PREC inner) |
Adds: (. | |
Private Attributes | |
std::list< char * > | lines |
The generated code. | |
std::map< std::string, Type * > | locals |
All locals in a Proc. | |
std::set< int > | usedLabels |
All used goto labels. |
|
Empty constructor, calls HLLCode().
Definition at line 50 of file chllcode.cpp. |
|
Empty constructor, calls HLLCode(p).
Definition at line 55 of file chllcode.cpp. |
|
Empty destructor.
Definition at line 60 of file chllcode.cpp. |
|
Prints an assignment expression.
Implements HLLCode. Definition at line 1209 of file chllcode.cpp. References Boomerang::get(), Prog::getFrontEndId(), Assignment::getLeft(), Exp::getOper(), Statement::getProc(), Proc::getProg(), Assign::getRight(), Exp::getSubExp1(), TypingStatement::getType(), indent(), isBareMemof(), HLLCode::m_proc, opFsize, opPC, opRegOf, PLAT_SPARC, result, and Exp::search(). |
|
Adds: break;.
Implements HLLCode. Definition at line 1168 of file chllcode.cpp. References appendLine(), and indent(). |
|
Adds a call to proc.
Implements HLLCode. Definition at line 1336 of file chllcode.cpp. References appendExp(), StatementList::begin(), indent(), PREC_ASSIGN, and StatementList::size(). |
|
Adds: default:.
Implements HLLCode. Definition at line 1070 of file chllcode.cpp. References appendLine(), and indent(). |
|
Adds: }.
Implements HLLCode. Definition at line 1079 of file chllcode.cpp. References appendLine(), and indent(). |
|
Adds: switch(cond) {.
Implements HLLCode. Definition at line 1039 of file chllcode.cpp. References appendExp(), appendLine(), indent(), and PREC_NONE. |
|
Adds: case opt :.
Implements HLLCode. Definition at line 1050 of file chllcode.cpp. References appendExp(), appendLine(), indent(), and PREC_NONE. |
|
Adds: break;.
Implements HLLCode. Definition at line 1061 of file chllcode.cpp. References appendLine(), and indent(). |
|
Adds: continue;.
Implements HLLCode. Definition at line 1160 of file chllcode.cpp. References appendLine(), and indent(). |
|
Adds: }.
Implements HLLCode. Definition at line 1012 of file chllcode.cpp. References appendLine(), and indent(). |
|
Adds: for(;;) {.
Implements HLLCode. Definition at line 1004 of file chllcode.cpp. References appendLine(), and indent(). |
|
Add the declaration for a global.
Implements HLLCode. Definition at line 1602 of file chllcode.cpp. References appendType(), and Type::isArray(). |
|
Adds: goto L ord.
Implements HLLCode. Definition at line 1132 of file chllcode.cpp. References appendLine(), indent(), and usedLabels. |
|
Adds: }.
Implements HLLCode. Definition at line 1098 of file chllcode.cpp. References appendLine(), and indent(). |
|
Adds: if(cond) {.
Implements HLLCode. Definition at line 1088 of file chllcode.cpp. References appendExp(), appendLine(), indent(), and PREC_NONE. |
|
Adds: }.
Implements HLLCode. Definition at line 1124 of file chllcode.cpp. References appendLine(), and indent(). |
|
Adds: if(cond) {.
Implements HLLCode. Definition at line 1106 of file chllcode.cpp. References appendExp(), appendLine(), indent(), and PREC_NONE. |
|
Adds: } else {.
Implements HLLCode. Definition at line 1116 of file chllcode.cpp. References appendLine(), and indent(). |
|
Adds an indirect call to exp.
Implements HLLCode. Definition at line 1401 of file chllcode.cpp. References appendExp(), StatementList::begin(), StatementList::end(), indent(), PREC_COMMA, and PREC_NONE. |
|
Adds: L ord :.
Implements HLLCode. Definition at line 1176 of file chllcode.cpp. References appendLine(). |
|
Adds one line of comment to the code.
Implements HLLCode. Definition at line 1645 of file chllcode.cpp. References appendLine(). |
|
Declare a local variable.
Implements HLLCode. Definition at line 1573 of file chllcode.cpp. References appendExp(), appendLine(), appendTypeIdent(), Type::clone(), UserProc::expFromSymbol(), Exp::getOper(), Exp::getSubExp1(), indent(), locals, HLLCode::m_proc, opGlobal, opParam, opSubscript, PREC_NONE, and Exp::print(). |
|
Adds: } while (cond);.
Implements HLLCode. Definition at line 1028 of file chllcode.cpp. References appendExp(), appendLine(), indent(), and PREC_NONE. |
|
Adds: do {.
Implements HLLCode. Definition at line 1020 of file chllcode.cpp. References appendLine(), and indent(). |
|
Adds: }.
Implements HLLCode. Definition at line 996 of file chllcode.cpp. References appendLine(), and indent(). |
|
Adds: while( cond) {.
Implements HLLCode. Definition at line 983 of file chllcode.cpp. References appendExp(), appendLine(), indent(), and PREC_NONE. |
|
Print the declaration of a function.
Definition at line 1483 of file chllcode.cpp. References Signature::getNumReturns(), Proc::getProg(), Signature::getReturnExp(), Signature::getReturnType(), Proc::getSignature(), Signature::getStackRegister(), UserProc::getTheReturnStatement(), Signature::isForced(), Exp::isRegN(), and NULL. Referenced by AddProcStart(), and AddPrototype(). |
|
Adds: }.
Implements HLLCode. Definition at line 1564 of file chllcode.cpp. References appendLine(). |
|
Print the start of a function, and also as a comment its address.
Implements HLLCode. Definition at line 1467 of file chllcode.cpp. References AddProcDec(), appendLine(), and Proc::getNativeAddress(). |
|
Add a prototype (for forward declaration).
Implements HLLCode. Definition at line 1475 of file chllcode.cpp. References AddProcDec(). |
|
Adds a return statement and returns the first expression in rets.
Implements HLLCode. Definition at line 1427 of file chllcode.cpp. References appendExp(), StatementList::begin(), StatementList::end(), Boomerang::get(), Signature::getNumReturns(), Proc::getSignature(), indent(), HLLCode::m_proc, PREC_NONE, and StatementList::size(). |
|
Definition at line 82 of file chllcode.cpp. References Exp::getOper(), Exp::isTypedExp(), UserProc::lookupSym(), HLLCode::m_proc, NULL, and progress. Referenced by AddCallStatement(), AddCaseCondHeader(), AddCaseCondOption(), AddIfCondHeader(), AddIfElseCondHeader(), AddIndCallStatement(), AddLocal(), AddPosttestedLoopEnd(), AddPretestedLoopHeader(), and AddReturnStatement(). |
|
Definition at line 1657 of file chllcode.cpp. References lines. |
|
|
Print the type represented by typ to str.
Definition at line 927 of file chllcode.cpp. References Type::asArray(), Type::asPointer(), ArrayType::getBaseType(), PointerType::getPointsTo(), NULL, Type::resolvesToArray(), and Type::resolvesToPointer(). Referenced by AddGlobal(), and appendTypeIdent(). |
|
Print the indented type to str.
Definition at line 946 of file chllcode.cpp. References appendType(), Type::asArray(), Type::asPointer(), ArrayType::getBaseType(), PointerType::getPointsTo(), Type::isArray(), Type::isPointer(), and NULL. Referenced by AddLocal(). |
|
Adds: ).
Definition at line 97 of file chllcode.h. |
|
Output 4 * indLevel spaces to str.
Definition at line 65 of file chllcode.cpp. Referenced by AddAssignmentStatement(), AddBreak(), AddCallStatement(), AddCaseCondElse(), AddCaseCondEnd(), AddCaseCondHeader(), AddCaseCondOption(), AddCaseCondOptionEnd(), AddContinue(), AddEndlessLoopEnd(), AddEndlessLoopHeader(), AddGoto(), AddIfCondEnd(), AddIfCondHeader(), AddIfElseCondEnd(), AddIfElseCondHeader(), AddIfElseCondOption(), AddIndCallStatement(), AddLocal(), AddPosttestedLoopEnd(), AddPosttestedLoopHeader(), AddPretestedLoopEnd(), AddPretestedLoopHeader(), and AddReturnStatement(). |
|
Adds: (.
Definition at line 94 of file chllcode.h. |
|
Dump all generated code to os.
Implements HLLCode. Definition at line 1637 of file chllcode.cpp. References lines, HLLCode::m_proc, and NULL. |
|
Search for the label L ord and remove it from the generated code.
Implements HLLCode. Definition at line 1183 of file chllcode.cpp. References lines. |
|
Removes labels from the code which are not in usedLabels.
Implements HLLCode. Definition at line 1144 of file chllcode.cpp. References lines, and usedLabels. |
|
Remove all generated code.
Reimplemented from HLLCode. Definition at line 978 of file chllcode.cpp. References lines. |
|
The generated code.
Definition at line 87 of file chllcode.h. Referenced by appendLine(), print(), RemoveLabel(), RemoveUnusedLabels(), and reset(). |
|
All locals in a Proc.
Definition at line 104 of file chllcode.h. Referenced by AddLocal(). |
|
All used goto labels.
Definition at line 107 of file chllcode.h. Referenced by AddGoto(), and RemoveUnusedLabels(). |