Changeset 262f085f for src/CodeGen


Ignore:
Timestamp:
May 5, 2017, 11:05:12 AM (8 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:
45a4ea7
Parents:
bdd0755
Message:

add version of CodeGen::generate for a single node for use in gdb

Location:
src/CodeGen
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rbdd0755 r262f085f  
    772772        void CodeGenerator::visit( ExprStmt * exprStmt ) {
    773773                assert( exprStmt );
    774                 // cast the top-level expression to void to reduce gcc warnings.
    775                 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                }
    776779                expr->accept( *this );
    777780                output << ";";
  • src/CodeGen/Generate.cc

    rbdd0755 r262f085f  
    2222#include "SynTree/Declaration.h"
    2323#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"
    2529
    2630using namespace std;
     
    3943                } // for
    4044        }
     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        }
    4155} // namespace CodeGen
    4256
  • src/CodeGen/Generate.h

    rbdd0755 r262f085f  
    2525        /// 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.)
    2626        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 );
    2730} // namespace CodeGen
    2831
Note: See TracChangeset for help on using the changeset viewer.