Changeset 982ed5b
- Timestamp:
- May 5, 2017, 1:38:42 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 805c167, c352893
- Parents:
- 43426d4 (diff), 4f9636f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r43426d4 r982ed5b 262 262 } // if 263 263 } else { 264 output << typeDecl->typeString() << " " << typeDecl->get_name(); 264 output << typeDecl->genTypeString() << " " << typeDecl->get_name(); 265 if ( typeDecl->get_kind() != TypeDecl::Any && typeDecl->get_sized() ) { 266 output << " | sized(" << typeDecl->get_name() << ")"; 267 } 265 268 if ( ! typeDecl->get_assertions().empty() ) { 266 269 output << " | { "; … … 769 772 void CodeGenerator::visit( ExprStmt * exprStmt ) { 770 773 assert( exprStmt ); 771 // cast the top-level expression to void to reduce gcc warnings. 772 Expression * expr = new CastExpr( exprStmt->get_expr() ); 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 } 773 779 expr->accept( *this ); 774 780 output << ";"; -
src/CodeGen/Generate.cc
r43426d4 r982ed5b 22 22 #include "SynTree/Declaration.h" 23 23 #include "CodeGenerator.h" 24 #include "Tuples/Tuples.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" 25 29 26 30 using namespace std; … … 39 43 } // for 40 44 } 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 } 41 55 } // namespace CodeGen 42 56 -
src/CodeGen/Generate.h
r43426d4 r982ed5b 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 gdb 29 void generate( BaseSyntaxNode * node, std::ostream & os ); 27 30 } // namespace CodeGen 28 31 -
src/GenPoly/PolyMutator.cc
r43426d4 r982ed5b 50 50 51 51 Statement * PolyMutator::mutateStatement( Statement *stmt ) { 52 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 53 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 52 59 Statement *newStmt = maybeMutate( stmt, *this ); 53 60 if ( ! stmtsToAdd.empty() || ! stmtsToAddAfter.empty() ) { … … 83 90 84 91 Statement * PolyMutator::mutate(IfStmt *ifStmt) { 92 ifStmt->set_condition( mutateExpression( ifStmt->get_condition() ) ); 85 93 ifStmt->set_thenPart( mutateStatement( ifStmt->get_thenPart() ) ); 86 94 ifStmt->set_elsePart( mutateStatement( ifStmt->get_elsePart() ) ); 87 ifStmt->set_condition( mutateExpression( ifStmt->get_condition() ) );88 95 return ifStmt; 89 96 } 90 97 91 98 Statement * PolyMutator::mutate(WhileStmt *whileStmt) { 99 whileStmt->set_condition( mutateExpression( whileStmt->get_condition() ) ); 92 100 whileStmt->set_body( mutateStatement( whileStmt->get_body() ) ); 93 whileStmt->set_condition( mutateExpression( whileStmt->get_condition() ) );94 101 return whileStmt; 95 102 } 96 103 97 104 Statement * PolyMutator::mutate(ForStmt *forStmt) { 98 forStmt->set_body( mutateStatement( forStmt->get_body() ) );99 105 mutateAll( forStmt->get_initialization(), *this ); 100 106 forStmt->set_condition( mutateExpression( forStmt->get_condition() ) ); 101 107 forStmt->set_increment( mutateExpression( forStmt->get_increment() ) ); 108 forStmt->set_body( mutateStatement( forStmt->get_body() ) ); 102 109 return forStmt; 103 110 } 104 111 105 112 Statement * PolyMutator::mutate(SwitchStmt *switchStmt) { 113 switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) ); 106 114 mutateStatementList( switchStmt->get_statements() ); 107 switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) );108 115 return switchStmt; 109 116 } 110 117 111 118 Statement * PolyMutator::mutate(CaseStmt *caseStmt) { 119 caseStmt->set_condition( mutateExpression( caseStmt->get_condition() ) ); 112 120 mutateStatementList( caseStmt->get_statements() ); 113 caseStmt->set_condition( mutateExpression( caseStmt->get_condition() ) );114 121 return caseStmt; 115 122 } -
src/ResolvExpr/AlternativeFinder.cc
r43426d4 r982ed5b 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 768 769 candidates.clear(); 770 candidates.splice( candidates.end(), alternatives ); 771 772 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 implicit 775 // conversions to each of the anonymous members, must happen after findMinCost since anon conversions 776 // are never the cheapest expression 769 777 for ( const Alternative & alt : alternatives ) { 770 778 addAnonConversions( alt ); 771 779 } 772 773 candidates.clear();774 candidates.splice( candidates.end(), alternatives );775 776 findMinCost( candidates.begin(), candidates.end(), std::back_inserter( alternatives ) );777 780 778 781 if ( alternatives.empty() && targetType && ! targetType->isVoid() ) { -
src/SynTree/BaseSyntaxNode.h
r43426d4 r982ed5b 18 18 19 19 #include "Common/utility.h" 20 #include "Visitor.h" 20 21 21 22 class BaseSyntaxNode { 22 23 public: 23 24 CodeLocation location; 25 26 virtual void accept( Visitor & v ) = 0; // temporary -- needs to be here so that BaseSyntaxNode is polymorphic and can be dynamic_cast 24 27 }; 25 28 -
src/SynTree/Declaration.h
r43426d4 r982ed5b 204 204 205 205 virtual std::string typeString() const; 206 virtual std::string genTypeString() const; 206 207 207 208 virtual TypeDecl *clone() const { return new TypeDecl( *this ); } -
src/SynTree/SynTree.h
r43426d4 r982ed5b 21 21 #include <map> 22 22 #include <iostream> 23 24 class BaseSyntaxNode; 23 25 24 26 class Declaration; -
src/SynTree/TypeDecl.cc
r43426d4 r982ed5b 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 31 36 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) { 32 37 return os << data.kind << ", " << data.isComplete;
Note: See TracChangeset
for help on using the changeset viewer.