Skip to content

Commit 4e4fa87

Browse files
committed
Style and document Java string-refine integration
1 parent 396f66e commit 4e4fa87

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/java_bytecode/java_bytecode_typecheck_expr.cpp

+23-8
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,19 @@ static std::string escape_non_alnum(const std::string &toescape)
117117
return escaped.str();
118118
}
119119

120-
static array_exprt utf16_to_array(const std::wstring& in)
120+
/*******************************************************************\
121+
122+
Function: utf16_to_array
123+
124+
Inputs: `in`: wide string to convert
125+
126+
Outputs: Returns a Java char array containing the same wchars.
127+
128+
Purpose: Convert UCS-2 or UTF-16 to an array expression.
129+
130+
\*******************************************************************/
131+
132+
static array_exprt utf16_to_array(const std::wstring &in)
121133
{
122134
const auto jchar=java_char_type();
123135
array_exprt ret(array_typet(jchar, infinity_exprt(java_int_type())));
@@ -168,15 +180,18 @@ void java_bytecode_typecheckt::typecheck_expr_java_string_literal(exprt &expr)
168180
// Regardless of string refinement setting, at least initialize
169181
// the literal with @clsid = String and @lock = false:
170182
symbol_typet jlo_symbol("java::java.lang.Object");
171-
const auto& jlo_struct=to_struct_type(ns.follow(jlo_symbol));
183+
const auto &jlo_struct=to_struct_type(ns.follow(jlo_symbol));
172184
struct_exprt jlo_init(jlo_symbol);
173-
const auto& jls_struct=to_struct_type(ns.follow(string_type));
185+
const auto &jls_struct=to_struct_type(ns.follow(string_type));
174186

175187
jlo_init.copy_to_operands(
176-
constant_exprt("java::java.lang.String",
177-
jlo_struct.components()[0].type()));
188+
constant_exprt(
189+
"java::java.lang.String",
190+
jlo_struct.components()[0].type()));
178191
jlo_init.copy_to_operands(
179-
from_integer(0, jlo_struct.components()[1].type()));
192+
from_integer(
193+
0,
194+
jlo_struct.components()[1].type()));
180195

181196
// If string refinement *is* around, populate the actual
182197
// contents as well:
@@ -185,7 +200,7 @@ void java_bytecode_typecheckt::typecheck_expr_java_string_literal(exprt &expr)
185200
struct_exprt literal_init(new_symbol.type);
186201
literal_init.move_to_operands(jlo_init);
187202

188-
// Initialise the string with a constant utf-16 array:
203+
// Initialize the string with a constant utf-16 array:
189204
symbolt array_symbol;
190205
array_symbol.name=escaped_symbol_name+"_constarray";
191206
array_symbol.type=array_typet(
@@ -203,7 +218,7 @@ void java_bytecode_typecheckt::typecheck_expr_java_string_literal(exprt &expr)
203218
array_symbol.value=literal_array;
204219

205220
if(symbol_table.add(array_symbol))
206-
throw "failed to add constarray symbol to symtab";
221+
throw "failed to add constarray symbol to symbol table";
207222

208223
literal_init.copy_to_operands(
209224
from_integer(literal_array.operands().size(),

0 commit comments

Comments
 (0)