Changeset ae8b942 for src/SynTree


Ignore:
Timestamp:
Jan 29, 2016, 4:36:46 PM (9 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:
5721a6d
Parents:
d3b7937 (diff), 73a28e2 (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.
Message:

Merge branch 'master' of plg2:software/cfa/cfa-cc

Location:
src/SynTree
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    rd3b7937 rae8b942  
    103103SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) :
    104104                Expression( _aname ), expr(expr_), type(0), isType(false) {
    105         add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
     105        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    106106}
    107107
    108108SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
    109109                Expression( _aname ), expr(0), type(type_), isType(true) {
    110         add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
     110        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    111111}
    112112
     
    134134AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) :
    135135                Expression( _aname ), expr(expr_), type(0), isType(false) {
    136         add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
     136        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    137137}
    138138
    139139AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
    140140                Expression( _aname ), expr(0), type(type_), isType(true) {
    141         add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
     141        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    142142}
    143143
     
    158158        else
    159159                expr->print(os, indent + 2);
     160
     161        os << std::endl;
     162        Expression::print( os, indent );
     163}
     164
     165OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) :
     166                Expression( _aname ), type(type_), member(member_) {
     167        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     168}
     169
     170OffsetofExpr::OffsetofExpr( const OffsetofExpr &other ) :
     171        Expression( other ), type( maybeClone( other.type ) ), member( maybeClone( other.member ) ) {}
     172
     173OffsetofExpr::~OffsetofExpr() {
     174        delete type;
     175        delete member;
     176}
     177
     178void OffsetofExpr::print( std::ostream &os, int indent) const {
     179        os << std::string( indent, ' ' ) << "Offsetof Expression on member ";
     180
     181        if ( member ) {
     182                os << member->get_name();
     183        } else {
     184                os << "<NULL>";
     185        }
     186
     187        os << " of ";
     188
     189        if ( type ) {
     190                type->print(os, indent + 2);
     191        } else {
     192                os << "<NULL>";
     193        }
    160194
    161195        os << std::endl;
  • src/SynTree/Expression.h

    rd3b7937 rae8b942  
    319319};
    320320
     321/// OffsetofExpr represents an offsetof expression
     322class OffsetofExpr : public Expression {
     323  public:
     324        OffsetofExpr( Type *type, DeclarationWithType *member, Expression *_aname = 0 );
     325        OffsetofExpr( const OffsetofExpr &other );
     326        virtual ~OffsetofExpr();
     327
     328        Type *get_type() const { return type; }
     329        void set_type( Type *newValue ) { type = newValue; }
     330        DeclarationWithType *get_member() const { return member; }
     331        void set_member( DeclarationWithType *newValue ) { member = newValue; }
     332
     333        virtual OffsetofExpr *clone() const { return new OffsetofExpr( *this ); }
     334        virtual void accept( Visitor &v ) { v.visit( this ); }
     335        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     336        virtual void print( std::ostream &os, int indent = 0 ) const;
     337  private:
     338        Type *type;
     339        DeclarationWithType *member;
     340};
     341
    321342/// AttrExpr represents an @attribute expression (like sizeof, but user-defined)
    322343class AttrExpr : public Expression {
  • src/SynTree/Initializer.h

    rd3b7937 rae8b942  
    5555class SingleInit : public Initializer {
    5656  public:
    57         SingleInit( Expression *value, std::list< Expression *> &designators );
     57        SingleInit( Expression *value, std::list< Expression *> &designators = *(new std::list<Expression *>()) );
    5858        SingleInit( const SingleInit &other );
    5959        virtual ~SingleInit();
  • src/SynTree/Mutator.cc

    rd3b7937 rae8b942  
    261261}
    262262
     263Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
     264        mutateAll( offsetofExpr->get_results(), *this );
     265        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
     266        offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
     267        return offsetofExpr;
     268}
     269
    263270Expression *Mutator::mutate( AttrExpr *attrExpr ) {
    264271        mutateAll( attrExpr->get_results(), *this );
  • src/SynTree/Mutator.h

    rd3b7937 rae8b942  
    6565        virtual Expression* mutate( SizeofExpr *sizeofExpr );
    6666        virtual Expression* mutate( AlignofExpr *alignofExpr );
     67        virtual Expression* mutate( OffsetofExpr *offsetofExpr );
    6768        virtual Expression* mutate( AttrExpr *attrExpr );
    6869        virtual Expression* mutate( LogicalExpr *logicalExpr );
  • src/SynTree/SynTree.h

    rd3b7937 rae8b942  
    7070class SizeofExpr;
    7171class AlignofExpr;
     72class OffsetofExpr;
    7273class AttrExpr;
    7374class LogicalExpr;
  • src/SynTree/Visitor.cc

    rd3b7937 rae8b942  
    219219}
    220220
     221void Visitor::visit( OffsetofExpr *offsetofExpr ) {
     222        acceptAll( offsetofExpr->get_results(), *this );
     223        maybeAccept( offsetofExpr->get_type(), *this );
     224        maybeAccept( offsetofExpr->get_member(), *this );
     225}
     226
    221227void Visitor::visit( AttrExpr *attrExpr ) {
    222228        acceptAll( attrExpr->get_results(), *this );
  • src/SynTree/Visitor.h

    rd3b7937 rae8b942  
    6565        virtual void visit( SizeofExpr *sizeofExpr );
    6666        virtual void visit( AlignofExpr *alignofExpr );
     67        virtual void visit( OffsetofExpr *offsetofExpr );
    6768        virtual void visit( AttrExpr *attrExpr );
    6869        virtual void visit( LogicalExpr *logicalExpr );
Note: See TracChangeset for help on using the changeset viewer.