Changeset 1d4580a for src/Parser/ParseNode.h
- Timestamp:
- Aug 14, 2016, 8:36:29 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:
- 777bfcf
- Parents:
- 46b4259
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
r46b4259 r1d4580a 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 11 12:24:11201613 // Update Count : 4 4312 // Last Modified On : Sun Aug 14 08:09:54 2016 13 // Update Count : 469 14 14 // 15 15 … … 45 45 virtual ~ParseNode(); 46 46 47 ParseNode *get_link() const { return next; } 47 ParseNode *get_next() const { return next; } 48 ParseNode *set_next( ParseNode *newlink ) { next = newlink; return this; } 48 49 ParseNode *get_last(); 49 ParseNode *set_link( ParseNode * ); 50 void set_next( ParseNode *newlink ) { next = newlink; } 50 ParseNode *set_last( ParseNode * ); 51 51 52 52 virtual ParseNode *clone() const { return 0; }; … … 343 343 ~StatementNode(); 344 344 345 static StatementNode *newCatchStmt( DeclarationNode *d = 0, StatementNode *s = 0, bool catchRestP = false );346 347 345 StatementNode *set_block( StatementNode *b ) { block = b; return this; } 348 346 StatementNode *get_block() const { return block; } … … 357 355 358 356 void addDeclaration( DeclarationNode *newDecl ) { decl = newDecl; } 359 void setCatchRest( bool newVal ) { isCatchRest = newVal; } 360 361 std::string get_target() const; 357 358 void setCatchRest( bool newVal ) { catchAny = newVal; } 362 359 363 360 // StatementNode *add_controlexp( ExpressionNode * ); … … 368 365 virtual StatementNode *clone() const; 369 366 virtual Statement *build() const; 370 p rivate:367 public: 371 368 static const char *StType[]; 372 369 Type type; … … 374 371 StatementNode *block; 375 372 std::list<std::string> labels; 376 std::string *target; // target label for jump statements373 std::string *target; // target label for jump statements 377 374 DeclarationNode *decl; 378 bool isCatchRest;375 bool catchAny; 379 376 }; // StatementNode 380 377 381 378 class StatementNode2 : public StatementNode { 382 379 public: 383 StatementNode2() { }380 StatementNode2() { stmt = nullptr; } 384 381 StatementNode2( Statement *stmt ) : stmt( stmt ) {} 382 StatementNode2( DeclarationNode *decl ); 385 383 virtual ~StatementNode2() {} 386 384 … … 392 390 return this; 393 391 } 392 virtual std::list<std::string> get_labels() const { assert( false ); return StatementNode::get_labels(); } 393 394 394 virtual StatementNode *append_last_case( StatementNode * ); 395 virtual std::list<std::string> get_labels() const { assert( false ); return StatementNode::get_labels(); }396 395 397 396 virtual void print( std::ostream &os, int indent = 0 ) {} … … 401 400 }; // StatementNode 402 401 402 Statement *build_expr( ExpressionNode *ctl ); 403 403 404 struct ForCtl { 404 405 ForCtl( ExpressionNode *expr, ExpressionNode *condition, ExpressionNode *change ) : 405 init( new StatementNode ( StatementNode::Exp, expr) ), condition( condition ), change( change ) {}406 init( new StatementNode2( build_expr( expr ) ) ), condition( condition ), change( change ) {} 406 407 ForCtl( DeclarationNode *decl, ExpressionNode *condition, ExpressionNode *change ) : 407 init( new StatementNode ( decl ) ), condition( condition ), change( change ) {}408 init( new StatementNode2( decl ) ), condition( condition ), change( change ) {} 408 409 409 410 StatementNode *init; … … 412 413 }; 413 414 414 Statement *build_expr( ExpressionNode *ctl );415 415 Statement *build_if( ExpressionNode *ctl, StatementNode *then_stmt, StatementNode *else_stmt ); 416 416 Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ); … … 423 423 Statement *build_return( ExpressionNode *ctl ); 424 424 Statement *build_throw( ExpressionNode *ctl ); 425 Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ); 426 Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny = false ); 427 Statement *build_finally( StatementNode *stmt ); 425 428 426 429 //############################################################################## … … 429 432 public: 430 433 CompoundStmtNode(); 431 CompoundStmtNode( const std::string * );432 434 CompoundStmtNode( StatementNode * ); 433 435 ~CompoundStmtNode(); … … 477 479 errors.append( e ); 478 480 } // try 479 cur = dynamic_cast< NodeType *>( cur->get_ link() );481 cur = dynamic_cast< NodeType *>( cur->get_next() ); 480 482 } // while 481 483 if ( ! errors.isEmpty() ) {
Note: See TracChangeset
for help on using the changeset viewer.