Changeset 937e51d for src/Parser/ParseNode.h
- Timestamp:
- Jun 26, 2015, 4:00:26 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 0df292b, e0ff3e6
- Parents:
- eb50842 (diff), 1869adf (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
-
src/Parser/ParseNode.h (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
reb50842 r937e51d 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat May 16 13:30:24201513 // Update Count : 312 // Last Modified On : Wed Jun 24 14:09:51 2015 13 // Update Count : 81 14 14 // 15 15 … … 22 22 23 23 #include "utility.h" 24 #include "SynTree/Declaration.h" 24 #include "Parser/LinkageSpec.h" 25 #include "SynTree/Type.h" 26 //#include "SynTree/Declaration.h" 25 27 #include "UniqueName.h" 26 28 … … 36 38 class ParseNode { 37 39 public: 38 ParseNode( void ); 39 ParseNode ( std::string ); 40 virtual ~ParseNode( void ); 41 42 ParseNode *set_name ( std::string ) ; 43 ParseNode *set_name ( std::string * ) ; 44 45 std::string get_name( void ); 46 47 ParseNode *get_link( void ) const; 48 ParseNode *get_last( void ); 40 ParseNode(); 41 ParseNode( const std::string * ); 42 virtual ~ParseNode(); 43 44 ParseNode *get_link() const; 45 ParseNode *get_last(); 49 46 ParseNode *set_link( ParseNode * ); 50 47 void set_next( ParseNode *newlink ) { next = newlink; } … … 52 49 virtual ParseNode *clone() const { return 0; }; 53 50 54 const std::string get_name( void ) const;51 const std::string &get_name() const { return *name; } 55 52 virtual void print( std::ostream &, int indent = 0 ) const; 56 53 virtual void printList( std::ostream &, int indent = 0 ) const; … … 58 55 ParseNode &operator,( ParseNode &); 59 56 protected: 60 std::stringname;57 const std::string *name; 61 58 ParseNode *next; 62 59 static int indent_by; … … 68 65 public: 69 66 ExpressionNode(); 70 ExpressionNode( std::string * );67 ExpressionNode( const std::string * ); 71 68 ExpressionNode( const ExpressionNode &other ); 72 69 virtual ~ExpressionNode() {} // cannot delete asArgName because it might be referenced elsewhere … … 77 74 78 75 ExpressionNode *get_argName() const { return argName; } 79 ExpressionNode *set_asArgName( std::string *aName );76 ExpressionNode *set_asArgName( const std::string *aName ); 80 77 ExpressionNode *set_asArgName( ExpressionNode *aDesignator ); 81 78 … … 105 102 class ConstantNode : public ExpressionNode { 106 103 public: 107 enum Type { 108 Integer, Float, Character, String /* , Range, EnumConstant */ 109 }; 110 111 ConstantNode( void ); 112 ConstantNode( std::string * ); 104 enum Type { Integer, Float, Character, String }; 105 113 106 ConstantNode( Type, std::string * ); 114 ConstantNode( const ConstantNode &other );115 107 116 108 virtual ConstantNode *clone() const { return new ConstantNode( *this ); } 117 118 Type get_type( void ) const ; 109 Type get_type( void ) const { return type; } 119 110 virtual void print( std::ostream &, int indent = 0) const; 120 111 virtual void printOneLine( std::ostream &, int indent = 0) const; 121 112 122 std::stringget_value() const { return value; }123 ConstantNode *append (std::string *newValue );113 const std::string &get_value() const { return value; } 114 ConstantNode *appendstr( const std::string *newValue ); 124 115 125 116 Expression *build() const; 126 117 private: 127 void classify( std::string &);128 118 Type type; 129 std::string value; 130 bool sign; 131 short base; 132 int longs, size; 119 BasicType::Kind btype; 120 std::string &value; 133 121 }; 134 122 … … 136 124 public: 137 125 VarRefNode(); 138 VarRefNode( std::string *, bool isLabel = false );126 VarRefNode( const std::string *, bool isLabel = false ); 139 127 VarRefNode( const VarRefNode &other ); 140 128 … … 143 131 virtual VarRefNode *clone() const { return new VarRefNode( *this ); } 144 132 145 virtual void print( std::ostream &, int indent = 0 ) const;146 virtual void printOneLine( std::ostream &, int indent = 0 ) const;133 virtual void print( std::ostream &, int indent = 0 ) const; 134 virtual void printOneLine( std::ostream &, int indent = 0 ) const; 147 135 private: 148 136 bool isLabel; … … 183 171 virtual OperatorNode *clone() const { return new OperatorNode( *this ); } 184 172 185 Type get_type( void) const;186 std::string get_typename( void) const;173 Type get_type() const; 174 const char *get_typename() const; 187 175 188 176 virtual void print( std::ostream &, int indent = 0) const; … … 198 186 class CompositeExprNode : public ExpressionNode { 199 187 public: 200 CompositeExprNode( void);201 CompositeExprNode( std::string * );188 CompositeExprNode(); 189 CompositeExprNode( const std::string * ); 202 190 CompositeExprNode( ExpressionNode *f, ExpressionNode *args = 0 ); 203 191 CompositeExprNode( ExpressionNode *f, ExpressionNode *arg1, ExpressionNode *arg2 ); … … 278 266 public: 279 267 enum Qualifier { Const, Restrict, Volatile, Lvalue, Atomic, Attribute }; 280 enum StorageClass { Extern, Static, Auto, Register, Inline, Fortran };268 enum StorageClass { Extern, Static, Auto, Register, Inline, Fortran, Noreturn, Threadlocal, NoStorageClass, }; 281 269 enum BasicType { Char, Int, Float, Double, Void, Bool, Complex, Imaginary }; 282 enum Modifier { Signed, Unsigned, Short, Long };283 enum TyCon{ Struct, Union, Context };270 enum Modifier { Signed, Unsigned, Short, Long }; 271 enum Aggregate { Struct, Union, Context }; 284 272 enum TypeClass { Type, Dtype, Ftype }; 285 273 274 static const char *storageName[]; 286 275 static const char *qualifierName[]; 287 276 static const char *basicTypeName[]; 288 277 static const char *modifierName[]; 289 static const char * tyConName[];278 static const char *aggregateName[]; 290 279 static const char *typeClassName[]; 291 280 … … 298 287 static DeclarationNode *newForall( DeclarationNode *); 299 288 static DeclarationNode *newFromTypedef( std::string *); 300 static DeclarationNode *newAggregate( TyConkind, std::string *name, DeclarationNode *formals, ExpressionNode *actuals, DeclarationNode *fields );289 static DeclarationNode *newAggregate( Aggregate kind, std::string *name, DeclarationNode *formals, ExpressionNode *actuals, DeclarationNode *fields ); 301 290 static DeclarationNode *newEnum( std::string *name, DeclarationNode *constants ); 302 291 static DeclarationNode *newEnumConstant( std::string *name, ExpressionNode *constant ); 303 292 static DeclarationNode *newName( std::string *); 304 static DeclarationNode *newFromTypeGen( std::string *, ExpressionNode *params );293 static DeclarationNode *newFromTypeGen( std::string *, ExpressionNode *params ); 305 294 static DeclarationNode *newTypeParam( TypeClass, std::string *); 306 295 static DeclarationNode *newContext( std::string *name, DeclarationNode *params, DeclarationNode *asserts ); … … 313 302 static DeclarationNode *newTuple( DeclarationNode *members ); 314 303 static DeclarationNode *newTypeof( ExpressionNode *expr ); 315 static DeclarationNode *newAttr( std::string *, ExpressionNode *expr );316 static DeclarationNode *newAttr( std::string *, DeclarationNode *type );304 static DeclarationNode *newAttr( std::string *, ExpressionNode *expr ); 305 static DeclarationNode *newAttr( std::string *, DeclarationNode *type ); 317 306 318 307 DeclarationNode *addQualifiers( DeclarationNode *); … … 340 329 DeclarationNode *cloneBaseType( DeclarationNode *newdecl ); 341 330 342 DeclarationNode *appendList( DeclarationNode *);331 DeclarationNode *appendList( DeclarationNode * ); 343 332 344 333 DeclarationNode *clone() const; … … 350 339 351 340 bool get_hasEllipsis() const; 352 std::stringget_name() const { return name; }341 const std::string &get_name() const { return name; } 353 342 LinkageSpec::Type get_linkage() const { return linkage; } 354 343 DeclarationNode *extractAggregate() const; … … 357 346 ~DeclarationNode(); 358 347 private: 359 Declaration::StorageClass buildStorageClass() const;360 bool build Inline() const;348 StorageClass buildStorageClass() const; 349 bool buildFuncSpecifier( StorageClass key ) const; 361 350 362 351 TypeData *type; … … 380 369 }; 381 370 382 StatementNode( void);383 StatementNode( std::string);371 StatementNode(); 372 StatementNode( const std::string * ); 384 373 StatementNode( Type, ExpressionNode *e = 0, StatementNode *s = 0 ); 385 374 StatementNode( Type, std::string *target ); … … 387 376 388 377 389 ~StatementNode( void);390 391 static StatementNode *newCatchStmt( DeclarationNode *d = 0, StatementNode *s = 0, bool catchRestP = false );378 ~StatementNode(); 379 380 static StatementNode *newCatchStmt( DeclarationNode *d = 0, StatementNode *s = 0, bool catchRestP = false ); 392 381 393 382 void set_control( ExpressionNode * ); … … 396 385 ExpressionNode *get_control() const ; 397 386 StatementNode *get_block() const; 398 StatementNode::Type get_type( void) const;399 400 StatementNode *add_label( std::string * );387 StatementNode::Type get_type() const; 388 389 StatementNode *add_label( const std::string * ); 401 390 std::list<std::string> *get_labels() const; 402 391 … … 429 418 class CompoundStmtNode : public StatementNode { 430 419 public: 431 CompoundStmtNode( void);432 CompoundStmtNode( std::string * );420 CompoundStmtNode(); 421 CompoundStmtNode( const std::string * ); 433 422 CompoundStmtNode( StatementNode * ); 434 423 ~CompoundStmtNode(); … … 499 488 500 489 // in DeclarationNode.cc 501 void buildList( const DeclarationNode *firstNode, std::list< Declaration * > &outputList );490 void buildList( const DeclarationNode *firstNode, std::list< Declaration * > &outputList ); 502 491 void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType *> &outputList ); 503 void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList );492 void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList ); 504 493 505 494 // in ExpressionNode.cc
Note:
See TracChangeset
for help on using the changeset viewer.