Changeset bdd516a for translator/SynTree


Ignore:
Timestamp:
Apr 28, 2015, 4:21:36 PM (11 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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
Message:

fixed sizeof type variable, find lowest cost alternative for sizeof expression, removed unused classes, added compiler flag, remove temporary file for -CFA, formatting

Location:
translator/SynTree
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • translator/SynTree/Initializer.cc

    rad17ba6a rbdd516a  
    3939}
    4040
    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 
    5441ListInit::ListInit( std::list<Initializer*> &_initializers, std::list<Expression *> &_designators )
    5542    : initializers( _initializers ), designators( _designators ) {
  • translator/SynTree/Initializer.h

    rad17ba6a rbdd516a  
    6161};
    6262
    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 
    10363// ListInit represents an initializer that is composed recursively of a list of initializers; this is used to initialize
    10464// an array or aggregate
  • translator/SynTree/Mutator.cc

    rad17ba6a rbdd516a  
    368368}
    369369
    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 
    380370Initializer *Mutator::mutate( SingleInit *singleInit ) {
    381371    singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
  • translator/SynTree/Mutator.h

    rad17ba6a rbdd516a  
    7272    virtual Type* mutate( AttrType *attrType );
    7373
    74     virtual Initializer* mutate( MemberInit *memberInit );
    75     virtual Initializer* mutate( ElementInit *elementInit );
    7674    virtual Initializer* mutate( SingleInit *singleInit );
    7775    virtual Initializer* mutate( ListInit *listInit );
  • translator/SynTree/SynTree.h

    rad17ba6a rbdd516a  
    8989
    9090class Initializer;
    91 class MemberInit;
    92 class ElementInit;
    9391class SingleInit;
    9492class ListInit;
  • translator/SynTree/Type.cc

    rad17ba6a rbdd516a  
    5757        os << "lvalue ";
    5858    } // if
     59    if ( tq.isAtomic ) {
     60        os << "_Atomic ";
     61    } // if
    5962}
  • translator/SynTree/Type.h

    rad17ba6a rbdd516a  
    1010  public:
    1111    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 ) {}
    1414       
    1515        Qualifiers &operator+=( const Qualifiers &other );
     
    2727        bool isRestrict;
    2828        bool isLvalue;
     29        bool isAtomic;
    2930    }; 
    3031
     
    3839    bool get_isRestrict() { return tq.isRestrict; }
    3940    bool get_isLvalue() { return tq.isLvalue; }
     41    bool get_isAtomic() { return tq.isAtomic; }
    4042    void set_isConst( bool newValue ) { tq.isConst = newValue; }
    4143    void set_iisVolatile( bool newValue ) { tq.isVolatile = newValue; }
    4244    void set_isRestrict( bool newValue ) { tq.isRestrict = newValue; }
    4345    void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; }
     46    void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; }
    4447    std::list<TypeDecl*>& get_forall() { return forall; }
    4548
     
    380383    isRestrict |= other.isRestrict;
    381384    isLvalue |= other.isLvalue;
     385    isAtomic |= other.isAtomic;
    382386    return *this;
    383387}
     
    387391    if ( other.isVolatile ) isVolatile = 0;
    388392    if ( other.isRestrict ) isRestrict = 0;
     393    if ( other.isAtomic ) isAtomic = 0;
    389394    return *this;
    390395}
     
    398403inline bool Type::Qualifiers::operator==( const Qualifiers &other ) {
    399404    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;
    403409}
    404410
     
    406412    return isConst != other.isConst
    407413        || isVolatile != other.isVolatile
    408         || isRestrict != other.isRestrict;
    409 ///         && isLvalue == other.isLvalue;
     414        || isRestrict != other.isRestrict
     415//      || isLvalue != other.isLvalue
     416        || isAtomic != other.isAtomic;
    410417}
    411418
     
    413420    return isConst <= other.isConst
    414421        && isVolatile <= other.isVolatile
    415         && isRestrict <= other.isRestrict;
    416 ///         && isLvalue >= other.isLvalue;
     422        && isRestrict <= other.isRestrict
     423//      && isLvalue >= other.isLvalue
     424        && isAtomic == other.isAtomic;
    417425}
    418426
     
    420428    return isConst >= other.isConst
    421429        && isVolatile >= other.isVolatile
    422         && isRestrict >= other.isRestrict;
    423 ///         && isLvalue <= other.isLvalue;
     430        && isRestrict >= other.isRestrict
     431//      && isLvalue <= other.isLvalue
     432        && isAtomic == other.isAtomic;
    424433}
    425434
  • translator/SynTree/Visitor.cc

    rad17ba6a rbdd516a  
    309309}
    310310
    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 
    319311void Visitor::visit(SingleInit *singleInit) {
    320312    singleInit->get_value()->accept( *this );
  • translator/SynTree/Visitor.h

    rad17ba6a rbdd516a  
    7272    virtual void visit( AttrType *attrType );
    7373
    74     virtual void visit( MemberInit *memberInit );
    75     virtual void visit( ElementInit *elementInit );
    7674    virtual void visit( SingleInit *singleInit );
    7775    virtual void visit( ListInit *listInit );
Note: See TracChangeset for help on using the changeset viewer.