Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RegexLWCGCompiler.cs
Go to the documentation of this file.
4
6
7internal sealed class RegexLWCGCompiler : RegexCompiler
8{
9 private static readonly bool s_includePatternInName = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_TEXT_REGULAREXPRESSIONS_PATTERNINNAME") == "1";
10
11 private static readonly Type[] s_paramTypes = new Type[1] { typeof(RegexRunner) };
12
13 private static int s_regexCount;
14
16 : base(persistsAssembly: false)
17 {
18 }
19
21 {
22 _code = code;
23 _codes = code.Codes;
24 _strings = code.Strings;
25 _leadingCharClasses = code.LeadingCharClasses;
30 _hasTimeout = hasTimeout;
31 uint value = (uint)Interlocked.Increment(ref s_regexCount);
32 string value2 = string.Empty;
34 {
35 value2 = "_" + ((pattern.Length > 100) ? pattern.AsSpan(0, 100) : ((ReadOnlySpan<char>)pattern));
36 }
37 DynamicMethod goMethod = DefineDynamicMethod($"Regex{value}_Go{value2}", null, typeof(CompiledRegexRunner));
38 GenerateGo();
39 DynamicMethod findFirstCharMethod = DefineDynamicMethod($"Regex{value}_FindFirstChar{value2}", typeof(bool), typeof(CompiledRegexRunner));
41 return new CompiledRegexRunnerFactory(goMethod, findFirstCharMethod, _trackcount);
42 }
43
44 private DynamicMethod DefineDynamicMethod(string methname, Type returntype, Type hostType)
45 {
46 DynamicMethod dynamicMethod = new DynamicMethod(methname, MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard, returntype, s_paramTypes, hostType, skipVisibility: false);
47 _ilg = dynamicMethod.GetILGenerator();
48 return dynamicMethod;
49 }
50}
static ? string GetEnvironmentVariable(string variable)
readonly RegexBoyerMoore BoyerMoorePrefix
Definition RegexCode.cs:25
string bool CaseInsensitive[] _leadingCharClasses
DynamicMethod DefineDynamicMethod(string methname, Type returntype, Type hostType)
RegexRunnerFactory FactoryInstanceFromCode(string pattern, RegexCode code, RegexOptions options, bool hasTimeout)
static int Increment(ref int location)