Skip to content

Commit db1cd5f

Browse files
Cleaning the initialization of string expressions from constants
1 parent e9e3989 commit db1cd5f

File tree

1 file changed

+4
-46
lines changed

1 file changed

+4
-46
lines changed

src/solvers/refinement/string_constraint_generator_constants.cpp

+4-46
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,6 @@ Author: Romain Brenguier, [email protected]
1313

1414
/*******************************************************************\
1515
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-
3916
Function: string_constraint_generatort::add_axioms_for_constant
4017
4118
Inputs: a string constant
@@ -107,7 +84,9 @@ string_exprt string_constraint_generatort::add_axioms_for_empty_string(
10784
10885
Function: string_constraint_generatort::add_axioms_from_literal
10986
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.
11190
11291
Outputs: string expression
11392
@@ -123,28 +102,7 @@ string_exprt string_constraint_generatort::add_axioms_from_literal(
123102
assert(args.size()==1); // Bad args to string literal?
124103

125104
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();
148106
const refined_string_typet &ref_type=to_refined_string_type(f.type());
149107
return add_axioms_for_constant(sval, ref_type);
150108
}

0 commit comments

Comments
 (0)