Changeset bdd516a for translator/SynTree
- Timestamp:
- Apr 28, 2015, 4:21:36 PM (11 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:
- 42e2ad7
- Parents:
- ad17ba6a
- Location:
- translator/SynTree
- Files:
-
- 9 edited
-
Initializer.cc (modified) (1 diff)
-
Initializer.h (modified) (1 diff)
-
Mutator.cc (modified) (1 diff)
-
Mutator.h (modified) (1 diff)
-
SynTree.h (modified) (1 diff)
-
Type.cc (modified) (1 diff)
-
Type.h (modified) (9 diffs)
-
Visitor.cc (modified) (1 diff)
-
Visitor.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
translator/SynTree/Initializer.cc
rad17ba6a rbdd516a 39 39 } 40 40 41 MemberInit::MemberInit( Expression *_value, std::string _member ) : member ( _member ), value ( _value ) {}42 43 MemberInit::~MemberInit() {}44 45 MemberInit * MemberInit::clone() const {46 return new MemberInit( *this );47 }48 49 void MemberInit::print( std::ostream &os, int indent ) {50 os << "Member Initializer";51 value->print( os, indent+2 );52 }53 54 41 ListInit::ListInit( std::list<Initializer*> &_initializers, std::list<Expression *> &_designators ) 55 42 : initializers( _initializers ), designators( _designators ) { -
translator/SynTree/Initializer.h
rad17ba6a rbdd516a 61 61 }; 62 62 63 // MemberInit represents an initializer for a member of an aggregate object (e.g., struct q { int a; } x = { a : 4 } )64 class MemberInit : public Initializer {65 public:66 MemberInit( Expression *value, std::string member = std::string("") );67 virtual ~MemberInit();68 69 std::string get_member() { return member; }70 void set_member( std::string newValue ) { member = newValue; }71 Expression *get_value() { return value; }72 void set_value( Expression *newValue ) { value = newValue; }73 74 virtual MemberInit *clone() const;75 virtual void accept( Visitor &v ) { v.visit( this ); }76 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }77 virtual void print( std::ostream &os, int indent = 0 );78 private:79 std::string member;80 Expression *value;81 };82 83 // ElementInit represents an initializer of an element of an array (e.g., [10] int x = { [7] : 4 }84 class ElementInit : public Initializer {85 public:86 ElementInit( Expression *value );87 virtual ~ElementInit();88 89 int get_index() { return index; }90 void set_index( int newValue ) { index = newValue; }91 Expression *get_value() { return value; }92 void set_value( Expression *newValue ) { value = newValue; }93 94 virtual ElementInit *clone() const;95 virtual void accept( Visitor &v ) { v.visit( this ); }96 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }97 virtual void print( std::ostream &os, int indent = 0 );98 private:99 int index;100 Expression *value;101 };102 103 63 // ListInit represents an initializer that is composed recursively of a list of initializers; this is used to initialize 104 64 // an array or aggregate -
translator/SynTree/Mutator.cc
rad17ba6a rbdd516a 368 368 } 369 369 370 Initializer *Mutator::mutate( MemberInit *memberInit ) {371 memberInit->set_value( memberInit->get_value()->acceptMutator( *this ) );372 return memberInit;373 }374 375 Initializer *Mutator::mutate( ElementInit *elementInit ) {376 elementInit->set_value( elementInit->get_value()->acceptMutator( *this ) );377 return elementInit;378 }379 380 370 Initializer *Mutator::mutate( SingleInit *singleInit ) { 381 371 singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) ); -
translator/SynTree/Mutator.h
rad17ba6a rbdd516a 72 72 virtual Type* mutate( AttrType *attrType ); 73 73 74 virtual Initializer* mutate( MemberInit *memberInit );75 virtual Initializer* mutate( ElementInit *elementInit );76 74 virtual Initializer* mutate( SingleInit *singleInit ); 77 75 virtual Initializer* mutate( ListInit *listInit ); -
translator/SynTree/SynTree.h
rad17ba6a rbdd516a 89 89 90 90 class Initializer; 91 class MemberInit;92 class ElementInit;93 91 class SingleInit; 94 92 class ListInit; -
translator/SynTree/Type.cc
rad17ba6a rbdd516a 57 57 os << "lvalue "; 58 58 } // if 59 if ( tq.isAtomic ) { 60 os << "_Atomic "; 61 } // if 59 62 } -
translator/SynTree/Type.h
rad17ba6a rbdd516a 10 10 public: 11 11 struct Qualifiers { 12 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ) {}13 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue) {}12 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ) {} 13 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ) {} 14 14 15 15 Qualifiers &operator+=( const Qualifiers &other ); … … 27 27 bool isRestrict; 28 28 bool isLvalue; 29 bool isAtomic; 29 30 }; 30 31 … … 38 39 bool get_isRestrict() { return tq.isRestrict; } 39 40 bool get_isLvalue() { return tq.isLvalue; } 41 bool get_isAtomic() { return tq.isAtomic; } 40 42 void set_isConst( bool newValue ) { tq.isConst = newValue; } 41 43 void set_iisVolatile( bool newValue ) { tq.isVolatile = newValue; } 42 44 void set_isRestrict( bool newValue ) { tq.isRestrict = newValue; } 43 45 void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; } 46 void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; } 44 47 std::list<TypeDecl*>& get_forall() { return forall; } 45 48 … … 380 383 isRestrict |= other.isRestrict; 381 384 isLvalue |= other.isLvalue; 385 isAtomic |= other.isAtomic; 382 386 return *this; 383 387 } … … 387 391 if ( other.isVolatile ) isVolatile = 0; 388 392 if ( other.isRestrict ) isRestrict = 0; 393 if ( other.isAtomic ) isAtomic = 0; 389 394 return *this; 390 395 } … … 398 403 inline bool Type::Qualifiers::operator==( const Qualifiers &other ) { 399 404 return isConst == other.isConst 400 && isVolatile == other.isVolatile 401 && isRestrict == other.isRestrict; 402 /// && isLvalue == other.isLvalue; 405 && isVolatile == other.isVolatile 406 && isRestrict == other.isRestrict 407 // && isLvalue == other.isLvalue 408 && isAtomic == other.isAtomic; 403 409 } 404 410 … … 406 412 return isConst != other.isConst 407 413 || isVolatile != other.isVolatile 408 || isRestrict != other.isRestrict; 409 /// && isLvalue == other.isLvalue; 414 || isRestrict != other.isRestrict 415 // || isLvalue != other.isLvalue 416 || isAtomic != other.isAtomic; 410 417 } 411 418 … … 413 420 return isConst <= other.isConst 414 421 && isVolatile <= other.isVolatile 415 && isRestrict <= other.isRestrict; 416 /// && isLvalue >= other.isLvalue; 422 && isRestrict <= other.isRestrict 423 // && isLvalue >= other.isLvalue 424 && isAtomic == other.isAtomic; 417 425 } 418 426 … … 420 428 return isConst >= other.isConst 421 429 && isVolatile >= other.isVolatile 422 && isRestrict >= other.isRestrict; 423 /// && isLvalue <= other.isLvalue; 430 && isRestrict >= other.isRestrict 431 // && isLvalue <= other.isLvalue 432 && isAtomic == other.isAtomic; 424 433 } 425 434 -
translator/SynTree/Visitor.cc
rad17ba6a rbdd516a 309 309 } 310 310 311 void Visitor::visit(MemberInit *memberInit) {312 memberInit->get_value()->accept( *this );313 }314 315 void Visitor::visit(ElementInit *elementInit) {316 elementInit->get_value()->accept( *this );317 }318 319 311 void Visitor::visit(SingleInit *singleInit) { 320 312 singleInit->get_value()->accept( *this ); -
translator/SynTree/Visitor.h
rad17ba6a rbdd516a 72 72 virtual void visit( AttrType *attrType ); 73 73 74 virtual void visit( MemberInit *memberInit );75 virtual void visit( ElementInit *elementInit );76 74 virtual void visit( SingleInit *singleInit ); 77 75 virtual void visit( ListInit *listInit );
Note:
See TracChangeset
for help on using the changeset viewer.