Changes in / [e365cb5:37bf576]


Ignore:
Location:
src
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • src/ArgTweak/FunctionFixer.cc

    re365cb5 r37bf576  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FunctionFixer.cc --
     7// FunctionFixer.cc -- 
    88//
    99// Author           : Rodolfo G. Esteves
     
    4242        Expression *FunctionFixer::mutate( UntypedExpr *untypedExpr ) throw ( SemanticError ) {
    4343                assert( untypedExpr != 0 );
     44                NameExpr *function;
    4445
    45                 if ( NameExpr * function = dynamic_cast< NameExpr *>(untypedExpr->get_function() ) ) {
     46                if ( ( function = dynamic_cast< NameExpr *>(untypedExpr->get_function()) ) != 0 ) {
    4647                        std::list < DeclarationWithType * > options;
    4748                        index->lookupId ( function->get_name(), options );
    4849                        for ( std::list < DeclarationWithType * >::iterator i = options.begin(); i != options.end(); i++ ) {
    49                                 if ( FunctionType * f = dynamic_cast< FunctionType * > ( (*i)->get_type() ) )   {
     50                                FunctionType *f;
     51                                if ( ( f = dynamic_cast< FunctionType * > ( (*i)->get_type() ) ) != 0 ) {
    5052                                        std::list < DeclarationWithType * > &pars = f->get_parameters();
     53
    5154                                        bool candidateExists ;
    52                                         for ( std::list < DeclarationWithType * >::iterator p = pars.begin(); p != pars.end(); p++ ) {
     55                                        for ( std::list < DeclarationWithType * >::iterator p = pars.begin(); p != pars.end(); p++ )
    5356                                                if ( ( candidateExists = align( f->get_parameters(), untypedExpr->get_args(), Matcher() ) ) ) break;
    54                                         }
     57
    5558                                        if ( ! candidateExists ) throw SemanticError("Error in function call");
    5659                                } // if
  • src/CodeGen/CodeGenerator.cc

    re365cb5 r37bf576  
    3333#include "OperatorTable.h"
    3434#include "GenType.h"
    35 
    36 #include "InitTweak/InitTweak.h"
    3735
    3836using namespace std;
     
    257255                                std::list< Expression* >::iterator arg = applicationExpr->get_args().begin();
    258256                                switch ( opInfo.type ) {
    259                                   case OT_CTOR:
    260                                   case OT_DTOR:
    261                                         {
    262                                                 // if the first argument's type is const then GCC complains. In this
    263                                                 // case, output an explicit ctor/dtor call and exit, rather than following
    264                                                 // the normal path
    265                                                 assert( arg != applicationExpr->get_args().end() );
    266                                                 assert( (*arg)->get_results().size() >= 1 );
    267                                                 Type * baseType = InitTweak::getPointerBase( (*arg)->get_results().front() );
    268                                                 if ( baseType->get_isConst() ) {
    269                                                         // cast away the qualifiers, to eliminate warnings
    270                                                         Type * newType = baseType->clone();
    271                                                         newType->get_qualifiers() = Type::Qualifiers();
    272                                                         *arg = new CastExpr( *arg, new PointerType( Type::Qualifiers(), newType ) );
    273                                                         varExpr->accept( *this );
    274                                                         output << "(";
    275                                                         genCommaList( applicationExpr->get_args().begin(), applicationExpr->get_args().end() );
    276                                                         output << ")";
    277                                                         return;
    278                                                 }
    279                                         }
    280                                         // intentional fallthrough - instrinsic ctor/dtor for non-const objects should
    281                                         // be handled the same way as assignment
    282257                                  case OT_PREFIXASSIGN:
    283258                                  case OT_POSTFIXASSIGN:
    284259                                  case OT_INFIXASSIGN:
     260                                  case OT_CTOR:
     261                                  case OT_DTOR:
    285262                                        {
    286263                                                assert( arg != applicationExpr->get_args().end() );
     
    292269                                                        UntypedExpr *newExpr = new UntypedExpr( new NameExpr( "*?" ) );
    293270                                                        newExpr->get_args().push_back( *arg );
    294                                                         assert( (*arg)->get_results().size() == 1 );
    295                                                         Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() );
    296                                                         assert( type );
    297                                                         newExpr->get_results().push_back( type );
    298271                                                        *arg = newExpr;
    299272                                                } // if
  • src/GenPoly/Box.cc

    re365cb5 r37bf576  
    19471947                                UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) );
    19481948                                derefExpr->get_args().push_back( derefdVar );
    1949                                 // xxx - should set results on derefExpr
    19501949                                derefdVar = derefExpr;
    19511950                        }
  • src/InitTweak/FixGlobalInit.cc

    re365cb5 r37bf576  
    125125                std::list< Statement * > & destroyStatements = destroyFunction->get_statements()->get_kids();
    126126
     127                // if ( objDecl->get_init() == NULL ) return;
    127128                if ( ! tryConstruct( objDecl ) ) return; // don't construct @= or designated objects
     129                if ( objDecl->get_type()->get_isConst() ) return; // temporary: can't assign to a const variable
    128130                if ( objDecl->get_storageClass() == DeclarationNode::Extern ) return;
    129131                // C allows you to initialize objects with constant expressions
     
    144146                        init->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) );
    145147                        init->get_args().push_back( new VariableExpr( newObj ) );
    146                         initStatements.push_back( new ImplicitCtorDtorStmt( new ExprStmt( noLabels, init ) ) );
     148                        initStatements.push_back( new ExprStmt( noLabels, init ) );
    147149
    148150                        // add destructor calls to global destroy function
    149151                        UntypedExpr * destroy = new UntypedExpr( new NameExpr( "^?{}" ) );
    150152                        destroy->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) );
    151                         destroyStatements.push_front( new ImplicitCtorDtorStmt( new ExprStmt( noLabels, destroy ) ) );
     153                        destroyStatements.push_front( new ExprStmt( noLabels, destroy ) );
    152154                }
    153155        }
  • src/InitTweak/FixInit.cc

    re365cb5 r37bf576  
    132132                                return appExpr;
    133133                        } else if ( DeclarationWithType * funcDecl = dynamic_cast< DeclarationWithType * > ( function->get_var() ) ) {
     134                                // FunctionType * ftype = funcDecl->get_functionType();
    134135                                FunctionType * ftype = dynamic_cast< FunctionType * >( GenPoly::getFunctionType( funcDecl->get_type() ) );
    135136                                assert( ftype );
  • src/InitTweak/GenInit.cc

    re365cb5 r37bf576  
    164164                                                assert( ctor.size() == 1 );
    165165                                                assert( dtor.size() == 1 );
    166                                                 objDecl->set_init( new ConstructorInit( new ImplicitCtorDtorStmt( ctor.front() ), new ImplicitCtorDtorStmt( dtor.front() ), objDecl->get_init() ) );
     166
     167                                                objDecl->set_init( new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ) );
    167168                                        } else {
    168169                                                // array came with an initializer list: initialize each element
     
    184185                                        ExprStmt * ctorStmt = new ExprStmt( noLabels, ctor );
    185186                                        ExprStmt * dtorStmt = new ExprStmt( noLabels, dtor );
    186                                         objDecl->set_init( new ConstructorInit( new ImplicitCtorDtorStmt( ctorStmt ), new ImplicitCtorDtorStmt( dtorStmt ), objDecl->get_init() ) );
     187                                        objDecl->set_init( new ConstructorInit( ctorStmt, dtorStmt, objDecl->get_init() ) );
    187188                                }
    188189                        }
  • src/InitTweak/InitTweak.cc

    re365cb5 r37bf576  
    6060  }
    6161
    62   Expression * getCtorDtorCall( Statement * stmt ) {
    63     if ( stmt == NULL ) return NULL;
     62  bool isInstrinsicSingleArgCallStmt( Statement * stmt ) {
     63    if ( stmt == NULL ) return false;
    6464    if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) {
    65       return exprStmt->get_expr();
     65      ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( exprStmt->get_expr() );
     66      assert( appExpr );
     67      VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() );
     68      assert( function );
     69      // check for Intrinsic only - don't want to remove all overridable ctor/dtors because autogenerated ctor/dtor
     70      // will call all member dtors, and some members may have a user defined dtor.
     71      FunctionType * funcType = GenPoly::getFunctionType( function->get_var()->get_type() );
     72      assert( funcType );
     73      return function->get_var()->get_linkage() == LinkageSpec::Intrinsic && funcType->get_parameters().size() == 1;
    6674    } else if ( CompoundStmt * compoundStmt = dynamic_cast< CompoundStmt * >( stmt ) ) {
    6775      // could also be a compound statement with a loop, in the case of an array
     
    6977      ForStmt * forStmt = dynamic_cast< ForStmt * >( compoundStmt->get_kids().back() );
    7078      assert( forStmt && forStmt->get_body() );
    71       return getCtorDtorCall( forStmt->get_body() );
    72     } if ( ImplicitCtorDtorStmt * impCtorDtorStmt = dynamic_cast< ImplicitCtorDtorStmt * > ( stmt ) ) {
    73       return getCtorDtorCall( impCtorDtorStmt->get_callStmt() );
     79      return isInstrinsicSingleArgCallStmt( forStmt->get_body() );
    7480    } else {
    7581      // should never get here
     
    7783    }
    7884  }
    79 
    80   bool isInstrinsicSingleArgCallStmt( Statement * stmt ) {
    81     Expression * callExpr = getCtorDtorCall( stmt );
    82     if ( ! callExpr ) return false;
    83     ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( callExpr );
    84     assert( appExpr );
    85     VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() );
    86     assert( function );
    87     // check for Intrinsic only - don't want to remove all overridable ctor/dtors because autogenerated ctor/dtor
    88     // will call all member dtors, and some members may have a user defined dtor.
    89     FunctionType * funcType = GenPoly::getFunctionType( function->get_var()->get_type() );
    90     assert( funcType );
    91     return function->get_var()->get_linkage() == LinkageSpec::Intrinsic && funcType->get_parameters().size() == 1;
    92   }
    93 
    94   namespace {
    95     template<typename CallExpr>
    96     Expression * callArg( CallExpr * callExpr, unsigned int pos ) {
    97       if ( pos >= callExpr->get_args().size() ) assert( false && "asking for argument that doesn't exist. Return NULL/throw exception?" );
    98       for ( Expression * arg : callExpr->get_args() ) {
    99         if ( pos == 0 ) return arg;
    100         pos--;
    101       }
    102       assert( false );
    103     }
    104   }
    105 
    106   Expression * getCallArg( Expression * callExpr, unsigned int pos ) {
    107     if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( callExpr ) ) {
    108       return callArg( appExpr, pos );
    109     } else if ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * >( callExpr ) ) {
    110       return callArg( untypedExpr, pos );
    111     } else {
    112       assert( false && "Unexpected expression type passed to getCallArg" );
    113     }
    114   }
    115 
    116   namespace {
    117     template<typename CallExpr>
    118     std::string funcName( CallExpr * expr ) {
    119       Expression * func = expr->get_function();
    120       if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( func ) ) {
    121         return nameExpr->get_name();
    122       } else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( func ) ) {
    123         return varExpr->get_var()->get_name();
    124       } else {
    125         assert( false && "Unexpected expression type being called as a function in call expression" );
    126       }
    127     }
    128   }
    129 
    130   std::string getFunctionName( Expression * expr ) {
    131     if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr ) ) {
    132       return funcName( appExpr );
    133     } else if ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * > ( expr ) ) {
    134       return funcName( untypedExpr );
    135     } else {
    136       assert( false && "Unexpected expression type passed to getFunctionName" );
    137     }
    138   }
    139 
    140   Type * getPointerBase( Type * type ) {
    141     if ( PointerType * ptrType = dynamic_cast< PointerType * >( type ) ) {
    142       return ptrType->get_base();
    143     } else if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) {
    144       return arrayType->get_base();
    145     } else {
    146       return NULL;
    147     }
    148   }
    149 
    15085}
  • src/InitTweak/InitTweak.h

    re365cb5 r37bf576  
    3939  /// Currently has assertions that make it less than fully general.
    4040  bool isInstrinsicSingleArgCallStmt( Statement * expr );
    41 
    42   /// get the Ctor/Dtor call expression from a Statement that looks like a generated ctor/dtor call
    43   Expression * getCtorDtorCall( Statement * stmt );
    44 
    45   /// returns the name of the function being called
    46   std::string getFunctionName( Expression * expr );
    47 
    48   /// returns the argument to a call expression in position N indexed from 0
    49   Expression * getCallArg( Expression * callExpr, unsigned int pos );
    50 
    51   /// returns the base type of a PointerType or ArrayType
    52   Type * getPointerBase( Type * );
    5341} // namespace
    5442
  • src/ResolvExpr/AlternativeFinder.cc

    re365cb5 r37bf576  
    3939#include "Tuples/NameMatcher.h"
    4040#include "Common/utility.h"
    41 #include "InitTweak/InitTweak.h"
    4241
    4342extern bool resolvep;
     
    547546
    548547                {
    549                         std::string fname = InitTweak::getFunctionName( untypedExpr );
    550                         if ( fname == "&&" ) {
     548                        NameExpr *fname = 0;;
     549                        if ( ( fname = dynamic_cast<NameExpr *>( untypedExpr->get_function()))
     550                                 && ( fname->get_name() == std::string("&&")) ) {
    551551                                VoidType v = Type::Qualifiers();                // resolve to type void *
    552552                                PointerType pt( Type::Qualifiers(), v.clone() );
  • src/ResolvExpr/Resolver.cc

    re365cb5 r37bf576  
    5252                virtual void visit( BranchStmt *branchStmt );
    5353                virtual void visit( ReturnStmt *returnStmt );
    54                 virtual void visit( ImplicitCtorDtorStmt * impCtorDtorStmt );
    5554
    5655                virtual void visit( SingleInit *singleInit );
     
    493492                } catch ( SemanticError ) {
    494493                        // no alternatives for the constructor initializer - fallback on C-style initializer
    495                         // xxx - not sure if this makes a ton of sense - should maybe never be able to have this situation?
     494                        // xxx- not sure if this makes a ton of sense - should maybe never be able to have this situation?
    496495                        fallbackInit( ctorInit );
    497496                        return;
     
    514513                }
    515514        }
    516 
    517         void Resolver::visit( ImplicitCtorDtorStmt * impCtorDtorStmt ) {
    518                 // this code is fairly gross. If VariableExpr didn't have its own results list then this could be cleaned up a bit
    519                 // by remembering the ObjectDecl in the ImplicitCtorDtorStmt and changing the ObjectDecl's type temporarily, but currently
    520                 // VariableExprs have their own type list which is manipulated in AlternativeFinder (e.g. in inferRecursive).
    521 
    522                 // before resolving ctor/dtor, need to remove type qualifiers from the first argument (the object being constructed)
    523                 Expression * callExpr = InitTweak::getCtorDtorCall( impCtorDtorStmt );
    524                 assert( callExpr );
    525                 Expression * constructee = InitTweak::getCallArg( callExpr, 0 );
    526                 Type * type = 0;
    527                 if ( UntypedExpr * plusExpr = dynamic_cast< UntypedExpr * >( constructee ) ) {
    528                         // constructee is <array>+<index>
    529                         // get Variable <array>, then get the base type of the VariableExpr - this is the type that needs to be fixed
    530                         Expression * arr = InitTweak::getCallArg( plusExpr, 0 );
    531                         assert( dynamic_cast< VariableExpr * >( arr ) );
    532                         assert( arr && arr->get_results().size() == 1 );
    533                         type = InitTweak::getPointerBase( arr->get_results().front() );
    534                         assert( type );
    535                 } else {
    536                         // otherwise, constructing a plain object, which means the object's address is being taken.
    537                         // Need to get the type of the VariableExpr object, because the AddressExpr is rebuilt and uses the
    538                         // type of the VariableExpr to do so.
    539                         assert( constructee->get_results().size() == 1 );
    540                         AddressExpr * addrExpr = dynamic_cast< AddressExpr * > ( constructee );
    541                         assert( addrExpr );
    542                         VariableExpr * varExpr = dynamic_cast< VariableExpr * >( addrExpr->get_arg() );
    543                         assert( varExpr && varExpr->get_results().size() == 1 );
    544                         type = varExpr->get_results().front();
    545                 }
    546                 // remember qualifiers so they can be replaced
    547                 Type::Qualifiers qualifiers = type->get_qualifiers();
    548 
    549                 // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
    550                 // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
    551                 // remove lvalue as a qualifier, this can change to
    552                 //   type->get_qualifiers() = Type::Qualifiers();
    553                 type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, true);
    554 
    555                 // finally, resolve the ctor/dtor
    556                 impCtorDtorStmt->get_callStmt()->accept( *this );
    557 
    558                 // reset type qualifiers, but first need to figure out where everything is again
    559                 // because the expressions are often changed by the resolver.
    560                 callExpr = InitTweak::getCtorDtorCall( impCtorDtorStmt );
    561                 assert( callExpr );
    562                 constructee = InitTweak::getCallArg( callExpr, 0 );
    563                 if ( ApplicationExpr * plusExpr = dynamic_cast< ApplicationExpr * >( constructee ) ) {
    564                         // constructee is <array>+<index>
    565                         // get Variable <array>, then get the base type of the VariableExpr - this is the type that needs to be fixed
    566                         Expression * arr = InitTweak::getCallArg( plusExpr, 0 );
    567                         assert( dynamic_cast< VariableExpr * >( arr ) );
    568                         assert( arr && arr->get_results().size() == 1 );
    569                         type = InitTweak::getPointerBase( arr->get_results().front() );
    570                         assert( type );
    571                         type->get_qualifiers() = qualifiers;
    572                 } else {
    573                         // otherwise constructing a plain object
    574                         // replace qualifiers on AddressExpr and on inner VariableExpr
    575                         assert( constructee->get_results().size() == 1 );
    576                         AddressExpr * addrExpr = dynamic_cast< AddressExpr * > ( constructee );
    577                         assert( addrExpr );
    578                         type = InitTweak::getPointerBase( addrExpr->get_results().front() );
    579                         assert( type );
    580                         type->get_qualifiers() = qualifiers;
    581 
    582                         VariableExpr * varExpr = dynamic_cast< VariableExpr * >( addrExpr->get_arg() );
    583                         assert( varExpr && varExpr->get_results().size() == 1 );
    584                         type = varExpr->get_results().front();
    585                         type->get_qualifiers() = qualifiers;
    586                 }
    587         }
    588515} // namespace ResolvExpr
    589516
  • src/SynTree/Initializer.cc

    re365cb5 r37bf576  
    2020
    2121Initializer::Initializer( bool maybeConstructed ) : maybeConstructed( maybeConstructed ) {}
    22 Initializer::Initializer( const Initializer & other ) : maybeConstructed( other.maybeConstructed ) {
    23 }
    24 
    2522
    2623Initializer::~Initializer() {}
     
    4239}
    4340
    44 SingleInit::~SingleInit() {
    45         deleteAll(designators);
    46 }
     41SingleInit::~SingleInit() {}
     42
     43SingleInit *SingleInit::clone() const { return new SingleInit( *this); }
    4744
    4845void SingleInit::print( std::ostream &os, int indent ) {
     
    6158
    6259ListInit::ListInit( const std::list<Initializer*> &_initializers, const std::list<Expression *> &_designators, bool maybeConstructed )
    63         : Initializer( maybeConstructed ), initializers( _initializers ), designators( _designators ) {
     60        : Initializer( maybeConstructed), initializers( _initializers ), designators( _designators ) {
    6461}
    6562
    66 ListInit::~ListInit() {
    67         deleteAll( initializers );
    68         deleteAll( designators );
     63ListInit::~ListInit() {}
     64
     65ListInit *ListInit::clone() const {
     66        return new ListInit( *this );
    6967}
    7068
     
    8785
    8886ConstructorInit::ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init ) : Initializer( true ), ctor( ctor ), dtor( dtor ), init( init ) {}
    89 ConstructorInit::ConstructorInit( const ConstructorInit &other ) : Initializer( other ), ctor( maybeClone( other.ctor ) ), dtor( maybeClone( other.dtor ) ), init( maybeClone( other.init ) ) {
     87ConstructorInit::~ConstructorInit() {
     88        delete ctor;
     89        delete init;
    9090}
    9191
    92 ConstructorInit::~ConstructorInit() {
    93         delete ctor;
    94         delete dtor;
    95         delete init;
     92ConstructorInit *ConstructorInit::clone() const {
     93        return new ConstructorInit( *this );
    9694}
    9795
  • src/SynTree/Initializer.h

    re365cb5 r37bf576  
    2020#include "Visitor.h"
    2121#include "Mutator.h"
    22 #include "Type.h"
    2322
    2423#include <cassert>
     
    2928        //      Initializer( std::string _name = std::string(""), int _pos = 0 );
    3029        Initializer( bool maybeConstructed );
    31         Initializer( const Initializer & other );
    3230        virtual ~Initializer();
    3331
     
    7068        std::list<Expression *> &get_designators() { return designators; }
    7169
    72         virtual SingleInit *clone() const { return new SingleInit( *this); }
     70        virtual SingleInit *clone() const;
    7371        virtual void accept( Visitor &v ) { v.visit( this ); }
    7472        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     
    9694        std::list<Initializer*>::iterator end_initializers() { return initializers.end(); }
    9795
    98         virtual ListInit *clone() const { return new ListInit( *this ); }
     96        virtual ListInit *clone() const;
    9997        virtual void accept( Visitor &v ) { v.visit( this ); }
    10098        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     
    110108  public:
    111109        ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init );
    112         ConstructorInit( const ConstructorInit &other );
    113110        virtual ~ConstructorInit();
    114111
     
    120117        Initializer * get_init() const { return init; }
    121118
    122         ConstructorInit *clone() const { return new ConstructorInit( *this ); }
     119        virtual ConstructorInit *clone() const;
    123120        virtual void accept( Visitor &v ) { v.visit( this ); }
    124121        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
  • src/SynTree/Mutator.cc

    re365cb5 r37bf576  
    182182}
    183183
    184 Statement *Mutator::mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
    185         impCtorDtorStmt->set_callStmt( maybeMutate( impCtorDtorStmt->get_callStmt(), *this ) );
    186         return impCtorDtorStmt;
    187 }
    188 
    189184Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
    190185        mutateAll( applicationExpr->get_results(), *this );
  • src/SynTree/Mutator.h

    re365cb5 r37bf576  
    5252        virtual NullStmt* mutate( NullStmt *nullStmt );
    5353        virtual Statement* mutate( DeclStmt *declStmt );
    54         virtual Statement* mutate( ImplicitCtorDtorStmt *impCtorDtorStmt );
    5554
    5655        virtual Expression* mutate( ApplicationExpr *applicationExpr );
  • src/SynTree/Statement.cc

    re365cb5 r37bf576  
    358358
    359359void CatchStmt::print( std::ostream &os, int indent ) const {
    360         os << "Catch Statement" << endl;
     360        os << string( indent, ' ' ) << "Catch Statement" << endl;
    361361
    362362        os << string( indent, ' ' ) << "... catching" << endl;
     
    383383
    384384void FinallyStmt::print( std::ostream &os, int indent ) const {
    385         os << "Finally Statement" << endl;
     385        os << string( indent, ' ' ) << "Finally Statement" << endl;
    386386        os << string( indent + 2, ' ' ) << "with block: " << endl;
    387387        block->print( os, indent + 4 );
     
    393393void NullStmt::print( std::ostream &os, int indent ) const {
    394394        os << "Null Statement" << endl ;
    395 }
    396 
    397 ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement( std::list<Label>() ), callStmt( callStmt ) {
    398         assert( callStmt );
    399 }
    400 
    401 ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ) : Statement( other ), callStmt( other.callStmt ) {
    402 }
    403 
    404 ImplicitCtorDtorStmt::~ImplicitCtorDtorStmt() {
    405 }
    406 
    407 void ImplicitCtorDtorStmt::print( std::ostream &os, int indent ) const {
    408         os << "Implicit Ctor Dtor Statement" << endl;
    409         os << string( indent + 2, ' ' ) << "with Ctor/Dtor: ";
    410         callStmt->print( os, indent + 2);
    411         os << endl;
    412395}
    413396
  • src/SynTree/Statement.h

    re365cb5 r37bf576  
    2121#include "Mutator.h"
    2222#include "Common/SemanticError.h"
    23 #include "Type.h"
    2423
    2524class Statement {
     
    395394        virtual ~DeclStmt();
    396395
    397         Declaration *get_decl() const { return decl; }
     396        Declaration *get_decl() { return decl; }
    398397        void set_decl( Declaration *newValue ) { decl = newValue; }
    399398
     
    405404        Declaration *decl;
    406405};
    407 
    408 
    409 /// represents an implicit application of a constructor or destructor. Qualifiers are replaced
    410 /// immediately before and after the call so that qualified objects can be constructed
    411 /// with the same functions as unqualified objects.
    412 class ImplicitCtorDtorStmt : public Statement {
    413   public:
    414         ImplicitCtorDtorStmt( Statement * callStmt );
    415         ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
    416         virtual ~ImplicitCtorDtorStmt();
    417 
    418         Statement *get_callStmt() const { return callStmt; }
    419         void set_callStmt( Statement * newValue ) { callStmt = newValue; }
    420 
    421         virtual ImplicitCtorDtorStmt *clone() const { return new ImplicitCtorDtorStmt( *this ); }
    422         virtual void accept( Visitor &v ) { v.visit( this ); }
    423         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    424         virtual void print( std::ostream &os, int indent = 0 ) const;
    425 
    426   private:
    427         // Non-owned pointer to the constructor/destructor statement
    428         Statement * callStmt;
    429 };
    430 
    431406
    432407std::ostream & operator<<( std::ostream & out, Statement * statement );
  • src/SynTree/SynTree.h

    re365cb5 r37bf576  
    5656class DeclStmt;
    5757class NullStmt;
    58 class ImplicitCtorDtorStmt;
    5958
    6059class Expression;
  • src/SynTree/Type.cc

    re365cb5 r37bf576  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Type.cc --
     7// Type.cc -- 
    88//
    99// Author           : Richard C. Bilson
     
    5454}
    5555
    56 void Type::Qualifiers::print( std::ostream &os, int indent ) const {
    57         if ( isConst ) {
    58                 os << "const ";
    59         } // if
    60         if ( isVolatile ) {
    61                 os << "volatile ";
    62         } // if
    63         if ( isRestrict ) {
    64                 os << "restrict ";
    65         } // if
    66         if ( isLvalue ) {
    67                 os << "lvalue ";
    68         } // if
    69         if ( isAtomic ) {
    70                 os << "_Atomic ";
    71         } // if
    72         if ( isAttribute ) {
    73                 os << "__attribute(( )) ";
    74         } // if
    75 }
    76 
    7756void Type::print( std::ostream &os, int indent ) const {
    7857        if ( ! forall.empty() ) {
     
    8160                os << std::string( indent+2, ' ' );
    8261        } // if
    83         tq.print( os, indent );
     62        if ( tq.isConst ) {
     63                os << "const ";
     64        } // if
     65        if ( tq.isVolatile ) {
     66                os << "volatile ";
     67        } // if
     68        if ( tq.isRestrict ) {
     69                os << "restrict ";
     70        } // if
     71        if ( tq.isLvalue ) {
     72                os << "lvalue ";
     73        } // if
     74        if ( tq.isAtomic ) {
     75                os << "_Atomic ";
     76        } // if
     77        if ( tq.isAttribute ) {
     78                os << "__attribute(( )) ";
     79        } // if
    8480}
    8581
  • src/SynTree/Type.h

    re365cb5 r37bf576  
    3636                bool operator<( const Qualifiers &other );
    3737                bool operator>( const Qualifiers &other );
    38                 void print( std::ostream &os, int indent = 0 ) const;
    3938
    4039                bool isConst;
  • src/SynTree/Visitor.cc

    re365cb5 r37bf576  
    152152}
    153153
    154 void Visitor::visit( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
    155         maybeAccept( impCtorDtorStmt->get_callStmt(), *this );
    156 }
    157 
    158154void Visitor::visit( ApplicationExpr *applicationExpr ) {
    159155        acceptAll( applicationExpr->get_results(), *this );
  • src/SynTree/Visitor.h

    re365cb5 r37bf576  
    5252        virtual void visit( NullStmt *nullStmt );
    5353        virtual void visit( DeclStmt *declStmt );
    54         virtual void visit( ImplicitCtorDtorStmt *impCtorDtorStmt );
    5554
    5655        virtual void visit( ApplicationExpr *applicationExpr );
  • src/examples/avltree/avl-private.h

    re365cb5 r37bf576  
    1 #ifndef AVL_PRIVATE_H
    21#include "avl.h"
    32
     
    1413forall(otype K | Comparable(K), otype V)
    1514int height(tree(K, V) * t);
    16 
    17 #endif
Note: See TracChangeset for help on using the changeset viewer.