Skip to content

Commit

Permalink
[JVM] Support unicode numbers in Rakudo better
Browse files Browse the repository at this point in the history
This is everything but a proper implementation of getuniprop_str and
unipropcode. But it makes the evaluations mentioned in
rakudo/rakudo#4760 work on the JVM backend.
  • Loading branch information
usev6 committed Oct 2, 2022
1 parent ebff3c7 commit bddcbca
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/vm/jvm/runtime/org/raku/nqp/runtime/Ops.java
Original file line number Diff line number Diff line change
Expand Up @@ -7648,12 +7648,36 @@ else if ((0xE000 <= codePoint && codePoint <= 0xF8FF)
return name;
}

private static final int UNIPROP_NUMERIC_VALUE_NUMERATOR = 19;
private static final int UNIPROP_NUMERIC_VALUE_DENOMINATOR = 10;

/* TODO: Make this handle more properties. */
public static String getuniprop_str(long codepoint, long property, ThreadContext tc) {
return "";
String res = "";
if (property == UNIPROP_NUMERIC_VALUE_NUMERATOR || property == UNIPROP_NUMERIC_VALUE_DENOMINATOR) {
/* NFKD will decompose fractions into numerator and denominator,
* separated by "FRACTION SLASH" (\u2044). */
String[] fraction = Normalizer.normalize(Character.toString((char)codepoint),
Normalizer.Form.NFKD).split("\u2044");
if (property == UNIPROP_NUMERIC_VALUE_DENOMINATOR) {
res = fraction.length == 2 ? fraction[1] : "1";
} else {
res = fraction[0];
}
}
return res;
}

/* TODO: Make this handle more properties. */
public static long unipropcode(String prop, ThreadContext tc) {
return -1;
switch (prop) {
case "Numeric_Value_Numerator":
return UNIPROP_NUMERIC_VALUE_NUMERATOR;
case "Numeric_Value_Denominator":
return UNIPROP_NUMERIC_VALUE_DENOMINATOR;
default:
return -1;
}
}

public static SixModelObject force_gc(ThreadContext tc) {
Expand Down

0 comments on commit bddcbca

Please sign in to comment.