Changes in src/AST/Expr.cpp [60aaa51d:c36298d]
- File:
-
- 1 edited
-
src/AST/Expr.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Expr.cpp
r60aaa51d rc36298d 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 15 17:00:00 2019 11 // Last Modified By : A aron B. Moss12 // Created On : Wed May 15 17:00:00 201913 // Update Count : 111 // Last Modified By : Andrew Beach 12 // Created On : Thr Jun 13 13:38:00 2019 13 // Update Count : 2 14 14 // 15 15 … … 194 194 if ( const BasicType * bty = result.as< BasicType >() ) { 195 195 if ( bty->isInteger() ) { 196 return val.ival; 196 assert(ival); 197 return ival.value(); 197 198 } 198 199 } else if ( result.as< ZeroType >() ) { … … 204 205 } 205 206 206 double ConstantExpr::floatValue() const {207 if ( const BasicType * bty = result.as< BasicType >() ) {208 if ( ! bty->isInteger() ) {209 return val.dval;210 }211 }212 SemanticError( this, "Constant expression of non-floating-point type " );213 }214 215 207 ConstantExpr * ConstantExpr::from_bool( const CodeLocation & loc, bool b ) { 216 208 return new ConstantExpr{ 217 209 loc, new BasicType{ BasicType::Bool }, b ? "1" : "0", (unsigned long long)b }; 218 }219 220 ConstantExpr * ConstantExpr::from_char( const CodeLocation & loc, char c ) {221 return new ConstantExpr{222 loc, new BasicType{ BasicType::Char }, std::to_string( c ), (unsigned long long)c };223 210 } 224 211 … … 232 219 loc, new BasicType{ BasicType::LongUnsignedInt }, std::to_string( i ), 233 220 (unsigned long long)i }; 234 }235 236 ConstantExpr * ConstantExpr::from_double( const CodeLocation & loc, double d ) {237 return new ConstantExpr{ loc, new BasicType{ BasicType::Double }, std::to_string( d ), d };238 }239 240 ConstantExpr * ConstantExpr::from_string( const CodeLocation & loc, const std::string & s ) {241 return new ConstantExpr{242 loc,243 new ArrayType{244 new BasicType{ BasicType::Char, CV::Const },245 ConstantExpr::from_int( loc, s.size() + 1 /* null terminator */ ),246 FixedLen, DynamicDim },247 std::string{"\""} + s + "\"",248 (unsigned long long)0,249 ConstantExpr::String };250 221 } 251 222 … … 382 353 383 354 UniqueExpr::UniqueExpr( const CodeLocation & loc, const Expr * e, unsigned long long i ) 384 : Expr( loc, e->result ), id( i ) {355 : Expr( loc, e->result ), expr( e ), id( i ) { 385 356 assert( expr ); 386 357 if ( id == -1ull ) {
Note:
See TracChangeset
for help on using the changeset viewer.