Changeset 7880579 for src/Parser/ParseNode.h
- Timestamp:
- Aug 16, 2016, 8:59:49 AM (8 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:
- 0da3e2c, 13e3b50, 7527e63
- Parents:
- b1848a0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
rb1848a0 r7880579 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 15 14:52:12201613 // Update Count : 5 1212 // Last Modified On : Tue Aug 16 08:37:47 2016 13 // Update Count : 527 14 14 // 15 15 … … 22 22 #include <memory> 23 23 24 #include "Common/utility.h"25 24 #include "Parser/LinkageSpec.h" 26 25 #include "SynTree/Type.h" 27 26 #include "SynTree/Expression.h" 28 27 #include "SynTree/Statement.h" 29 //#include "SynTree/Declaration.h" 28 #include "SynTree/Label.h" 29 #include "Common/utility.h" 30 30 #include "Common/UniqueName.h" 31 #include "SynTree/Label.h"32 31 33 32 class StatementNode; … … 37 36 class InitializerNode; 38 37 39 // Builder 38 //############################################################################## 39 40 40 class ParseNode { 41 41 public: … … 44 44 ParseNode( const std::string & ); // for copy constructing subclasses 45 45 virtual ~ParseNode(); 46 virtual ParseNode *clone() const { assert( false ); return nullptr; }; 46 47 47 48 ParseNode *get_next() const { return next; } … … 50 51 ParseNode *set_last( ParseNode * ); 51 52 52 virtual ParseNode *clone() const { return 0; };53 54 53 const std::string &get_name() const { return name; } 55 54 void set_name( const std::string &newValue ) { name = newValue; } 56 55 57 virtual void print( std::ostream &os, int indent = 0 ) const ;56 virtual void print( std::ostream &os, int indent = 0 ) const {} 58 57 virtual void printList( std::ostream &os, int indent = 0 ) const; 59 60 ParseNode &operator,( ParseNode & ); 61 protected: 58 private: 59 static int indent_by; 60 61 ParseNode *next; 62 62 std::string name; 63 static int indent_by; 64 ParseNode *next; 65 }; 63 }; // ParseNode 66 64 67 65 //############################################################################## … … 104 102 virtual ~ExpressionNode() {} 105 103 106 virtual ExpressionNode *clone() const { return 0; }104 virtual ExpressionNode *clone() const { assert( false ); return nullptr; } 107 105 108 106 bool get_extension() const { return extension; } … … 119 117 120 118 template< typename T > 121 struct maybeBuild_t< Expression, T> {119 struct maybeBuild_t< Expression, T > { 122 120 static inline Expression * doit( const T *orig ) { 123 121 if ( orig ) { … … 126 124 return p; 127 125 } else { 128 return 0;126 return nullptr; 129 127 } // if 130 128 } … … 228 226 static DeclarationNode *newBuiltinType( BuiltinType ); 229 227 228 DeclarationNode(); 229 ~DeclarationNode(); 230 DeclarationNode *clone() const; 231 230 232 DeclarationNode *addQualifiers( DeclarationNode *); 231 233 DeclarationNode *copyStorageClasses( DeclarationNode *); … … 254 256 DeclarationNode *appendList( DeclarationNode * ); 255 257 256 DeclarationNode *clone() const;257 258 void print( std::ostream &os, int indent = 0 ) const; 258 259 void printList( std::ostream &os, int indent = 0 ) const; … … 269 270 bool get_extension() const { return extension; } 270 271 DeclarationNode *set_extension( bool exten ) { extension = exten; return this; } 271 272 DeclarationNode();273 ~DeclarationNode();274 272 private: 275 273 StorageClass buildStorageClass() const; … … 351 349 void buildList( const NodeType *firstNode, std::list< SynTreeType * > &outputList ) { 352 350 SemanticError errors; 353 std::back_insert_iterator< std::list< SynTreeType * > > out( outputList );351 std::back_insert_iterator< std::list< SynTreeType * > > out( outputList ); 354 352 const NodeType *cur = firstNode; 355 353 356 354 while ( cur ) { 357 355 try { 358 // SynTreeType *result = dynamic_cast< SynTreeType * >( maybeBuild<typename std::result_of<decltype(&NodeType::build)(NodeType)>::type>( cur ) );359 SynTreeType *result = dynamic_cast< SynTreeType * >( maybeBuild<typename std::pointer_traits<decltype(cur->build())>::element_type>( cur ) );356 // SynTreeType *result = dynamic_cast< SynTreeType * >( maybeBuild< typename std::result_of< decltype(&NodeType::build)(NodeType)>::type >( cur ) ); 357 SynTreeType *result = dynamic_cast< SynTreeType * >( maybeBuild< typename std::pointer_traits< decltype(cur->build())>::element_type >( cur ) ); 360 358 if ( result ) { 361 359 *out++ = result; … … 365 363 errors.append( e ); 366 364 } // try 367 cur = dynamic_cast< NodeType * >( cur->get_next() );365 cur = dynamic_cast< NodeType * >( cur->get_next() ); 368 366 } // while 369 367 if ( ! errors.isEmpty() ) { … … 374 372 // in DeclarationNode.cc 375 373 void buildList( const DeclarationNode *firstNode, std::list< Declaration * > &outputList ); 376 void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType * > &outputList );374 void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType * > &outputList ); 377 375 void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList ); 378 376
Note: See TracChangeset
for help on using the changeset viewer.