13
13
14
14
/* ******************************************************************\
15
15
16
- Function: string_constraint_generatort::extract_java_string
17
-
18
- Inputs: a symbol expression representing a java literal
19
-
20
- Outputs: a string constant
21
-
22
- Purpose: extract java string from symbol expression when they are encoded
23
- inside the symbol name
24
-
25
- \*******************************************************************/
26
-
27
- irep_idt string_constraint_generatort::extract_java_string (
28
- const symbol_exprt &s)
29
- {
30
- std::string tmp=id2string (s.get_identifier ());
31
- std::string prefix (" java::java.lang.String.Literal." );
32
- assert (has_prefix (tmp, prefix));
33
- std::string value=tmp.substr (prefix.length ());
34
- return irep_idt (value);
35
- }
36
-
37
- /* ******************************************************************\
38
-
39
16
Function: string_constraint_generatort::add_axioms_for_constant
40
17
41
18
Inputs: a string constant
@@ -107,7 +84,9 @@ string_exprt string_constraint_generatort::add_axioms_for_empty_string(
107
84
108
85
Function: string_constraint_generatort::add_axioms_from_literal
109
86
110
- Inputs: function application with an argument which is a string literal
87
+ Inputs:
88
+ f - function application with an argument which is a string literal
89
+ that is a constant with a string value.
111
90
112
91
Outputs: string expression
113
92
@@ -123,28 +102,7 @@ string_exprt string_constraint_generatort::add_axioms_from_literal(
123
102
assert (args.size ()==1 ); // Bad args to string literal?
124
103
125
104
const exprt &arg=args[0 ];
126
- irep_idt sval;
127
-
128
- assert (arg.operands ().size ()==1 );
129
- if (arg.op0 ().operands ().size ()==2 &&
130
- arg.op0 ().op0 ().id ()==ID_string_constant)
131
- {
132
- // C string constant
133
- const exprt &s=arg.op0 ().op0 ();
134
- sval=to_string_constant (s).get_value ();
135
- }
136
- else
137
- {
138
- // Java string constant
139
- assert (false ); // TODO: Check if used. On the contrary, discard else.
140
- assert (arg.id ()==ID_symbol);
141
- const exprt &s=arg.op0 ();
142
-
143
- // It seems the value of the string is lost,
144
- // we need to recover it from the identifier
145
- sval=extract_java_string (to_symbol_expr (s));
146
- }
147
-
105
+ irep_idt sval=to_constant_expr (arg).get_value ();
148
106
const refined_string_typet &ref_type=to_refined_string_type (f.type ());
149
107
return add_axioms_for_constant (sval, ref_type);
150
108
}
0 commit comments