Changeset 262f085f


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
Files:
5 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
  • src/SynTree/BaseSyntaxNode.h

    rbdd0755 r262f085f  
    1818
    1919#include "Common/utility.h"
     20#include "Visitor.h"
    2021
    2122class BaseSyntaxNode {
    2223  public:
    2324        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
    2427};
    2528
  • src/SynTree/SynTree.h

    rbdd0755 r262f085f  
    2121#include <map>
    2222#include <iostream>
     23
     24class BaseSyntaxNode;
    2325
    2426class Declaration;
Note: See TracChangeset for help on using the changeset viewer.