Changeset 70a06f6 for src/SynTree


Ignore:
Timestamp:
Apr 14, 2016, 4:13:10 PM (10 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:
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.
Message:

Merge branch 'master' into ctor

Conflicts:

src/CodeGen/CodeGenerator.cc
src/GenPoly/Box.cc
src/Parser/DeclarationNode.cc
src/Parser/ParseNode.h
src/Parser/parser.cc
src/Parser/parser.yy
src/SymTab/AddVisit.h
src/SymTab/Validate.cc
src/SynTree/Expression.cc
src/SynTree/Expression.h
src/SynTree/Mutator.cc
src/SynTree/Mutator.h
src/SynTree/SynTree.h
src/SynTree/Visitor.cc
src/SynTree/Visitor.h
src/libcfa/iostream.c

Location:
src/SynTree
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    rdb4ecc5 r70a06f6  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 14 13:02:28 2016
    13 // Update Count     : 34
     12// Last Modified On : Thu Apr 14 15:33:12 2016
     13// Update Count     : 40
    1414//
    1515
     
    2222
    2323#include "Type.h"
     24#include "Initializer.h"
    2425#include "Expression.h"
    2526#include "Declaration.h"
     
    213214
    214215        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
     227OffsetPackExpr::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
     231OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
     232
     233OffsetPackExpr::~OffsetPackExpr() { delete type; }
     234
     235void OffsetPackExpr::print( std::ostream &os, int indent ) const {
     236        os << std::string( indent, ' ' ) << "Offset pack expression on ";
    215237
    216238        if ( type ) {
     
    478500
    479501
     502CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
     503        add_result( type->clone() );
     504}
     505
     506CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}
     507
     508CompoundLiteralExpr::~CompoundLiteralExpr() {
     509        delete initializer;
     510        delete type;
     511}
     512
     513void 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
    480519
    481520std::ostream & operator<<( std::ostream & out, Expression * expr ) {
  • src/SynTree/Expression.h

    rdb4ecc5 r70a06f6  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 14 12:04:58 2016
    13 // Update Count     : 19
     12// Last Modified On : Thu Apr 14 15:40:56 2016
     13// Update Count     : 21
    1414//
    1515
     
    363363};
    364364
     365/// Expression representing a pack of field-offsets for a generic type
     366class OffsetPackExpr : public Expression {
     367public:
     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
     381private:
     382        StructInstType *type;
     383};
     384
    365385/// AttrExpr represents an @attribute expression (like sizeof, but user-defined)
    366386class AttrExpr : public Expression {
     
    593613};
    594614
     615/// CompoundLiteralExpr represents a C99 'compound literal'
     616class 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
    595637std::ostream & operator<<( std::ostream & out, Expression * expr );
    596638
  • src/SynTree/Mutator.cc

    rdb4ecc5 r70a06f6  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Apr 08 14:01:47 2016
    13 // Update Count     : 15
     12// Last Modified On : Thu Apr 14 15:32:19 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 );
     
    341347        mutateAll( valofExpr->get_results(), *this );
    342348        return valofExpr;
     349}
     350
     351Expression *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;
    343356}
    344357
  • src/SynTree/Mutator.h

    rdb4ecc5 r70a06f6  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Apr 08 13:22:04 2016
    13 // Update Count     : 9
     12// Last Modified On : Thu Apr 14 15:32:00 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 );
     
    7778        virtual Expression* mutate( ImplicitCopyCtorExpr *impCpCtorExpr );
    7879        virtual Expression* mutate( UntypedValofExpr *valofExpr );
     80        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
    7981
    8082        virtual Type* mutate( VoidType *basicType );
  • src/SynTree/SynTree.h

    rdb4ecc5 r70a06f6  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Apr 08 13:49:47 2016
    13 // Update Count     : 4
     12// Last Modified On : Thu Apr 14 15:31:36 2016
     13// Update Count     : 5
    1414//
    1515
     
    7272class UntypedOffsetofExpr;
    7373class OffsetofExpr;
     74class OffsetPackExpr;
    7475class AttrExpr;
    7576class LogicalExpr;
     
    8283class ImplicitCopyCtorExpr;
    8384class UntypedValofExpr;
     85class CompoundLiteralExpr;
    8486
    8587class Type;
  • src/SynTree/Visitor.cc

    rdb4ecc5 r70a06f6  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Apr 08 13:53:21 2016
     12// Last Modified On : Thu Apr 14 15:31:18 2016
    1313// Update Count     : 18
    1414//
     
    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 );
     
    288293        acceptAll( valofExpr->get_results(), *this );
    289294        maybeAccept( valofExpr->get_body(), *this );
     295}
     296
     297void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
     298        acceptAll( compLitExpr->get_results(), *this );
     299        maybeAccept( compLitExpr->get_type(), *this );
     300        maybeAccept( compLitExpr->get_initializer(), *this );
    290301}
    291302
  • src/SynTree/Visitor.h

    rdb4ecc5 r70a06f6  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Apr 08 13:26:31 2016
    13 // Update Count     : 6
     12// Last Modified On : Thu Apr 14 15:30:58 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 );
     
    7778        virtual void visit( ImplicitCopyCtorExpr *impCpCtorExpr );
    7879        virtual void visit( UntypedValofExpr *valofExpr );
     80        virtual void visit( CompoundLiteralExpr *compLitExpr );
    7981
    8082        virtual void visit( VoidType *basicType );
Note: See TracChangeset for help on using the changeset viewer.