Changeset 1048b31 for src/SynTree


Ignore:
Timestamp:
May 2, 2016, 3:28:16 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
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.
Message:

Merge branch 'master' into global-init

Location:
src/SynTree
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r1f6e009 r1048b31  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:10:29 2015
    13 // Update Count     : 34
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Apr  8 17:16:23 2016
     13// Update Count     : 40
    1414//
    1515
     
    2222
    2323#include "Type.h"
     24#include "Initializer.h"
    2425#include "Expression.h"
    2526#include "Declaration.h"
     
    211212
    212213        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
     225OffsetPackExpr::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
     229OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
     230
     231OffsetPackExpr::~OffsetPackExpr() { delete type; }
     232
     233void OffsetPackExpr::print( std::ostream &os, int indent ) const {
     234        os << std::string( indent, ' ' ) << "Offset pack expression on ";
    213235
    214236        if ( type ) {
     
    443465
    444466
     467CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
     468        add_result( type->clone() );
     469}
     470
     471CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}
     472
     473CompoundLiteralExpr::~CompoundLiteralExpr() {
     474        delete initializer;
     475        delete type;
     476}
     477
     478void 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
    445484
    446485std::ostream & operator<<( std::ostream & out, Expression * expr ) {
  • src/SynTree/Expression.h

    r1f6e009 r1048b31  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 09 14:10:21 2015
    13 // Update Count     : 19
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Apr  8 17:18:06 2016
     13// Update Count     : 21
    1414//
    1515
     
    362362};
    363363
     364/// Expression representing a pack of field-offsets for a generic type
     365class OffsetPackExpr : public Expression {
     366public:
     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
     380private:
     381        StructInstType *type;
     382};
     383
    364384/// AttrExpr represents an @attribute expression (like sizeof, but user-defined)
    365385class AttrExpr : public Expression {
     
    557577};
    558578
     579/// CompoundLiteralExpr represents a C99 'compound literal'
     580class 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
    559601std::ostream & operator<<( std::ostream & out, Expression * expr );
    560602
  • src/SynTree/Mutator.cc

    r1f6e009 r1048b31  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:28:20 2016
    13 // Update Count     : 12
     12// Last Modified On : Fri Apr  1 18:05:16 2016
     13// Update Count     : 16
    1414//
    1515
     
    274274}
    275275
     276Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
     277        mutateAll( offsetPackExpr->get_results(), *this );
     278        offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
     279        return offsetPackExpr;
     280}
     281
    276282Expression *Mutator::mutate( AttrExpr *attrExpr ) {
    277283        mutateAll( attrExpr->get_results(), *this );
     
    334340        mutateAll( valofExpr->get_results(), *this );
    335341        return valofExpr;
     342}
     343
     344Expression *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;
    336349}
    337350
  • src/SynTree/Mutator.h

    r1f6e009 r1048b31  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:33:11 2016
    13 // Update Count     : 9
     12// Last Modified On : Fri Apr  1 17:26:56 2016
     13// Update Count     : 10
    1414//
    1515#include <cassert>
     
    6767        virtual Expression* mutate( UntypedOffsetofExpr *offsetofExpr );
    6868        virtual Expression* mutate( OffsetofExpr *offsetofExpr );
     69        virtual Expression* mutate( OffsetPackExpr *offsetPackExpr );
    6970        virtual Expression* mutate( AttrExpr *attrExpr );
    7071        virtual Expression* mutate( LogicalExpr *logicalExpr );
     
    7677        virtual Expression* mutate( AsmExpr *asmExpr );
    7778        virtual Expression* mutate( UntypedValofExpr *valofExpr );
     79        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
    7880
    7981        virtual Type* mutate( VoidType *basicType );
  • src/SynTree/SynTree.h

    r1f6e009 r1048b31  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:29:00 2016
    13 // Update Count     : 4
     12// Last Modified On : Fri Apr  1 16:47:44 2016
     13// Update Count     : 5
    1414//
    1515
     
    7272class UntypedOffsetofExpr;
    7373class OffsetofExpr;
     74class OffsetPackExpr;
    7475class AttrExpr;
    7576class LogicalExpr;
     
    8182class AsmExpr;
    8283class UntypedValofExpr;
     84class CompoundLiteralExpr;
    8385
    8486class Type;
  • src/SynTree/Visitor.cc

    r1f6e009 r1048b31  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:29:23 2016
    13 // Update Count     : 16
     12// Last Modified On : Fri Apr  1 18:05:13 2016
     13// Update Count     : 18
    1414//
    1515
     
    230230}
    231231
     232void Visitor::visit( OffsetPackExpr *offsetPackExpr ) {
     233        acceptAll( offsetPackExpr->get_results(), *this );
     234        maybeAccept( offsetPackExpr->get_type(), *this );
     235}
     236
    232237void Visitor::visit( AttrExpr *attrExpr ) {
    233238        acceptAll( attrExpr->get_results(), *this );
     
    282287        acceptAll( valofExpr->get_results(), *this );
    283288        maybeAccept( valofExpr->get_body(), *this );
     289}
     290
     291void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
     292        acceptAll( compLitExpr->get_results(), *this );
     293        maybeAccept( compLitExpr->get_type(), *this );
     294        maybeAccept( compLitExpr->get_initializer(), *this );
    284295}
    285296
  • src/SynTree/Visitor.h

    r1f6e009 r1048b31  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:33:35 2016
    13 // Update Count     : 6
     12// Last Modified On : Fri Apr  1 17:26:55 2016
     13// Update Count     : 7
    1414//
    1515
     
    6767        virtual void visit( UntypedOffsetofExpr *offsetofExpr );
    6868        virtual void visit( OffsetofExpr *offsetofExpr );
     69        virtual void visit( OffsetPackExpr *offsetPackExpr );
    6970        virtual void visit( AttrExpr *attrExpr );
    7071        virtual void visit( LogicalExpr *logicalExpr );
     
    7677        virtual void visit( AsmExpr *asmExpr );
    7778        virtual void visit( UntypedValofExpr *valofExpr );
     79        virtual void visit( CompoundLiteralExpr *compLitExpr );
    7880
    7981        virtual void visit( VoidType *basicType );
Note: See TracChangeset for help on using the changeset viewer.