Ignore:
Timestamp:
Sep 1, 2017, 2:42:12 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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)
Message:

Remove TraitDecl? prior to CodeGen?, add debug codegen for TraitDecl?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/Generate.cc

    r2bf9c37 ra984e65  
    2121#include "CodeGenerator.h"           // for CodeGenerator, doSemicolon, oper...
    2222#include "GenType.h"                 // for genPrettyType
     23#include "Common/PassVisitor.h"      // for PassVisitor
    2324#include "Parser/LinkageSpec.h"      // for isBuiltin, isGeneratable
    2425#include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
     
    2930
    3031namespace 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
    3147        void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC, bool lineMarks ) {
     48                cleanTree( translationUnit );
     49
    3250                CodeGen::CodeGenerator cgv( os, pretty, generateC, lineMarks );
    3351                for ( auto & dcl : translationUnit ) {
     
    5270                os << std::endl;
    5371        }
     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
    5487} // namespace CodeGen
    5588
Note: See TracChangeset for help on using the changeset viewer.