Changes in src/Parser/ParseNode.h [630a82a:7305915]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
r630a82a r7305915 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ParseNode.h -- 7 // ParseNode.h -- 8 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 8 16:27:20 201613 // Update Count : 2 0512 // Last Modified On : Mon Jun 27 23:28:10 2016 13 // Update Count : 242 14 14 // 15 15 … … 20 20 #include <list> 21 21 #include <iterator> 22 #include <memory> 22 23 23 24 #include "Common/utility.h" 24 25 #include "Parser/LinkageSpec.h" 25 26 #include "SynTree/Type.h" 27 #include "SynTree/Expression.h" 26 28 //#include "SynTree/Declaration.h" 27 29 #include "Common/UniqueName.h" … … 79 81 ExpressionNode *set_argName( const std::string *aName ); 80 82 ExpressionNode *set_argName( ExpressionNode *aDesignator ); 83 bool get_extension() const { return extension; } 84 ExpressionNode *set_extension( bool exten ) { extension = exten; return this; } 81 85 82 86 virtual void print( std::ostream &, int indent = 0) const = 0; … … 87 91 void printDesignation ( std::ostream &, int indent = 0) const; 88 92 private: 89 ExpressionNode *argName; 93 ExpressionNode *argName = 0; 94 bool extension = false; 95 }; 96 97 template< typename T > 98 struct maybeBuild_t<Expression, T> { 99 static inline Expression * doit( const T *orig ) { 100 if ( orig ) { 101 Expression *p = orig->build(); 102 p->set_extension( orig->get_extension() ); 103 return p; 104 } else { 105 return 0; 106 } // if 107 } 90 108 }; 91 109 … … 108 126 109 127 ConstantNode( Type, std::string * ); 110 ConstantNode( const ConstantNode &other ) : value( *new std::string( other.value ) ) {};128 ConstantNode( const ConstantNode &other ) : type( other.type ), btype( other.btype), value( *new std::string( other.value ) ) {}; 111 129 ~ConstantNode() { delete &value; } 112 130 … … 177 195 enum Type { TupleC, Comma, TupleFieldSel, // n-adic 178 196 // triadic 179 Cond, NCond, 197 Cond, NCond, 180 198 // diadic 181 SizeOf, AlignOf, OffsetOf, Attr, CompLit, Plus, Minus, Mul, Div, Mod, Or, And,182 BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq, 199 SizeOf, AlignOf, OffsetOf, Attr, Plus, Minus, Mul, Div, Mod, Or, And, 200 BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq, 183 201 Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn, 184 202 Index, FieldSel, PFieldSel, Range, 185 203 // monadic 186 204 UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress, 205 Ctor, Dtor, 187 206 }; 188 207 … … 309 328 ValofExprNode( const ValofExprNode &other ); 310 329 ~ValofExprNode(); 311 330 312 331 virtual ValofExprNode *clone() const { return new ValofExprNode( *this ); } 313 332 … … 333 352 enum BuiltinType { Valist }; 334 353 335 static const char *storageName[]; 354 static const char *storageName[]; 336 355 static const char *qualifierName[]; 337 356 static const char *basicTypeName[]; … … 406 425 ExpressionNode *get_enumeratorValue() const { return enumeratorValue; } 407 426 427 bool get_extension() const { return extension; } 428 DeclarationNode *set_extension( bool exten ) { extension = exten; return this; } 429 408 430 DeclarationNode(); 409 431 ~DeclarationNode(); … … 421 443 bool hasEllipsis; 422 444 LinkageSpec::Type linkage; 445 bool extension = false; 423 446 424 447 static UniqueName anonymous; … … 427 450 class StatementNode : public ParseNode { 428 451 public: 429 enum Type { Exp, If, Switch, Case, Default, Choose, Fallthru, 452 enum Type { Exp, If, Switch, Case, Default, Choose, Fallthru, 430 453 While, Do, For, 431 454 Goto, Continue, Break, Return, Throw, … … 457 480 void addDeclaration( DeclarationNode *newDecl ) { decl = newDecl; } 458 481 void setCatchRest( bool newVal ) { isCatchRest = newVal; } 482 483 bool get_extension() const { return extension; } 484 StatementNode *set_extension( bool exten ) { extension = exten; return this; } 459 485 460 486 std::string get_target() const; … … 476 502 DeclarationNode *decl; 477 503 bool isCatchRest; 504 bool extension = false; 478 505 }; // StatementNode 479 506 … … 525 552 ExpressionNode *get_designators() const { return designator; } 526 553 554 InitializerNode *set_maybeConstructed( bool value ) { maybeConstructed = value; return this; } 555 bool get_maybeConstructed() const { return maybeConstructed; } 556 527 557 InitializerNode *next_init() const { return kids; } 528 558 … … 536 566 ExpressionNode *designator; // may be list 537 567 InitializerNode *kids; 568 bool maybeConstructed; 538 569 }; 539 570 … … 569 600 while ( cur ) { 570 601 try { 571 SynTreeType *result = dynamic_cast< SynTreeType *>( cur->build() ); 602 // SynTreeType *result = dynamic_cast< SynTreeType *>( maybeBuild<typename std::result_of<decltype(&NodeType::build)(NodeType)>::type>( cur ) ); 603 SynTreeType *result = dynamic_cast< SynTreeType *>( maybeBuild<typename std::pointer_traits<decltype(cur->build())>::element_type>( cur ) ); 572 604 if ( result ) { 573 605 *out++ = result;
Note:
See TracChangeset
for help on using the changeset viewer.