Changes in / [4f9636f:bd951f7]


Ignore:
Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r4f9636f rbd951f7  
    262262                        } // if
    263263                } else {
    264                         output << typeDecl->genTypeString() << " " << typeDecl->get_name();
    265                         if ( typeDecl->get_kind() != TypeDecl::Any && typeDecl->get_sized() ) {
    266                                 output << " | sized(" << typeDecl->get_name() << ")";
    267                         }
     264                        output << typeDecl->typeString() << " " << typeDecl->get_name();
    268265                        if ( ! typeDecl->get_assertions().empty() ) {
    269266                                output << " | { ";
     
    772769        void CodeGenerator::visit( ExprStmt * exprStmt ) {
    773770                assert( exprStmt );
    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                 }
     771                // cast the top-level expression to void to reduce gcc warnings.
     772                Expression * expr = new CastExpr( exprStmt->get_expr() );
    779773                expr->accept( *this );
    780774                output << ";";
  • src/CodeGen/Generate.cc

    r4f9636f rbd951f7  
    2222#include "SynTree/Declaration.h"
    2323#include "CodeGenerator.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"
     24#include "Tuples/Tuples.h"
    2925
    3026using namespace std;
     
    4339                } // for
    4440        }
    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         }
    5541} // namespace CodeGen
    5642
  • src/CodeGen/Generate.h

    r4f9636f rbd951f7  
    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 );
    3027} // namespace CodeGen
    3128
  • src/GenPoly/PolyMutator.cc

    r4f9636f rbd951f7  
    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 
    5952                Statement *newStmt = maybeMutate( stmt, *this );
    6053                if ( ! stmtsToAdd.empty() || ! stmtsToAddAfter.empty() ) {
     
    9083
    9184        Statement * PolyMutator::mutate(IfStmt *ifStmt) {
    92                 ifStmt->set_condition(  mutateExpression( ifStmt->get_condition() ) );
    9385                ifStmt->set_thenPart(  mutateStatement( ifStmt->get_thenPart() ) );
    9486                ifStmt->set_elsePart(  mutateStatement( ifStmt->get_elsePart() ) );
     87                ifStmt->set_condition(  mutateExpression( ifStmt->get_condition() ) );
    9588                return ifStmt;
    9689        }
    9790
    9891        Statement * PolyMutator::mutate(WhileStmt *whileStmt) {
     92                whileStmt->set_body(  mutateStatement( whileStmt->get_body() ) );
    9993                whileStmt->set_condition(  mutateExpression( whileStmt->get_condition() ) );
    100                 whileStmt->set_body(  mutateStatement( whileStmt->get_body() ) );
    10194                return whileStmt;
    10295        }
    10396
    10497        Statement * PolyMutator::mutate(ForStmt *forStmt) {
     98                forStmt->set_body(  mutateStatement( forStmt->get_body() ) );
    10599                mutateAll( forStmt->get_initialization(), *this );
    106100                forStmt->set_condition(  mutateExpression( forStmt->get_condition() ) );
    107101                forStmt->set_increment(  mutateExpression( forStmt->get_increment() ) );
    108                 forStmt->set_body(  mutateStatement( forStmt->get_body() ) );
    109102                return forStmt;
    110103        }
    111104
    112105        Statement * PolyMutator::mutate(SwitchStmt *switchStmt) {
     106                mutateStatementList( switchStmt->get_statements() );
    113107                switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) );
    114                 mutateStatementList( switchStmt->get_statements() );
    115108                return switchStmt;
    116109        }
    117110
    118111        Statement * PolyMutator::mutate(CaseStmt *caseStmt) {
     112                mutateStatementList( caseStmt->get_statements() );
    119113                caseStmt->set_condition(  mutateExpression( caseStmt->get_condition() ) );
    120                 mutateStatementList( caseStmt->get_statements() );
    121114                return caseStmt;
    122115        }
  • src/ResolvExpr/AlternativeFinder.cc

    r4f9636f rbd951f7  
    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
     769                for ( const Alternative & alt : alternatives ) {
     770                        addAnonConversions( alt );
     771                }
    768772
    769773                candidates.clear();
     
    771775
    772776                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
    777                 for ( const Alternative & alt : alternatives ) {
    778                         addAnonConversions( alt );
    779                 }
    780777
    781778                if ( alternatives.empty() && targetType && ! targetType->isVoid() ) {
  • src/SynTree/BaseSyntaxNode.h

    r4f9636f rbd951f7  
    1818
    1919#include "Common/utility.h"
    20 #include "Visitor.h"
    2120
    2221class BaseSyntaxNode {
    2322  public:
    2423        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
    2724};
    2825
  • src/SynTree/Declaration.h

    r4f9636f rbd951f7  
    204204
    205205        virtual std::string typeString() const;
    206         virtual std::string genTypeString() const;
    207206
    208207        virtual TypeDecl *clone() const { return new TypeDecl( *this ); }
  • src/SynTree/SynTree.h

    r4f9636f rbd951f7  
    2121#include <map>
    2222#include <iostream>
    23 
    24 class BaseSyntaxNode;
    2523
    2624class Declaration;
  • src/SynTree/TypeDecl.cc

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