Changeset 579263a for src/SynTree


Ignore:
Timestamp:
Jun 26, 2017, 4:48:35 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
bb1cd95
Parents:
e4d829b (diff), 2a7b3ca (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 designations

Conflicts:

src/InitTweak/FixInit.cc
src/SymTab/Autogen.h
src/SynTree/Initializer.cc
src/SynTree/Initializer.h
src/Tuples/TupleExpansion.cc

Location:
src/SynTree
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/BaseSyntaxNode.h

    re4d829b r579263a  
    2424        CodeLocation location;
    2525
    26         virtual void accept( Visitor & v ) = 0; // temporary -- needs to be here so that BaseSyntaxNode is polymorphic and can be dynamic_cast
     26        virtual ~BaseSyntaxNode() {}
     27
     28        virtual void accept( Visitor & v ) = 0;
    2729};
    2830
  • src/SynTree/Constant.cc

    re4d829b r579263a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 30 15:18:38 2015
    13 // Update Count     : 12
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Jun 22 10:11:00 2017
     13// Update Count     : 28
    1414//
    1515
     
    2121#include "Type.h"
    2222
    23 Constant::Constant( Type *type_, std::string value_ ) : type( type_ ), value( value_ ) {}
     23Constant::Constant( Type * type, std::string rep, unsigned long long val ) : type( type ), rep( rep ), val( val ) {}
     24Constant::Constant( Type * type, std::string rep, double val ) : type( type ), rep( rep ), val( val ) {}
    2425
    25 Constant::Constant( const Constant &other ) {
     26Constant::Constant( const Constant &other ) : rep( other.rep ), val( other.val ) {
    2627        type = other.type->clone();
    27         value = other.value;
    2828}
    2929
    3030Constant::~Constant() { delete type; }
    3131
     32Constant Constant::from_bool( bool b ) {
     33        return Constant( new BasicType( Type::Qualifiers(), BasicType::Bool ), b ? "1" : "0" , (unsigned long long int)b );
     34}
     35
    3236Constant Constant::from_int( int i ) {
    33         return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ) );
     37        return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ), (unsigned long long int)i );
    3438}
    3539
    3640Constant Constant::from_ulong( unsigned long i ) {
    37         return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ) );
     41        return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ), (unsigned long long int)i );
    3842}
    3943
    4044Constant Constant::from_double( double d ) {
    41         return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ) );
     45        return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ), d );
    4246}
    4347
    44 Constant *Constant::clone() const { assert( false ); return 0; }
    45 
    4648void Constant::print( std::ostream &os ) const {
    47         os << "(" << value;
     49        os << "(" << rep << " " << val.ival;
    4850        if ( type ) {
    4951                os << ": ";
  • src/SynTree/Constant.h

    re4d829b r579263a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 30 13:33:17 2016
    13 // Update Count     : 6
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Jun 22 10:13:00 2017
     13// Update Count     : 15
    1414//
    1515
     
    2323class Constant {
    2424  public:
    25         Constant( Type *type, std::string value );
    26         Constant( const Constant &other );
     25        Constant( Type * type, std::string rep, unsigned long long val );
     26        Constant( Type * type, std::string rep, double val );
     27        Constant( const Constant & other );
    2728        virtual ~Constant();
    2829
    29         Type *get_type() { return type; }
    30         void set_type( Type *newValue ) { type = newValue; }
    31         std::string &get_value() { return value; }
    32         void set_value( std::string newValue ) { value = newValue; }
     30        Type * get_type() { return type; }
     31        void set_type( Type * newValue ) { type = newValue; }
     32        std::string & get_value() { return rep; }
     33        void set_value( std::string newValue ) { rep = newValue; }
    3334
     35        /// generates a boolean constant of the given bool
     36        static Constant from_bool( bool b );
    3437        /// generates an integer constant of the given int
    3538        static Constant from_int( int i );
     
    3942        static Constant from_double( double d );
    4043
    41         virtual Constant *clone() const;
    42         virtual void accept( Visitor &v ) { v.visit( this ); }
    43         virtual Constant *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    44         virtual void print( std::ostream &os ) const;
     44        virtual void accept( Visitor & v ) { v.visit( this ); }
     45        virtual Constant * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     46        virtual void print( std::ostream & os ) const;
    4547  private:
    46         Type *type;
    47         std::string value;
     48        Type * type;
     49        std::string rep;
     50        union Val {
     51                unsigned long long ival;
     52                double dval;
     53                Val( unsigned long long ival ) : ival( ival ) {}
     54                Val( double dval ) : dval( dval ) {}
     55        } val;
    4856};
    4957
  • src/SynTree/Expression.cc

    re4d829b r579263a  
    287287}
    288288
    289 // CastExpr *CastExpr::clone() const { return 0; }
    290 
    291289void CastExpr::print( std::ostream &os, int indent ) const {
    292290        os << "Cast of:" << std::endl << std::string( indent+2, ' ' );
     
    354352}
    355353
    356 //// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned...
    357354MemberExpr::MemberExpr( const MemberExpr &other ) :
    358355                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
     
    360357
    361358MemberExpr::~MemberExpr() {
    362         // delete member;
     359        // don't delete the member declaration, since it points somewhere else in the tree
    363360        delete aggregate;
    364361}
     
    590587}
    591588
    592 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
    593 
    594 UntypedValofExpr::~UntypedValofExpr() { delete body; }
    595 
    596 void UntypedValofExpr::print( std::ostream &os, int indent ) const {
    597         os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl;
    598         if ( get_body() != 0 )
    599                 get_body()->print( os, indent + 2 );
    600 }
    601 
    602589RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    603590RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
  • src/SynTree/Expression.h

    re4d829b r579263a  
    226226};
    227227
    228 /// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer
     228/// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer.
     229/// Does not take ownership of member.
    229230class MemberExpr : public Expression {
    230231  public:
     
    247248};
    248249
    249 /// VariableExpr represents an expression that simply refers to the value of a named variable
     250/// VariableExpr represents an expression that simply refers to the value of a named variable.
     251/// Does not take ownership of var.
    250252class VariableExpr : public Expression {
    251253  public:
     
    598600};
    599601
    600 /// ValofExpr represents a GCC 'lambda expression'
    601 class UntypedValofExpr : public Expression {
    602   public:
    603         UntypedValofExpr( Statement *_body, Expression *_aname = nullptr ) : Expression( _aname ), body ( _body ) {}
    604         UntypedValofExpr( const UntypedValofExpr & other );
    605         virtual ~UntypedValofExpr();
    606 
    607         Expression * get_value();
    608         Statement * get_body() const { return body; }
    609 
    610         virtual UntypedValofExpr * clone() const { return new UntypedValofExpr( * this ); }
    611         virtual void accept( Visitor & v ) { v.visit( this ); }
    612         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    613         virtual void print( std::ostream & os, int indent = 0 ) const;
    614   private:
    615         Statement * body;
    616 };
    617 
    618602/// RangeExpr represents a range e.g. '3 ... 5' or '1~10'
    619603class RangeExpr : public Expression {
     
    688672        Expression * tuple;
    689673        unsigned int index;
    690 };
    691 
    692 /// MemberTupleExpr represents a tuple member selection operation on a struct type, e.g. s.[a, b, c] after processing by the expression analyzer
    693 class MemberTupleExpr : public Expression {
    694   public:
    695         MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname = nullptr );
    696         MemberTupleExpr( const MemberTupleExpr & other );
    697         virtual ~MemberTupleExpr();
    698 
    699         Expression * get_member() const { return member; }
    700         Expression * get_aggregate() const { return aggregate; }
    701         MemberTupleExpr * set_member( Expression * newValue ) { member = newValue; return this; }
    702         MemberTupleExpr * set_aggregate( Expression * newValue ) { aggregate = newValue; return this; }
    703 
    704         virtual MemberTupleExpr * clone() const { return new MemberTupleExpr( * this ); }
    705         virtual void accept( Visitor & v ) { v.visit( this ); }
    706         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    707         virtual void print( std::ostream & os, int indent = 0 ) const;
    708   private:
    709         Expression * member;
    710         Expression * aggregate;
    711674};
    712675
  • src/SynTree/Initializer.cc

    re4d829b r579263a  
    4242        } // if
    4343}
    44 
    4544
    4645Initializer::Initializer( bool maybeConstructed ) : maybeConstructed( maybeConstructed ) {}
  • src/SynTree/Mutator.cc

    re4d829b r579263a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 30 16:45:19 2017
    13 // Update Count     : 22
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thu Jun 22 13:43:00 2017
     13// Update Count     : 24
    1414//
    1515
     
    153153}
    154154
     155Statement *Mutator::mutate( ThrowStmt *throwStmt ) {
     156        throwStmt->set_expr( maybeMutate( throwStmt->get_expr(), *this ) );
     157        throwStmt->set_target( maybeMutate( throwStmt->get_target(), *this ) );
     158        return throwStmt;
     159}
     160
    155161Statement *Mutator::mutate( TryStmt *tryStmt ) {
    156162        tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
    157163        mutateAll( tryStmt->get_catchers(), *this );
     164        tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) );
    158165        return tryStmt;
    159166}
     
    161168Statement *Mutator::mutate( CatchStmt *catchStmt ) {
    162169        catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
     170        catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) );
    163171        catchStmt->set_body( maybeMutate( catchStmt->get_body(), *this ) );
    164172        return catchStmt;
     
    374382}
    375383
    376 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
    377         valofExpr->set_env( maybeMutate( valofExpr->get_env(), *this ) );
    378         valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) );
    379         return valofExpr;
    380 }
    381 
    382384Expression *Mutator::mutate( RangeExpr *rangeExpr ) {
    383385        rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
     
    405407        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
    406408        tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
    407         return tupleExpr;
    408 }
    409 
    410 Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) {
    411         tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
    412         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
    413         tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) );
    414         tupleExpr->set_aggregate( maybeMutate( tupleExpr->get_aggregate(), *this ) );
    415409        return tupleExpr;
    416410}
  • src/SynTree/Mutator.h

    re4d829b r579263a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  9 14:23:23 2017
    13 // Update Count     : 13
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thu Jun  8 15:45:00 2017
     13// Update Count     : 14
    1414//
    1515#include <cassert>
     
    4646        virtual Statement* mutate( BranchStmt *branchStmt );
    4747        virtual Statement* mutate( ReturnStmt *returnStmt );
    48         virtual Statement* mutate( TryStmt *returnStmt );
     48        virtual Statement* mutate( ThrowStmt *throwStmt );
     49        virtual Statement* mutate( TryStmt *tryStmt );
    4950        virtual Statement* mutate( CatchStmt *catchStmt );
    5051        virtual Statement* mutate( FinallyStmt *catchStmt );
     
    7778        virtual Expression* mutate( ConstructorExpr *ctorExpr );
    7879        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
    79         virtual Expression* mutate( UntypedValofExpr *valofExpr );
    8080        virtual Expression* mutate( RangeExpr *rangeExpr );
    8181        virtual Expression* mutate( UntypedTupleExpr *tupleExpr );
    8282        virtual Expression* mutate( TupleExpr *tupleExpr );
    8383        virtual Expression* mutate( TupleIndexExpr *tupleExpr );
    84         virtual Expression* mutate( MemberTupleExpr *tupleExpr );
    8584        virtual Expression* mutate( TupleAssignExpr *assignExpr );
    8685        virtual Expression* mutate( StmtExpr * stmtExpr );
  • src/SynTree/ObjectDecl.cc

    re4d829b r579263a  
    5656
    5757        if ( init ) {
    58                 os << " with initializer ";
    59                 init->print( os, indent );
    60                 os << std::endl << std::string(indent, ' ');
     58                os << " with initializer " << std::endl;
     59                init->print( os, indent+2 );
     60                os << std::endl << std::string(indent+2, ' ');
    6161                os << "maybeConstructed? " << init->get_maybeConstructed();
    6262        } // if
  • src/SynTree/Statement.cc

    re4d829b r579263a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 12 13:58:48 2016
    13 // Update Count     : 62
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Jun 12 10:37:00 2017
     13// Update Count     : 64
    1414//
    1515
     
    101101}
    102102
    103 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) : Statement( labels ), expr( _expr ), isThrow( throwP ) {}
    104 
    105 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ), isThrow( other.isThrow ) {}
     103ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr ) : Statement( labels ), expr( _expr ) {}
     104
     105ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
    106106
    107107ReturnStmt::~ReturnStmt() {
     
    110110
    111111void ReturnStmt::print( std::ostream &os, int indent ) const {
    112         os << string ( isThrow? "Throw":"Return" ) << " Statement, returning: ";
     112        os <<  "Return Statement, returning: ";
    113113        if ( expr != 0 ) {
    114114                os << endl << string( indent+2, ' ' );
     
    287287}
    288288
    289 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &_handlers, FinallyStmt *_finallyBlock ) :
     289ThrowStmt::ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target ) :
     290                Statement( labels ), kind(kind), expr(expr), target(target)     {
     291        assertf(Resume == kind || nullptr == target, "Non-local termination throw is not accepted." );
     292}
     293
     294ThrowStmt::ThrowStmt( const ThrowStmt &other ) :
     295        Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) {
     296}
     297
     298ThrowStmt::~ThrowStmt() {
     299        delete expr;
     300        delete target;
     301}
     302
     303void ThrowStmt::print( std::ostream &os, int indent) const {
     304        if ( target ) {
     305                os << "Non-Local ";
     306        }
     307        os << "Throw Statement, raising: ";
     308        expr->print(os, indent + 4);
     309        if ( target ) {
     310                os << "At: ";
     311                target->print(os, indent + 4);
     312        }
     313}
     314
     315TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &_handlers, FinallyStmt *_finallyBlock ) :
    290316        Statement( labels ), block( tryBlock ),  handlers( _handlers ), finallyBlock( _finallyBlock ) {
    291317}
     
    308334        // handlers
    309335        os << string( indent + 2, ' ' ) << "and handlers: " << endl;
    310         for ( std::list<Statement *>::const_iterator i = handlers.begin(); i != handlers.end(); i++)
     336        for ( std::list<CatchStmt *>::const_iterator i = handlers.begin(); i != handlers.end(); i++)
    311337                (*i )->print( os, indent + 4 );
    312338
     
    318344}
    319345
    320 CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool catchAny ) :
    321         Statement( labels ), decl ( _decl ), body( _body ), catchRest ( catchAny ) {
     346CatchStmt::CatchStmt( std::list<Label> labels, Kind _kind, Declaration *_decl, Expression *_cond, Statement *_body ) :
     347        Statement( labels ), kind ( _kind ), decl ( _decl ), cond ( _cond ), body( _body ) {
    322348}
    323349
    324350CatchStmt::CatchStmt( const CatchStmt & other ) :
    325         Statement( other ), decl ( maybeClone( other.decl ) ), body( maybeClone( other.body ) ), catchRest ( other.catchRest ) {
     351        Statement( other ), kind ( other.kind ), decl ( maybeClone( other.decl ) ), cond ( maybeClone( other.cond ) ), body( maybeClone( other.body ) ) {
    326352}
    327353
     
    332358
    333359void CatchStmt::print( std::ostream &os, int indent ) const {
    334         os << "Catch Statement" << endl;
     360        os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
    335361
    336362        os << string( indent, ' ' ) << "... catching" << endl;
     
    338364                decl->printShort( os, indent + 4 );
    339365                os << endl;
    340         } else if ( catchRest )
    341                 os << string( indent + 4 , ' ' ) << "the rest" << endl;
     366        }
    342367        else
    343368                os << string( indent + 4 , ' ' ) << ">>> Error:  this catch clause must have a declaration <<<" << endl;
  • src/SynTree/Statement.h

    re4d829b r579263a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 12 13:57:46 2016
    13 // Update Count     : 65
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Jun 12 13:35:00 2017
     13// Update Count     : 67
    1414//
    1515
     
    5757  private:
    5858        std::list<Statement*> kids;
     59};
     60
     61class NullStmt : public CompoundStmt {
     62  public:
     63        NullStmt();
     64        NullStmt( std::list<Label> labels );
     65
     66        virtual NullStmt *clone() const { return new NullStmt( *this ); }
     67        virtual void accept( Visitor &v ) { v.visit( this ); }
     68        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     69        virtual void print( std::ostream &os, int indent = 0 ) const;
     70
     71  private:
    5972};
    6073
     
    261274class ReturnStmt : public Statement {
    262275  public:
    263         ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false );
     276        ReturnStmt( std::list<Label> labels, Expression *expr );
    264277        ReturnStmt( const ReturnStmt &other );
    265278        virtual ~ReturnStmt();
     
    274287  private:
    275288        Expression *expr;
    276         bool isThrow;
    277 };
    278 
    279 
    280 class NullStmt : public CompoundStmt {
    281   public:
    282         NullStmt();
    283         NullStmt( std::list<Label> labels );
    284 
    285         virtual NullStmt *clone() const { return new NullStmt( *this ); }
    286         virtual void accept( Visitor &v ) { v.visit( this ); }
    287         virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    288         virtual void print( std::ostream &os, int indent = 0 ) const;
    289 
    290   private:
     289};
     290
     291class ThrowStmt : public Statement {
     292  public:
     293        enum Kind { Terminate, Resume };
     294
     295        ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr );
     296        ThrowStmt( const ThrowStmt &other );
     297        virtual ~ThrowStmt();
     298
     299        Kind get_kind() { return kind; }
     300        Expression * get_expr() { return expr; }
     301        void set_expr( Expression * newExpr ) { expr = newExpr; }
     302        Expression * get_target() { return target; }
     303        void set_target( Expression * newTarget ) { target = newTarget; }
     304
     305        virtual ThrowStmt *clone() const { return new ThrowStmt( *this ); }
     306        virtual void accept( Visitor &v ) { v.visit( this ); }
     307        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     308        virtual void print( std::ostream &os, int indent = 0 ) const;
     309  private:
     310        Kind kind;
     311        Expression * expr;
     312        Expression * target;
    291313};
    292314
    293315class TryStmt : public Statement {
    294316  public:
    295         TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
     317        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
    296318        TryStmt( const TryStmt &other );
    297319        virtual ~TryStmt();
     
    299321        CompoundStmt *get_block() const { return block; }
    300322        void set_block( CompoundStmt *newValue ) { block = newValue; }
    301         std::list<Statement *>& get_catchers() { return handlers; }
     323        std::list<CatchStmt *>& get_catchers() { return handlers; }
    302324
    303325        FinallyStmt *get_finally() const { return finallyBlock; }
     
    311333  private:
    312334        CompoundStmt *block;
    313         std::list<Statement *> handlers;
     335        std::list<CatchStmt *> handlers;
    314336        FinallyStmt *finallyBlock;
    315337};
     
    317339class CatchStmt : public Statement {
    318340  public:
    319         CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool catchAny = false );
     341        enum Kind { Terminate, Resume };
     342
     343        CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl,
     344                   Expression *cond, Statement *body );
    320345        CatchStmt( const CatchStmt &other );
    321346        virtual ~CatchStmt();
    322347
     348        Kind get_kind() { return kind; }
    323349        Declaration *get_decl() { return decl; }
    324350        void set_decl( Declaration *newValue ) { decl = newValue; }
    325 
     351        Expression *get_cond() { return cond; }
     352        void set_cond( Expression *newCond ) { cond = newCond; }
    326353        Statement *get_body() { return body; }
    327354        void set_body( Statement *newValue ) { body = newValue; }
     
    333360
    334361  private:
     362        Kind kind;
    335363        Declaration *decl;
     364        Expression *cond;
    336365        Statement *body;
    337         bool catchRest;
    338366};
    339367
  • src/SynTree/SynTree.h

    re4d829b r579263a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  9 14:23:49 2017
    13 // Update Count     : 8
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thu Jun  8 17:00:00 2017
     13// Update Count     : 9
    1414//
    1515
     
    5151class BranchStmt;
    5252class ReturnStmt;
     53class ThrowStmt;
    5354class TryStmt;
    5455class CatchStmt;
     
    8990class TupleExpr;
    9091class TupleIndexExpr;
    91 class MemberTupleExpr;
    9292class TupleAssignExpr;
    9393class StmtExpr;
  • src/SynTree/TupleExpr.cc

    re4d829b r579263a  
    7878}
    7979
    80 MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) {
    81         set_result( maybeClone( member->get_result() ) ); // xxx - ???
    82 }
    83 
    84 MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) {
    85 }
    86 
    87 MemberTupleExpr::~MemberTupleExpr() {
    88         delete member;
    89         delete aggregate;
    90 }
    91 
    92 void MemberTupleExpr::print( std::ostream &os, int indent ) const {
    93         os << "Member Tuple Expression, with aggregate:" << std::endl;
    94         os << std::string( indent+2, ' ' );
    95         aggregate->print( os, indent+2 );
    96         os << std::string( indent+2, ' ' ) << "with member: " << std::endl;
    97         os << std::string( indent+2, ' ' );
    98         member->print( os, indent+2 );
    99         Expression::print( os, indent );
    100 }
    101 
    10280TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ) {
    10381        // convert internally into a StmtExpr which contains the declarations and produces the tuple of the assignments
  • src/SynTree/Visitor.cc

    re4d829b r579263a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 30 16:45:25 2017
    13 // Update Count     : 24
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thu Jun 22 13:41:00 2017
     13// Update Count     : 26
    1414//
    1515
     
    129129}
    130130
     131void Visitor::visit( ThrowStmt * throwStmt ) {
     132        maybeAccept( throwStmt->get_expr(), *this );
     133        maybeAccept( throwStmt->get_target(), *this );
     134}
     135
    131136void Visitor::visit( TryStmt *tryStmt ) {
    132137        maybeAccept( tryStmt->get_block(), *this );
    133138        acceptAll( tryStmt->get_catchers(), *this );
     139        maybeAccept( tryStmt->get_finally(), *this );
    134140}
    135141
    136142void Visitor::visit( CatchStmt *catchStmt ) {
    137143        maybeAccept( catchStmt->get_decl(), *this );
     144        maybeAccept( catchStmt->get_cond(), *this );
    138145        maybeAccept( catchStmt->get_body(), *this );
    139146}
     
    296303}
    297304
    298 void Visitor::visit( UntypedValofExpr *valofExpr ) {
    299         maybeAccept( valofExpr->get_result(), *this );
    300         maybeAccept( valofExpr->get_body(), *this );
    301 }
    302 
    303305void Visitor::visit( RangeExpr *rangeExpr ) {
    304306        maybeAccept( rangeExpr->get_low(), *this );
     
    319321        maybeAccept( tupleExpr->get_result(), *this );
    320322        maybeAccept( tupleExpr->get_tuple(), *this );
    321 }
    322 
    323 void Visitor::visit( MemberTupleExpr *tupleExpr ) {
    324         maybeAccept( tupleExpr->get_result(), *this );
    325         maybeAccept( tupleExpr->get_member(), *this );
    326         maybeAccept( tupleExpr->get_aggregate(), *this );
    327323}
    328324
  • src/SynTree/Visitor.h

    re4d829b r579263a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed May  3 08:58:00 2017
    13 // Update Count     : 10
     12// Last Modified On : Thr Jun 08 15:45:00 2017
     13// Update Count     : 11
    1414//
    1515
     
    4949        virtual void visit( BranchStmt *branchStmt );
    5050        virtual void visit( ReturnStmt *returnStmt );
     51        virtual void visit( ThrowStmt *throwStmt );
    5152        virtual void visit( TryStmt *tryStmt );
    5253        virtual void visit( CatchStmt *catchStmt );
     
    8081        virtual void visit( ConstructorExpr * ctorExpr );
    8182        virtual void visit( CompoundLiteralExpr *compLitExpr );
    82         virtual void visit( UntypedValofExpr *valofExpr );
    8383        virtual void visit( RangeExpr *rangeExpr );
    8484        virtual void visit( UntypedTupleExpr *tupleExpr );
    8585        virtual void visit( TupleExpr *tupleExpr );
    8686        virtual void visit( TupleIndexExpr *tupleExpr );
    87         virtual void visit( MemberTupleExpr *tupleExpr );
    8887        virtual void visit( TupleAssignExpr *assignExpr );
    8988        virtual void visit( StmtExpr * stmtExpr );
  • src/SynTree/ZeroOneType.cc

    re4d829b r579263a  
    2020ZeroType::ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes ) : Type( tq, attributes ) {}
    2121
    22 void ZeroType::print( std::ostream &os, int indent ) const {
     22void ZeroType::print( std::ostream &os, __attribute__((unused)) int indent ) const {
    2323        os << "zero_t";
    2424}
     
    2828OneType::OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes ) : Type( tq, attributes ) {}
    2929
    30 void OneType::print( std::ostream &os, int indent ) const {
     30void OneType::print( std::ostream &os, __attribute__((unused)) int indent ) const {
    3131        os << "one_t";
    3232}
Note: See TracChangeset for help on using the changeset viewer.