Changeset 6a1dfda for src/SynTree
- Timestamp:
- Jun 13, 2019, 8:41:11 PM (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:
- c36298d
- Parents:
- dc5072f (diff), 6896548 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- Peter A. Buhr <pabuhr@…> (06/13/19 20:39:34)
- git-committer:
- Peter A. Buhr <pabuhr@…> (06/13/19 20:41:11)
- Location:
- src/SynTree
- Files:
-
- 2 edited
-
Constant.cc (modified) (1 diff)
-
Constant.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Constant.cc
rdc5072f r6a1dfda 51 51 } 52 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 );53 Constant Constant::from_string( std::string const & cEscapedVal, Type *charType ) { 54 assert(cEscapedVal.length() >= 2); 55 assert(cEscapedVal.front() == '"'); 56 assert(cEscapedVal.back() == '"'); 57 ArrayType * at = new ArrayType( noQualifiers, charType, 58 new ConstantExpr( Constant::from_ulong( cEscapedVal.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"' 59 false, false ); 60 return Constant( at, cEscapedVal, (unsigned long long int)0 ); 61 61 } 62 62 -
src/SynTree/Constant.h
rdc5072f r6a1dfda 52 52 static Constant from_double( double d ); 53 53 /// generates an array of chars constant of the given string 54 static Constant from_string( std::string const & s);54 static Constant from_string( std::string const & cEscapedVal, Type *charType ); 55 55 56 56 /// generates a null pointer value for the given type. void * if omitted.
Note:
See TracChangeset
for help on using the changeset viewer.