Changeset ca35c51


Ignore:
Timestamp:
Jun 30, 2016, 1:47:52 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
1bc1bb2
Parents:
84d4d6f
Message:

move implementation of ConstantNode? to ConstantExpr?

Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/CaseRangeMutator.cc

    r84d4d6f rca35c51  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 25 21:22:40 2016
    13 // Update Count     : 4
     12// Last Modified On : Thu Jun 30 13:28:55 2016
     13// Update Count     : 8
    1414//
    1515
  • src/GenPoly/Box.cc

    r84d4d6f rca35c51  
    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 : Fri May 13 14:51:21 2016
    13 // Update Count     : 295
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jun 29 21:43:03 2016
     13// Update Count     : 296
    1414//
    1515
     
    22942294                                // all union members are at offset zero
    22952295                                delete offsetofExpr;
    2296                                 return new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::string("0") ) );
     2296                                return new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), "0" ) );
    22972297                        } else return offsetofExpr;
    22982298                }
  • src/GenPoly/GenPoly.cc

    r84d4d6f rca35c51  
    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 May 25 13:39:21 2016
    13 // Update Count     : 13
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jun 29 21:45:53 2016
     13// Update Count     : 14
    1414//
    1515
     
    7878                type = replaceTypeInst( type, env );
    7979
    80                 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
     80                if ( dynamic_cast< TypeInstType * >( type ) ) {
    8181                        return type;
    8282                } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) {
  • src/InitTweak/FixGlobalInit.cc

    r84d4d6f rca35c51  
    99// Author           : Rob Schluntz
    1010// Created On       : Mon May 04 15:14:56 2016
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 13 11:37:30 2016
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jun 29 22:33:15 2016
     13// Update Count     : 4
    1414//
    1515
     
    8585                        init->accept( checker );
    8686                        return checker.isConstExpr;
    87                 }
     87                } // if
    8888                // for all intents and purposes, no initializer means const expr
    8989                return true;
     
    9898                } else {
    9999                        translationUnit.push_back( fixer.initFunction );
    100                 }
     100                } // if
     101
    101102                if ( fixer.destroyFunction->get_statements()->get_kids().empty() ) {
    102103                        delete fixer.destroyFunction;
    103104                } else {
    104105                        translationUnit.push_back( fixer.destroyFunction );
    105                 }
     106                } // if
    106107        }
    107108
     
    146147                // if ( isConstExpr( objDecl->get_init() ) ) return;
    147148
    148                 if ( ArrayType * at = dynamic_cast< ArrayType * > ( objDecl->get_type() ) ) {
     149                if ( dynamic_cast< ArrayType * > ( objDecl->get_type() ) ) {
    149150                        // xxx - initialize each element of the array
    150151                } else {
     
    164165                        destroy->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) );
    165166                        destroyStatements.push_front( new ImplicitCtorDtorStmt( new ExprStmt( noLabels, destroy ) ) );
    166                 }
     167                } // if
    167168        }
    168169
  • src/Parser/ExpressionNode.cc

    r84d4d6f rca35c51  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 13 14:46:17 2016
    13 // Update Count     : 307
     12// Last Modified On : Thu Jun 30 13:33:16 2016
     13// Update Count     : 319
    1414//
    1515
     
    1919#include <sstream>
    2020#include <cstdio>
    21 #include <climits>
    2221
    2322#include "ParseNode.h"
     
    9089//##############################################################################
    9190
    92 static inline bool checkU( char c ) { return c == 'u' || c == 'U'; }
    93 static inline bool checkL( char c ) { return c == 'l' || c == 'L'; }
    94 static inline bool checkF( char c ) { return c == 'f' || c == 'F'; }
    95 static inline bool checkD( char c ) { return c == 'd' || c == 'D'; }
    96 static inline bool checkI( char c ) { return c == 'i' || c == 'I'; }
    97 static inline bool checkX( char c ) { return c == 'x' || c == 'X'; }
    98 
    99 // Difficult to separate extra parts of constants during lexing because actions are not allow in the middle of patterns:
    100 //
    101 //              prefix action constant action suffix
    102 //
    103 // Alternatively, breaking a pattern using BEGIN does not work if the following pattern can be empty:
    104 //
    105 //              constant BEGIN CONT ...
    106 //              <CONT>(...)? BEGIN 0 ... // possible empty suffix
    107 //
    108 // because the CONT rule is NOT triggered if the pattern is empty. Hence, constants are reparsed here to determine their
    109 // type.
    110 
    111 ConstantNode::ConstantNode( Type t, string *inVal ) : type( t ), value( *inVal ) {
    112         // lexing divides constants into 4 kinds
    113         switch ( type ) {
    114           case Integer:
    115                 {
    116                         static const BasicType::Kind kind[2][3] = {
    117                                 { BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt },
    118                                 { BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt },
    119                         };
    120                         bool dec = true, Unsigned = false;                      // decimal, unsigned constant
    121                         int size;                                                                       // 0 => int, 1 => long, 2 => long long
    122                         unsigned long long v;                                           // converted integral value
    123                         size_t last = value.length() - 1;                       // last character of constant
    124 
    125                         if ( value[0] == '0' ) {                                        // octal constant ?
    126                                 dec = false;
    127                                 if ( last != 0 && checkX( value[1] ) ) { // hex constant ?
    128                                         sscanf( (char *)value.c_str(), "%llx", &v );
    129                                         //printf( "%llx %llu\n", v, v );
    130                                 } else {
    131                                         sscanf( (char *)value.c_str(), "%llo", &v );
    132                                         //printf( "%llo %llu\n", v, v );
    133                                 } // if
    134                         } else {                                                                        // decimal constant ?
    135                                 sscanf( (char *)value.c_str(), "%llu", &v );
    136                                 //printf( "%llu %llu\n", v, v );
    137                         } // if
    138 
    139                         if ( v <= INT_MAX ) {                                           // signed int
    140                                 size = 0;
    141                         } else if ( v <= UINT_MAX && ! dec ) {          // unsigned int
    142                                 size = 0;
    143                                 Unsigned = true;                                                // unsigned
    144                         } else if ( v <= LONG_MAX ) {                           // signed long int
    145                                 size = 1;
    146                         } else if ( v <= ULONG_MAX && ( ! dec || LONG_MAX == LLONG_MAX ) ) { // signed long int
    147                                 size = 1;
    148                                 Unsigned = true;                                                // unsigned long int
    149                         } else if ( v <= LLONG_MAX ) {                          // signed long long int
    150                                 size = 2;
    151                         } else {                                                                        // unsigned long long int
    152                                 size = 2;
    153                                 Unsigned = true;                                                // unsigned long long int
    154                         } // if
    155 
    156                         if ( checkU( value[last] ) ) {                          // suffix 'u' ?
    157                                 Unsigned = true;
    158                                 if ( last > 0 && checkL( value[ last - 1 ] ) ) { // suffix 'l' ?
    159                                         size = 1;
    160                                         if ( last > 1 && checkL( value[ last - 2 ] ) ) { // suffix 'll' ?
    161                                                 size = 2;
    162                                         } // if
    163                                 } // if
    164                         } else if ( checkL( value[ last ] ) ) {         // suffix 'l' ?
    165                                 size = 1;
    166                                 if ( last > 0 && checkL( value[ last - 1 ] ) ) { // suffix 'll' ?
    167                                         size = 2;
    168                                         if ( last > 1 && checkU( value[ last - 2 ] ) ) { // suffix 'u' ?
    169                                                 Unsigned = true;
    170                                         } // if
    171                                 } else {
    172                                         if ( last > 0 && checkU( value[ last - 1 ] ) ) { // suffix 'u' ?
    173                                                 Unsigned = true;
    174                                         } // if
    175                                 } // if
    176                         } // if
    177                         btype = kind[Unsigned][size];                           // lookup constant type
    178                         break;
    179                 }
    180           case Float:
    181                 {
    182                         static const BasicType::Kind kind[2][3] = {
    183                                 { BasicType::Float, BasicType::Double, BasicType::LongDouble },
    184                                 { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex },
    185                         };
    186                         bool complx = false;                                            // real, complex
    187                         int size = 1;                                                           // 0 => float, 1 => double (default), 2 => long double
    188                         // floating-point constant has minimum of 2 characters: 1. or .1
    189                         size_t last = value.length() - 1;
    190 
    191                         if ( checkI( value[last] ) ) {                          // imaginary ?
    192                                 complx = true;
    193                                 last -= 1;                                                              // backup one character
    194                         } // if
    195                         if ( checkF( value[last] ) ) {                          // float ?
    196                                 size = 0;
    197                         } else if ( checkD( value[last] ) ) {           // double ?
    198                                 size = 1;
    199                         } else if ( checkL( value[last] ) ) {           // long double ?
    200                                 size = 2;
    201                         } // if
    202                         if ( ! complx && checkI( value[last - 1] ) ) { // imaginary ?
    203                                 complx = true;
    204                         } // if
    205                         btype = kind[complx][size];                                     // lookup constant type
    206                         break;
    207                 }
    208           case Character:
    209                 btype = BasicType::Char;                                                // default
    210                 if ( string( "LUu" ).find( value[0] ) != string::npos ) {
    211                         // ???
    212                 } // if
    213                 break;
    214           case String:
    215                 // array of char
    216                 if ( string( "LUu" ).find( value[0] ) != string::npos ) {
    217                         if ( value[0] == 'u' && value[1] == '8' ) {
    218                                 // ???
    219                         } else {
    220                                 // ???
    221                         } // if
    222                 } // if
    223                 break;
    224         } // switch
     91ConstantNode::ConstantNode( ConstantExpr *expr ) : expr( expr ) {
    22592} // ConstantNode::ConstantNode
    22693
    22794ConstantNode *ConstantNode::appendstr( const std::string *newValue ) {
    22895        assert( newValue != 0 );
    229         assert( type == String );
     96        string value = expr->get_constant()->get_value();
    23097
    23198        // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string.
     
    237104
    238105void ConstantNode::printOneLine( std::ostream &os, int indent ) const {
    239         os << string( indent, ' ' );
    240         printDesignation( os );
    241 
    242         switch ( type ) {
    243           case Integer:
    244           case Float:
    245                 os << value ;
    246                 break;
    247           case Character:
    248                 os << "'" << value << "'";
    249                 break;
    250           case String:
    251                 os << '"' << value << '"';
    252                 break;
    253         } // switch
    254 
    255         os << ' ';
     106        // os << string( indent, ' ' );
     107        // printDesignation( os );
     108
     109        // switch ( type ) {
     110        //   case Integer:
     111        //   case Float:
     112        //      os << value ;
     113        //      break;
     114        //   case Character:
     115        //      os << "'" << value << "'";
     116        //      break;
     117        //   case String:
     118        //      os << '"' << value << '"';
     119        //      break;
     120        // } // switch
     121
     122        // os << ' ';
    256123}
    257124
     
    262129
    263130Expression *ConstantNode::build() const {
    264         ::Type::Qualifiers q;                                                           // no qualifiers on constants
    265 
    266         switch ( get_type() ) {
    267           case String:
    268                 {
    269                         // string should probably be a primitive type
    270                         ArrayType *at = new ArrayType( q, new BasicType( q, BasicType::Char ),
    271                                                                                    new ConstantExpr(
    272                                                                                            Constant( new BasicType( q, BasicType::UnsignedInt ),
    273                                                                                                                  toString( value.size()+1-2 ) ) ),  // +1 for '\0' and -2 for '"'
    274                                                                                    false, false );
    275                         return new ConstantExpr( Constant( at, value ), maybeBuild< Expression >( get_argName() ) );
    276                 }
    277           default:
    278                 return new ConstantExpr( Constant( new BasicType( q, btype ), get_value() ), maybeBuild< Expression >( get_argName() ) );
    279         }
     131        return expr->clone();
    280132}
    281133
  • src/Parser/ParseNode.cc

    r84d4d6f rca35c51  
    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 Jun 30 13:30:43 2016
     13// Update Count     : 50
    1414//
    1515
     16#include <climits>
    1617#include "ParseNode.h"
    1718using namespace std;
     19
     20// Difficult to separate extra parts of constants during lexing because actions are not allow in the middle of patterns:
     21//
     22//              prefix action constant action suffix
     23//
     24// Alternatively, breaking a pattern using BEGIN does not work if the following pattern can be empty:
     25//
     26//              constant BEGIN CONT ...
     27//              <CONT>(...)? BEGIN 0 ... // possible empty suffix
     28//
     29// because the CONT rule is NOT triggered if the pattern is empty. Hence, constants are reparsed here to determine their
     30// type.
     31
     32static inline bool checkU( char c ) { return c == 'u' || c == 'U'; }
     33static inline bool checkL( char c ) { return c == 'l' || c == 'L'; }
     34static inline bool checkF( char c ) { return c == 'f' || c == 'F'; }
     35static inline bool checkD( char c ) { return c == 'd' || c == 'D'; }
     36static inline bool checkI( char c ) { return c == 'i' || c == 'I'; }
     37static inline bool checkX( char c ) { return c == 'x' || c == 'X'; }
     38
     39BasicType::Kind literalType( ConstantNode::Type type, string &value ) {
     40        BasicType::Kind btype;
     41
     42        // lexing divides constants into 4 kinds
     43        switch ( type ) {
     44          case ConstantNode::Integer:
     45                {
     46                        static const BasicType::Kind kind[2][3] = {
     47                                { BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt },
     48                                { BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt },
     49                        };
     50                        bool dec = true, Unsigned = false;                      // decimal, unsigned constant
     51                        int size;                                                                       // 0 => int, 1 => long, 2 => long long
     52                        unsigned long long v;                                           // converted integral value
     53                        size_t last = value.length() - 1;                       // last character of constant
     54
     55                        if ( value[0] == '0' ) {                                        // octal constant ?
     56                                dec = false;
     57                                if ( last != 0 && checkX( value[1] ) ) { // hex constant ?
     58                                        sscanf( (char *)value.c_str(), "%llx", &v );
     59                                        //printf( "%llx %llu\n", v, v );
     60                                } else {
     61                                        sscanf( (char *)value.c_str(), "%llo", &v );
     62                                        //printf( "%llo %llu\n", v, v );
     63                                } // if
     64                        } else {                                                                        // decimal constant ?
     65                                sscanf( (char *)value.c_str(), "%llu", &v );
     66                                //printf( "%llu %llu\n", v, v );
     67                        } // if
     68
     69                        if ( v <= INT_MAX ) {                                           // signed int
     70                                size = 0;
     71                        } else if ( v <= UINT_MAX && ! dec ) {          // unsigned int
     72                                size = 0;
     73                                Unsigned = true;                                                // unsigned
     74                        } else if ( v <= LONG_MAX ) {                           // signed long int
     75                                size = 1;
     76                        } else if ( v <= ULONG_MAX && ( ! dec || LONG_MAX == LLONG_MAX ) ) { // signed long int
     77                                size = 1;
     78                                Unsigned = true;                                                // unsigned long int
     79                        } else if ( v <= LLONG_MAX ) {                          // signed long long int
     80                                size = 2;
     81                        } else {                                                                        // unsigned long long int
     82                                size = 2;
     83                                Unsigned = true;                                                // unsigned long long int
     84                        } // if
     85
     86                        if ( checkU( value[last] ) ) {                          // suffix 'u' ?
     87                                Unsigned = true;
     88                                if ( last > 0 && checkL( value[ last - 1 ] ) ) { // suffix 'l' ?
     89                                        size = 1;
     90                                        if ( last > 1 && checkL( value[ last - 2 ] ) ) { // suffix 'll' ?
     91                                                size = 2;
     92                                        } // if
     93                                } // if
     94                        } else if ( checkL( value[ last ] ) ) {         // suffix 'l' ?
     95                                size = 1;
     96                                if ( last > 0 && checkL( value[ last - 1 ] ) ) { // suffix 'll' ?
     97                                        size = 2;
     98                                        if ( last > 1 && checkU( value[ last - 2 ] ) ) { // suffix 'u' ?
     99                                                Unsigned = true;
     100                                        } // if
     101                                } else {
     102                                        if ( last > 0 && checkU( value[ last - 1 ] ) ) { // suffix 'u' ?
     103                                                Unsigned = true;
     104                                        } // if
     105                                } // if
     106                        } // if
     107                        btype = kind[Unsigned][size];                           // lookup constant type
     108                        break;
     109                }
     110          case ConstantNode::Float:
     111                {
     112                        static const BasicType::Kind kind[2][3] = {
     113                                { BasicType::Float, BasicType::Double, BasicType::LongDouble },
     114                                { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex },
     115                        };
     116                        bool complx = false;                                            // real, complex
     117                        int size = 1;                                                           // 0 => float, 1 => double (default), 2 => long double
     118                        // floating-point constant has minimum of 2 characters: 1. or .1
     119                        size_t last = value.length() - 1;
     120
     121                        if ( checkI( value[last] ) ) {                          // imaginary ?
     122                                complx = true;
     123                                last -= 1;                                                              // backup one character
     124                        } // if
     125                        if ( checkF( value[last] ) ) {                          // float ?
     126                                size = 0;
     127                        } else if ( checkD( value[last] ) ) {           // double ?
     128                                size = 1;
     129                        } else if ( checkL( value[last] ) ) {           // long double ?
     130                                size = 2;
     131                        } // if
     132                        if ( ! complx && checkI( value[last - 1] ) ) { // imaginary ?
     133                                complx = true;
     134                        } // if
     135                        btype = kind[complx][size];                                     // lookup constant type
     136                        break;
     137                }
     138          case ConstantNode::Character:
     139                btype = BasicType::Char;                                                // default
     140                if ( string( "LUu" ).find( value[0] ) != string::npos ) {
     141                        // ???
     142                } // if
     143                break;
     144          case ConstantNode::String:
     145                assert( false );
     146                // array of char
     147                if ( string( "LUu" ).find( value[0] ) != string::npos ) {
     148                        if ( value[0] == 'u' && value[1] == '8' ) {
     149                                // ???
     150                        } else {
     151                                // ???
     152                        } // if
     153                } // if
     154                break;
     155        } // switch
     156        return btype;
     157} // literalType
     158
     159ConstantNode *makeConstant( ConstantNode::Type type, std::string *str ) {
     160        ::Type::Qualifiers emptyQualifiers;                                     // no qualifiers on constants
     161        return new ConstantNode( new ConstantExpr( Constant( new BasicType( emptyQualifiers, literalType( type, *str ) ), *str ), nullptr ) );
     162}
     163
     164ConstantNode *makeConstantStr( ConstantNode::Type type, std::string *str ) {
     165        ::Type::Qualifiers emptyQualifiers;                                     // no qualifiers on constants
     166        // string should probably be a primitive type
     167        ArrayType *at = new ArrayType( emptyQualifiers, new BasicType( emptyQualifiers, BasicType::Char ),
     168                                                                   new ConstantExpr(
     169                                                                           Constant( new BasicType( emptyQualifiers, BasicType::UnsignedInt ),
     170                                                                                                 toString( str->size()+1-2 ) ) ),  // +1 for '\0' and -2 for '"'
     171                                                                   false, false );
     172        return new ConstantNode( new ConstantExpr( Constant( at, *str ), nullptr ) );
     173}
     174
    18175
    19176// Builder
  • src/Parser/ParseNode.h

    r84d4d6f rca35c51  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 27 23:28:10 2016
    13 // Update Count     : 242
     12// Last Modified On : Thu Jun 30 11:48:28 2016
     13// Update Count     : 252
    1414//
    1515
     
    126126        enum Type { Integer, Float, Character, String };
    127127
    128         ConstantNode( Type, std::string * );
    129         ConstantNode( const ConstantNode &other ) : type( other.type ), btype( other.btype), value( *new std::string( other.value ) ) {};
    130         ~ConstantNode() { delete &value; }
     128        ConstantNode( ConstantExpr * );
     129        ConstantNode( const ConstantNode &other ) : expr( other.expr->clone() ) {};
     130        ~ConstantNode() { delete expr; }
    131131
    132132        virtual ConstantNode *clone() const { return new ConstantNode( *this ); }
    133         Type get_type( void ) const { return type; }
    134133        virtual void print( std::ostream &, int indent = 0) const;
    135134        virtual void printOneLine( std::ostream &, int indent = 0) const;
    136135
    137         const std::string &get_value() const { return value; }
    138136        ConstantNode *appendstr( const std::string *newValue );
    139137
    140138        Expression *build() const;
    141139  private:
    142         Type type;
    143         BasicType::Kind btype;
    144         std::string &value;
    145 };
     140        ConstantExpr *expr;
     141};
     142
     143ConstantNode *makeConstant( ConstantNode::Type, std::string * );
     144ConstantNode *makeConstantStr( ConstantNode::Type type, std::string *str );
    146145
    147146class VarRefNode : public ExpressionNode {
  • src/Parser/parser.cc

    r84d4d6f rca35c51  
    52375237/* Line 1806 of yacc.c  */
    52385238#line 305 "parser.yy"
    5239     { (yyval.constant) = new ConstantNode( ConstantNode::Integer, (yyvsp[(1) - (1)].tok) ); }
     5239    { (yyval.constant) = makeConstant( ConstantNode::Integer, (yyvsp[(1) - (1)].tok) ); }
    52405240    break;
    52415241
     
    52445244/* Line 1806 of yacc.c  */
    52455245#line 306 "parser.yy"
    5246     { (yyval.constant) = new ConstantNode( ConstantNode::Float, (yyvsp[(1) - (1)].tok) ); }
     5246    { (yyval.constant) = makeConstant( ConstantNode::Float, (yyvsp[(1) - (1)].tok) ); }
    52475247    break;
    52485248
     
    52515251/* Line 1806 of yacc.c  */
    52525252#line 307 "parser.yy"
    5253     { (yyval.constant) = new ConstantNode( ConstantNode::Character, (yyvsp[(1) - (1)].tok) ); }
     5253    { (yyval.constant) = makeConstant( ConstantNode::Character, (yyvsp[(1) - (1)].tok) ); }
    52545254    break;
    52555255
     
    52585258/* Line 1806 of yacc.c  */
    52595259#line 332 "parser.yy"
    5260     { (yyval.constant) = new ConstantNode( ConstantNode::String, (yyvsp[(1) - (1)].tok) ); }
     5260    { (yyval.constant) = makeConstantStr( ConstantNode::String, (yyvsp[(1) - (1)].tok) ); }
    52615261    break;
    52625262
     
    59535953/* Line 1806 of yacc.c  */
    59545954#line 684 "parser.yy"
    5955     { (yyval.sn) = new StatementNode( (yyvsp[(2) - (2)].decl) )/*->set_extension( true )*/; }
     5955    { (yyval.sn) = (new StatementNode( (yyvsp[(2) - (2)].decl) ))->set_extension( true ); }
    59565956    break;
    59575957
     
    72667266/* Line 1806 of yacc.c  */
    72677267#line 1474 "parser.yy"
    7268     { (yyval.decl) = (yyvsp[(2) - (3)].decl)/*->set_extension( true )*/; }
     7268    { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); }
    72697269    break;
    72707270
     
    72737273/* Line 1806 of yacc.c  */
    72747274#line 1477 "parser.yy"
    7275     { (yyval.decl) = (yyvsp[(2) - (3)].decl)/*->set_extension( true )*/; }
     7275    { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); }
    72767276    break;
    72777277
     
    80578057/* Line 1806 of yacc.c  */
    80588058#line 1993 "parser.yy"
    8059     { (yyval.decl) = (yyvsp[(2) - (2)].decl)/*->set_extension( true )*/; }
     8059    { (yyval.decl) = (yyvsp[(2) - (2)].decl)->set_extension( true ); }
    80608060    break;
    80618061
  • src/Parser/parser.yy

    r84d4d6f rca35c51  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 27 17:47:56 2016
    13 // Update Count     : 1627
     12// Last Modified On : Thu Jun 30 13:26:01 2016
     13// Update Count     : 1639
    1414//
    1515
     
    303303constant:
    304304                // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant".
    305         INTEGERconstant                                                         { $$ = new ConstantNode( ConstantNode::Integer, $1 ); }
    306         | FLOATINGconstant                                                      { $$ = new ConstantNode( ConstantNode::Float, $1 ); }
    307         | CHARACTERconstant                                                     { $$ = new ConstantNode( ConstantNode::Character, $1 ); }
     305INTEGERconstant                                                                 { $$ = makeConstant( ConstantNode::Integer, $1 ); }
     306        | FLOATINGconstant                                                      { $$ = makeConstant( ConstantNode::Float, $1 ); }
     307        | CHARACTERconstant                                                     { $$ = makeConstant( ConstantNode::Character, $1 ); }
    308308        ;
    309309
     
    330330
    331331string_literal_list:                                                                    // juxtaposed strings are concatenated
    332         STRINGliteral                                                           { $$ = new ConstantNode( ConstantNode::String, $1 ); }
     332        STRINGliteral                                                           { $$ = makeConstantStr( ConstantNode::String, $1 ); }
    333333        | string_literal_list STRINGliteral                     { $$ = $1->appendstr( $2 ); }
    334334        ;
     
    682682                { $$ = new StatementNode( $1 ); }
    683683        | EXTENSION declaration                                                         // GCC
    684                 { $$ = new StatementNode( $2 )/*->set_extension( true )*/; }
     684        { $$ = (new StatementNode( $2 ))->set_extension( true ); }
    685685        | function_definition
    686686                { $$ = new StatementNode( $1 ); }
     
    14721472        new_field_declaring_list ';'                                            // CFA, new style field declaration
    14731473        | EXTENSION new_field_declaring_list ';'                        // GCC
    1474                 { $$ = $2/*->set_extension( true )*/; }
     1474                { $$ = $2->set_extension( true ); }
    14751475        | field_declaring_list ';'
    14761476        | EXTENSION field_declaring_list ';'                            // GCC
    1477                 { $$ = $2/*->set_extension( true )*/; }
     1477                { $$ = $2->set_extension( true ); }
    14781478        ;
    14791479
     
    19911991                }
    19921992        | EXTENSION external_definition
    1993                 { $$ = $2/*->set_extension( true )*/; }
     1993                { $$ = $2->set_extension( true ); }
    19941994        ;
    19951995
  • src/SynTree/Constant.h

    r84d4d6f rca35c51  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 30 15:19:16 2015
    13 // Update Count     : 5
     12// Last Modified On : Thu Jun 30 13:33:17 2016
     13// Update Count     : 6
    1414//
    1515
     
    2929        Type *get_type() { return type; }
    3030        void set_type( Type *newValue ) { type = newValue; }
    31         std::string get_value() { return value; }
     31        std::string &get_value() { return value; }
    3232        void set_value( std::string newValue ) { value = newValue; }
    3333
Note: See TracChangeset for help on using the changeset viewer.