Changes in / [43ee2a8:543159b]
- Location:
- src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
r43ee2a8 r543159b 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:17:07 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Aug 12 13:51:11201513 // Update Count : 2 5411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Aug 11 15:13:48 2015 13 // Update Count : 200 14 14 // 15 15 … … 32 32 ExpressionNode::ExpressionNode() : ParseNode(), argName( 0 ) {} 33 33 34 ExpressionNode::ExpressionNode( const string *name ) : ParseNode( name), argName( 0 ) {}34 ExpressionNode::ExpressionNode( const string *name_ ) : ParseNode( name_ ), argName( 0 ) {} 35 35 36 36 ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.name ) { … … 290 290 DesignatorNode::DesignatorNode( ExpressionNode *expr, bool isArrayIndex ) : isArrayIndex( isArrayIndex ) { 291 291 set_argName( expr ); 292 assert( get_argName() );293 294 if ( ! isArrayIndex ) {295 if ( VarRefNode * var = dynamic_cast< VarRefNode * >( expr ) ) {296 297 stringstream ss( var->get_name() );298 double value;299 if ( ss >> value ) {300 // this is a floating point constant. It MUST be301 // ".0" or ".1", otherwise the program is invalid302 if ( ! (var->get_name() == ".0" || var->get_name() == ".1") ) {303 throw SemanticError( "invalid designator name: " + var->get_name() );304 } // if305 var->set_name( var->get_name().substr(1) );306 } // if307 } // if308 } // if309 292 } 310 293 … … 312 295 } 313 296 314 class DesignatorFixer : public Mutator {315 public:316 virtual Expression* mutate( NameExpr *nameExpr ) {317 if ( nameExpr->get_name() == "0" || nameExpr->get_name() == "1" ) {318 Constant val( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nameExpr->get_name() );319 delete nameExpr;320 return new ConstantExpr( val );321 }322 return nameExpr;323 }324 };325 326 297 Expression *DesignatorNode::build() const { 327 Expression * ret = get_argName()->build();328 329 298 if ( isArrayIndex ) { 330 // need to traverse entire structure and change any instances of 0 or 1 to 331 // ConstantExpr 332 DesignatorFixer fixer; 333 ret = ret->acceptMutator( fixer ); 334 } // if 335 336 return ret; 299 return new NameExpr( get_name(), maybeBuild< Expression >( get_argName() ) ); 300 } else { 301 return new NameExpr( get_name(), maybeBuild< Expression >( get_argName() ) ); 302 } // if 337 303 } 338 304 -
src/Parser/ParseNode.cc
r43ee2a8 r543159b 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:26:29 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Aug 12 13:26:00201513 // Update Count : 3611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 30 14:55:54 2015 13 // Update Count : 26 14 14 // 15 15 … … 20 20 int ParseNode::indent_by = 4; 21 21 22 ParseNode::ParseNode() : next( 0 ) {}; 23 ParseNode::ParseNode( const string *name ) : name( *name ), next( 0 ) { delete name; } 24 ParseNode::ParseNode( const string &name ) : name( name ), next( 0 ) { } 22 ParseNode::ParseNode() : name( 0 ), next( 0 ) {}; 23 ParseNode::ParseNode( const string *name_ ) : name( name_ ), next( 0 ) {} 25 24 26 25 ParseNode::~ParseNode() { 27 delete next; 26 delete next; delete name; 28 27 }; 29 28 -
src/Parser/ParseNode.h
r43ee2a8 r543159b 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:28:16 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Aug 12 13:27:11201513 // Update Count : 1 7211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Aug 11 15:11:29 2015 13 // Update Count : 145 14 14 // 15 15 … … 40 40 ParseNode(); 41 41 ParseNode( const std::string * ); 42 ParseNode( const std::string & ); // for copy constructing subclasses43 42 virtual ~ParseNode(); 44 43 … … 50 49 virtual ParseNode *clone() const { return 0; }; 51 50 52 const std::string &get_name() const { return name; } 53 void set_name( const std::string &newValue ) { name = newValue; } 54 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; -
src/SynTree/ArrayType.cc
r43ee2a8 r543159b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Aug 12 14:19:07201513 // Update Count : 1111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 6 14:11:48 2015 13 // Update Count : 9 14 14 // 15 15 … … 50 50 } // if 51 51 if ( dimension ) { 52 os << " 53 dimension->print( os, 0);52 os << "with dimension of "; 53 dimension->print( os, indent ); 54 54 } // if 55 55 } -
src/SynTree/BasicType.cc
r43ee2a8 r543159b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Aug 12 14:15:45201513 // Update Count : 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jun 7 08:44:36 2015 13 // Update Count : 5 14 14 // 15 15 … … 28 28 29 29 Type::print( os, indent ); 30 os << kindNames[ kind ] ;30 os << kindNames[ kind ] << ' '; 31 31 } 32 32 -
src/SynTree/Expression.cc
r43ee2a8 r543159b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Aug 12 14:02:45201513 // Update Count : 3011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 28 16:27:17 2015 13 // Update Count : 22 14 14 // 15 15 … … 72 72 73 73 void ConstantExpr::print( std::ostream &os, int indent ) const { 74 os << std::string( indent, ' ' ) <<"constant expression " ;74 os << "constant expression " ; 75 75 constant.print( os ); 76 76 Expression::print( os, indent ); 77 os << std::endl;78 77 } 79 78 -
src/SynTree/Initializer.cc
r43ee2a8 r543159b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Aug 12 14:05:25 201513 // Update Count : 1411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 09:02:45 2015 13 // Update Count : 2 14 14 // 15 15 … … 43 43 44 44 void SingleInit::print( std::ostream &os, int indent ) { 45 os << std::endl << std::string(indent, ' ' ) << "Simple Initializer: " << std::endl;46 value->print( os, indent+ 4);45 os << std::endl << std::string(indent, ' ' ) << "Simple Initializer: "; 46 value->print( os, indent+2 ); 47 47 48 48 if ( ! designators.empty() ) { 49 os << std::endl << std::string(indent + 2, ' ' ) << "designated by: " << std::endl;50 for ( std::list < Expression * >::iterator i = designators.begin(); i != designators.end(); i++ ) {49 os << std::endl << std::string(indent + 2, ' ' ) << "designated by: " ; 50 for ( std::list < Expression * >::iterator i = designators.begin(); i != designators.end(); i++ ) 51 51 ( *i )->print(os, indent + 4 ); 52 }53 52 } // if 54 53 }
Note: See TracChangeset
for help on using the changeset viewer.