Changeset c331406 for src/SynTree


Ignore:
Timestamp:
Aug 5, 2016, 11:03:04 AM (10 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, stuck-waitfor-destruct, with_gc
Children:
a2f920f
Parents:
5070fe4 (diff), 1b0020a (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 changes from master

Location:
src/SynTree
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/AddStmtVisitor.cc

    r5070fe4 rc331406  
    1010// Created On       : Wed Jun 22 12:11:17 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 12 17:49:59 2016
    13 // Update Count     : 12
     12// Last Modified On : Thu Aug  4 11:23:47 2016
     13// Update Count     : 16
    1414//
    1515
     
    7171
    7272void AddStmtVisitor::visit(SwitchStmt *switchStmt) {
    73         visitStatementList( switchStmt->get_branches() );
     73        visitStatementList( switchStmt->get_statements() );
    7474        maybeAccept( switchStmt->get_condition(), *this );
    7575}
  • src/SynTree/Declaration.cc

    r5070fe4 rc331406  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Declaration.cc -- 
     7// Declaration.cc --
    88//
    99// Author           : Richard C. Bilson
     
    2020#include "Initializer.h"
    2121#include "Type.h"
     22#include "Attribute.h"
    2223#include "Common/utility.h"
    2324
  • src/SynTree/Declaration.h

    r5070fe4 rc331406  
    6464class DeclarationWithType : public Declaration {
    6565  public:
    66         DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage );
     66        DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, const std::list< Attribute * > & attributes );
    6767        DeclarationWithType( const DeclarationWithType &other );
    6868        virtual ~DeclarationWithType();
     
    7575        int get_scopeLevel() const { return scopeLevel; }
    7676        void set_scopeLevel( int newValue ) { scopeLevel = newValue; }
     77
     78        std::list< Attribute * >& get_attributes() { return attributes; }
     79        const std::list< Attribute * >& get_attributes() const { return attributes; }
    7780
    7881        virtual DeclarationWithType *clone() const = 0;
     
    8790        // shadowed identifiers can be accessed
    8891        int scopeLevel = 0;
     92
     93        std::list< Attribute * > attributes;
    8994};
    9095
     
    9297        typedef DeclarationWithType Parent;
    9398  public:
    94         ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline = false, bool isNoreturn = false );
     99        ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes = std::list< Attribute * >(), bool isInline = false, bool isNoreturn = false );
    95100        ObjectDecl( const ObjectDecl &other );
    96101        virtual ~ObjectDecl();
     
    131136        std::list< std::string >& get_oldIdents() { return oldIdents; }
    132137        std::list< Declaration* >& get_oldDecls() { return oldDecls; }
    133         std::list< Attribute * >& get_attributes() { return attributes; }
    134138
    135139        virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); }
     
    143147        std::list< std::string > oldIdents;
    144148        std::list< Declaration* > oldDecls;
    145         std::list< Attribute * > attributes;
    146149};
    147150
  • src/SynTree/DeclarationWithType.cc

    r5070fe4 rc331406  
    1616#include "Declaration.h"
    1717#include "Type.h"
     18#include "Attribute.h"
    1819#include "Common/utility.h"
    1920
    20 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage )
    21                 : Declaration( name, sc, linkage ) {
     21DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, const std::list< Attribute * > & attributes )
     22                : Declaration( name, sc, linkage ), attributes( attributes ) {
    2223}
    2324
    2425DeclarationWithType::DeclarationWithType( const DeclarationWithType &other )
    2526                : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ) {
     27        cloneAll( other.attributes, attributes );
    2628}
    2729
    2830DeclarationWithType::~DeclarationWithType() {
     31        deleteAll( attributes );
    2932}
    3033
  • src/SynTree/Expression.cc

    r5070fe4 rc331406  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 13 16:03:39 2016
    13 // Update Count     : 42
     12// Last Modified On : Wed Aug  3 17:06:51 2016
     13// Update Count     : 45
    1414//
    1515
     
    344344}
    345345
     346//// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned...
    346347MemberExpr::MemberExpr( const MemberExpr &other ) :
    347                 Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) {
     348                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
    348349}
    349350
    350351MemberExpr::~MemberExpr() {
    351         delete member;
     352        // delete member;
    352353        delete aggregate;
    353354}
     
    528529}
    529530
     531RangeExpr::RangeExpr( ConstantExpr *low, ConstantExpr *high ) : low( low ), high( high ) {}
     532RangeExpr::RangeExpr( const RangeExpr &other ) : low( other.low->clone() ), high( other.high->clone() ) {}
     533void RangeExpr::print( std::ostream &os, int indent ) const {
     534        os << std::string( indent, ' ' ) << "Range Expression: ";
     535        low->print( os, indent );
     536        os << " ... ";
     537        high->print( os, indent );
     538}
    530539
    531540std::ostream & operator<<( std::ostream & out, Expression * expr ) {
  • src/SynTree/Expression.h

    r5070fe4 rc331406  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul  4 14:45:32 2016
    13 // Update Count     : 23
     12// Last Modified On : Wed Aug  3 17:08:44 2016
     13// Update Count     : 27
    1414//
    1515
     
    1818
    1919#include <map>
     20#include <memory>
    2021#include "SynTree.h"
    2122#include "Visitor.h"
     
    634635};
    635636
     637class RangeExpr : public Expression {
     638  public:
     639        RangeExpr( ConstantExpr *low, ConstantExpr *high );
     640        RangeExpr( const RangeExpr &other );
     641
     642        ConstantExpr * get_low() const { return low.get(); }
     643        ConstantExpr * get_high() const { return high.get(); }
     644        RangeExpr * set_low( ConstantExpr *low ) { RangeExpr::low.reset( low ); return this; }
     645        RangeExpr * set_high( ConstantExpr *high ) { RangeExpr::high.reset( high ); return this; }
     646
     647        virtual RangeExpr *clone() const { return new RangeExpr( *this ); }
     648        virtual void accept( Visitor &v ) { v.visit( this ); }
     649        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     650        virtual void print( std::ostream &os, int indent = 0 ) const;
     651  private:
     652        std::unique_ptr<ConstantExpr> low, high;
     653};
     654
    636655std::ostream & operator<<( std::ostream & out, Expression * expr );
    637656
  • src/SynTree/FunctionDecl.cc

    r5070fe4 rc331406  
    2323
    2424FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, std::list< Attribute * > attributes )
    25                 : Parent( name, sc, linkage ), type( type ), statements( statements ), attributes( attributes ) {
     25                : Parent( name, sc, linkage, attributes ), type( type ), statements( statements ) {
    2626        set_isInline( isInline );
    2727        set_isNoreturn( isNoreturn );
     
    3434FunctionDecl::FunctionDecl( const FunctionDecl &other )
    3535        : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
    36                 cloneAll( other.attributes, attributes );
    3736}
    3837
     
    4039        delete type;
    4140        delete statements;
    42         deleteAll( attributes );
    4341}
    4442
     
    6967        } // if
    7068
    71         printAll( attributes, os, indent );
     69        printAll( get_attributes(), os, indent );
    7270
    7371        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
  • src/SynTree/Initializer.h

    r5070fe4 rc331406  
    9393        std::list<Initializer*> &get_initializers() { return initializers; }
    9494
    95         std::list<Initializer*>::iterator begin_initializers() { return initializers.begin(); }
    96         std::list<Initializer*>::iterator end_initializers() { return initializers.end(); }
     95        typedef std::list<Initializer*>::iterator iterator;
     96        iterator begin() { return initializers.begin(); }
     97        iterator end() { return initializers.end(); }
    9798
    9899        virtual ListInit *clone() const { return new ListInit( *this ); }
  • src/SynTree/Label.h

    r5070fe4 rc331406  
    2424class Label {
    2525  public:
    26         Label( const std::string & name = "", Statement * labelled = 0 ) : name( name ), labelled( labelled ) {}
     26        Label( const std::string & name = "", Statement * labelled = 0, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : name( name ), labelled( labelled ), attributes( attributes ) {}
    2727        Label( const char * name, Statement * labelled = 0 ) : name( name ), labelled( labelled ) {}
    2828
  • src/SynTree/Mutator.cc

    r5070fe4 rc331406  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 12 17:51:19 2016
    13 // Update Count     : 17
     12// Last Modified On : Thu Aug  4 11:23:21 2016
     13// Update Count     : 19
    1414//
    1515
     
    126126Statement *Mutator::mutate( SwitchStmt *switchStmt ) {
    127127        switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
    128         mutateAll( switchStmt->get_branches(), *this );
     128        mutateAll( switchStmt->get_statements(), *this );
    129129        return switchStmt;
    130130}
     
    349349        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
    350350        return compLitExpr;
     351}
     352
     353Expression *Mutator::mutate( RangeExpr *rangeExpr ) {
     354        rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) );
     355        rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
     356        return rangeExpr;
    351357}
    352358
  • src/SynTree/Mutator.h

    r5070fe4 rc331406  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 12 17:51:43 2016
    13 // Update Count     : 11
     12// Last Modified On : Wed Aug  3 16:59:45 2016
     13// Update Count     : 12
    1414//
    1515#include <cassert>
     
    7878        virtual Expression* mutate( UntypedValofExpr *valofExpr );
    7979        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
     80        virtual Expression* mutate( RangeExpr *rangeExpr );
    8081
    8182        virtual Type* mutate( VoidType *basicType );
  • src/SynTree/ObjectDecl.cc

    r5070fe4 rc331406  
    1818#include "Initializer.h"
    1919#include "Expression.h"
     20#include "Attribute.h"
    2021#include "Common/utility.h"
    2122#include "Statement.h"
    2223
    23 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline, bool isNoreturn )
    24         : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
     24ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, bool isInline, bool isNoreturn )
     25        : Parent( name, sc, linkage, attributes ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
    2526        set_isInline( isInline );
    2627        set_isNoreturn( isNoreturn );
     
    4546                os << LinkageSpec::toString( get_linkage() ) << " ";
    4647        } // if
     48
     49        printAll( get_attributes(), os, indent );
    4750
    4851        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
     
    8083        } // if
    8184
     85        // xxx - should printShort print attributes?
     86
    8287        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    8388                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
  • src/SynTree/Statement.cc

    r5070fe4 rc331406  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 12 17:52:32 2016
    13 // Update Count     : 55
     12// Last Modified On : Thu Aug  4 11:25:20 2016
     13// Update Count     : 61
    1414//
    1515
     
    143143}
    144144
    145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches ):
    146         Statement( _labels ), condition( _condition ), branches( _branches ) {
     145SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_statements ):
     146        Statement( _labels ), condition( _condition ), statements( _statements ) {
    147147}
    148148
    149149SwitchStmt::SwitchStmt( const SwitchStmt & other ):
    150150        Statement( other ), condition( maybeClone( other.condition ) ) {
    151         cloneAll( other.branches, branches );
     151        cloneAll( other.statements, statements );
    152152}
    153153
    154154SwitchStmt::~SwitchStmt() {
    155155        delete condition;
    156         // destroy branches
    157 }
    158 
    159 void SwitchStmt::add_case( CaseStmt *c ) {}
     156        // destroy statements
     157}
    160158
    161159void SwitchStmt::print( std::ostream &os, int indent ) const {
     
    164162        os << endl;
    165163
    166         // branches
     164        // statements
    167165        std::list<Statement *>::const_iterator i;
    168         for ( i = branches.begin(); i != branches.end(); i++)
     166        for ( i = statements.begin(); i != statements.end(); i++)
    169167                (*i)->print( os, indent + 4 );
    170168
    171         //for_each( branches.begin(), branches.end(), mem_fun( bind1st(&Statement::print ), os ));
     169        //for_each( statements.begin(), statements.end(), mem_fun( bind1st(&Statement::print ), os ));
    172170}
    173171
     
    187185}
    188186
    189 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> branches ) {
    190         return new CaseStmt( labels, 0, branches, true );
     187CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> stmts ) {
     188        return new CaseStmt( labels, 0, stmts, true );
    191189}
    192190
  • src/SynTree/Statement.h

    r5070fe4 rc331406  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 12 17:53:29 2016
    13 // Update Count     : 47
     12// Last Modified On : Thu Aug  4 11:26:02 2016
     13// Update Count     : 64
    1414//
    1515
     
    129129class SwitchStmt : public Statement {
    130130  public:
    131         SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
     131        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
    132132        SwitchStmt( const SwitchStmt &other );
    133133        virtual ~SwitchStmt();
     
    136136        void set_condition( Expression *newValue ) { condition = newValue; }
    137137
    138         std::list<Statement *> & get_branches() { return branches; }
    139         void add_case( CaseStmt * );
     138        std::list<Statement *> & get_statements() { return statements; }
    140139
    141140        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    146145  private:
    147146        Expression * condition;
    148         std::list<Statement *> branches; // should be list of CaseStmt
     147        std::list<Statement *> statements;
    149148};
    150149
    151150class CaseStmt : public Statement {
    152151  public:
    153         CaseStmt( std::list<Label> labels, Expression *conditions,
    154               std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
     152        CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    155153        CaseStmt( const CaseStmt &other );
    156154        virtual ~CaseStmt();
    157155
    158         static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(),
    159                 std::list<Statement *> stmts = std::list<Statement *>() );
     156        static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() );
    160157
    161158        bool isDefault() const { return _isDefault; }
  • src/SynTree/SynTree.h

    r5070fe4 rc331406  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 12 17:54:02 2016
    13 // Update Count     : 6
     12// Last Modified On : Wed Aug  3 17:02:34 2016
     13// Update Count     : 7
    1414//
    1515
     
    8383class UntypedValofExpr;
    8484class CompoundLiteralExpr;
     85class RangeExpr;
    8586
    8687class Type;
  • src/SynTree/Visitor.cc

    r5070fe4 rc331406  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 12 17:54:39 2016
    13 // Update Count     : 19
     12// Last Modified On : Thu Aug  4 11:24:25 2016
     13// Update Count     : 21
    1414//
    1515
     
    109109void Visitor::visit( SwitchStmt *switchStmt ) {
    110110        maybeAccept( switchStmt->get_condition(), *this );
    111         acceptAll( switchStmt->get_branches(), *this );
     111        acceptAll( switchStmt->get_statements(), *this );
    112112}
    113113
     
    296296        maybeAccept( compLitExpr->get_type(), *this );
    297297        maybeAccept( compLitExpr->get_initializer(), *this );
     298}
     299
     300void Visitor::visit( RangeExpr *rangeExpr ) {
     301        maybeAccept( rangeExpr->get_low(), *this );
     302        maybeAccept( rangeExpr->get_high(), *this );
    298303}
    299304
  • src/SynTree/Visitor.h

    r5070fe4 rc331406  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 12 17:55:09 2016
    13 // Update Count     : 8
     12// Last Modified On : Wed Aug  3 17:01:50 2016
     13// Update Count     : 9
    1414//
    1515
     
    7878        virtual void visit( UntypedValofExpr *valofExpr );
    7979        virtual void visit( CompoundLiteralExpr *compLitExpr );
     80        virtual void visit( RangeExpr *rangeExpr );
    8081
    8182        virtual void visit( VoidType *basicType );
Note: See TracChangeset for help on using the changeset viewer.