diff options
Diffstat (limited to 'lib/chillcg')
-rwxr-xr-x | lib/chillcg/include/code_gen/CG_chillRepr.h | 5 | ||||
-rwxr-xr-x | lib/chillcg/src/CG_chillBuilder.cc | 42 |
2 files changed, 9 insertions, 38 deletions
diff --git a/lib/chillcg/include/code_gen/CG_chillRepr.h b/lib/chillcg/include/code_gen/CG_chillRepr.h index 34e9876..ea2048b 100755 --- a/lib/chillcg/include/code_gen/CG_chillRepr.h +++ b/lib/chillcg/include/code_gen/CG_chillRepr.h @@ -39,13 +39,11 @@ namespace omega { CG_chillRepr(chillAST_Node *chillast) { stmtclassname = strdup(chillast->getTypeString()); - //fprintf(stderr, "made new chillRepr of class %s\n", stmtclassname); if (chillast->getType() == CHILLAST_NODE_COMPOUNDSTMT) { std::vector<chillAST_Node *> &children = *(chillast->getChildren()); int numchildren = children.size(); for (int i = 0; i < numchildren; i++) { chillnodes.push_back(children[i]); - //fprintf(stderr, "adding a statement from a CompoundStmt\n"); } } else { // for now, assume it's a single statement chillnodes.push_back(chillast); // ?? @@ -72,12 +70,9 @@ namespace omega { void dump() const { printChillNodes(); }; void Dump() const; - //void DumpToFile(FILE *fp = stderr) const; private: - char *stmtclassname; // chill - }; diff --git a/lib/chillcg/src/CG_chillBuilder.cc b/lib/chillcg/src/CG_chillBuilder.cc index 51a02be..ef53e27 100755 --- a/lib/chillcg/src/CG_chillBuilder.cc +++ b/lib/chillcg/src/CG_chillBuilder.cc @@ -36,13 +36,6 @@ namespace omega { chillAST_Node *SubCompoundStmt( const char *oldvar, CG_chillRepr *newvar, chillAST_Node *n, chillAST_Node *parent ); chillAST_Node *SubMemberExpr( const char *oldvar, CG_chillRepr *newvar, chillAST_Node *n, chillAST_Node *parent ); - - - // chillAST_Node *Sub( const char *oldvar, CG_chillRepr *newvar, chillAST_Node *n, chillAST_Node *parent ); // fwd decl - - - - chillAST_Node *substituteChill( const char *oldvar, CG_chillRepr *newvar, chillAST_Node *n, chillAST_Node *parent = NULL ) { if (n == NULL) { fprintf(stderr, "substituteChill() pointer n == NULL\n"); // DIE @@ -235,9 +228,6 @@ namespace omega { chillAST_Node *SubCallExpr( const char *oldvar, CG_chillRepr *newvar, chillAST_Node *n, chillAST_Node *parent = NULL ) { chillAST_CallExpr *CE = (chillAST_CallExpr *) n; - //fprintf(stderr, "substituting for oldvar %s in ", oldvar ); - //CE->print(); printf("\n"); fflush(stdout); - int nargs = CE->getNumChildren(); for (int i=1; i<nargs; i++) { CE->setChild(i,substituteChill( oldvar, newvar, CE->getChild(i), CE)); @@ -248,8 +238,6 @@ namespace omega { chillAST_Node *SubReturnStmt( const char *oldvar, CG_chillRepr *newvar, chillAST_Node *n, chillAST_Node *parent = NULL ) { - //fprintf(stderr, "SubReturnStmt()\n"); - chillAST_ReturnStmt *RS = (chillAST_ReturnStmt *)n; if (RS->getRetVal()) RS->setRetVal(substituteChill(oldvar, newvar, RS->getRetVal(), RS)); return RS; @@ -261,17 +249,18 @@ namespace omega { chillAST_IfStmt *IS = (chillAST_IfStmt *)n; //IS->print(0, stderr); fprintf(stderr, "\n\n"); chillAST_Node *sub; - if ( sub = IS->getCond() ) IS->setCond( substituteChill(oldvar, newvar, sub, IS)); - if ( sub = IS->getThen() ) IS->setThen( substituteChill(oldvar, newvar, sub, IS)); - sub = IS->getElse(); //fprintf(stderr, "sub(else) = %p\n", sub); - if ( sub = IS->getElse() ) IS->setElse( substituteChill(oldvar, newvar, sub, IS)); + sub = IS->getCond(); + if ( sub ) IS->setCond( substituteChill(oldvar, newvar, sub, IS)); + sub = IS->getThen(); + if ( sub ) IS->setThen( substituteChill(oldvar, newvar, sub, IS)); + sub = IS->getElse(); + if ( sub ) IS->setElse( substituteChill(oldvar, newvar, sub, IS)); return IS; } chillAST_Node *SubCompoundStmt( const char *oldvar, CG_chillRepr *newvar, chillAST_Node *n, chillAST_Node *parent = NULL ) { - //fprintf(stderr, "SubCompoundStmt()\n"); chillAST_CompoundStmt *CS = (chillAST_CompoundStmt *)n; int numchildren = CS->getNumChildren(); @@ -285,14 +274,9 @@ namespace omega { chillAST_Node *SubMemberExpr( const char *oldvar, CG_chillRepr *newvar, chillAST_Node *n, chillAST_Node *parent = NULL ) { - //fprintf(stderr, "SubMemberExpr( oldvar %s ) \n", oldvar); chillAST_MemberExpr *ME = (chillAST_MemberExpr *)n; - - ME->base = substituteChill(oldvar, newvar, ME->base, ME ); - - - // - return ME; + ME->base = substituteChill(oldvar, newvar, ME->base, ME ); + return ME; } @@ -304,19 +288,11 @@ namespace omega { } CG_chillBuilder::CG_chillBuilder(chillAST_SourceFile *top, chillAST_FunctionDecl *func) { - //fprintf(stderr, "\nCG_chillBuilder::CG_chillBuilder()\n"); toplevel = top; currentfunction = func; - //fprintf(stderr, "\nfunction is:\n"); currentfunction->print(); printf("\n\n"); fflush(stdout); - - symtab_ = currentfunction->getSymbolTable(); + symtab_ = currentfunction->getParameters(); symtab2_ = currentfunction->getBody()->getSymbolTable(); - - //printf("\nsymtab_:\n"); fflush(stdout); - //printSymbolTable( symtab_ ); - //printf("\n\nsymtab2_:\n"); fflush(stdout); - //printSymbolTable( symtab2_ ); } CG_chillBuilder::~CG_chillBuilder() { |