Changes in src/Parser/ExpressionNode.cc [e8ccca3:cccc534]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
re8ccca3 rcccc534 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:17:07 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Sep 1 15:07:09201713 // Update Count : 61811 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 2 11:12:00 2017 13 // Update Count : 568 14 14 // 15 15 … … 58 58 static inline bool checkX( char c ) { return c == 'x' || c == 'X'; } 59 59 60 static void sepNumeric( string & str, string & units ) { 61 string::size_type posn = str.find_first_of( "`" ); 62 if ( posn != string::npos ) { 63 units = "?" + str.substr( posn ); // extract units 64 str.erase( posn ); // remove units 65 } // if 66 } // sepNumeric 67 68 Expression * build_constantInteger( std::string & str ) { 60 Expression * build_constantInteger( const std::string & str ) { 69 61 static const BasicType::Kind kind[2][3] = { 70 62 { BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt }, 71 63 { BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt }, 72 64 }; 73 74 string units; // units75 sepNumeric( str, units ); // separate constant from units76 77 65 bool dec = true, Unsigned = false; // decimal, unsigned constant 78 66 int size; // 0 => int, 1 => long, 2 => long long … … 81 69 Expression * ret; 82 70 83 // ROB: what do we do with units on 0 and 1?84 71 // special constants 85 72 if ( str == "0" ) { … … 147 134 ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) ); 148 135 CLEANUP: 149 if ( units.length() != 0 ) {150 ret = new UntypedExpr( new NameExpr( units, ret ) );151 } // if152 153 136 delete &str; // created by lex 154 137 return ret; 155 138 } // build_constantInteger 156 139 157 Expression * build_constantFloat( std::string & str ) {140 Expression * build_constantFloat( const std::string & str ) { 158 141 static const BasicType::Kind kind[2][3] = { 159 142 { BasicType::Float, BasicType::Double, BasicType::LongDouble }, 160 143 { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex }, 161 144 }; 162 163 string units; // units164 sepNumeric( str, units ); // separate constant from units165 145 166 146 bool complx = false; // real, complex … … 189 169 190 170 Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) ); 191 if ( units.length() != 0 ) {192 ret = new UntypedExpr( new NameExpr( units, ret ) );193 } // if194 195 171 delete &str; // created by lex 196 172 return ret; 197 173 } // build_constantFloat 198 174 199 static void sepString( string & str, string & units, char delimit ) { 200 string::size_type posn = str.find_last_of( delimit ) + 1; 201 if ( posn != str.length() ) { 202 units = "?" + str.substr( posn ); // extract units 203 str.erase( posn ); // remove units 204 } // if 205 } // sepString 206 207 Expression * build_constantChar( std::string & str ) { 208 string units; // units 209 sepString( str, units, '\'' ); // separate constant from units 210 175 Expression * build_constantChar( const std::string & str ) { 211 176 Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) ); 212 if ( units.length() != 0 ) {213 ret = new UntypedExpr( new NameExpr( units, ret ) );214 } // if215 216 177 delete &str; // created by lex 217 178 return ret; 218 179 } // build_constantChar 219 180 220 ConstantExpr * build_constantStr( std::string & str ) { 221 string units; // units 222 sepString( str, units, '"' ); // separate constant from units 223 181 ConstantExpr * build_constantStr( const std::string & str ) { 182 // string should probably be a primitive type 224 183 ArrayType * at = new ArrayType( noQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), 225 226 184 new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"' 185 false, false ); 227 186 ConstantExpr * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) ); // constant 0 is ignored for pure string value 228 // ROB: type mismatch229 // if ( units.length() != 0 ) {230 // ret = new UntypedExpr( new NameExpr( units, ret ) );231 // } // if232 233 187 delete &str; // created by lex 234 188 return ret; … … 360 314 Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node ) { 361 315 std::list< Expression * > args; 362 args.push_back( maybeMoveBuild< Expression >(expr_node) ); // xxx 316 args.push_back( maybeMoveBuild< Expression >(expr_node) ); // xxx -- this is exactly the same as the val case now, refactor this code. 363 317 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 364 318 } // build_unary_ptr
Note:
See TracChangeset
for help on using the changeset viewer.