Changeset c36298d for src/AST/Expr.cpp
- Timestamp:
- Jun 17, 2019, 11:01:04 AM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b4d34fa
- Parents:
- 6a1dfda
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Expr.cpp
r6a1dfda rc36298d 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 221 } 239 222
Note: See TracChangeset
for help on using the changeset viewer.