Changeset 982ed5b for src


Ignore:
Timestamp:
May 5, 2017, 1:38:42 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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.
Message:

Merge branches 'master' and 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r43426d4 r982ed5b  
    262262                        } // if
    263263                } 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                        }
    265268                        if ( ! typeDecl->get_assertions().empty() ) {
    266269                                output << " | { ";
     
    769772        void CodeGenerator::visit( ExprStmt * exprStmt ) {
    770773                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                }
    773779                expr->accept( *this );
    774780                output << ";";
  • src/CodeGen/Generate.cc

    r43426d4 r982ed5b  
    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

    r43426d4 r982ed5b  
    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/GenPoly/PolyMutator.cc

    r43426d4 r982ed5b  
    5050
    5151        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
    5259                Statement *newStmt = maybeMutate( stmt, *this );
    5360                if ( ! stmtsToAdd.empty() || ! stmtsToAddAfter.empty() ) {
     
    8390
    8491        Statement * PolyMutator::mutate(IfStmt *ifStmt) {
     92                ifStmt->set_condition(  mutateExpression( ifStmt->get_condition() ) );
    8593                ifStmt->set_thenPart(  mutateStatement( ifStmt->get_thenPart() ) );
    8694                ifStmt->set_elsePart(  mutateStatement( ifStmt->get_elsePart() ) );
    87                 ifStmt->set_condition(  mutateExpression( ifStmt->get_condition() ) );
    8895                return ifStmt;
    8996        }
    9097
    9198        Statement * PolyMutator::mutate(WhileStmt *whileStmt) {
     99                whileStmt->set_condition(  mutateExpression( whileStmt->get_condition() ) );
    92100                whileStmt->set_body(  mutateStatement( whileStmt->get_body() ) );
    93                 whileStmt->set_condition(  mutateExpression( whileStmt->get_condition() ) );
    94101                return whileStmt;
    95102        }
    96103
    97104        Statement * PolyMutator::mutate(ForStmt *forStmt) {
    98                 forStmt->set_body(  mutateStatement( forStmt->get_body() ) );
    99105                mutateAll( forStmt->get_initialization(), *this );
    100106                forStmt->set_condition(  mutateExpression( forStmt->get_condition() ) );
    101107                forStmt->set_increment(  mutateExpression( forStmt->get_increment() ) );
     108                forStmt->set_body(  mutateStatement( forStmt->get_body() ) );
    102109                return forStmt;
    103110        }
    104111
    105112        Statement * PolyMutator::mutate(SwitchStmt *switchStmt) {
     113                switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) );
    106114                mutateStatementList( switchStmt->get_statements() );
    107                 switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) );
    108115                return switchStmt;
    109116        }
    110117
    111118        Statement * PolyMutator::mutate(CaseStmt *caseStmt) {
     119                caseStmt->set_condition(  mutateExpression( caseStmt->get_condition() ) );
    112120                mutateStatementList( caseStmt->get_statements() );
    113                 caseStmt->set_condition(  mutateExpression( caseStmt->get_condition() ) );
    114121                return caseStmt;
    115122        }
  • src/ResolvExpr/AlternativeFinder.cc

    r43426d4 r982ed5b  
    766766                        } // if
    767767                } // 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
    769777                for ( const Alternative & alt : alternatives ) {
    770778                        addAnonConversions( alt );
    771779                }
    772 
    773                 candidates.clear();
    774                 candidates.splice( candidates.end(), alternatives );
    775 
    776                 findMinCost( candidates.begin(), candidates.end(), std::back_inserter( alternatives ) );
    777780
    778781                if ( alternatives.empty() && targetType && ! targetType->isVoid() ) {
  • src/SynTree/BaseSyntaxNode.h

    r43426d4 r982ed5b  
    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/Declaration.h

    r43426d4 r982ed5b  
    204204
    205205        virtual std::string typeString() const;
     206        virtual std::string genTypeString() const;
    206207
    207208        virtual TypeDecl *clone() const { return new TypeDecl( *this ); }
  • src/SynTree/SynTree.h

    r43426d4 r982ed5b  
    2121#include <map>
    2222#include <iostream>
     23
     24class BaseSyntaxNode;
    2325
    2426class Declaration;
  • src/SynTree/TypeDecl.cc

    r43426d4 r982ed5b  
    2929}
    3030
     31std::string TypeDecl::genTypeString() const {
     32        static const std::string kindNames[] = { "otype", "dtype", "ftype", "ttype" };
     33        return kindNames[ kind ];
     34}
     35
    3136std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) {
    3237  return os << data.kind << ", " << data.isComplete;
Note: See TracChangeset for help on using the changeset viewer.