using System.Globalization;
using System.Reflection;
using System.Reflection.Emit;
+using System.Threading;
#if NET_2_0
using System.Collections.Generic;
}
}
+ LocalBuilder local_textinfo;
+
/*
* Create a dynamic method which is equivalent to the RxInterpreter.EvalByteCode
* method specialized to the given program and a given pc. Return the newly
*/
Frame frame = new Frame (ilgen);
+ /* Cache the textinfo used by Char.ToLower () */
+ local_textinfo = ilgen.DeclareLocal (typeof (TextInfo));
+ ilgen.Emit (OpCodes.Call, typeof (Thread).GetMethod ("get_CurrentThread"));
+ ilgen.Emit (OpCodes.Call, typeof (Thread).GetMethod ("get_CurrentCulture"));
+ ilgen.Emit (OpCodes.Call, typeof (CultureInfo).GetMethod ("get_TextInfo"));
+ ilgen.Emit (OpCodes.Stloc, local_textinfo);
+
m = EmitEvalMethodBody (m, ilgen, frame, program, pc, program.Length, false, false, out pc);
if (m == null)
return null;
ilgen.Emit (OpCodes.Bge, l1);
}
+ if (ignore)
+ ilgen.Emit (OpCodes.Ldloc, local_textinfo);
+
// int c = str [strpos];
LocalBuilder local_c = ilgen.DeclareLocal (typeof (char));
ilgen.Emit (OpCodes.Ldarg_0);
}
ilgen.Emit (OpCodes.Callvirt, typeof (string).GetMethod ("get_Chars"));
if (ignore)
- ilgen.Emit (OpCodes.Call, typeof (Char).GetMethod ("ToLower", new Type [] { typeof (char) }));
+ ilgen.Emit (OpCodes.Callvirt, typeof (TextInfo).GetMethod ("ToLower", new Type [] { typeof (char) }));
if (op == RxOp.Char) {
ilgen.Emit (OpCodes.Conv_I4);
}
// int c = str [strpos];
LocalBuilder local_c = ilgen.DeclareLocal (typeof (int));
+ if (ignore)
+ ilgen.Emit (OpCodes.Ldloc, local_textinfo);
ilgen.Emit (OpCodes.Ldarg_0);
ilgen.Emit (OpCodes.Ldfld, fi_str);
ilgen.Emit (OpCodes.Ldarg_1);
ilgen.Emit (OpCodes.Callvirt, typeof (string).GetMethod ("get_Chars"));
ilgen.Emit (OpCodes.Conv_I4);
if (ignore)
- ilgen.Emit (OpCodes.Call, typeof (Char).GetMethod ("ToLower", new Type [] { typeof (char) }));
+ ilgen.Emit (OpCodes.Callvirt, typeof (TextInfo).GetMethod ("ToLower", new Type [] { typeof (char) }));
// c -= program [pc + 1];
if (unicode) {
ilgen.Emit (OpCodes.Ldc_I4, ReadShort (program, pc + 1));
for (i = 0; i < length; ++i) {
// if (*(strptr + i) != program [start + i])
// return false;
+ if (ignore)
+ ilgen.Emit (OpCodes.Ldloc, local_textinfo);
ilgen.Emit (OpCodes.Ldloc, local_strptr);
ilgen.Emit (OpCodes.Ldc_I4, i * 2);
ilgen.Emit (OpCodes.Add);
ilgen.Emit (OpCodes.Ldind_I2);
if (ignore)
- ilgen.Emit (OpCodes.Call, typeof (Char).GetMethod ("ToLower", new Type [] { typeof (char) }));
+ ilgen.Emit (OpCodes.Callvirt, typeof (TextInfo).GetMethod ("ToLower", new Type [] { typeof (char) }));
ilgen.Emit (OpCodes.Ldc_I4, (int)program [start + i]);
ilgen.Emit (OpCodes.Bne_Un, frame.label_fail);
}
while (start < end) {
//if (str [strpos] != program [start])
// return false;
+ if (ignore)
+ ilgen.Emit (OpCodes.Ldloc, local_textinfo);
ilgen.Emit (OpCodes.Ldloc, local_str);
ilgen.Emit (OpCodes.Ldarg_1);
ilgen.Emit (OpCodes.Callvirt, typeof (string).GetMethod ("get_Chars"));
if (ignore)
- ilgen.Emit (OpCodes.Call, typeof (Char).GetMethod ("ToLower", new Type [] { typeof (char) }));
+ ilgen.Emit (OpCodes.Callvirt, typeof (TextInfo).GetMethod ("ToLower", new Type [] { typeof (char) }));
ilgen.Emit (OpCodes.Ldc_I4, unicode ? ReadShort (program, start) : (int)program [start]);
ilgen.Emit (OpCodes.Bne_Un, frame.label_fail);
//strpos++;
ilgen.MarkLabel (l_loop_body);
//if (str [strpos] != str [start])
//return false;
+ if (ignore)
+ ilgen.Emit (OpCodes.Ldloc, local_textinfo);
ilgen.Emit (OpCodes.Ldloc, local_str);
ilgen.Emit (OpCodes.Ldarg_1);
ilgen.Emit (OpCodes.Callvirt, typeof (string).GetMethod ("get_Chars"));
if (ignore)
- ilgen.Emit (OpCodes.Call, typeof (Char).GetMethod ("ToLower", new Type [] { typeof (char) }));
+ ilgen.Emit (OpCodes.Callvirt, typeof (TextInfo).GetMethod ("ToLower", new Type [] { typeof (char) }));
+ if (ignore)
+ ilgen.Emit (OpCodes.Ldloc, local_textinfo);
ilgen.Emit (OpCodes.Ldloc, local_str);
ilgen.Emit (OpCodes.Ldloc, loc_start);
ilgen.Emit (OpCodes.Callvirt, typeof (string).GetMethod ("get_Chars"));
if (ignore)
- ilgen.Emit (OpCodes.Call, typeof (Char).GetMethod ("ToLower", new Type [] { typeof (char) }));
+ ilgen.Emit (OpCodes.Callvirt, typeof (TextInfo).GetMethod ("ToLower", new Type [] { typeof (char) }));
ilgen.Emit (OpCodes.Bne_Un, frame.label_fail);
// strpos++;
ilgen.Emit (OpCodes.Ldarg_1);