Go to the documentation of this file.
33 for(
const auto c : in)
41 bool string_refinement_enabled)
47 const std::string escaped_symbol_name_with_prefix =
50 auto findit = symbol_table.
symbols.find(escaped_symbol_name_with_prefix);
51 if(findit != symbol_table.
symbols.end())
52 return findit->second.symbol_expr();
54 #ifndef CPROVER_INVARIANT_DO_NOT_CHECK
57 !initialize_function || initialize_function->value.is_nil(),
63 new_symbol.
name = escaped_symbol_name_with_prefix;
64 new_symbol.
type = string_type;
65 new_symbol.
type.
set(ID_C_constant,
true);
66 new_symbol.
base_name = escaped_symbol_name;
68 new_symbol.
mode = ID_java;
86 if(string_refinement_enabled)
92 literal_init.
operands().resize(jls_struct.components().size());
93 const std::size_t jlo_nb = jls_struct.component_number(
"@java.lang.Object");
94 literal_init.operands()[jlo_nb] = jlo_init;
96 const std::size_t length_nb = jls_struct.component_number(
"length");
97 const typet &length_type = jls_struct.components()[length_nb].type();
99 literal_init.operands()[length_nb] = length;
103 array_symbol.
name = escaped_symbol_name_with_prefix +
"_constarray";
104 array_symbol.
base_name = escaped_symbol_name +
"_constarray";
106 array_symbol.
mode = ID_java;
112 array_symbol.
value = data;
114 array_symbol.
type.
set(ID_C_constant,
true);
116 if(symbol_table.
add(array_symbol))
117 throw "failed to add constarray symbol to symbol table";
123 const std::size_t data_nb = jls_struct.component_number(
"data");
124 literal_init.operands()[data_nb] = array_pointer;
128 return_symbol.
name = escaped_symbol_name_with_prefix +
"_return_value";
129 return_symbol.
base_name = escaped_symbol_name +
"_return_value";
131 escaped_symbol_name.length() > 10
132 ? escaped_symbol_name.substr(0, 10) +
"..._return_value"
133 : escaped_symbol_name +
"_return_value";
134 return_symbol.
mode = ID_java;
140 ID_cprover_associate_array_to_pointer_func,
141 {array_symbol.
value, array_pointer},
145 return_symbol.
type.
set(ID_C_constant,
true);
146 if(symbol_table.
add(return_symbol))
147 throw "failed to add return symbol to symbol table";
153 exprt init_comma_expr(ID_comma);
154 init_comma_expr.
type() = literal_init.type();
156 return_symbol.
symbol_expr(), std::move(literal_init));
157 new_symbol.
value = init_comma_expr;
159 else if(jls_struct.components().size()>=1 &&
160 jls_struct.components()[0].get_name()==
"@java.lang.Object")
166 for(
const auto &comp : jls_struct.components())
168 if(comp.get_name()==
"@java.lang.Object")
176 literal_init.copy_to_operands(*init);
178 new_symbol.
value = literal_init;
184 new_symbol.
value = jlo_init;
188 bool add_failed = symbol_table.
add(new_symbol);
191 "string literal symbol was already checked not to be "
192 "in the symbol table, so adding it should succeed");
200 bool string_refinement_enabled)
205 string_refinement_enabled);
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
void java_root_class_init(struct_exprt &jlo, const struct_typet &root_type, const irep_idt &class_identifier)
Adds members for an object of the root class (usually java.lang.Object).
static array_exprt utf16_to_array(const std::wstring &in)
Convert UCS-2 or UTF-16 to an array expression.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
#define CHECK_RETURN(CONDITION)
std::string escape_non_alnum(const std::string &to_escape)
Replace non-alphanumeric characters with _xx escapes, where xx are hex digits.
The type of an expression, extends irept.
typet type
Type of symbol.
exprt make_function_application(const irep_idt &function_name, const exprt::operandst &arguments, const typet &range, symbol_table_baset &symbol_table)
Create a (mathematical) function application expression.
Base class for all expressions.
irep_idt base_name
Base (non-scoped) name.
A struct tag type, i.e., struct_typet with an identifier.
Expression to hold a symbol (variable)
symbol_exprt get_or_create_string_literal_symbol(const java_string_literal_exprt &string_expr, symbol_table_baset &symbol_table, bool string_refinement_enabled)
Creates or gets an existing constant global symbol for a given string literal.
optionalt< exprt > zero_initializer(const typet &type, const source_locationt &source_location, const namespacet &ns)
Create the equivalent of zero for type type.
irep_idt pretty_name
Language-specific display name.
Struct constructor from list of elements.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
typet & type()
Return the type of the expression.
irep_idt mode
Language mode.
const std::string & id2string(const irep_idt &d)
void set(const irep_idt &name, const irep_idt &value)
The symbol table base class interface.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
#define INITIALIZE_FUNCTION
signedbv_typet java_int_type()
std::wstring utf8_to_utf16_native_endian(const std::string &in)
Convert UTF8-encoded string to UTF-16 with architecture-native endianness.
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
exprt value
Initial value of symbol.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
unsignedbv_typet java_char_type()
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
const symbolt * lookup(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
const java_class_typet & to_java_class_type(const typet &type)
Operator to return the address of an object.
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
const source_locationt & source_location() const
Array constructor from list of elements.
#define JAVA_STRING_LITERAL_PREFIX
irep_idt name
The unique identifier.