Changes in / [4f9636f:bd951f7]
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r4f9636f rbd951f7 262 262 } // if 263 263 } else { 264 output << typeDecl->genTypeString() << " " << typeDecl->get_name(); 265 if ( typeDecl->get_kind() != TypeDecl::Any && typeDecl->get_sized() ) { 266 output << " | sized(" << typeDecl->get_name() << ")"; 267 } 264 output << typeDecl->typeString() << " " << typeDecl->get_name(); 268 265 if ( ! typeDecl->get_assertions().empty() ) { 269 266 output << " | { "; … … 772 769 void CodeGenerator::visit( ExprStmt * exprStmt ) { 773 770 assert( exprStmt ); 774 Expression * expr = exprStmt->get_expr(); 775 if ( genC ) { 776 // cast the top-level expression to void to reduce gcc warnings. 777 expr = new CastExpr( expr ); 778 } 771 // cast the top-level expression to void to reduce gcc warnings. 772 Expression * expr = new CastExpr( exprStmt->get_expr() ); 779 773 expr->accept( *this ); 780 774 output << ";"; -
src/CodeGen/Generate.cc
r4f9636f rbd951f7 22 22 #include "SynTree/Declaration.h" 23 23 #include "CodeGenerator.h" 24 #include "GenType.h" 25 #include "SynTree/SynTree.h" 26 #include "SynTree/Type.h" 27 #include "SynTree/BaseSyntaxNode.h" 28 // #include "Tuples/Tuples.h" 24 #include "Tuples/Tuples.h" 29 25 30 26 using namespace std; … … 43 39 } // for 44 40 } 45 46 void generate( BaseSyntaxNode * node, std::ostream & os ) {47 if ( Type * type = dynamic_cast< Type * >( node ) ) {48 os << CodeGen::genPrettyType( type, "" );49 } else {50 CodeGen::CodeGenerator cgv( os, true, false );51 node->accept( cgv );52 }53 os << std::endl;54 }55 41 } // namespace CodeGen 56 42 -
src/CodeGen/Generate.h
r4f9636f rbd951f7 25 25 /// Generates code. doIntrinsics determines if intrinsic functions are printed, pretty formats output nicely (e.g., uses unmangled names, etc.), generateC is true when the output must consist only of C code (allows some assertions, etc.) 26 26 void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC = false ); 27 28 /// Generate code for a single node -- helpful for debugging in gdb29 void generate( BaseSyntaxNode * node, std::ostream & os );30 27 } // namespace CodeGen 31 28 -
src/GenPoly/PolyMutator.cc
r4f9636f rbd951f7 50 50 51 51 Statement * PolyMutator::mutateStatement( Statement *stmt ) { 52 // don't want statements from outer CompoundStmts to be added to this CompoundStmt53 ValueGuard< std::list< Statement* > > oldStmtsToAdd( stmtsToAdd );54 ValueGuard< std::list< Statement* > > oldStmtsToAddAfter( stmtsToAddAfter );55 ValueGuard< TypeSubstitution * > oldEnv( env );56 stmtsToAdd.clear();57 stmtsToAddAfter.clear();58 59 52 Statement *newStmt = maybeMutate( stmt, *this ); 60 53 if ( ! stmtsToAdd.empty() || ! stmtsToAddAfter.empty() ) { … … 90 83 91 84 Statement * PolyMutator::mutate(IfStmt *ifStmt) { 92 ifStmt->set_condition( mutateExpression( ifStmt->get_condition() ) );93 85 ifStmt->set_thenPart( mutateStatement( ifStmt->get_thenPart() ) ); 94 86 ifStmt->set_elsePart( mutateStatement( ifStmt->get_elsePart() ) ); 87 ifStmt->set_condition( mutateExpression( ifStmt->get_condition() ) ); 95 88 return ifStmt; 96 89 } 97 90 98 91 Statement * PolyMutator::mutate(WhileStmt *whileStmt) { 92 whileStmt->set_body( mutateStatement( whileStmt->get_body() ) ); 99 93 whileStmt->set_condition( mutateExpression( whileStmt->get_condition() ) ); 100 whileStmt->set_body( mutateStatement( whileStmt->get_body() ) );101 94 return whileStmt; 102 95 } 103 96 104 97 Statement * PolyMutator::mutate(ForStmt *forStmt) { 98 forStmt->set_body( mutateStatement( forStmt->get_body() ) ); 105 99 mutateAll( forStmt->get_initialization(), *this ); 106 100 forStmt->set_condition( mutateExpression( forStmt->get_condition() ) ); 107 101 forStmt->set_increment( mutateExpression( forStmt->get_increment() ) ); 108 forStmt->set_body( mutateStatement( forStmt->get_body() ) );109 102 return forStmt; 110 103 } 111 104 112 105 Statement * PolyMutator::mutate(SwitchStmt *switchStmt) { 106 mutateStatementList( switchStmt->get_statements() ); 113 107 switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) ); 114 mutateStatementList( switchStmt->get_statements() );115 108 return switchStmt; 116 109 } 117 110 118 111 Statement * PolyMutator::mutate(CaseStmt *caseStmt) { 112 mutateStatementList( caseStmt->get_statements() ); 119 113 caseStmt->set_condition( mutateExpression( caseStmt->get_condition() ) ); 120 mutateStatementList( caseStmt->get_statements() );121 114 return caseStmt; 122 115 } -
src/ResolvExpr/AlternativeFinder.cc
r4f9636f rbd951f7 766 766 } // if 767 767 } // for 768 // function may return struct or union value, in which case we need to add alternatives for implicit conversions to each of the anonymous members 769 for ( const Alternative & alt : alternatives ) { 770 addAnonConversions( alt ); 771 } 768 772 769 773 candidates.clear(); … … 771 775 772 776 findMinCost( candidates.begin(), candidates.end(), std::back_inserter( alternatives ) ); 773 774 // function may return struct or union value, in which case we need to add alternatives for implicit775 // conversions to each of the anonymous members, must happen after findMinCost since anon conversions776 // are never the cheapest expression777 for ( const Alternative & alt : alternatives ) {778 addAnonConversions( alt );779 }780 777 781 778 if ( alternatives.empty() && targetType && ! targetType->isVoid() ) { -
src/SynTree/BaseSyntaxNode.h
r4f9636f rbd951f7 18 18 19 19 #include "Common/utility.h" 20 #include "Visitor.h"21 20 22 21 class BaseSyntaxNode { 23 22 public: 24 23 CodeLocation location; 25 26 virtual void accept( Visitor & v ) = 0; // temporary -- needs to be here so that BaseSyntaxNode is polymorphic and can be dynamic_cast27 24 }; 28 25 -
src/SynTree/Declaration.h
r4f9636f rbd951f7 204 204 205 205 virtual std::string typeString() const; 206 virtual std::string genTypeString() const;207 206 208 207 virtual TypeDecl *clone() const { return new TypeDecl( *this ); } -
src/SynTree/SynTree.h
r4f9636f rbd951f7 21 21 #include <map> 22 22 #include <iostream> 23 24 class BaseSyntaxNode;25 23 26 24 class Declaration; -
src/SynTree/TypeDecl.cc
r4f9636f rbd951f7 29 29 } 30 30 31 std::string TypeDecl::genTypeString() const {32 static const std::string kindNames[] = { "otype", "dtype", "ftype", "ttype" };33 return kindNames[ kind ];34 }35 36 31 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) { 37 32 return os << data.kind << ", " << data.isComplete;
Note: See TracChangeset
for help on using the changeset viewer.