Changeset e9a3b20b for src/SynTree
- Timestamp:
- Jun 21, 2017, 5:47:52 PM (8 years ago)
- 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:
- 1a18423, 2c37f34, 925b7f4, 969ee0df, fda8168
- Parents:
- d56e5bc (diff), 06edda0 (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. - Location:
- src/SynTree
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/BaseSyntaxNode.h
rd56e5bc re9a3b20b 24 24 CodeLocation location; 25 25 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; 27 29 }; 28 30 -
src/SynTree/Expression.cc
rd56e5bc re9a3b20b 288 288 } 289 289 290 // CastExpr *CastExpr::clone() const { return 0; }291 292 290 void CastExpr::print( std::ostream &os, int indent ) const { 293 291 os << "Cast of:" << std::endl << std::string( indent+2, ' ' ); … … 355 353 } 356 354 357 //// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned...358 355 MemberExpr::MemberExpr( const MemberExpr &other ) : 359 356 Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) { … … 361 358 362 359 MemberExpr::~MemberExpr() { 363 // d elete member;360 // don't delete the member declaration, since it points somewhere else in the tree 364 361 delete aggregate; 365 362 } … … 591 588 } 592 589 593 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}594 595 UntypedValofExpr::~UntypedValofExpr() { delete body; }596 597 void UntypedValofExpr::print( std::ostream &os, int indent ) const {598 os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl;599 if ( get_body() != 0 )600 get_body()->print( os, indent + 2 );601 }602 603 590 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {} 604 591 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {} -
src/SynTree/Expression.h
rd56e5bc re9a3b20b 226 226 }; 227 227 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. 229 230 class MemberExpr : public Expression { 230 231 public: … … 247 248 }; 248 249 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. 250 252 class VariableExpr : public Expression { 251 253 public: … … 598 600 }; 599 601 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 618 602 /// RangeExpr represents a range e.g. '3 ... 5' or '1~10' 619 603 class RangeExpr : public Expression { -
src/SynTree/Mutator.cc
rd56e5bc re9a3b20b 380 380 } 381 381 382 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {383 valofExpr->set_env( maybeMutate( valofExpr->get_env(), *this ) );384 valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) );385 return valofExpr;386 }387 388 382 Expression *Mutator::mutate( RangeExpr *rangeExpr ) { 389 383 rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) ); -
src/SynTree/Mutator.h
rd56e5bc re9a3b20b 78 78 virtual Expression* mutate( ConstructorExpr *ctorExpr ); 79 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 80 virtual Expression* mutate( UntypedValofExpr *valofExpr );81 80 virtual Expression* mutate( RangeExpr *rangeExpr ); 82 81 virtual Expression* mutate( UntypedTupleExpr *tupleExpr ); -
src/SynTree/ObjectDecl.cc
rd56e5bc re9a3b20b 56 56 57 57 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, ' '); 61 61 os << "maybeConstructed? " << init->get_maybeConstructed(); 62 62 } // if -
src/SynTree/Statement.cc
rd56e5bc re9a3b20b 313 313 } 314 314 315 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list< Statement *> &_handlers, FinallyStmt *_finallyBlock ) :315 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &_handlers, FinallyStmt *_finallyBlock ) : 316 316 Statement( labels ), block( tryBlock ), handlers( _handlers ), finallyBlock( _finallyBlock ) { 317 317 } … … 334 334 // handlers 335 335 os << string( indent + 2, ' ' ) << "and handlers: " << endl; 336 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++) 337 337 (*i )->print( os, indent + 4 ); 338 338 -
src/SynTree/Statement.h
rd56e5bc re9a3b20b 315 315 class TryStmt : public Statement { 316 316 public: 317 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 ); 318 318 TryStmt( const TryStmt &other ); 319 319 virtual ~TryStmt(); … … 321 321 CompoundStmt *get_block() const { return block; } 322 322 void set_block( CompoundStmt *newValue ) { block = newValue; } 323 std::list< Statement *>& get_catchers() { return handlers; }323 std::list<CatchStmt *>& get_catchers() { return handlers; } 324 324 325 325 FinallyStmt *get_finally() const { return finallyBlock; } … … 333 333 private: 334 334 CompoundStmt *block; 335 std::list< Statement *> handlers;335 std::list<CatchStmt *> handlers; 336 336 FinallyStmt *finallyBlock; 337 337 }; -
src/SynTree/Visitor.cc
rd56e5bc re9a3b20b 301 301 } 302 302 303 void Visitor::visit( UntypedValofExpr *valofExpr ) {304 maybeAccept( valofExpr->get_result(), *this );305 maybeAccept( valofExpr->get_body(), *this );306 }307 308 303 void Visitor::visit( RangeExpr *rangeExpr ) { 309 304 maybeAccept( rangeExpr->get_low(), *this ); -
src/SynTree/Visitor.h
rd56e5bc re9a3b20b 81 81 virtual void visit( ConstructorExpr * ctorExpr ); 82 82 virtual void visit( CompoundLiteralExpr *compLitExpr ); 83 virtual void visit( UntypedValofExpr *valofExpr );84 83 virtual void visit( RangeExpr *rangeExpr ); 85 84 virtual void visit( UntypedTupleExpr *tupleExpr ); … … 163 162 } // if 164 163 } catch( SemanticError &e ) { 165 e.set_location( (*i)->location ); 164 e.set_location( (*i)->location ); 166 165 errors.append( e ); 167 166 } // try
Note: See TracChangeset
for help on using the changeset viewer.