Skip to content

Commit 25ffad4

Browse files
committed
Do not use dstringt-specific APIs with irep_idt
Always use id2string instead of as_string, and directly refer to the string container rather than indirectly via dstringt's API.
1 parent 534f4d2 commit 25ffad4

6 files changed

+15
-15
lines changed

src/goto-programs/interpreter.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
2020

2121
#include <util/invariant.h>
2222
#include <util/std_types.h>
23+
#include <util/string_container.h>
2324
#include <util/symbol_table.h>
2425
#include <util/ieee_float.h>
2526
#include <util/fixedbv.h>
@@ -642,7 +643,7 @@ exprt interpretert::get_value(
642643
{
643644
// Strings are currently encoded by their irep_idt ID.
644645
return constant_exprt(
645-
irep_idt::make_from_table_index(rhs[integer2size_t(offset)].to_long()),
646+
get_string_container().get_string(rhs[integer2size_t(offset)].to_long()),
646647
type);
647648
}
648649

src/goto-programs/interpreter_evaluate.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Author: Daniel Kroening, [email protected]
1919
#include <util/invariant.h>
2020
#include <util/fixedbv.h>
2121
#include <util/std_expr.h>
22+
#include <util/string_container.h>
2223
#include <util/pointer_offset_size.h>
2324

2425
#include <langapi/language_util.h>
@@ -394,7 +395,7 @@ void interpretert::evaluate(
394395
if(show)
395396
warning() << "string decoding not fully implemented "
396397
<< length << eom;
397-
mp_integer tmp=value.get_no();
398+
mp_integer tmp = get_string_container()[id2string(value)];
398399
dest.push_back(tmp);
399400
return;
400401
}

src/java_bytecode/java_bytecode_convert_class.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ static void find_and_replace_parameter(
685685
{
686686
// get the name of the parameter, e.g., `T` from `java::Class::T`
687687
const std::string &parameter_full_name =
688-
as_string(parameter.type_variable_ref().get_identifier());
688+
id2string(parameter.type_variable_ref().get_identifier());
689689
const std::string &parameter_name =
690690
parameter_full_name.substr(parameter_full_name.rfind("::") + 2);
691691

@@ -696,7 +696,7 @@ static void find_and_replace_parameter(
696696
[&parameter_name](const java_generic_parametert &replacement_param)
697697
{
698698
const std::string &replacement_parameter_full_name =
699-
as_string(replacement_param.type_variable().get_identifier());
699+
id2string(replacement_param.type_variable().get_identifier());
700700
return parameter_name.compare(
701701
replacement_parameter_full_name.substr(
702702
replacement_parameter_full_name.rfind("::") + 2)) == 0;
@@ -706,7 +706,7 @@ static void find_and_replace_parameter(
706706
if(replacement_parameter_p != replacement_parameters.end())
707707
{
708708
const std::string &replacement_parameter_full_name =
709-
as_string(replacement_parameter_p->type_variable().get_identifier());
709+
id2string(replacement_parameter_p->type_variable().get_identifier());
710710

711711
// the replacement parameter is a viable one, i.e., it comes from an outer
712712
// class

src/java_bytecode/java_bytecode_convert_method.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ code_blockt &java_bytecode_convert_methodt::get_or_create_block_for_pcrange(
798798
// any block-internal edges to target the inner header block.
799799

800800
const irep_idt child_label_name=child_label.get_label();
801-
std::string new_label_str=as_string(child_label_name);
801+
std::string new_label_str = id2string(child_label_name);
802802
new_label_str+='$';
803803
irep_idt new_label_irep(new_label_str);
804804

@@ -1281,8 +1281,9 @@ codet java_bytecode_convert_methodt::convert_instructions(
12811281
// constructors.
12821282
if(statement=="invokespecial")
12831283
{
1284-
if(as_string(arg0.get(ID_identifier))
1285-
.find("<init>")!=std::string::npos)
1284+
if(
1285+
id2string(arg0.get(ID_identifier)).find("<init>") !=
1286+
std::string::npos)
12861287
{
12871288
if(needed_lazy_methods)
12881289
needed_lazy_methods->add_needed_class(classname);

src/java_bytecode/java_object_factory.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ void java_object_factoryt::gen_nondet_struct_init(
10341034
if(skip_classid)
10351035
continue;
10361036

1037-
irep_idt qualified_clsid="java::"+as_string(class_identifier);
1037+
irep_idt qualified_clsid = "java::" + id2string(class_identifier);
10381038
constant_exprt ci(qualified_clsid, string_typet());
10391039
code_assignt code(me, ci);
10401040
code.add_source_location()=loc;
@@ -1329,13 +1329,13 @@ void java_object_factoryt::gen_nondet_array_init(
13291329
exprt java_zero=from_integer(0, java_int_type());
13301330
assignments.copy_to_operands(code_assignt(counter_expr, java_zero));
13311331

1332-
std::string head_name=as_string(counter.base_name)+"_header";
1332+
std::string head_name = id2string(counter.base_name) + "_header";
13331333
code_labelt init_head_label(head_name, code_skipt());
13341334
code_gotot goto_head(head_name);
13351335

13361336
assignments.move_to_operands(init_head_label);
13371337

1338-
std::string done_name=as_string(counter.base_name)+"_done";
1338+
std::string done_name = id2string(counter.base_name) + "_done";
13391339
code_labelt init_done_label(done_name, code_skipt());
13401340
code_gotot goto_done(done_name);
13411341

src/util/symbol_table_base.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ void symbol_table_baset::show(std::ostream &out) const
3838
std::sort(
3939
sorted_names.begin(),
4040
sorted_names.end(),
41-
[](const irep_idt &a, const irep_idt &b)
42-
{
43-
return as_string(a) < as_string(b);
44-
});
41+
[](const irep_idt &a, const irep_idt &b) { return a.compare(b); });
4542
out << "\n"
4643
<< "Symbols:"
4744
<< "\n";

0 commit comments

Comments
 (0)