Changeset 1048b31 for src/SynTree
- Timestamp:
- May 2, 2016, 3:28:16 PM (9 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, with_gc
- Children:
- 1b7ea43
- Parents:
- 1f6e009 (diff), e945826 (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:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r1f6e009 r1048b31 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" … … 211 212 212 213 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 225 OffsetPackExpr::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 229 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {} 230 231 OffsetPackExpr::~OffsetPackExpr() { delete type; } 232 233 void OffsetPackExpr::print( std::ostream &os, int indent ) const { 234 os << std::string( indent, ' ' ) << "Offset pack expression on "; 213 235 214 236 if ( type ) { … … 443 465 444 466 467 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) { 468 add_result( type->clone() ); 469 } 470 471 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {} 472 473 CompoundLiteralExpr::~CompoundLiteralExpr() { 474 delete initializer; 475 delete type; 476 } 477 478 void 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 445 484 446 485 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.h
r1f6e009 r1048b31 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 … … 362 362 }; 363 363 364 /// Expression representing a pack of field-offsets for a generic type 365 class OffsetPackExpr : public Expression { 366 public: 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 380 private: 381 StructInstType *type; 382 }; 383 364 384 /// AttrExpr represents an @attribute expression (like sizeof, but user-defined) 365 385 class AttrExpr : public Expression { … … 557 577 }; 558 578 579 /// CompoundLiteralExpr represents a C99 'compound literal' 580 class 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; 599 }; 600 559 601 std::ostream & operator<<( std::ostream & out, Expression * expr ); 560 602 -
src/SynTree/Mutator.cc
r1f6e009 r1048b31 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 … … 274 274 } 275 275 276 Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) { 277 mutateAll( offsetPackExpr->get_results(), *this ); 278 offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) ); 279 return offsetPackExpr; 280 } 281 276 282 Expression *Mutator::mutate( AttrExpr *attrExpr ) { 277 283 mutateAll( attrExpr->get_results(), *this ); … … 334 340 mutateAll( valofExpr->get_results(), *this ); 335 341 return valofExpr; 342 } 343 344 Expression *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; 336 349 } 337 350 -
src/SynTree/Mutator.h
r1f6e009 r1048b31 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> … … 67 67 virtual Expression* mutate( UntypedOffsetofExpr *offsetofExpr ); 68 68 virtual Expression* mutate( OffsetofExpr *offsetofExpr ); 69 virtual Expression* mutate( OffsetPackExpr *offsetPackExpr ); 69 70 virtual Expression* mutate( AttrExpr *attrExpr ); 70 71 virtual Expression* mutate( LogicalExpr *logicalExpr ); … … 76 77 virtual Expression* mutate( AsmExpr *asmExpr ); 77 78 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 78 80 79 81 virtual Type* mutate( VoidType *basicType ); -
src/SynTree/SynTree.h
r1f6e009 r1048b31 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 … … 72 72 class UntypedOffsetofExpr; 73 73 class OffsetofExpr; 74 class OffsetPackExpr; 74 75 class AttrExpr; 75 76 class LogicalExpr; … … 81 82 class AsmExpr; 82 83 class UntypedValofExpr; 84 class CompoundLiteralExpr; 83 85 84 86 class Type; -
src/SynTree/Visitor.cc
r1f6e009 r1048b31 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 … … 230 230 } 231 231 232 void Visitor::visit( OffsetPackExpr *offsetPackExpr ) { 233 acceptAll( offsetPackExpr->get_results(), *this ); 234 maybeAccept( offsetPackExpr->get_type(), *this ); 235 } 236 232 237 void Visitor::visit( AttrExpr *attrExpr ) { 233 238 acceptAll( attrExpr->get_results(), *this ); … … 282 287 acceptAll( valofExpr->get_results(), *this ); 283 288 maybeAccept( valofExpr->get_body(), *this ); 289 } 290 291 void Visitor::visit( CompoundLiteralExpr *compLitExpr ) { 292 acceptAll( compLitExpr->get_results(), *this ); 293 maybeAccept( compLitExpr->get_type(), *this ); 294 maybeAccept( compLitExpr->get_initializer(), *this ); 284 295 } 285 296 -
src/SynTree/Visitor.h
r1f6e009 r1048b31 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 … … 67 67 virtual void visit( UntypedOffsetofExpr *offsetofExpr ); 68 68 virtual void visit( OffsetofExpr *offsetofExpr ); 69 virtual void visit( OffsetPackExpr *offsetPackExpr ); 69 70 virtual void visit( AttrExpr *attrExpr ); 70 71 virtual void visit( LogicalExpr *logicalExpr ); … … 76 77 virtual void visit( AsmExpr *asmExpr ); 77 78 virtual void visit( UntypedValofExpr *valofExpr ); 79 virtual void visit( CompoundLiteralExpr *compLitExpr ); 78 80 79 81 virtual void visit( VoidType *basicType );
Note: See TracChangeset
for help on using the changeset viewer.