Changeset e82aa9df for src/Parser/ParseNode.h
- Timestamp:
- Aug 15, 2016, 4:13:38 PM (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:
- b1848a0
- Parents:
- 797347f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
r797347f re82aa9df 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 14 16:29:20201613 // Update Count : 48312 // Last Modified On : Mon Aug 15 14:52:12 2016 13 // Update Count : 512 14 14 // 15 15 … … 64 64 ParseNode *next; 65 65 }; 66 67 ParseNode *mkList( ParseNode & );68 66 69 67 //############################################################################## … … 133 131 }; 134 132 135 //##############################################################################136 137 Expression *build_constantInteger( std::string &str );138 Expression *build_constantFloat( std::string &str );139 Expression *build_constantChar( std::string &str );140 ConstantExpr *build_constantStr( std::string &str );141 142 //##############################################################################143 144 NameExpr *build_varref( const std::string *name, bool labelp = false );145 146 //##############################################################################147 148 Expression *build_typevalue( DeclarationNode *decl );149 150 //##############################################################################151 152 133 enum class OperKinds { 153 134 // diadic … … 160 141 Ctor, Dtor, 161 142 }; 143 144 struct LabelNode { 145 std::list< Label > labels; 146 }; 147 148 Expression *build_constantInteger( std::string &str ); 149 Expression *build_constantFloat( std::string &str ); 150 Expression *build_constantChar( std::string &str ); 151 ConstantExpr *build_constantStr( std::string &str ); 152 153 NameExpr *build_varref( const std::string *name, bool labelp = false ); 154 Expression *build_typevalue( DeclarationNode *decl ); 162 155 163 156 Expression *build_cast( DeclarationNode * decl_node, ExpressionNode *expr_node ); … … 183 176 Expression *build_func( ExpressionNode * function, ExpressionNode * expr_node ); 184 177 Expression *build_range( ExpressionNode * low, ExpressionNode *high ); 185 186 //############################################################################## 187 188 Expression *build_asm( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ); 189 190 //############################################################################## 191 192 class LabelNode : public ExpressionNode { 193 public: 194 virtual Expression *build() const { return NULL; } 195 virtual LabelNode *clone() const { assert( false ); return new LabelNode( *this ); } 196 197 virtual void print( std::ostream &os, int indent = 0) const; 198 virtual void printOneLine( std::ostream &os, int indent = 0) const; 199 200 const std::list< Label > &get_labels() const { return labels; }; 201 void append_label( std::string * label ) { labels.push_back( *label ); delete label; } 202 private: 203 std::list< Label > labels; 204 }; 205 206 //############################################################################## 207 178 Expression *build_asmexpr( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ); 208 179 Expression *build_valexpr( StatementNode *s ); 209 210 //##############################################################################211 212 180 Expression *build_compoundLiteral( DeclarationNode *decl_node, InitializerNode *kids ); 213 181 … … 275 243 DeclarationNode *addNewArray( DeclarationNode *array ); 276 244 DeclarationNode *addParamList( DeclarationNode *list ); 277 DeclarationNode *addIdList( DeclarationNode *list ); 245 DeclarationNode *addIdList( DeclarationNode *list ); // old-style functions 278 246 DeclarationNode *addInitializer( InitializerNode *init ); 279 247 … … 328 296 class StatementNode : public ParseNode { 329 297 public: 330 enum Type { Exp, If, Switch, Case, Default, Choose, Fallthru, 331 While, Do, For, 332 Goto, Continue, Break, Return, Throw, 333 Try, Catch, Finally, Asm, 334 Decl 335 }; 336 337 StatementNode(); 298 StatementNode() { stmt = nullptr; } 299 StatementNode( Statement *stmt ) : stmt( stmt ) {} 338 300 StatementNode( DeclarationNode *decl ); 339 ~StatementNode(); 340 341 StatementNode::Type get_type() const { return type; } 342 343 virtual StatementNode *add_label( const std::string * ); 344 virtual std::list<std::string> get_labels() const { return labels; } 345 346 void addDeclaration( DeclarationNode *newDecl ) { decl = newDecl; } 347 348 virtual StatementNode *append_last_case( StatementNode * ); 349 350 virtual void print( std::ostream &os, int indent = 0) const {} 351 virtual StatementNode *clone() const; 352 virtual Statement *build() const; 353 public: 354 static const char *StType[]; 355 Type type; 356 std::list<std::string> labels; 357 DeclarationNode *decl; 358 }; // StatementNode 359 360 class StatementNode2 : public StatementNode { 361 public: 362 StatementNode2() { stmt = nullptr; } 363 StatementNode2( Statement *stmt ) : stmt( stmt ) {} 364 StatementNode2( DeclarationNode *decl ); 365 virtual ~StatementNode2() {} 366 367 virtual StatementNode2 *clone() const { assert( false ); return nullptr; } 301 virtual ~StatementNode() {} 302 303 virtual StatementNode *clone() const { assert( false ); return nullptr; } 368 304 virtual Statement *build() const { return stmt; } 369 305 370 virtual StatementNode 2*add_label( const std::string * name ) {306 virtual StatementNode *add_label( const std::string * name ) { 371 307 stmt->get_labels().emplace_back( *name ); 372 308 return this; 373 309 } 374 virtual std::list<std::string> get_labels() const { assert( false ); return StatementNode::get_labels(); }375 310 376 311 virtual StatementNode *append_last_case( StatementNode * ); … … 386 321 struct ForCtl { 387 322 ForCtl( ExpressionNode *expr, ExpressionNode *condition, ExpressionNode *change ) : 388 init( new StatementNode 2( build_expr( expr ) ) ), condition( condition ), change( change ) {}323 init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {} 389 324 ForCtl( DeclarationNode *decl, ExpressionNode *condition, ExpressionNode *change ) : 390 init( new StatementNode 2( decl ) ), condition( condition ), change( change ) {}325 init( new StatementNode( decl ) ), condition( condition ), change( change ) {} 391 326 392 327 StatementNode *init; … … 408 343 Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny = false ); 409 344 Statement *build_finally( StatementNode *stmt ); 410 411 //############################################################################## 412 413 class CompoundStmtNode : public StatementNode { 414 public: 415 CompoundStmtNode(); 416 CompoundStmtNode( StatementNode * ); 417 ~CompoundStmtNode(); 418 419 void add_statement( StatementNode * ); 420 421 void print( std::ostream &os, int indent = 0 ) const; 422 virtual Statement *build() const; 423 private: 424 StatementNode *first, *last; 425 }; 426 427 //############################################################################## 428 429 class AsmStmtNode : public StatementNode { 430 public: 431 AsmStmtNode( bool voltile, ConstantExpr *instruction, ExpressionNode *output = 0, ExpressionNode *input = 0, ExpressionNode *clobber = 0, LabelNode *gotolabels = 0 ); 432 ~AsmStmtNode(); 433 434 void print( std::ostream &os, int indent = 0 ) const {} 435 Statement *build() const; 436 private: 437 bool voltile; 438 ConstantExpr *instruction; 439 ExpressionNode *output, *input; 440 ExpressionNode *clobber; 441 std::list< Label > gotolabels; 442 }; 345 Statement *build_compound( StatementNode *first ); 346 Statement *build_asmstmt( bool voltile, ConstantExpr *instruction, ExpressionNode *output = 0, ExpressionNode *input = 0, ExpressionNode *clobber = 0, LabelNode *gotolabels = 0 ); 443 347 444 348 //##############################################################################
Note: See TracChangeset
for help on using the changeset viewer.