@@ -833,8 +833,8 @@ public static String cwd() {
833
833
}
834
834
835
835
public static String chdir (String path , ThreadContext tc ) {
836
- die_s ("chdir is not available on JVM" , tc );
837
- return null ;
836
+ die_s ("chdir is not available on JVM" , tc );
837
+ return null ;
838
838
}
839
839
840
840
public static long mkdir (String path , long mode , ThreadContext tc ) {
@@ -919,7 +919,7 @@ public static String gethostname(){
919
919
920
920
// To be removed once shell3 is adopted
921
921
public static long shell1 (String cmd , ThreadContext tc ) {
922
- return shell3 (cmd , cwd (), getenvhash (tc ), tc );
922
+ return shell3 (cmd , cwd (), getenvhash (tc ), tc );
923
923
}
924
924
925
925
public static long shell3 (String cmd , String dir , SixModelObject envObj , ThreadContext tc ) {
@@ -3098,8 +3098,8 @@ public static String concat(String valA, String valB) {
3098
3098
}
3099
3099
3100
3100
public static String chr (long ord , ThreadContext tc ) {
3101
- if (ord < 0 )
3102
- throw ExceptionHandling .dieInternal (tc , "chr codepoint cannot be negative" );
3101
+ if (ord < 0 )
3102
+ throw ExceptionHandling .dieInternal (tc , "chr codepoint cannot be negative" );
3103
3103
3104
3104
return (new StringBuffer ()).append (Character .toChars ((int )ord )).toString ();
3105
3105
}
@@ -4855,8 +4855,9 @@ public static SixModelObject nfafromstatelist(SixModelObject states, SixModelObj
4855
4855
nfa .states [i ][curEdge ].act = act ;
4856
4856
nfa .states [i ][curEdge ].to = to ;
4857
4857
4858
- switch (act ) {
4858
+ switch (act & 0xff ) {
4859
4859
case NFA .EDGE_FATE :
4860
+ case NFA .EDGE_CODEPOINT_LL :
4860
4861
case NFA .EDGE_CODEPOINT :
4861
4862
case NFA .EDGE_CODEPOINT_NEG :
4862
4863
case NFA .EDGE_CHARCLASS :
@@ -4867,6 +4868,7 @@ public static SixModelObject nfafromstatelist(SixModelObject states, SixModelObj
4867
4868
case NFA .EDGE_CHARLIST_NEG :
4868
4869
nfa .states [i ][curEdge ].arg_s = edgeInfo .at_pos_boxed (tc , j + 1 ).get_str (tc );
4869
4870
break ;
4871
+ case NFA .EDGE_CODEPOINT_I_LL :
4870
4872
case NFA .EDGE_CODEPOINT_I :
4871
4873
case NFA .EDGE_CODEPOINT_I_NEG :
4872
4874
case NFA .EDGE_CHARRANGE :
@@ -4930,6 +4932,7 @@ private static int[] runNFA(ThreadContext tc, NFAInstance nfa, String target, lo
4930
4932
/* Allocate a "done states" array. */
4931
4933
int numStates = nfa .numStates ;
4932
4934
int [] done = new int [numStates + 1 ];
4935
+ long orig_pos = pos ;
4933
4936
4934
4937
/* Clear out other re-used arrays. */
4935
4938
ArrayList <Integer > fates = tc .fates ;
@@ -4939,6 +4942,11 @@ private static int[] runNFA(ThreadContext tc, NFAInstance nfa, String target, lo
4939
4942
nextst .clear ();
4940
4943
fates .clear ();
4941
4944
4945
+ /* XXX needs to be cached, but tc breaks stage0 when I try */
4946
+ long [] longlit = new long [200 ]; // also needs proper sizing to # of alternatives
4947
+ for (int i = 0 ; i < 200 ; i ++)
4948
+ longlit [i ] = 0 ;
4949
+
4942
4950
nextst .add (1 );
4943
4951
while (!nextst .isEmpty () && pos <= eos ) {
4944
4952
/* Translation of:
@@ -4968,11 +4976,15 @@ private static int[] runNFA(ThreadContext tc, NFAInstance nfa, String target, lo
4968
4976
int act = edgeInfo [i ].act ;
4969
4977
int to = edgeInfo [i ].to ;
4970
4978
4971
- if (act == NFA .EDGE_FATE ) {
4979
+ if (act < 0 ) {
4980
+ act &= 0xff ;
4981
+ }
4982
+ else if (act == NFA .EDGE_FATE ) {
4972
4983
/* Crossed a fate edge. Check if we already saw this, and
4973
4984
* if so bump the entry we already saw. */
4974
4985
int arg = edgeInfo [i ].arg_i ;
4975
4986
boolean foundFate = false ;
4987
+ arg &= 0xffffff ;
4976
4988
for (int j = 0 ; j < fates .size (); j ++) {
4977
4989
if (foundFate )
4978
4990
fates .set (j - 1 , fates .get (j ));
@@ -4982,22 +4994,34 @@ private static int[] runNFA(ThreadContext tc, NFAInstance nfa, String target, lo
4982
4994
prevFates --;
4983
4995
}
4984
4996
}
4997
+ arg -= longlit [arg ] << 24 ;
4985
4998
if (foundFate )
4986
4999
fates .set (fates .size () - 1 , arg );
4987
5000
else
4988
5001
fates .add (arg );
5002
+ continue ;
4989
5003
}
4990
5004
else if (act == NFA .EDGE_EPSILON && to <= numStates && done [to ] != gen ) {
4991
5005
curst .add (to );
5006
+ continue ;
4992
5007
}
4993
- else if (pos >= eos ) {
5008
+
5009
+ if (pos >= eos ) {
4994
5010
/* Can't match, so drop state. */
4995
5011
}
4996
5012
else if (act == NFA .EDGE_CODEPOINT ) {
4997
5013
char arg = (char )edgeInfo [i ].arg_i ;
4998
5014
if (target .charAt ((int )pos ) == arg )
4999
5015
nextst .add (to );
5000
5016
}
5017
+ else if (act == NFA .EDGE_CODEPOINT_LL ) {
5018
+ int fate = (edgeInfo [i ].act >> 8 ) & 0xfffff ; /* act is probably signed 32 bits */
5019
+ char arg = (char )edgeInfo [i ].arg_i ;
5020
+ if (target .charAt ((int )pos ) == arg ) {
5021
+ nextst .add (to );
5022
+ longlit [fate ] = pos - orig_pos ;
5023
+ }
5024
+ }
5001
5025
else if (act == NFA .EDGE_CODEPOINT_NEG ) {
5002
5026
char arg = (char )edgeInfo [i ].arg_i ;
5003
5027
if (target .charAt ((int )pos ) != arg )
@@ -5028,6 +5052,16 @@ else if (act == NFA.EDGE_CODEPOINT_I) {
5028
5052
if (ord == lc_arg || ord == uc_arg )
5029
5053
nextst .add (to );
5030
5054
}
5055
+ else if (act == NFA .EDGE_CODEPOINT_I_LL ) {
5056
+ int fate = (edgeInfo [i ].act >> 8 ) & 0xfffff ; /* act is probably signed 32 bits */
5057
+ char uc_arg = edgeInfo [i ].arg_uc ;
5058
+ char lc_arg = edgeInfo [i ].arg_lc ;
5059
+ char ord = target .charAt ((int )pos );
5060
+ if (ord == lc_arg || ord == uc_arg ) {
5061
+ nextst .add (to );
5062
+ longlit [fate ] = pos - orig_pos ;
5063
+ }
5064
+ }
5031
5065
else if (act == NFA .EDGE_CODEPOINT_I_NEG ) {
5032
5066
char uc_arg = edgeInfo [i ].arg_uc ;
5033
5067
char lc_arg = edgeInfo [i ].arg_lc ;
@@ -5066,7 +5100,7 @@ else if (act == NFA.EDGE_CHARRANGE_NEG) {
5066
5100
}
5067
5101
}
5068
5102
5069
- /* strip any literal lengths, leaving only fates */
5103
+ /* strip any literal lengths, leaving only fates */
5070
5104
int [] result = new int [fates .size ()];
5071
5105
for (int i = 0 ; i < fates .size (); i ++)
5072
5106
result [i ] = fates .get (i ) & 0xffffff ;
@@ -5332,7 +5366,7 @@ public static long isprime_I(SixModelObject a, long certainty, ThreadContext tc)
5332
5366
BigInteger bi = getBI (tc , a );
5333
5367
if (bi .compareTo (BigInteger .valueOf (1 )) <= 0 ) {
5334
5368
return 0 ;
5335
- }
5369
+ }
5336
5370
return bi .isProbablePrime ((int )certainty ) ? 1 : 0 ;
5337
5371
}
5338
5372
@@ -5695,14 +5729,14 @@ public static SixModelObject jvmgetconfig(ThreadContext tc) {
5695
5729
SixModelObject res = hashType .st .REPR .allocate (tc , hashType .st );
5696
5730
5697
5731
try {
5698
- InputStream is = Ops .class .getResourceAsStream ("/jvmconfig.properties" );
5699
- Properties config = new Properties ();
5700
- config .load (is );
5701
- for (String name : config .stringPropertyNames ())
5702
- res .bind_key_boxed (tc , name , box_s (config .getProperty (name ), strType , tc ));
5703
- } catch (Throwable e ) {
5704
- die_s ("Failed to load config.properties" , tc );
5705
- }
5732
+ InputStream is = Ops .class .getResourceAsStream ("/jvmconfig.properties" );
5733
+ Properties config = new Properties ();
5734
+ config .load (is );
5735
+ for (String name : config .stringPropertyNames ())
5736
+ res .bind_key_boxed (tc , name , box_s (config .getProperty (name ), strType , tc ));
5737
+ } catch (Throwable e ) {
5738
+ die_s ("Failed to load config.properties" , tc );
5739
+ }
5706
5740
5707
5741
return res ;
5708
5742
}
0 commit comments