Changeset 7527e63 for src/SynTree
- Timestamp:
- Aug 16, 2016, 3:20:06 PM (9 years ago)
- 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, with_gc
- Children:
- 1f6d4624
- Parents:
- 950f7a7 (diff), 7880579 (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. - Location:
- src/SynTree
- Files:
-
- 17 edited
-
AddStmtVisitor.cc (modified) (2 diffs)
-
Declaration.cc (modified) (2 diffs)
-
Declaration.h (modified) (6 diffs)
-
DeclarationWithType.cc (modified) (1 diff)
-
Expression.cc (modified) (3 diffs)
-
Expression.h (modified) (24 diffs)
-
FunctionDecl.cc (modified) (4 diffs)
-
Initializer.h (modified) (1 diff)
-
Label.h (modified) (2 diffs)
-
Mutator.cc (modified) (3 diffs)
-
Mutator.h (modified) (2 diffs)
-
ObjectDecl.cc (modified) (3 diffs)
-
Statement.cc (modified) (5 diffs)
-
Statement.h (modified) (5 diffs)
-
SynTree.h (modified) (2 diffs)
-
Visitor.cc (modified) (3 diffs)
-
Visitor.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AddStmtVisitor.cc
r950f7a7 r7527e63 10 10 // Created On : Wed Jun 22 12:11:17 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:49:59201613 // Update Count : 1 212 // Last Modified On : Thu Aug 4 11:23:47 2016 13 // Update Count : 16 14 14 // 15 15 … … 71 71 72 72 void AddStmtVisitor::visit(SwitchStmt *switchStmt) { 73 visitStatementList( switchStmt->get_ branches() );73 visitStatementList( switchStmt->get_statements() ); 74 74 maybeAccept( switchStmt->get_condition(), *this ); 75 75 } -
src/SynTree/Declaration.cc
r950f7a7 r7527e63 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Declaration.cc -- 7 // Declaration.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 20 20 #include "Initializer.h" 21 21 #include "Type.h" 22 #include "Attribute.h" 22 23 #include "Common/utility.h" 23 24 -
src/SynTree/Declaration.h
r950f7a7 r7527e63 64 64 class DeclarationWithType : public Declaration { 65 65 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 ); 67 67 DeclarationWithType( const DeclarationWithType &other ); 68 68 virtual ~DeclarationWithType(); … … 75 75 int get_scopeLevel() const { return scopeLevel; } 76 76 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; } 77 80 78 81 virtual DeclarationWithType *clone() const = 0; … … 87 90 // shadowed identifiers can be accessed 88 91 int scopeLevel = 0; 92 93 std::list< Attribute * > attributes; 89 94 }; 90 95 … … 92 97 typedef DeclarationWithType Parent; 93 98 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 ); 95 100 ObjectDecl( const ObjectDecl &other ); 96 101 virtual ~ObjectDecl(); … … 131 136 std::list< std::string >& get_oldIdents() { return oldIdents; } 132 137 std::list< Declaration* >& get_oldDecls() { return oldDecls; } 133 std::list< Attribute * >& get_attributes() { return attributes; }134 138 135 139 virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); } … … 143 147 std::list< std::string > oldIdents; 144 148 std::list< Declaration* > oldDecls; 145 std::list< Attribute * > attributes;146 149 }; 147 150 -
src/SynTree/DeclarationWithType.cc
r950f7a7 r7527e63 16 16 #include "Declaration.h" 17 17 #include "Type.h" 18 #include "Attribute.h" 18 19 #include "Common/utility.h" 19 20 20 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage )21 : Declaration( name, sc, linkage ) {21 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, const std::list< Attribute * > & attributes ) 22 : Declaration( name, sc, linkage ), attributes( attributes ) { 22 23 } 23 24 24 25 DeclarationWithType::DeclarationWithType( const DeclarationWithType &other ) 25 26 : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ) { 27 cloneAll( other.attributes, attributes ); 26 28 } 27 29 28 30 DeclarationWithType::~DeclarationWithType() { 31 deleteAll( attributes ); 29 32 } 30 33 -
src/SynTree/Expression.cc
r950f7a7 r7527e63 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 13 16:03:39201613 // Update Count : 4 212 // Last Modified On : Fri Aug 5 14:23:56 2016 13 // Update Count : 49 14 14 // 15 15 … … 344 344 } 345 345 346 //// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned... 346 347 MemberExpr::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 ) ) { 348 349 } 349 350 350 351 MemberExpr::~MemberExpr() { 351 delete member;352 // delete member; 352 353 delete aggregate; 353 354 } … … 528 529 } 529 530 531 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {} 532 RangeExpr::RangeExpr( const RangeExpr &other ) : low( other.low->clone() ), high( other.high->clone() ) {} 533 void 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 } 530 539 531 540 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.h
r950f7a7 r7527e63 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 4 14:45:32201613 // Update Count : 2312 // Last Modified On : Sat Aug 6 08:52:53 2016 13 // Update Count : 35 14 14 // 15 15 … … 18 18 19 19 #include <map> 20 #include <memory> 20 21 #include "SynTree.h" 21 22 #include "Visitor.h" … … 27 28 class Expression { 28 29 public: 29 Expression( Expression *_aname = 0);30 Expression( Expression *_aname = nullptr ); 30 31 Expression( const Expression &other ); 31 32 virtual ~Expression(); … … 69 70 typedef std::map< UniqueId, ParamEntry > InferredParams; 70 71 71 /// ApplicationExpr represents the application of a function to a set of parameters. This is the 72 /// result of running anUntypedExpr through the expression analyzer.72 /// ApplicationExpr represents the application of a function to a set of parameters. This is the result of running an 73 /// UntypedExpr through the expression analyzer. 73 74 class ApplicationExpr : public Expression { 74 75 public: … … 92 93 }; 93 94 94 /// UntypedExpr represents the application of a function to a set of parameters, but where the 95 /// particular overload for the function name has not yet been determined. Most operators are96 /// converted into functional form automatically, topermit operator overloading.95 /// UntypedExpr represents the application of a function to a set of parameters, but where the particular overload for 96 /// the function name has not yet been determined. Most operators are converted into functional form automatically, to 97 /// permit operator overloading. 97 98 class UntypedExpr : public Expression { 98 99 public: 99 UntypedExpr( Expression *function, Expression *_aname = 0);100 UntypedExpr( Expression *function, Expression *_aname = nullptr ); 100 101 UntypedExpr( const UntypedExpr &other ); 101 UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = 0);102 UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = nullptr ); 102 103 virtual ~UntypedExpr(); 103 104 … … 123 124 class NameExpr : public Expression { 124 125 public: 125 NameExpr( std::string name, Expression *_aname = 0);126 NameExpr( std::string name, Expression *_aname = nullptr ); 126 127 NameExpr( const NameExpr &other ); 127 128 virtual ~NameExpr(); … … 144 145 class AddressExpr : public Expression { 145 146 public: 146 AddressExpr( Expression *arg, Expression *_aname = 0);147 AddressExpr( Expression *arg, Expression *_aname = nullptr ); 147 148 AddressExpr( const AddressExpr &other ); 148 149 virtual ~AddressExpr(); … … 180 181 class CastExpr : public Expression { 181 182 public: 182 CastExpr( Expression *arg, Expression *_aname = 0);183 CastExpr( Expression *arg, Type *toType, Expression *_aname = 0);183 CastExpr( Expression *arg, Expression *_aname = nullptr ); 184 CastExpr( Expression *arg, Type *toType, Expression *_aname = nullptr ); 184 185 CastExpr( const CastExpr &other ); 185 186 virtual ~CastExpr(); … … 199 200 class UntypedMemberExpr : public Expression { 200 201 public: 201 UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = 0);202 UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = nullptr ); 202 203 UntypedMemberExpr( const UntypedMemberExpr &other ); 203 204 virtual ~UntypedMemberExpr(); … … 220 221 class MemberExpr : public Expression { 221 222 public: 222 MemberExpr( DeclarationWithType *member, Expression *aggregate, Expression *_aname = 0);223 MemberExpr( DeclarationWithType *member, Expression *aggregate, Expression *_aname = nullptr ); 223 224 MemberExpr( const MemberExpr &other ); 224 225 virtual ~MemberExpr(); … … 241 242 class VariableExpr : public Expression { 242 243 public: 243 VariableExpr( DeclarationWithType *var, Expression *_aname = 0);244 VariableExpr( DeclarationWithType *var, Expression *_aname = nullptr ); 244 245 VariableExpr( const VariableExpr &other ); 245 246 virtual ~VariableExpr(); … … 259 260 class ConstantExpr : public Expression { 260 261 public: 261 ConstantExpr( Constant constant, Expression *_aname = 0);262 ConstantExpr( Constant constant, Expression *_aname = nullptr ); 262 263 ConstantExpr( const ConstantExpr &other ); 263 264 virtual ~ConstantExpr(); … … 277 278 class SizeofExpr : public Expression { 278 279 public: 279 SizeofExpr( Expression *expr, Expression *_aname = 0);280 SizeofExpr( Expression *expr, Expression *_aname = nullptr ); 280 281 SizeofExpr( const SizeofExpr &other ); 281 SizeofExpr( Type *type, Expression *_aname = 0);282 SizeofExpr( Type *type, Expression *_aname = nullptr ); 282 283 virtual ~SizeofExpr(); 283 284 … … 302 303 class AlignofExpr : public Expression { 303 304 public: 304 AlignofExpr( Expression *expr, Expression *_aname = 0);305 AlignofExpr( Expression *expr, Expression *_aname = nullptr ); 305 306 AlignofExpr( const AlignofExpr &other ); 306 AlignofExpr( Type *type, Expression *_aname = 0);307 AlignofExpr( Type *type, Expression *_aname = nullptr ); 307 308 virtual ~AlignofExpr(); 308 309 … … 327 328 class UntypedOffsetofExpr : public Expression { 328 329 public: 329 UntypedOffsetofExpr( Type *type, const std::string &member, Expression *_aname = 0);330 UntypedOffsetofExpr( Type *type, const std::string &member, Expression *_aname = nullptr ); 330 331 UntypedOffsetofExpr( const UntypedOffsetofExpr &other ); 331 332 virtual ~UntypedOffsetofExpr(); … … 348 349 class OffsetofExpr : public Expression { 349 350 public: 350 OffsetofExpr( Type *type, DeclarationWithType *member, Expression *_aname = 0);351 OffsetofExpr( Type *type, DeclarationWithType *member, Expression *_aname = nullptr ); 351 352 OffsetofExpr( const OffsetofExpr &other ); 352 353 virtual ~OffsetofExpr(); … … 389 390 class AttrExpr : public Expression { 390 391 public: 391 AttrExpr(Expression *attr, Expression *expr, Expression *_aname = 0);392 AttrExpr(Expression *attr, Expression *expr, Expression *_aname = nullptr ); 392 393 AttrExpr( const AttrExpr &other ); 393 AttrExpr( Expression *attr, Type *type, Expression *_aname = 0);394 AttrExpr( Expression *attr, Type *type, Expression *_aname = nullptr ); 394 395 virtual ~AttrExpr(); 395 396 … … 417 418 class LogicalExpr : public Expression { 418 419 public: 419 LogicalExpr( Expression *arg1, Expression *arg2, bool andp = true, Expression *_aname = 0);420 LogicalExpr( Expression *arg1, Expression *arg2, bool andp = true, Expression *_aname = nullptr ); 420 421 LogicalExpr( const LogicalExpr &other ); 421 422 virtual ~LogicalExpr(); … … 440 441 class ConditionalExpr : public Expression { 441 442 public: 442 ConditionalExpr( Expression *arg1, Expression *arg2, Expression *arg3, Expression *_aname = 0);443 ConditionalExpr( Expression *arg1, Expression *arg2, Expression *arg3, Expression *_aname = nullptr ); 443 444 ConditionalExpr( const ConditionalExpr &other ); 444 445 virtual ~ConditionalExpr(); … … 464 465 class CommaExpr : public Expression { 465 466 public: 466 CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname = 0);467 CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname = nullptr ); 467 468 CommaExpr( const CommaExpr &other ); 468 469 virtual ~CommaExpr(); … … 485 486 class TupleExpr : public Expression { 486 487 public: 487 TupleExpr( Expression *_aname = 0);488 TupleExpr( Expression *_aname = nullptr ); 488 489 TupleExpr( const TupleExpr &other ); 489 490 virtual ~TupleExpr(); … … 503 504 class SolvedTupleExpr : public Expression { 504 505 public: 505 SolvedTupleExpr( Expression *_aname = 0) : Expression( _aname ) {}506 SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = 0);506 SolvedTupleExpr( Expression *_aname = nullptr ) : Expression( _aname ) {} 507 SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = nullptr ); 507 508 SolvedTupleExpr( const SolvedTupleExpr &other ); 508 509 virtual ~SolvedTupleExpr() {} … … 597 598 class UntypedValofExpr : public Expression { 598 599 public: 599 UntypedValofExpr( Statement *_body, Expression *_aname = 0) : Expression( _aname ), body ( _body ) {}600 UntypedValofExpr( Statement *_body, Expression *_aname = nullptr ) : Expression( _aname ), body ( _body ) {} 600 601 UntypedValofExpr( const UntypedValofExpr & other ); 601 602 virtual ~UntypedValofExpr(); … … 632 633 Type * type; 633 634 Initializer * initializer; 635 }; 636 637 class RangeExpr : public Expression { 638 public: 639 RangeExpr( Expression *low, Expression *high ); 640 RangeExpr( const RangeExpr &other ); 641 642 Expression * get_low() const { return low; } 643 Expression * get_high() const { return high; } 644 RangeExpr * set_low( Expression *low ) { RangeExpr::low = low; return this; } 645 RangeExpr * set_high( Expression *high ) { RangeExpr::high = 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 Expression *low, *high; 634 653 }; 635 654 -
src/SynTree/FunctionDecl.cc
r950f7a7 r7527e63 23 23 24 24 FunctionDecl::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 ) { 26 26 set_isInline( isInline ); 27 27 set_isNoreturn( isNoreturn ); … … 34 34 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 35 35 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) { 36 cloneAll( other.attributes, attributes );37 36 } 38 37 … … 40 39 delete type; 41 40 delete statements; 42 deleteAll( attributes );43 41 } 44 42 … … 69 67 } // if 70 68 71 printAll( attributes, os, indent );69 printAll( get_attributes(), os, indent ); 72 70 73 71 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { -
src/SynTree/Initializer.h
r950f7a7 r7527e63 93 93 std::list<Initializer*> &get_initializers() { return initializers; } 94 94 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(); } 97 98 98 99 virtual ListInit *clone() const { return new ListInit( *this ); } -
src/SynTree/Label.h
r950f7a7 r7527e63 9 9 // Author : Rob Schluntz 10 10 // Created On : Wed Jun 8 12:53:12 2016 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Jun 8 12:53:28201613 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 7 14:44:29 2016 13 // Update Count : 2 14 14 // 15 15 … … 24 24 class Label { 25 25 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 ) {} 27 27 Label( const char * name, Statement * labelled = 0 ) : name( name ), labelled( labelled ) {} 28 28 -
src/SynTree/Mutator.cc
r950f7a7 r7527e63 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:51:19201613 // Update Count : 1 712 // Last Modified On : Thu Aug 4 11:23:21 2016 13 // Update Count : 19 14 14 // 15 15 … … 126 126 Statement *Mutator::mutate( SwitchStmt *switchStmt ) { 127 127 switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) ); 128 mutateAll( switchStmt->get_ branches(), *this );128 mutateAll( switchStmt->get_statements(), *this ); 129 129 return switchStmt; 130 130 } … … 349 349 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); 350 350 return compLitExpr; 351 } 352 353 Expression *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; 351 357 } 352 358 -
src/SynTree/Mutator.h
r950f7a7 r7527e63 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:51:43201613 // Update Count : 1 112 // Last Modified On : Wed Aug 3 16:59:45 2016 13 // Update Count : 12 14 14 // 15 15 #include <cassert> … … 78 78 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 79 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 80 virtual Expression* mutate( RangeExpr *rangeExpr ); 80 81 81 82 virtual Type* mutate( VoidType *basicType ); -
src/SynTree/ObjectDecl.cc
r950f7a7 r7527e63 18 18 #include "Initializer.h" 19 19 #include "Expression.h" 20 #include "Attribute.h" 20 21 #include "Common/utility.h" 21 22 #include "Statement.h" 22 23 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 ) {24 ObjectDecl::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 ) { 25 26 set_isInline( isInline ); 26 27 set_isNoreturn( isNoreturn ); … … 45 46 os << LinkageSpec::toString( get_linkage() ) << " "; 46 47 } // if 48 49 printAll( get_attributes(), os, indent ); 47 50 48 51 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { … … 80 83 } // if 81 84 85 // xxx - should printShort print attributes? 86 82 87 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 83 88 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; -
src/SynTree/Statement.cc
r950f7a7 r7527e63 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:52:32201613 // Update Count : 5512 // Last Modified On : Fri Aug 12 13:58:48 2016 13 // Update Count : 62 14 14 // 15 15 … … 143 143 } 144 144 145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_ branches ):146 Statement( _labels ), condition( _condition ), branches( _branches ) {145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_statements ): 146 Statement( _labels ), condition( _condition ), statements( _statements ) { 147 147 } 148 148 149 149 SwitchStmt::SwitchStmt( const SwitchStmt & other ): 150 150 Statement( other ), condition( maybeClone( other.condition ) ) { 151 cloneAll( other. branches, branches );151 cloneAll( other.statements, statements ); 152 152 } 153 153 154 154 SwitchStmt::~SwitchStmt() { 155 155 delete condition; 156 // destroy branches 157 } 158 159 void SwitchStmt::add_case( CaseStmt *c ) {} 156 // destroy statements 157 } 160 158 161 159 void SwitchStmt::print( std::ostream &os, int indent ) const { … … 164 162 os << endl; 165 163 166 // branches164 // statements 167 165 std::list<Statement *>::const_iterator i; 168 for ( i = branches.begin(); i != branches.end(); i++)166 for ( i = statements.begin(); i != statements.end(); i++) 169 167 (*i)->print( os, indent + 4 ); 170 168 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 )); 172 170 } 173 171 … … 187 185 } 188 186 189 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> branches ) {190 return new CaseStmt( labels, 0, branches, true );187 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> stmts ) { 188 return new CaseStmt( labels, 0, stmts, true ); 191 189 } 192 190 … … 311 309 } 312 310 313 CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool isCatchRest) :314 Statement( labels ), decl ( _decl ), body( _body ), catchRest ( isCatchRest) {311 CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool catchAny ) : 312 Statement( labels ), decl ( _decl ), body( _body ), catchRest ( catchAny ) { 315 313 } 316 314 -
src/SynTree/Statement.h
r950f7a7 r7527e63 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:53:29201613 // Update Count : 4712 // Last Modified On : Fri Aug 12 13:57:46 2016 13 // Update Count : 65 14 14 // 15 15 … … 129 129 class SwitchStmt : public Statement { 130 130 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 ); 132 132 SwitchStmt( const SwitchStmt &other ); 133 133 virtual ~SwitchStmt(); … … 136 136 void set_condition( Expression *newValue ) { condition = newValue; } 137 137 138 std::list<Statement *> & get_branches() { return branches; } 139 void add_case( CaseStmt * ); 138 std::list<Statement *> & get_statements() { return statements; } 140 139 141 140 virtual void accept( Visitor &v ) { v.visit( this ); } … … 146 145 private: 147 146 Expression * condition; 148 std::list<Statement *> branches; // should be list of CaseStmt147 std::list<Statement *> statements; 149 148 }; 150 149 151 150 class CaseStmt : public Statement { 152 151 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); 155 153 CaseStmt( const CaseStmt &other ); 156 154 virtual ~CaseStmt(); 157 155 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 *>() ); 160 157 161 158 bool isDefault() const { return _isDefault; } … … 317 314 class CatchStmt : public Statement { 318 315 public: 319 CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool isCatchRest= false );316 CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool catchAny = false ); 320 317 CatchStmt( const CatchStmt &other ); 321 318 virtual ~CatchStmt(); -
src/SynTree/SynTree.h
r950f7a7 r7527e63 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:54:02201613 // Update Count : 612 // Last Modified On : Wed Aug 3 17:02:34 2016 13 // Update Count : 7 14 14 // 15 15 … … 83 83 class UntypedValofExpr; 84 84 class CompoundLiteralExpr; 85 class RangeExpr; 85 86 86 87 class Type; -
src/SynTree/Visitor.cc
r950f7a7 r7527e63 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:54:39201613 // Update Count : 1912 // Last Modified On : Thu Aug 4 11:24:25 2016 13 // Update Count : 21 14 14 // 15 15 … … 109 109 void Visitor::visit( SwitchStmt *switchStmt ) { 110 110 maybeAccept( switchStmt->get_condition(), *this ); 111 acceptAll( switchStmt->get_ branches(), *this );111 acceptAll( switchStmt->get_statements(), *this ); 112 112 } 113 113 … … 296 296 maybeAccept( compLitExpr->get_type(), *this ); 297 297 maybeAccept( compLitExpr->get_initializer(), *this ); 298 } 299 300 void Visitor::visit( RangeExpr *rangeExpr ) { 301 maybeAccept( rangeExpr->get_low(), *this ); 302 maybeAccept( rangeExpr->get_high(), *this ); 298 303 } 299 304 -
src/SynTree/Visitor.h
r950f7a7 r7527e63 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:55:09201613 // Update Count : 812 // Last Modified On : Wed Aug 3 17:01:50 2016 13 // Update Count : 9 14 14 // 15 15 … … 78 78 virtual void visit( UntypedValofExpr *valofExpr ); 79 79 virtual void visit( CompoundLiteralExpr *compLitExpr ); 80 virtual void visit( RangeExpr *rangeExpr ); 80 81 81 82 virtual void visit( VoidType *basicType );
Note:
See TracChangeset
for help on using the changeset viewer.