Changeset 630a82a for src/SynTree
- Timestamp:
- Apr 8, 2016, 5:22:29 PM (8 years ago)
- 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, string, with_gc
- Children:
- 3da470c
- Parents:
- 3d9b5da
- Location:
- src/SynTree
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r3d9b5da r630a82a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:10:29 201513 // Update Count : 3411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 8 17:16:23 2016 13 // Update Count : 40 14 14 // 15 15 … … 22 22 23 23 #include "Type.h" 24 #include "Initializer.h" 24 25 #include "Expression.h" 25 26 #include "Declaration.h" … … 443 444 444 445 446 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) { 447 add_result( type->clone() ); 448 } 449 450 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {} 451 452 CompoundLiteralExpr::~CompoundLiteralExpr() { 453 delete initializer; 454 delete type; 455 } 456 457 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const { 458 os << "Compound Literal Expression: " << std::endl; 459 if ( type ) type->print( os, indent + 2 ); 460 if ( initializer ) initializer->print( os, indent + 2 ); 461 } 462 445 463 446 464 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.h
r3d9b5da r630a82a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:10:21 201513 // Update Count : 1911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 8 17:18:06 2016 13 // Update Count : 21 14 14 // 15 15 … … 557 557 }; 558 558 559 /// CompoundLiteralExpr represents a C99 'compound literal' 560 class CompoundLiteralExpr : public Expression { 561 public: 562 CompoundLiteralExpr( Type * type, Initializer * initializer ); 563 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 564 ~CompoundLiteralExpr(); 565 566 Type * get_type() const { return type; } 567 void set_type( Type * t ) { type = t; } 568 569 Initializer * get_initializer() const { return initializer; } 570 void set_initializer( Initializer * i ) { initializer = i; } 571 572 virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); } 573 virtual void accept( Visitor &v ) { v.visit( this ); } 574 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 575 virtual void print( std::ostream &os, int indent = 0 ) const; 576 private: 577 Type * type; 578 Initializer * initializer; 579 }; 580 559 581 std::ostream & operator<<( std::ostream & out, Expression * expr ); 560 582 -
src/SynTree/Mutator.cc
r3d9b5da r630a82a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:28:20201613 // Update Count : 1 212 // Last Modified On : Fri Apr 1 18:05:16 2016 13 // Update Count : 16 14 14 // 15 15 … … 336 336 } 337 337 338 Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) { 339 mutateAll( compLitExpr->get_results(), *this ); 340 compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) ); 341 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); 342 return compLitExpr; 343 } 344 338 345 Type *Mutator::mutate( VoidType *voidType ) { 339 346 mutateAll( voidType->get_forall(), *this ); -
src/SynTree/Mutator.h
r3d9b5da r630a82a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:33:11201613 // Update Count : 912 // Last Modified On : Fri Apr 1 17:26:56 2016 13 // Update Count : 10 14 14 // 15 15 #include <cassert> … … 76 76 virtual Expression* mutate( AsmExpr *asmExpr ); 77 77 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 78 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 78 79 79 80 virtual Type* mutate( VoidType *basicType ); -
src/SynTree/SynTree.h
r3d9b5da r630a82a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:29:00201613 // Update Count : 412 // Last Modified On : Fri Apr 1 16:47:44 2016 13 // Update Count : 5 14 14 // 15 15 … … 81 81 class AsmExpr; 82 82 class UntypedValofExpr; 83 class CompoundLiteralExpr; 83 84 84 85 class Type; -
src/SynTree/Visitor.cc
r3d9b5da r630a82a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:29:23 201613 // Update Count : 1 612 // Last Modified On : Fri Apr 1 18:05:13 2016 13 // Update Count : 18 14 14 // 15 15 … … 284 284 } 285 285 286 void Visitor::visit( CompoundLiteralExpr *compLitExpr ) { 287 acceptAll( compLitExpr->get_results(), *this ); 288 maybeAccept( compLitExpr->get_type(), *this ); 289 maybeAccept( compLitExpr->get_initializer(), *this ); 290 } 291 286 292 void Visitor::visit( VoidType *voidType ) { 287 293 acceptAll( voidType->get_forall(), *this ); -
src/SynTree/Visitor.h
r3d9b5da r630a82a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:33:35 201613 // Update Count : 612 // Last Modified On : Fri Apr 1 17:26:55 2016 13 // Update Count : 7 14 14 // 15 15 … … 76 76 virtual void visit( AsmExpr *asmExpr ); 77 77 virtual void visit( UntypedValofExpr *valofExpr ); 78 virtual void visit( CompoundLiteralExpr *compLitExpr ); 78 79 79 80 virtual void visit( VoidType *basicType );
Note: See TracChangeset
for help on using the changeset viewer.