Changeset 0f9e4403 for src/SynTree


Ignore:
Timestamp:
Apr 15, 2016, 12:03:11 PM (10 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, stuck-waitfor-destruct, with_gc
Children:
29ad0ac
Parents:
c5833e8 (diff), 37f0da8 (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 branch 'master' into gc_noraii

Location:
src/SynTree
Files:
1 added
2 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/AggregateDecl.cc

    rc5833e8 r0f9e4403  
    1010// Created On       : Sun May 17 23:56:39 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 13 08:12:49 2015
    13 // Update Count     : 6
     12// Last Modified On : Wed Mar  2 17:28:00 2016
     13// Update Count     : 7
    1414//
    1515
     
    6464std::string EnumDecl::typeString() const { return "enum"; }
    6565
    66 std::string ContextDecl::typeString() const { return "context"; }
     66std::string TraitDecl::typeString() const { return "context"; }
    6767
    6868// Local Variables: //
  • src/SynTree/Constant.cc

    rc5833e8 r0f9e4403  
    1616#include <iostream>
    1717#include <list>
     18#include <string>
    1819
    1920#include "Constant.h"
     
    2829
    2930Constant::~Constant() { delete type; }
     31
     32Constant Constant::from( int i ) {
     33        return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ) );
     34}
     35
     36Constant Constant::from( unsigned long i ) {
     37        return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ) );
     38}
     39
     40Constant Constant::from( double d ) {
     41        return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ) );
     42}
    3043
    3144Constant *Constant::clone() const { assert( false ); return 0; }
  • src/SynTree/Constant.h

    rc5833e8 r0f9e4403  
    3232        void set_value( std::string newValue ) { value = newValue; }
    3333
     34        /// generates an integer constant of the given int
     35        static Constant from( int i );
     36        /// generates an integer constant of the given unsigned long int
     37        static Constant from( unsigned long i );
     38        /// generates a floating point constant of the given double
     39        static Constant from( double d );
     40
    3441        virtual Constant *clone() const;
    3542        virtual void accept( Visitor &v ) { v.visit( this ); }
  • src/SynTree/Declaration.h

    rc5833e8 r0f9e4403  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:08:22 2015
    13 // Update Count     : 32
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Mar  2 17:28:11 2016
     13// Update Count     : 33
    1414//
    1515
     
    246246};
    247247
    248 class ContextDecl : public AggregateDecl {
    249         typedef AggregateDecl Parent;
    250   public:
    251         ContextDecl( const std::string &name ) : Parent( name ) {}
    252         ContextDecl( const ContextDecl &other ) : Parent( other ) {}
    253 
    254         virtual ContextDecl *clone() const { return new ContextDecl( *this ); }
     248class TraitDecl : public AggregateDecl {
     249        typedef AggregateDecl Parent;
     250  public:
     251        TraitDecl( const std::string &name ) : Parent( name ) {}
     252        TraitDecl( const TraitDecl &other ) : Parent( other ) {}
     253
     254        virtual TraitDecl *clone() const { return new TraitDecl( *this ); }
    255255        virtual void accept( Visitor &v ) { v.visit( this ); }
    256256        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
  • src/SynTree/Expression.cc

    rc5833e8 r0f9e4403  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Expression.cc -- 
     7// Expression.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:10:29 2015
    13 // Update Count     : 34
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Apr  8 17:16:23 2016
     13// Update Count     : 40
    1414//
    1515
     
    2222
    2323#include "Type.h"
     24#include "Initializer.h"
    2425#include "Expression.h"
    2526#include "Declaration.h"
     
    211212
    212213        os << " of ";
     214
     215        if ( type ) {
     216                type->print(os, indent + 2);
     217        } else {
     218                os << "<NULL>";
     219        }
     220
     221        os << std::endl;
     222        Expression::print( os, indent );
     223}
     224
     225OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
     226        add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
     227}
     228
     229OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
     230
     231OffsetPackExpr::~OffsetPackExpr() { delete type; }
     232
     233void OffsetPackExpr::print( std::ostream &os, int indent ) const {
     234        os << std::string( indent, ' ' ) << "Offset pack expression on ";
    213235
    214236        if ( type ) {
     
    422444}
    423445
     446AsmExpr::AsmExpr( const AsmExpr & other ) : inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
     447
     448
    424449void AsmExpr::print( std::ostream &os, int indent ) const {
    425450        os << "Asm Expression: " << std::endl;
     
    429454}
    430455
     456UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
     457
     458UntypedValofExpr::~UntypedValofExpr() { delete body; }
     459
    431460void UntypedValofExpr::print( std::ostream &os, int indent ) const {
    432461        os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl;
     
    434463                get_body()->print( os, indent + 2 );
    435464}
     465
     466
     467CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
     468        add_result( type->clone() );
     469}
     470
     471CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}
     472
     473CompoundLiteralExpr::~CompoundLiteralExpr() {
     474        delete initializer;
     475        delete type;
     476}
     477
     478void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {
     479        os << "Compound Literal Expression: " << std::endl;
     480        if ( type ) type->print( os, indent + 2 );
     481        if ( initializer ) initializer->print( os, indent + 2 );
     482}
     483
    436484
    437485std::ostream & operator<<( std::ostream & out, Expression * expr ) {
  • src/SynTree/Expression.h

    rc5833e8 r0f9e4403  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Expression.h -- 
     7// Expression.h --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:10:21 2015
    13 // Update Count     : 19
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Apr  8 17:18:06 2016
     13// Update Count     : 21
    1414//
    1515
     
    155155};
    156156
     157// xxx - this doesn't appear to actually be hooked in anywhere. We should use this instead of the "&&"" UntypedExpr hack
    157158class LabelAddressExpr : public Expression {
    158159  public:
    159160        LabelAddressExpr( Expression *arg );
    160         LabelAddressExpr( const AddressExpr &other );
     161        LabelAddressExpr( const LabelAddressExpr &other );
    161162        virtual ~LabelAddressExpr();
    162163
     
    251252};
    252253
    253 /// ConstantExpr represents an expression that simply refers to the value of a constant 
     254/// ConstantExpr represents an expression that simply refers to the value of a constant
    254255class ConstantExpr : public Expression {
    255256  public:
     
    359360        Type *type;
    360361        DeclarationWithType *member;
     362};
     363
     364/// Expression representing a pack of field-offsets for a generic type
     365class OffsetPackExpr : public Expression {
     366public:
     367        OffsetPackExpr( StructInstType *type_, Expression *aname_ = 0 );
     368        OffsetPackExpr( const OffsetPackExpr &other );
     369        virtual ~OffsetPackExpr();
     370
     371        StructInstType *get_type() const { return type; }
     372        void set_type( StructInstType *newValue ) { type = newValue; }
     373
     374        virtual OffsetPackExpr *clone() const { return new OffsetPackExpr( *this ); }
     375        virtual void accept( Visitor &v ) { v.visit( this ); }
     376        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     377
     378        virtual void print( std::ostream &os, int indent = 0 ) const;
     379
     380private:
     381        StructInstType *type;
    361382};
    362383
     
    515536  public:
    516537        AsmExpr( Expression *inout, ConstantExpr *constraint, Expression *operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
     538        AsmExpr( const AsmExpr & other );
    517539        virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
    518540
     
    541563  public:
    542564        UntypedValofExpr( Statement *_body, Expression *_aname = 0 ) : Expression( _aname ), body ( _body ) {}
    543         virtual ~UntypedValofExpr() {}
     565        UntypedValofExpr( const UntypedValofExpr & other );
     566        virtual ~UntypedValofExpr();
    544567
    545568        Expression *get_value();
     
    552575  private:
    553576        Statement *body;
     577};
     578
     579/// CompoundLiteralExpr represents a C99 'compound literal'
     580class CompoundLiteralExpr : public Expression {
     581  public:
     582        CompoundLiteralExpr( Type * type, Initializer * initializer );
     583        CompoundLiteralExpr( const CompoundLiteralExpr &other );
     584        ~CompoundLiteralExpr();
     585
     586        Type * get_type() const { return type; }
     587        void set_type( Type * t ) { type = t; }
     588
     589        Initializer * get_initializer() const { return initializer; }
     590        void set_initializer( Initializer * i ) { initializer = i; }
     591
     592        virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); }
     593        virtual void accept( Visitor &v ) { v.visit( this ); }
     594        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     595        virtual void print( std::ostream &os, int indent = 0 ) const;
     596  private:
     597        Type * type;
     598        Initializer * initializer;
    554599};
    555600
  • src/SynTree/Mutator.cc

    rc5833e8 r0f9e4403  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 25 19:21:33 2015
    13 // Update Count     : 11
     12// Last Modified On : Fri Apr  1 18:05:16 2016
     13// Update Count     : 16
    1414//
    1515
     
    6363}
    6464
    65 Declaration *Mutator::mutate( ContextDecl *aggregateDecl ) {
     65Declaration *Mutator::mutate( TraitDecl *aggregateDecl ) {
    6666        handleAggregateDecl( aggregateDecl );
    6767        return aggregateDecl;
     
    274274}
    275275
     276Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
     277        mutateAll( offsetPackExpr->get_results(), *this );
     278        offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
     279        return offsetPackExpr;
     280}
     281
    276282Expression *Mutator::mutate( AttrExpr *attrExpr ) {
    277283        mutateAll( attrExpr->get_results(), *this );
     
    336342}
    337343
     344Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
     345        mutateAll( compLitExpr->get_results(), *this );
     346        compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) );
     347        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
     348        return compLitExpr;
     349}
     350
    338351Type *Mutator::mutate( VoidType *voidType ) {
    339352        mutateAll( voidType->get_forall(), *this );
     
    387400}
    388401
    389 Type *Mutator::mutate( ContextInstType *aggregateUseType ) {
     402Type *Mutator::mutate( TraitInstType *aggregateUseType ) {
    390403        handleReferenceToType( aggregateUseType );
    391404        mutateAll( aggregateUseType->get_members(), *this );
     
    421434}
    422435
     436Type *Mutator::mutate( VarArgsType *varArgsType ) {
     437        mutateAll( varArgsType->get_forall(), *this );
     438        return varArgsType;
     439}
     440
    423441Initializer *Mutator::mutate( SingleInit *singleInit ) {
    424442        singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
  • src/SynTree/Mutator.h

    rc5833e8 r0f9e4403  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 19 22:26:16 2015
    13 // Update Count     : 8
     12// Last Modified On : Fri Apr  1 17:26:56 2016
     13// Update Count     : 10
    1414//
    1515#include <cassert>
     
    3131        virtual Declaration* mutate( UnionDecl *aggregateDecl );
    3232        virtual Declaration* mutate( EnumDecl *aggregateDecl );
    33         virtual Declaration* mutate( ContextDecl *aggregateDecl );
     33        virtual Declaration* mutate( TraitDecl *aggregateDecl );
    3434        virtual TypeDecl* mutate( TypeDecl *typeDecl );
    3535        virtual Declaration* mutate( TypedefDecl *typeDecl );
     
    6767        virtual Expression* mutate( UntypedOffsetofExpr *offsetofExpr );
    6868        virtual Expression* mutate( OffsetofExpr *offsetofExpr );
     69        virtual Expression* mutate( OffsetPackExpr *offsetPackExpr );
    6970        virtual Expression* mutate( AttrExpr *attrExpr );
    7071        virtual Expression* mutate( LogicalExpr *logicalExpr );
     
    7677        virtual Expression* mutate( AsmExpr *asmExpr );
    7778        virtual Expression* mutate( UntypedValofExpr *valofExpr );
     79        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
    7880
    7981        virtual Type* mutate( VoidType *basicType );
     
    8587        virtual Type* mutate( UnionInstType *aggregateUseType );
    8688        virtual Type* mutate( EnumInstType *aggregateUseType );
    87         virtual Type* mutate( ContextInstType *aggregateUseType );
     89        virtual Type* mutate( TraitInstType *aggregateUseType );
    8890        virtual Type* mutate( TypeInstType *aggregateUseType );
    8991        virtual Type* mutate( TupleType *tupleType );
    9092        virtual Type* mutate( TypeofType *typeofType );
    9193        virtual Type* mutate( AttrType *attrType );
     94        virtual Type* mutate( VarArgsType *varArgsType );
    9295
    9396        virtual Initializer* mutate( SingleInit *singleInit );
  • src/SynTree/ReferenceToType.cc

    rc5833e8 r0f9e4403  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jun  7 08:31:48 2015
    13 // Update Count     : 4
     12// Last Modified On : Wed Mar  2 17:28:51 2016
     13// Update Count     : 5
    1414//
    1515
     
    8383std::string EnumInstType::typeString() const { return "enum"; }
    8484
    85 std::string ContextInstType::typeString() const { return "context"; }
     85std::string TraitInstType::typeString() const { return "context"; }
    8686
    87 ContextInstType::ContextInstType( const ContextInstType &other ) : Parent( other ) {
     87TraitInstType::TraitInstType( const TraitInstType &other ) : Parent( other ) {
    8888        cloneAll( other.members, members );
    8989}
    9090
    91 ContextInstType::~ContextInstType() {
     91TraitInstType::~TraitInstType() {
    9292        deleteAll( members );
    9393}
  • src/SynTree/Statement.cc

    rc5833e8 r0f9e4403  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Statement.cc -- 
     7// Statement.cc --
    88//
    99// Author           : Richard C. Bilson
     
    3636ExprStmt::ExprStmt( std::list<Label> _labels, Expression *_expr ) : Statement( _labels ), expr( _expr ) {}
    3737
    38 ExprStmt::~ExprStmt() {}
     38ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     39
     40ExprStmt::~ExprStmt() {
     41        delete expr;
     42}
    3943
    4044void ExprStmt::print( std::ostream &os, int indent ) const {
    4145        os << string( indent, ' ' ) << "Expression Statement:" << endl;
    4246        expr->print( os, indent + 2 );
    43 } 
     47}
    4448
    4549
    4650AsmStmt::AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement( labels ), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}
     51
     52AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) {
     53  cloneAll( other.output, output );
     54  cloneAll( other.input, input );
     55  cloneAll( other.clobber, clobber );
     56}
    4757
    4858AsmStmt::~AsmStmt() {
     
    6070                os << endl << std::string( indent, ' ' ) << "output: " << endl;
    6171                printAll( output, os, indent + 2 );
    62         } // if 
     72        } // if
    6373        if ( ! input.empty() ) {
    6474                os << std::string( indent, ' ' ) << "input: " << endl << std::string( indent, ' ' );
     
    6979                printAll( clobber, os, indent + 2 );
    7080        } // if
    71 } 
     81}
    7282
    7383
     
    93103ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) : Statement( labels ), expr( _expr ), isThrow( throwP ) {}
    94104
     105ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ), isThrow( other.isThrow ) {}
     106
    95107ReturnStmt::~ReturnStmt() {
    96108        delete expr;
     
    106118        Statement( _labels ), condition( _condition ), thenPart( _thenPart ), elsePart( _elsePart ) {}
    107119
     120IfStmt::IfStmt( const IfStmt & other ) :
     121        Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) {}
     122
    108123IfStmt::~IfStmt() {}
    109124
     
    123138SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches ):
    124139        Statement( _labels ), condition( _condition ), branches( _branches ) {
     140}
     141
     142SwitchStmt::SwitchStmt( const SwitchStmt & other ):
     143        Statement( other ), condition( maybeClone( other.condition ) ) {
     144        cloneAll( other.branches, branches );
    125145}
    126146
     
    145165}
    146166
    147 CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) : 
     167CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) :
    148168        Statement( _labels ), condition( _condition ), stmts( _statements ), _isDefault( deflt ) {
    149169        if ( isDefault() && condition != 0 )
    150170                throw SemanticError("default with conditions");
     171}
     172
     173CaseStmt::CaseStmt( const CaseStmt & other ) :
     174        Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) {
     175        cloneAll( other.stmts, stmts );
    151176}
    152177
     
    181206}
    182207
     208ChooseStmt::ChooseStmt( const ChooseStmt & other ):
     209        Statement( other ), condition( maybeClone( other.condition ) ) {
     210                cloneAll( other.branches, branches );
     211}
     212
    183213ChooseStmt::~ChooseStmt() {
    184214        delete condition;
     
    208238}
    209239
     240WhileStmt::WhileStmt( const WhileStmt & other ):
     241        Statement( other ), condition( maybeClone( other.condition ) ), body( maybeClone( other.body ) ), isDoWhile( other.isDoWhile ) {
     242}
     243
    210244WhileStmt::~WhileStmt() {
    211245        delete body;
     
    223257ForStmt::ForStmt( std::list<Label> labels, std::list<Statement *> initialization_, Expression *condition_, Expression *increment_, Statement *body_ ):
    224258        Statement( labels ), initialization( initialization_ ), condition( condition_ ), increment( increment_ ), body( body_ ) {
     259}
     260
     261ForStmt::ForStmt( const ForStmt & other ):
     262        Statement( other ), condition( maybeClone( other.condition ) ), increment( maybeClone( other.increment ) ), body( maybeClone( other.body ) ) {
     263                cloneAll( other.initialization, initialization );
     264
    225265}
    226266
     
    241281        os << string( indent, ' ' ) << "For Statement" << endl ;
    242282
    243         os << string( indent + 2, ' ' ) << "initialization: \n"; 
     283        os << string( indent + 2, ' ' ) << "initialization: \n";
    244284        for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) {
    245285                (*it)->print( os, indent + 4 );
    246286        }
    247287
    248         os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; 
     288        os << "\n" << string( indent + 2, ' ' ) << "condition: \n";
    249289        if ( condition != 0 )
    250290                condition->print( os, indent + 4 );
    251291
    252         os << "\n" << string( indent + 2, ' ' ) << "increment: \n"; 
     292        os << "\n" << string( indent + 2, ' ' ) << "increment: \n";
    253293        if ( increment != 0 )
    254294                increment->print( os, indent + 4 );
    255295
    256         os << "\n" << string( indent + 2, ' ' ) << "statement block: \n"; 
     296        os << "\n" << string( indent + 2, ' ' ) << "statement block: \n";
    257297        if ( body != 0 )
    258298                body->print( os, indent + 4 );
     
    265305}
    266306
    267 TryStmt::TryStmt( const TryStmt &other ) : Statement( other.labels ) {
    268         block = other.block;
    269         std::copy( other.handlers.begin(), other.handlers.end(), back_inserter( handlers ) );
    270         finallyBlock = other.finallyBlock;
     307TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {
     308        cloneAll( other.handlers, handlers );
    271309}
    272310
     
    294332CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool isCatchRest ) :
    295333        Statement( labels ), decl ( _decl ), body( _body ), catchRest ( isCatchRest ) {
     334}
     335
     336CatchStmt::CatchStmt( const CatchStmt & other ) :
     337        Statement( other ), decl ( maybeClone( other.decl ) ), body( maybeClone( other.body ) ), catchRest ( other.catchRest ) {
    296338}
    297339
     
    319361}
    320362
     363FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) {
     364}
     365
    321366FinallyStmt::~FinallyStmt() {
    322367        delete block;
     
    331376NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {}
    332377NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {}
    333 NullStmt::~NullStmt() {}
    334378
    335379void NullStmt::print( std::ostream &os, int indent ) const {
  • src/SynTree/Statement.h

    rc5833e8 r0f9e4403  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Statement.h -- 
     7// Statement.h --
    88//
    99// Author           : Richard C. Bilson
     
    5757  public:
    5858        ExprStmt( std::list<Label> labels, Expression *expr );
     59        ExprStmt( const ExprStmt &other );
    5960        virtual ~ExprStmt();
    6061
     
    7374  public:
    7475        AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
     76        AsmStmt( const AsmStmt &other );
    7577        virtual ~AsmStmt();
    7678
     
    103105  public:
    104106        IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
     107        IfStmt( const IfStmt &other );
    105108        virtual ~IfStmt();
    106109
     
    111114        Statement *get_elsePart() { return elsePart; }
    112115        void set_elsePart( Statement *newValue ) { elsePart = newValue; }
    113        
     116
    114117        virtual IfStmt *clone() const { return new IfStmt( *this ); }
    115118        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    125128  public:
    126129        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
     130        SwitchStmt( const SwitchStmt &other );
    127131        virtual ~SwitchStmt();
    128132
     
    146150  public:
    147151        ChooseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
     152        ChooseStmt( const ChooseStmt &other );
    148153        virtual ~ChooseStmt();
    149154
     
    177182class CaseStmt : public Statement {
    178183  public:
    179         CaseStmt( std::list<Label> labels, Expression *conditions, 
     184        CaseStmt( std::list<Label> labels, Expression *conditions,
    180185              std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
     186        CaseStmt( const CaseStmt &other );
    181187        virtual ~CaseStmt();
    182188
     
    192198        std::list<Statement *> &get_statements() { return stmts; }
    193199        void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
    194        
     200
    195201        virtual void accept( Visitor &v ) { v.visit( this ); }
    196202        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     
    208214        WhileStmt( std::list<Label> labels, Expression *condition,
    209215               Statement *body, bool isDoWhile = false );
     216        WhileStmt( const WhileStmt &other );
    210217        virtual ~WhileStmt();
    211218
     
    216223        bool get_isDoWhile() { return isDoWhile; }
    217224        void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
    218        
     225
    219226        virtual WhileStmt *clone() const { return new WhileStmt( *this ); }
    220227        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    231238        ForStmt( std::list<Label> labels, std::list<Statement *> initialization,
    232239             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
     240        ForStmt( const ForStmt &other );
    233241        virtual ~ForStmt();
    234242
     
    241249        Statement *get_body() { return body; }
    242250        void set_body( Statement *newValue ) { body = newValue; }
    243        
     251
    244252        virtual ForStmt *clone() const { return new ForStmt( *this ); }
    245253        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    259267        BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
    260268        BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError);
    261         virtual ~BranchStmt() {}
    262269
    263270        Label get_originalTarget() { return originalTarget; }
    264271        Label get_target() { return target; }
    265272        void set_target( Label newValue ) { target = newValue; }
    266        
     273
    267274        Expression *get_computedTarget() { return computedTarget; }
    268275        void set_target( Expression * newValue ) { computedTarget = newValue; }
     
    286293  public:
    287294        ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false );
     295        ReturnStmt( const ReturnStmt &other );
    288296        virtual ~ReturnStmt();
    289297
    290298        Expression *get_expr() { return expr; }
    291299        void set_expr( Expression *newValue ) { expr = newValue; }
    292        
     300
    293301        virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); }
    294302        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    305313        NullStmt();
    306314        NullStmt( std::list<Label> labels );
    307         virtual ~NullStmt();
    308315
    309316        virtual NullStmt *clone() const { return new NullStmt( *this ); }
     
    311318        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    312319        virtual void print( std::ostream &os, int indent = 0 ) const;
    313        
    314   private:
    315 };
    316 
    317 class TryStmt : public Statement { 
     320
     321  private:
     322};
     323
     324class TryStmt : public Statement {
    318325  public:
    319326        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
     
    332339        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    333340        virtual void print( std::ostream &os, int indent = 0 ) const;
    334        
     341
    335342  private:
    336343        CompoundStmt *block;
    337344        std::list<Statement *> handlers;
    338345        FinallyStmt *finallyBlock;
    339 }; 
     346};
    340347
    341348class CatchStmt : public Statement {
    342349  public:
    343350        CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool isCatchRest = false );
     351        CatchStmt( const CatchStmt &other );
    344352        virtual ~CatchStmt();
    345353
     
    349357        Statement *get_body() { return body; }
    350358        void set_body( Statement *newValue ) { body = newValue; }
    351        
     359
    352360        virtual CatchStmt *clone() const { return new CatchStmt( *this ); }
    353361        virtual void accept( Visitor &v ) { v.visit( this ); }
    354362        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    355363        virtual void print( std::ostream &os, int indent = 0 ) const;
    356        
     364
    357365  private:
    358366        Declaration *decl;
     
    361369};
    362370
    363 class FinallyStmt : public Statement { 
     371class FinallyStmt : public Statement {
    364372  public:
    365373        FinallyStmt( std::list<Label> labels, CompoundStmt *block );
     374        FinallyStmt( const FinallyStmt &other );
    366375        virtual ~FinallyStmt();
    367376
    368377        CompoundStmt *get_block() const { return block; }
    369378        void set_block( CompoundStmt *newValue ) { block = newValue; }
    370        
     379
    371380        virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); }
    372381        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    375384  private:
    376385        CompoundStmt *block;
    377 }; 
     386};
    378387
    379388
  • src/SynTree/SynTree.h

    rc5833e8 r0f9e4403  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 23 23:25:04 2015
    13 // Update Count     : 3
     12// Last Modified On : Fri Apr  1 16:47:44 2016
     13// Update Count     : 5
    1414//
    1515
     
    3030class UnionDecl;
    3131class EnumDecl;
    32 class ContextDecl;
     32class TraitDecl;
    3333class NamedTypeDecl;
    3434class TypeDecl;
     
    7272class UntypedOffsetofExpr;
    7373class OffsetofExpr;
     74class OffsetPackExpr;
    7475class AttrExpr;
    7576class LogicalExpr;
     
    8182class AsmExpr;
    8283class UntypedValofExpr;
     84class CompoundLiteralExpr;
    8385
    8486class Type;
     
    9294class UnionInstType;
    9395class EnumInstType;
    94 class ContextInstType;
     96class TraitInstType;
    9597class TypeInstType;
    9698class TupleType;
    9799class TypeofType;
    98100class AttrType;
     101class VarArgsType;
    99102
    100103class Initializer;
  • src/SynTree/Type.h

    rc5833e8 r0f9e4403  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Dec 18 14:46:18 2015
    13 // Update Count     : 18
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Mar  2 17:29:08 2016
     13// Update Count     : 21
    1414//
    1515
     
    296296};
    297297
    298 class ContextInstType : public ReferenceToType {
     298class TraitInstType : public ReferenceToType {
    299299        typedef ReferenceToType Parent;
    300300  public:
    301         ContextInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {}
    302         ContextInstType( const ContextInstType &other );
    303         ~ContextInstType();
     301        TraitInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {}
     302        TraitInstType( const TraitInstType &other );
     303        ~TraitInstType();
    304304
    305305        std::list< Declaration* >& get_members() { return members; }
    306306
    307         virtual ContextInstType *clone() const { return new ContextInstType( *this ); }
     307        virtual TraitInstType *clone() const { return new TraitInstType( *this ); }
    308308        virtual void accept( Visitor &v ) { v.visit( this ); }
    309309        virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     
    400400};
    401401
     402/// Represents the GCC built-in varargs type
     403class VarArgsType : public Type {
     404  public:
     405        VarArgsType();
     406        VarArgsType( Type::Qualifiers tq );
     407
     408        virtual VarArgsType *clone() const { return new VarArgsType( *this ); }
     409        virtual void accept( Visitor &v ) { v.visit( this ); }
     410        virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     411        virtual void print( std::ostream &os, int indent = 0 ) const;
     412};
     413
    402414inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) {
    403415        isConst |= other.isConst;
  • src/SynTree/TypeSubstitution.cc

    rc5833e8 r0f9e4403  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 11:10:04 2015
    13 // Update Count     : 2
     12// Last Modified On : Wed Mar  2 17:29:15 2016
     13// Update Count     : 3
    1414//
    1515
     
    190190}
    191191
    192 Type * TypeSubstitution::mutate( ContextInstType *aggregateUseType ) {
     192Type * TypeSubstitution::mutate( TraitInstType *aggregateUseType ) {
    193193        return handleType( aggregateUseType );
    194194}
     
    196196Type * TypeSubstitution::mutate( TupleType *tupleType ) {
    197197        return handleType( tupleType );
     198}
     199
     200Type * TypeSubstitution::mutate( VarArgsType *varArgsType ) {
     201        return handleType( varArgsType );
    198202}
    199203
  • src/SynTree/TypeSubstitution.h

    rc5833e8 r0f9e4403  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 11:12:30 2015
    13 // Update Count     : 1
     12// Last Modified On : Wed Mar  2 17:33:19 2016
     13// Update Count     : 2
    1414//
    1515
     
    7272        virtual Type* mutate(UnionInstType *aggregateUseType);
    7373        virtual Type* mutate(EnumInstType *aggregateUseType);
    74         virtual Type* mutate(ContextInstType *aggregateUseType);
     74        virtual Type* mutate(TraitInstType *aggregateUseType);
    7575        virtual Type* mutate(TupleType *tupleType);
     76        virtual Type* mutate(VarArgsType *varArgsType);
    7677       
    7778        // TODO: worry about traversing into a forall-qualified function type or type decl with assertions
  • src/SynTree/Visitor.cc

    rc5833e8 r0f9e4403  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 24 16:11:05 2015
    13 // Update Count     : 15
     12// Last Modified On : Fri Apr  1 18:05:13 2016
     13// Update Count     : 18
    1414//
    1515
     
    5656}
    5757
    58 void Visitor::visit( ContextDecl *aggregateDecl ) {
     58void Visitor::visit( TraitDecl *aggregateDecl ) {
    5959        visit( static_cast< AggregateDecl* >( aggregateDecl ) );
    6060}
     
    230230}
    231231
     232void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {
     233        acceptAll( offsetPackExpr->get_results(), *this );
     234        maybeAccept( offsetPackExpr->get_type(), *this );
     235}
     236
    232237void Visitor::visit( AttrExpr *attrExpr ) {
    233238        acceptAll( attrExpr->get_results(), *this );
     
    284289}
    285290
     291void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
     292        acceptAll( compLitExpr->get_results(), *this );
     293        maybeAccept( compLitExpr->get_type(), *this );
     294        maybeAccept( compLitExpr->get_initializer(), *this );
     295}
     296
    286297void Visitor::visit( VoidType *voidType ) {
    287298        acceptAll( voidType->get_forall(), *this );
     
    326337}
    327338
    328 void Visitor::visit( ContextInstType *aggregateUseType ) {
     339void Visitor::visit( TraitInstType *aggregateUseType ) {
    329340        visit( static_cast< ReferenceToType * >( aggregateUseType ) );
    330341        acceptAll( aggregateUseType->get_members(), *this );
     
    355366}
    356367
     368void Visitor::visit( VarArgsType *varArgsType ) {
     369        acceptAll( varArgsType->get_forall(), *this );
     370}
     371
    357372void Visitor::visit( SingleInit *singleInit ) {
    358373        singleInit->get_value()->accept( *this );
  • src/SynTree/Visitor.h

    rc5833e8 r0f9e4403  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 25 21:20:44 2016
    13 // Update Count     : 5
     12// Last Modified On : Fri Apr  1 17:26:55 2016
     13// Update Count     : 7
    1414//
    1515
     
    3131        virtual void visit( UnionDecl *aggregateDecl );
    3232        virtual void visit( EnumDecl *aggregateDecl );
    33         virtual void visit( ContextDecl *aggregateDecl );
     33        virtual void visit( TraitDecl *aggregateDecl );
    3434        virtual void visit( TypeDecl *typeDecl );
    3535        virtual void visit( TypedefDecl *typeDecl );
     
    6767        virtual void visit( UntypedOffsetofExpr *offsetofExpr );
    6868        virtual void visit( OffsetofExpr *offsetofExpr );
     69        virtual void visit( OffsetPackExpr *offsetPackExpr );
    6970        virtual void visit( AttrExpr *attrExpr );
    7071        virtual void visit( LogicalExpr *logicalExpr );
     
    7677        virtual void visit( AsmExpr *asmExpr );
    7778        virtual void visit( UntypedValofExpr *valofExpr );
     79        virtual void visit( CompoundLiteralExpr *compLitExpr );
    7880
    7981        virtual void visit( VoidType *basicType );
     
    8587        virtual void visit( UnionInstType *aggregateUseType );
    8688        virtual void visit( EnumInstType *aggregateUseType );
    87         virtual void visit( ContextInstType *aggregateUseType );
     89        virtual void visit( TraitInstType *aggregateUseType );
    8890        virtual void visit( TypeInstType *aggregateUseType );
    8991        virtual void visit( TupleType *tupleType );
    9092        virtual void visit( TypeofType *typeofType );
    9193        virtual void visit( AttrType *attrType );
     94        virtual void visit( VarArgsType *varArgsType );
    9295
    9396        virtual void visit( SingleInit *singleInit );
  • src/SynTree/module.mk

    rc5833e8 r0f9e4403  
    2525       SynTree/TypeofType.cc \
    2626       SynTree/AttrType.cc \
     27       SynTree/VarArgsType.cc \
    2728       SynTree/Constant.cc \
    2829       SynTree/Expression.cc \
     
    4546       SynTree/Visitor.cc \
    4647       SynTree/Mutator.cc \
    47        SynTree/CodeGenVisitor.cc \
    4848       SynTree/TypeSubstitution.cc
    4949
Note: See TracChangeset for help on using the changeset viewer.