Changeset 70a06f6 for src/SynTree
- Timestamp:
- Apr 14, 2016, 4:13:10 PM (10 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:
- 356189a
- Parents:
- db4ecc5 (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. - Location:
- src/SynTree
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
rdb4ecc5 r70a06f6 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Apr 14 1 3:02:28201613 // Update Count : 3412 // Last Modified On : Thu Apr 14 15:33:12 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" … … 213 214 214 215 os << " of "; 216 217 if ( type ) { 218 type->print(os, indent + 2); 219 } else { 220 os << "<NULL>"; 221 } 222 223 os << std::endl; 224 Expression::print( os, indent ); 225 } 226 227 OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) { 228 add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) ); 229 } 230 231 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {} 232 233 OffsetPackExpr::~OffsetPackExpr() { delete type; } 234 235 void OffsetPackExpr::print( std::ostream &os, int indent ) const { 236 os << std::string( indent, ' ' ) << "Offset pack expression on "; 215 237 216 238 if ( type ) { … … 478 500 479 501 502 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) { 503 add_result( type->clone() ); 504 } 505 506 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {} 507 508 CompoundLiteralExpr::~CompoundLiteralExpr() { 509 delete initializer; 510 delete type; 511 } 512 513 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const { 514 os << "Compound Literal Expression: " << std::endl; 515 if ( type ) type->print( os, indent + 2 ); 516 if ( initializer ) initializer->print( os, indent + 2 ); 517 } 518 480 519 481 520 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.h
rdb4ecc5 r70a06f6 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Apr 14 1 2:04:58201613 // Update Count : 1912 // Last Modified On : Thu Apr 14 15:40:56 2016 13 // Update Count : 21 14 14 // 15 15 … … 363 363 }; 364 364 365 /// Expression representing a pack of field-offsets for a generic type 366 class OffsetPackExpr : public Expression { 367 public: 368 OffsetPackExpr( StructInstType *type_, Expression *aname_ = 0 ); 369 OffsetPackExpr( const OffsetPackExpr &other ); 370 virtual ~OffsetPackExpr(); 371 372 StructInstType *get_type() const { return type; } 373 void set_type( StructInstType *newValue ) { type = newValue; } 374 375 virtual OffsetPackExpr *clone() const { return new OffsetPackExpr( *this ); } 376 virtual void accept( Visitor &v ) { v.visit( this ); } 377 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 378 379 virtual void print( std::ostream &os, int indent = 0 ) const; 380 381 private: 382 StructInstType *type; 383 }; 384 365 385 /// AttrExpr represents an @attribute expression (like sizeof, but user-defined) 366 386 class AttrExpr : public Expression { … … 593 613 }; 594 614 615 /// CompoundLiteralExpr represents a C99 'compound literal' 616 class CompoundLiteralExpr : public Expression { 617 public: 618 CompoundLiteralExpr( Type * type, Initializer * initializer ); 619 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 620 ~CompoundLiteralExpr(); 621 622 Type * get_type() const { return type; } 623 void set_type( Type * t ) { type = t; } 624 625 Initializer * get_initializer() const { return initializer; } 626 void set_initializer( Initializer * i ) { initializer = i; } 627 628 virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); } 629 virtual void accept( Visitor &v ) { v.visit( this ); } 630 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 631 virtual void print( std::ostream &os, int indent = 0 ) const; 632 private: 633 Type * type; 634 Initializer * initializer; 635 }; 636 595 637 std::ostream & operator<<( std::ostream & out, Expression * expr ); 596 638 -
src/SynTree/Mutator.cc
rdb4ecc5 r70a06f6 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Apr 08 14:01:47201613 // Update Count : 1 512 // Last Modified On : Thu Apr 14 15:32:19 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 ); … … 341 347 mutateAll( valofExpr->get_results(), *this ); 342 348 return valofExpr; 349 } 350 351 Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) { 352 mutateAll( compLitExpr->get_results(), *this ); 353 compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) ); 354 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); 355 return compLitExpr; 343 356 } 344 357 -
src/SynTree/Mutator.h
rdb4ecc5 r70a06f6 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Apr 08 13:22:04201613 // Update Count : 912 // Last Modified On : Thu Apr 14 15:32:00 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 ); … … 77 78 virtual Expression* mutate( ImplicitCopyCtorExpr *impCpCtorExpr ); 78 79 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 80 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 79 81 80 82 virtual Type* mutate( VoidType *basicType ); -
src/SynTree/SynTree.h
rdb4ecc5 r70a06f6 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Apr 08 13:49:47201613 // Update Count : 412 // Last Modified On : Thu Apr 14 15:31:36 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; … … 82 83 class ImplicitCopyCtorExpr; 83 84 class UntypedValofExpr; 85 class CompoundLiteralExpr; 84 86 85 87 class Type; -
src/SynTree/Visitor.cc
rdb4ecc5 r70a06f6 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Apr 08 13:53:21201612 // Last Modified On : Thu Apr 14 15:31:18 2016 13 13 // Update Count : 18 14 14 // … … 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 ); … … 288 293 acceptAll( valofExpr->get_results(), *this ); 289 294 maybeAccept( valofExpr->get_body(), *this ); 295 } 296 297 void Visitor::visit( CompoundLiteralExpr *compLitExpr ) { 298 acceptAll( compLitExpr->get_results(), *this ); 299 maybeAccept( compLitExpr->get_type(), *this ); 300 maybeAccept( compLitExpr->get_initializer(), *this ); 290 301 } 291 302 -
src/SynTree/Visitor.h
rdb4ecc5 r70a06f6 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Apr 08 13:26:31201613 // Update Count : 612 // Last Modified On : Thu Apr 14 15:30:58 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 ); … … 77 78 virtual void visit( ImplicitCopyCtorExpr *impCpCtorExpr ); 78 79 virtual void visit( UntypedValofExpr *valofExpr ); 80 virtual void visit( CompoundLiteralExpr *compLitExpr ); 79 81 80 82 virtual void visit( VoidType *basicType );
Note:
See TracChangeset
for help on using the changeset viewer.