Changeset 87b5bf0 for src/Parser
- Timestamp:
- Jun 29, 2016, 2:30:12 PM (9 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, with_gc
- Children:
- e64365c
- Parents:
- 7305915 (diff), 2fb2ad5 (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. - Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
r7305915 r87b5bf0 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ExpressionNode.cc -- 8 // 7 // ExpressionNode.cc -- 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:17:07 2015 … … 12 12 // Last Modified On : Mon Jun 13 14:46:17 2016 13 13 // Update Count : 307 14 // 14 // 15 15 16 16 #include <cassert> … … 231 231 // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string. 232 232 value.insert( value.length() - 1, newValue->substr( 1, newValue->length() - 2 ) ); 233 233 234 234 delete newValue; // allocated by lexer 235 235 return this; … … 347 347 348 348 if ( isArrayIndex ) { 349 // need to traverse entire structure and change any instances of 0 or 1 to 349 // need to traverse entire structure and change any instances of 0 or 1 to 350 350 // ConstantExpr 351 351 DesignatorFixer fixer; … … 440 440 } 441 441 442 CompositeExprNode::CompositeExprNode( const CompositeExprNode &other ) : ExpressionNode( other ), function( maybeClone( other.function ) ) {442 CompositeExprNode::CompositeExprNode( const CompositeExprNode &other ) : ExpressionNode( other ), function( maybeClone( other.function ) ), arguments( 0 ) { 443 443 ParseNode *cur = other.arguments; 444 444 while ( cur ) { … … 608 608 { 609 609 assert( args.size() == 2 ); 610 610 611 611 if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args() ) ) { 612 612 NameExpr *member = dynamic_cast<NameExpr *>( args.back() ); -
src/Parser/ParseNode.h
r7305915 r87b5bf0 28 28 //#include "SynTree/Declaration.h" 29 29 #include "Common/UniqueName.h" 30 #include "SynTree/Label.h" 30 31 31 32 class ExpressionNode; … … 284 285 virtual void printOneLine( std::ostream &, int indent = 0) const; 285 286 286 const std::list< std::string> &get_labels() const { return labels; };287 const std::list< Label > &get_labels() const { return labels; }; 287 288 void append_label( std::string *label ) { labels.push_back( *label ); delete label; } 288 289 private: 289 std::list< std::string> labels;290 std::list< Label > labels; 290 291 }; 291 292 … … 532 533 ExpressionNode *output, *input; 533 534 ConstantNode *clobber; 534 std::list< std::string> gotolabels;535 std::list< Label > gotolabels; 535 536 }; 536 537 -
src/Parser/StatementNode.cc
r7305915 r87b5bf0 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // StatementNode.cc -- 7 // StatementNode.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 27 27 28 28 const char *StatementNode::StType[] = { 29 "Exp", "If", "Switch", "Case", "Default", "Choose", "Fallthru", 30 "While", "Do", "For", 29 "Exp", "If", "Switch", "Case", "Default", "Choose", "Fallthru", 30 "While", "Do", "For", 31 31 "Goto", "Continue", "Break", "Return", "Throw", 32 32 "Try", "Catch", "Finally", "Asm", … … 62 62 StatementNode::StatementNode( Type t, ExpressionNode *ctrl_label, StatementNode *block ) : type( t ), control( ctrl_label ), block( block ), labels( 0 ), target( 0 ), decl( 0 ), isCatchRest ( false ) { 63 63 this->control = ( t == Default ) ? 0 : control; 64 } 64 } 65 65 66 66 StatementNode::StatementNode( Type t, string *target ) : type( t ), control( 0 ), block( 0 ), labels( 0 ), target( target ), decl( 0 ), isCatchRest ( false ) {} … … 74 74 75 75 StatementNode * StatementNode::newCatchStmt( DeclarationNode *d, StatementNode *s, bool catchRestP ) { 76 StatementNode *ret = new StatementNode( StatementNode::Catch, 0, s ); 76 StatementNode *ret = new StatementNode( StatementNode::Catch, 0, s ); 77 77 ret->addDeclaration( d ); 78 78 ret->setCatchRest( catchRestP ); … … 101 101 StatementNode *StatementNode::add_label( const std::string *l ) { 102 102 if ( l != 0 ) { 103 labels.push_front( *l ); 103 labels.push_front( *l ); 104 104 delete l; 105 105 } // if … … 156 156 control->print( os, indent ); 157 157 os << endl; 158 } else 158 } else 159 159 os << string( indent, ' ' ) << "Null Statement" << endl; 160 160 break; … … 177 177 if ( block ) { 178 178 os << string( indent + ParseNode::indent_by, ' ' ) << "Branches of execution: " << endl; 179 block->printList( os, indent + 2 * ParseNode::indent_by ); 179 block->printList( os, indent + 2 * ParseNode::indent_by ); 180 180 } // if 181 181 if ( target ) { … … 258 258 case Fallthru: 259 259 return new FallthruStmt( labs ); 260 case Case: 260 case Case: 261 261 return new CaseStmt( labs, maybeBuild<Expression>(get_control()), branches ); 262 262 case Default: … … 394 394 os << string( indent + ParseNode::indent_by, ' ' ) << "Goto Labels:" << endl; 395 395 os << string( indent + 2 * ParseNode::indent_by, ' ' ); 396 for ( std::list< std::string>::const_iterator i = gotolabels.begin();; ) {396 for ( std::list<Label>::const_iterator i = gotolabels.begin();; ) { 397 397 os << *i; 398 398 i++; … … 426 426 } 427 427 428 Statement *NullStmtNode::build() const { 428 Statement *NullStmtNode::build() const { 429 429 return new NullStmt; 430 430 }
Note:
See TracChangeset
for help on using the changeset viewer.