Changeset a984e65 for src/CodeGen
- Timestamp:
- Sep 1, 2017, 2:42:12 PM (7 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:
- 51c6353
- Parents:
- 2bf9c37
- git-author:
- Rob Schluntz <rschlunt@…> (09/01/17 14:41:42)
- git-committer:
- Rob Schluntz <rschlunt@…> (09/01/17 14:42:12)
- Location:
- src/CodeGen
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r2bf9c37 ra984e65 195 195 } 196 196 197 output << kind; 198 if ( aggDecl->get_name() != "" ) 199 output << aggDecl->get_name(); 197 output << kind << aggDecl->get_name(); 200 198 201 199 if ( aggDecl->has_body() ) { … … 233 231 genAttributes( enumDecl->get_attributes() ); 234 232 235 if ( enumDecl->get_name() != "" ) 236 output << enumDecl->get_name(); 233 output << enumDecl->get_name(); 237 234 238 235 std::list< Declaration* > &memb = enumDecl->get_members(); … … 260 257 } 261 258 262 void CodeGenerator::visit( __attribute__((unused)) TraitDecl * traitDecl ) {} 259 void CodeGenerator::visit( TraitDecl * traitDecl ) { 260 assertf( ! genC, "TraitDecl nodes should not reach code generation." ); 261 extension( traitDecl ); 262 handleAggregate( traitDecl, "trait " ); 263 } 263 264 264 265 void CodeGenerator::visit( TypedefDecl * typeDecl ) { -
src/CodeGen/Generate.cc
r2bf9c37 ra984e65 21 21 #include "CodeGenerator.h" // for CodeGenerator, doSemicolon, oper... 22 22 #include "GenType.h" // for genPrettyType 23 #include "Common/PassVisitor.h" // for PassVisitor 23 24 #include "Parser/LinkageSpec.h" // for isBuiltin, isGeneratable 24 25 #include "SynTree/BaseSyntaxNode.h" // for BaseSyntaxNode … … 29 30 30 31 namespace CodeGen { 32 namespace { 33 /// Removes misc. nodes that should not exist in CodeGen 34 struct TreeCleaner { 35 void visit( CompoundStmt * stmt ); 36 37 static bool shouldClean( Declaration * ); 38 }; 39 40 void cleanTree( std::list< Declaration * > & translationUnit ) { 41 PassVisitor<TreeCleaner> cleaner; 42 filter( translationUnit, [](Declaration * decl) { return TreeCleaner::shouldClean(decl); }, false ); 43 acceptAll( translationUnit, cleaner ); 44 } // cleanTree 45 } // namespace 46 31 47 void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC, bool lineMarks ) { 48 cleanTree( translationUnit ); 49 32 50 CodeGen::CodeGenerator cgv( os, pretty, generateC, lineMarks ); 33 51 for ( auto & dcl : translationUnit ) { … … 52 70 os << std::endl; 53 71 } 72 73 namespace { 74 void TreeCleaner::visit( CompoundStmt * cstmt ) { 75 filter( cstmt->kids, [](Statement * stmt) { 76 if ( DeclStmt * declStmt = dynamic_cast< DeclStmt * >( stmt ) ) { 77 return shouldClean( declStmt->decl ); 78 } 79 return false; 80 }, false ); 81 } 82 83 bool TreeCleaner::shouldClean( Declaration * decl ) { 84 return dynamic_cast< TraitDecl * >( decl ); 85 } 86 } // namespace 54 87 } // namespace CodeGen 55 88
Note: See TracChangeset
for help on using the changeset viewer.