Changeset 19b5d6b for src/Parser/ParseNode.h
- Timestamp:
- Oct 4, 2016, 11:25:00 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 40744af8, a7976d79
- Parents:
- 6295081 (diff), 4b1fd2c (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
r6295081 r19b5d6b 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 12 08:00:05201613 // Update Count : 6 0312 // Last Modified On : Sat Sep 24 11:12:04 2016 13 // Update Count : 633 14 14 // 15 15 … … 41 41 public: 42 42 ParseNode() {}; 43 ParseNode( const std::string * name ) : name( * name ) { assert( false ); delete name; } 44 ParseNode( const std::string &name ) : name( name ) { assert( false ); } 45 virtual ~ParseNode() { delete next; }; 43 virtual ~ParseNode() { delete next; delete name; }; 46 44 virtual ParseNode * clone() const = 0; 47 45 48 46 ParseNode * get_next() const { return next; } 49 47 ParseNode * set_next( ParseNode * newlink ) { next = newlink; return this; } 48 50 49 ParseNode * get_last() { 51 50 ParseNode * current; 52 for ( current = this; current->get_next() != 0; current = current->get_next() );51 for ( current = this; current->get_next() != nullptr; current = current->get_next() ); 53 52 return current; 54 53 } 55 54 ParseNode * set_last( ParseNode * newlast ) { 56 if ( newlast != 0) get_last()->set_next( newlast );55 if ( newlast != nullptr ) get_last()->set_next( newlast ); 57 56 return this; 58 57 } 59 60 const std::string &get_name() const { return name; }61 void set_name( const std::string &newValue ) { name = newValue; }62 58 63 59 virtual void print( std::ostream &os, int indent = 0 ) const {} 64 60 virtual void printList( std::ostream &os, int indent = 0 ) const {} 65 private: 61 66 62 static int indent_by; 67 63 68 64 ParseNode * next = nullptr; 69 std::string name;65 std::string * name = nullptr; 70 66 }; // ParseNode 71 67 … … 74 70 class InitializerNode : public ParseNode { 75 71 public: 76 InitializerNode( ExpressionNode *, bool aggrp = false, ExpressionNode * des = 0);77 InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode * des = 0);72 InitializerNode( ExpressionNode *, bool aggrp = false, ExpressionNode * des = nullptr ); 73 InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode * des = nullptr ); 78 74 ~InitializerNode(); 79 75 virtual InitializerNode * clone() const { assert( false ); return nullptr; } … … 106 102 public: 107 103 ExpressionNode( Expression * expr = nullptr ) : expr( expr ) {} 108 ExpressionNode( Expression * expr, const std::string * name ) : ParseNode( name ), expr( expr ) {}109 104 ExpressionNode( const ExpressionNode &other ); 110 105 virtual ~ExpressionNode() {} … … 183 178 Expression * build_attrexpr( NameExpr * var, ExpressionNode * expr_node ); 184 179 Expression * build_attrtype( NameExpr * var, DeclarationNode * decl_node ); 185 Expression * build_tuple( ExpressionNode * expr_node = 0);180 Expression * build_tuple( ExpressionNode * expr_node = nullptr ); 186 181 Expression * build_func( ExpressionNode * function, ExpressionNode * expr_node ); 187 182 Expression * build_range( ExpressionNode * low, ExpressionNode * high ); … … 219 214 static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle = false ); 220 215 static DeclarationNode * newQualifier( Qualifier ); 221 static DeclarationNode * newForall( DeclarationNode * );216 static DeclarationNode * newForall( DeclarationNode * ); 222 217 static DeclarationNode * newStorageClass( StorageClass ); 223 218 static DeclarationNode * newBasicType( BasicType ); … … 226 221 static DeclarationNode * newLength( Length lnth ); 227 222 static DeclarationNode * newBuiltinType( BuiltinType ); 228 static DeclarationNode * newFromTypedef( std::string * );223 static DeclarationNode * newFromTypedef( std::string * ); 229 224 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 230 225 static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants ); 231 226 static DeclarationNode * newEnumConstant( std::string * name, ExpressionNode * constant ); 232 static DeclarationNode * newName( std::string * );227 static DeclarationNode * newName( std::string * ); 233 228 static DeclarationNode * newFromTypeGen( std::string *, ExpressionNode * params ); 234 static DeclarationNode * newTypeParam( TypeClass, std::string * );235 static DeclarationNode * newTrait( std::string * name, DeclarationNode * params, DeclarationNode * asserts );236 static DeclarationNode * newTraitUse( std::string * name, ExpressionNode * params );229 static DeclarationNode * newTypeParam( TypeClass, std::string * ); 230 static DeclarationNode * newTrait( const std::string * name, DeclarationNode * params, DeclarationNode * asserts ); 231 static DeclarationNode * newTraitUse( const std::string * name, ExpressionNode * params ); 237 232 static DeclarationNode * newTypeDecl( std::string * name, DeclarationNode * typeParams ); 238 233 static DeclarationNode * newPointer( DeclarationNode * qualifiers ); … … 249 244 DeclarationNode * clone() const; 250 245 251 DeclarationNode * addQualifiers( DeclarationNode * );246 DeclarationNode * addQualifiers( DeclarationNode * ); 252 247 void checkQualifiers( const TypeData *, const TypeData * ); 253 void checkStorageClasses( DeclarationNode * q);254 DeclarationNode * copyStorageClasses( DeclarationNode * );255 DeclarationNode * addType( DeclarationNode * );248 void checkStorageClasses( DeclarationNode * ); 249 DeclarationNode * copyStorageClasses( DeclarationNode * ); 250 DeclarationNode * addType( DeclarationNode * ); 256 251 DeclarationNode * addTypedef(); 257 DeclarationNode * addAssertions( DeclarationNode * );258 DeclarationNode * addName( std::string * );252 DeclarationNode * addAssertions( DeclarationNode * ); 253 DeclarationNode * addName( std::string * ); 259 254 DeclarationNode * addBitfield( ExpressionNode * size ); 260 255 DeclarationNode * addVarArgs(); … … 270 265 271 266 DeclarationNode * cloneType( std::string * newName ); 272 DeclarationNode * cloneType( DeclarationNode * existing );273 DeclarationNode * cloneType( int ) { return cloneType( ( std::string *)0 ); }274 DeclarationNode * cloneBaseType( std::string * newName );275 267 DeclarationNode * cloneBaseType( DeclarationNode * newdecl ); 276 268 … … 286 278 287 279 bool get_hasEllipsis() const; 288 const std::string &get_name() const { return name; }289 280 LinkageSpec::Spec get_linkage() const { return linkage; } 290 281 DeclarationNode * extractAggregate() const; … … 295 286 DeclarationNode * set_extension( bool exten ) { extension = exten; return this; } 296 287 public: 297 // StorageClass buildStorageClass() const;298 // bool buildFuncSpecifier( StorageClass key ) const;299 300 288 struct Variable_t { 289 const std::string * name; 301 290 DeclarationNode::TypeClass tyClass; 302 std::string name;303 291 DeclarationNode * assertions; 304 292 }; … … 306 294 307 295 struct Attr_t { 308 std::stringname;296 const std::string * name; 309 297 ExpressionNode * expr; 310 298 DeclarationNode * type; … … 315 303 316 304 TypeData * type; 317 std::string name;318 305 StorageClass storageClass; 319 306 bool isInline, isNoreturn; … … 331 318 332 319 Type * buildType( TypeData * type ); 333 //Type::Qualifiers buildQualifiers( const TypeData::Qualifiers & qualifiers );334 320 335 321 static inline Type * maybeMoveBuildType( const DeclarationNode * orig ) { … … 393 379 Statement * build_finally( StatementNode * stmt ); 394 380 Statement * build_compound( StatementNode * first ); 395 Statement * build_asmstmt( bool voltile, ConstantExpr * instruction, ExpressionNode * output = 0, ExpressionNode * input = 0, ExpressionNode * clobber = 0, LabelNode * gotolabels = 0);381 Statement * build_asmstmt( bool voltile, ConstantExpr * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr ); 396 382 397 383 //##############################################################################
Note: See TracChangeset
for help on using the changeset viewer.