Skip to content

Commit efb67a8

Browse files
committed
port EDGE_CHARRANGE to jvm backend
1 parent 7557ea1 commit efb67a8

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4850,7 +4850,9 @@ public static SixModelObject nfafromstatelist(SixModelObject states, SixModelObj
48504850
nfa.states[i][curEdge].arg_s = edgeInfo.at_pos_boxed(tc, j + 1).get_str(tc);
48514851
break;
48524852
case NFA.EDGE_CODEPOINT_I:
4853-
case NFA.EDGE_CODEPOINT_I_NEG: {
4853+
case NFA.EDGE_CODEPOINT_I_NEG:
4854+
case NFA.EDGE_CHARRANGE:
4855+
case NFA.EDGE_CHARRANGE_NEG: {
48544856
SixModelObject arg = edgeInfo.at_pos_boxed(tc, j + 1);
48554857
nfa.states[i][curEdge].arg_lc = (char)smart_numify(arg.at_pos_boxed(tc, 0), tc);
48564858
nfa.states[i][curEdge].arg_uc = (char)smart_numify(arg.at_pos_boxed(tc, 1), tc);
@@ -5015,6 +5017,20 @@ else if (act == NFA.EDGE_CODEPOINT_I_NEG) {
50155017
if (ord != lc_arg && ord != uc_arg)
50165018
nextst.add(to);
50175019
}
5020+
else if (act == NFA.EDGE_CHARRANGE) {
5021+
char uc_arg = edgeInfo[i].arg_uc;
5022+
char lc_arg = edgeInfo[i].arg_lc;
5023+
char ord = target.charAt((int)pos);
5024+
if (ord >= lc_arg && ord <= uc_arg)
5025+
nextst.add(to);
5026+
}
5027+
else if (act == NFA.EDGE_CHARRANGE_NEG) {
5028+
char uc_arg = edgeInfo[i].arg_uc;
5029+
char lc_arg = edgeInfo[i].arg_lc;
5030+
char ord = target.charAt((int)pos);
5031+
if (ord < lc_arg || ord > uc_arg)
5032+
nextst.add(to);
5033+
}
50185034
}
50195035
}
50205036

src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/NFA.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public class NFA extends REPR {
2020
public static final int EDGE_CHARLIST_NEG = 7;
2121
public static final int EDGE_CODEPOINT_I = 9;
2222
public static final int EDGE_CODEPOINT_I_NEG = 10;
23+
public static final int EDGE_GENERIC_VAR = 11;
24+
public static final int EDGE_CHARRANGE = 12;
25+
public static final int EDGE_CHARRANGE_NEG = 13;
2326

2427
public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) {
2528
STable st = new STable(this, HOW);
@@ -79,7 +82,9 @@ public void deserialize_finish(ThreadContext tc, STable st,
7982
body.states[i][j].arg_s = reader.readStr();
8083
break;
8184
case EDGE_CODEPOINT_I:
82-
case EDGE_CODEPOINT_I_NEG: {
85+
case EDGE_CODEPOINT_I_NEG:
86+
case EDGE_CHARRANGE:
87+
case EDGE_CHARRANGE_NEG: {
8388
body.states[i][j].arg_lc = (char)reader.readLong();
8489
body.states[i][j].arg_uc = (char)reader.readLong();
8590
break;
@@ -121,7 +126,9 @@ public void serialize(ThreadContext tc, SerializationWriter writer, SixModelObje
121126
writer.writeStr(body.states[i][j].arg_s);
122127
break;
123128
case EDGE_CODEPOINT_I:
124-
case EDGE_CODEPOINT_I_NEG: {
129+
case EDGE_CODEPOINT_I_NEG:
130+
case EDGE_CHARRANGE:
131+
case EDGE_CHARRANGE_NEG: {
125132
writer.writeInt(body.states[i][j].arg_lc);
126133
writer.writeInt(body.states[i][j].arg_uc);
127134
break;

0 commit comments

Comments
 (0)