Debian Codegraph @

mcs/class/referencesource/System/regex/system/text/regularexpressions/compiledregexrunnerfactory.cs

raw
1 //------------------------------------------------------------------------------
2 // <copyright file="CompiledRegexRunnerFactory.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // </copyright>
5 //------------------------------------------------------------------------------
6
7 using System.Diagnostics;
8 using System.Security.Permissions;
9
10 #if !SILVERLIGHT && !FULL_AOT_RUNTIME
11 using System.Reflection.Emit;
12
13 namespace System.Text.RegularExpressions {
14
15
16 internal sealed class CompiledRegexRunnerFactory : RegexRunnerFactory {
17 DynamicMethod goMethod;
18 DynamicMethod findFirstCharMethod;
19 DynamicMethod initTrackCountMethod;
20
21 internal CompiledRegexRunnerFactory (DynamicMethod go, DynamicMethod firstChar, DynamicMethod trackCount) {
22 this.goMethod = go;
23 this.findFirstCharMethod = firstChar;
24 this.initTrackCountMethod = trackCount;
25 //Debug.Assert(goMethod != null && findFirstCharMethod != null && initTrackCountMethod != null, "can't be null");
26 }
27
28 protected internal override RegexRunner CreateInstance() {
29 CompiledRegexRunner runner = new CompiledRegexRunner();
30
31 #if MONO_FEATURE_CAS
32 new ReflectionPermission(PermissionState.Unrestricted).Assert();
33 #endif
34 runner.SetDelegates((NoParamDelegate) goMethod.CreateDelegate(typeof(NoParamDelegate)),
35 (FindFirstCharDelegate) findFirstCharMethod.CreateDelegate(typeof(FindFirstCharDelegate)),
36 (NoParamDelegate) initTrackCountMethod.CreateDelegate(typeof(NoParamDelegate)));
37
38 return runner;
39 }
40 }
41
42 internal delegate RegexRunner CreateInstanceDelegate();
43 }
44
45 #endif
46