Changes in / [43ee2a8:543159b]


Ignore:
Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cc

    r43ee2a8 r543159b  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:17:07 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 12 13:51:11 2015
    13 // Update Count     : 254
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Aug 11 15:13:48 2015
     13// Update Count     : 200
    1414//
    1515
     
    3232ExpressionNode::ExpressionNode() : ParseNode(), argName( 0 ) {}
    3333
    34 ExpressionNode::ExpressionNode( const string *name ) : ParseNode( name ), argName( 0 ) {}
     34ExpressionNode::ExpressionNode( const string *name_ ) : ParseNode( name_ ), argName( 0 ) {}
    3535
    3636ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.name ) {
     
    290290DesignatorNode::DesignatorNode( ExpressionNode *expr, bool isArrayIndex ) : isArrayIndex( isArrayIndex ) {
    291291        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 be
    301                                 // ".0" or ".1", otherwise the program is invalid
    302                                 if ( ! (var->get_name() == ".0" || var->get_name() == ".1") ) {
    303                                         throw SemanticError( "invalid designator name: " + var->get_name() );
    304                                 } // if
    305                                 var->set_name( var->get_name().substr(1) );
    306                         } // if
    307                 } // if
    308         } // if
    309292}
    310293
     
    312295}
    313296
    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 
    326297Expression *DesignatorNode::build() const {
    327         Expression * ret = get_argName()->build();
    328 
    329298        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
    337303}
    338304
  • src/Parser/ParseNode.cc

    r43ee2a8 r543159b  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:26:29 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 12 13:26:00 2015
    13 // Update Count     : 36
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul 30 14:55:54 2015
     13// Update Count     : 26
    1414//
    1515
     
    2020int ParseNode::indent_by = 4;
    2121
    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 ) { }
     22ParseNode::ParseNode() : name( 0 ), next( 0 ) {};
     23ParseNode::ParseNode( const string *name_ ) : name( name_ ), next( 0 ) {}
    2524
    2625ParseNode::~ParseNode() {
    27         delete next;
     26        delete next; delete name;
    2827};
    2928
  • src/Parser/ParseNode.h

    r43ee2a8 r543159b  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:28:16 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 12 13:27:11 2015
    13 // Update Count     : 172
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Aug 11 15:11:29 2015
     13// Update Count     : 145
    1414//
    1515
     
    4040        ParseNode();
    4141        ParseNode( const std::string * );
    42         ParseNode( const std::string & );  // for copy constructing subclasses
    4342        virtual ~ParseNode();
    4443
     
    5049        virtual ParseNode *clone() const { return 0; };
    5150
    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; }
    5552        virtual void print( std::ostream &, int indent = 0 ) const;
    5653        virtual void printList( std::ostream &, int indent = 0 ) const;
     
    5855        ParseNode &operator,( ParseNode &);
    5956  protected:
    60         std::string name;
     57        const std::string *name;
    6158        ParseNode *next;
    6259        static int indent_by;
  • src/SynTree/ArrayType.cc

    r43ee2a8 r543159b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 12 14:19:07 2015
    13 // Update Count     : 11
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jun  6 14:11:48 2015
     13// Update Count     : 9
    1414//
    1515
     
    5050        } // if
    5151        if ( dimension ) {
    52                 os << " with dimension of ";
    53                 dimension->print( os, 0 );
     52                os << "with dimension of ";
     53                dimension->print( os, indent );
    5454        } // if
    5555}
  • src/SynTree/BasicType.cc

    r43ee2a8 r543159b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 12 14:15:45 2015
    13 // Update Count     : 6
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun Jun  7 08:44:36 2015
     13// Update Count     : 5
    1414//
    1515
     
    2828
    2929        Type::print( os, indent );
    30         os << kindNames[ kind ];
     30        os << kindNames[ kind ] << ' ';
    3131}
    3232
  • src/SynTree/Expression.cc

    r43ee2a8 r543159b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 12 14:02:45 2015
    13 // Update Count     : 30
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Jul 28 16:27:17 2015
     13// Update Count     : 22
    1414//
    1515
     
    7272
    7373void ConstantExpr::print( std::ostream &os, int indent ) const {
    74         os << std::string( indent, ' ' ) << "constant expression " ;
     74        os << "constant expression " ;
    7575        constant.print( os );
    7676        Expression::print( os, indent );
    77         os << std::endl;
    7877}
    7978
  • src/SynTree/Initializer.cc

    r43ee2a8 r543159b  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Aug 12 14:05:25 2015
    13 // Update Count     : 14
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon May 18 09:02:45 2015
     13// Update Count     : 2
    1414//
    1515
     
    4343
    4444void 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 );
    4747
    4848        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++ )
    5151                        ( *i )->print(os, indent + 4 );
    52                 }
    5352        } // if
    5453}
Note: See TracChangeset for help on using the changeset viewer.