Changes in / [d0bacde:bb0f974]
- Location:
- src/SynTree
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Constant.cc
rd0bacde rbb0f974 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Spt 28 14:49:00 201813 // Update Count : 3012 // Last Modified On : Fri Jul 14 14:50:00 2017 13 // Update Count : 29 14 14 // 15 15 … … 19 19 20 20 #include "Constant.h" 21 #include "Expression.h" // for ConstantExpr22 21 #include "Type.h" // for BasicType, Type, Type::Qualifiers, PointerType 23 22 … … 49 48 Constant Constant::from_double( double d ) { 50 49 return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ), d ); 51 }52 53 Constant Constant::from_string( std::string const & str ) {54 return Constant(55 new ArrayType(56 noQualifiers,57 new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),58 new ConstantExpr( Constant::from_int( str.size() + 1 /* \0 */ )),59 false, false ),60 std::string("\"") + str + "\"", (unsigned long long int)0 );61 50 } 62 51 -
src/SynTree/Constant.h
rd0bacde rbb0f974 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Spt 28 14:48:00 201813 // Update Count : 1 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:54:46 2017 13 // Update Count : 17 14 14 // 15 15 … … 51 51 /// generates a floating point constant of the given double 52 52 static Constant from_double( double d ); 53 /// generates an array of chars constant of the given string54 static Constant from_string( std::string const & s );55 53 56 54 /// generates a null pointer value for the given type. void * if omitted.
Note: See TracChangeset
for help on using the changeset viewer.