Skip to content

Commit d5795b5

Browse files
committed
Remove Character.toChars, highSurrogate, lowSurrogate models
Character.toChars was malformed (it tried to address a java::array[char] * like it was a raw char[], and tried to return an if_exprt of two arrays of differing type), and there is already an implementation in the models library with a perfectly good implementation. Character.highSurrogate and lowSurrogate were type unsound (creating additions of mixed type). Again, they add nothing on top of the shipped models library.
1 parent 157f567 commit d5795b5

File tree

4 files changed

+22
-56
lines changed

4 files changed

+22
-56
lines changed
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class C {
2+
3+
public void test() {
4+
char[] c = Character.toChars(5);
5+
assert c.length == 1;
6+
assert c[0] == 5;
7+
8+
char[] two_bytes = Character.toChars(0x10000);
9+
assert two_bytes.length == 2;
10+
assert two_bytes[0] == '\ud800';
11+
assert two_bytes[1] == '\udc00';
12+
}
13+
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
C.class
3+
--function C.test --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

jbmc/src/java_bytecode/character_refine_preprocess.cpp

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,6 @@ exprt character_refine_preprocesst::expr_of_high_surrogate(
321321
return std::move(high_surrogate);
322322
}
323323

324-
/// Converts function call to an assignment of an expression corresponding to
325-
/// the java method Character.highSurrogate:(C)Z
326-
codet character_refine_preprocesst::convert_high_surrogate(
327-
conversion_inputt &target)
328-
{
329-
return convert_char_function(
330-
&character_refine_preprocesst::expr_of_high_surrogate, target);
331-
}
332-
333324
/// Determines if the specified character is an ASCII lowercase character.
334325
/// \param chr: An expression of type character
335326
/// \param type: A type for the output
@@ -1141,16 +1132,6 @@ exprt character_refine_preprocesst::expr_of_low_surrogate(
11411132
return plus_exprt(uDC00, mod_exprt(chr, u0400));
11421133
}
11431134

1144-
/// Converts function call to an assignment of an expression corresponding to
1145-
/// the java method Character.lowSurrogate:(I)C
1146-
/// \param target: a position in a goto program
1147-
codet character_refine_preprocesst::convert_low_surrogate(
1148-
conversion_inputt &target)
1149-
{
1150-
return convert_char_function(
1151-
&character_refine_preprocesst::expr_of_low_surrogate, target);
1152-
}
1153-
11541135
/// Returns the value obtained by reversing the order of the bytes in the
11551136
/// specified char value.
11561137
/// \param chr: An expression of type character
@@ -1174,37 +1155,6 @@ codet character_refine_preprocesst::convert_reverse_bytes(
11741155
&character_refine_preprocesst::expr_of_reverse_bytes, target);
11751156
}
11761157

1177-
/// Converts the specified character (Unicode code point) to its UTF-16
1178-
/// representation stored in a char array. If the specified code point is a BMP
1179-
/// (Basic Multilingual Plane or Plane 0) value, the resulting char array has
1180-
/// the same value as codePoint. If the specified code point is a supplementary
1181-
/// code point, the resulting char array has the corresponding surrogate pair.
1182-
/// \param chr: An expression of type character
1183-
/// \param type: A type for the output
1184-
/// \return A character array expression of the given type
1185-
exprt character_refine_preprocesst::expr_of_to_chars(
1186-
const exprt &chr, const typet &type)
1187-
{
1188-
array_typet array_type=to_array_type(type);
1189-
const typet &char_type=array_type.subtype();
1190-
exprt low_surrogate=expr_of_low_surrogate(chr, char_type);
1191-
array_exprt case1({low_surrogate}, array_type);
1192-
exprt high_surrogate = expr_of_high_surrogate(chr, char_type);
1193-
array_exprt case2(
1194-
{std::move(low_surrogate), std::move(high_surrogate)}, array_type);
1195-
return if_exprt(
1196-
expr_of_is_bmp_code_point(chr, type), std::move(case1), std::move(case2));
1197-
}
1198-
1199-
/// Converts function call to an assignment of an expression corresponding to
1200-
/// the java method Character.toChars:(I)[C
1201-
/// \param target: a position in a goto program
1202-
codet character_refine_preprocesst::convert_to_chars(conversion_inputt &target)
1203-
{
1204-
return convert_char_function(
1205-
&character_refine_preprocesst::expr_of_to_chars, target);
1206-
}
1207-
12081158
/// Converts function call to an assignment of an expression corresponding to
12091159
/// the java method Character.toCodePoint:(CC)I
12101160
/// \param target: a position in a goto program
@@ -1433,8 +1383,6 @@ void character_refine_preprocesst::initialize_conversion_table()
14331383
&character_refine_preprocesst::convert_get_type_int;
14341384
conversion_table["java::java.lang.Character.hashCode:()I"]=
14351385
&character_refine_preprocesst::convert_hash_code;
1436-
conversion_table["java::java.lang.Character.highSurrogate:(I)C"]=
1437-
&character_refine_preprocesst::convert_high_surrogate;
14381386
conversion_table["java::java.lang.Character.isAlphabetic:(I)Z"]=
14391387
&character_refine_preprocesst::convert_is_alphabetic;
14401388
conversion_table["java::java.lang.Character.isBmpCodePoint:(I)Z"]=
@@ -1523,17 +1471,13 @@ void character_refine_preprocesst::initialize_conversion_table()
15231471
&character_refine_preprocesst::convert_is_whitespace_char;
15241472
conversion_table["java::java.lang.Character.isWhitespace:(I)Z"]=
15251473
&character_refine_preprocesst::convert_is_whitespace_int;
1526-
conversion_table["java::java.lang.Character.lowSurrogate:(I)C"]=
1527-
&character_refine_preprocesst::convert_is_low_surrogate;
15281474

15291475
// Not supported "java::java.lang.Character.offsetByCodePoints:([CIIII)I"
15301476
// Not supported "java::java.lang.Character.offsetByCodePoints:"
15311477
// "(Ljava.lang.CharacterSequence;II)I"
15321478

15331479
conversion_table["java::java.lang.Character.reverseBytes:(C)C"]=
15341480
&character_refine_preprocesst::convert_reverse_bytes;
1535-
conversion_table["java::java.lang.Character.toChars:(I)[C"]=
1536-
&character_refine_preprocesst::convert_to_chars;
15371481

15381482
// Not supported "java::java.lang.Character.toChars:(I[CI)I"
15391483

0 commit comments

Comments
 (0)