Exemplo n.º 1
0
        static FieldInfo GetBackingField(MethodInfo method, ILPattern pattern)
        {
            var result = ILPattern.Match(method, pattern);

            if (!result.success)
            {
                throw new ArgumentException();
            }

            object value;

            if (!result.TryGetData(FieldPattern.FieldKey, out value))
            {
                throw new InvalidOperationException();
            }

            return((FieldInfo)value);
        }
Exemplo n.º 2
0
        public static MatchContext Match(MethodBase method, ILPattern pattern)
        {
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }
            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }

            var instructions = method.GetInstructions();

            if (instructions.Count == 0)
            {
                throw new ArgumentException();
            }

            var context = new MatchContext(instructions[0]);

            pattern.Match(context);
            return(context);
        }
Exemplo n.º 3
0
			public EitherPattern (ILPattern a, ILPattern b) {
				this.a = a;
				this.b = b;
			}
Exemplo n.º 4
0
		public static ILPattern Either (ILPattern a, ILPattern b) {
			return new EitherPattern(a, b);
		}
Exemplo n.º 5
0
 public OptionalPattern(ILPattern optional)
 {
     this.pattern = optional;
 }
Exemplo n.º 6
0
 public static ILPattern Optional(ILPattern pattern)
 {
     return(new OptionalPattern(pattern));
 }
		static FieldInfo GetBackingField (MethodInfo method, ILPattern pattern)
		{
			var result = ILPattern.Match (method, pattern);
			if (!result.success)
				return null; // there is no matched backing field (constants in get{} cause this, among other things)

			object value;
			if (!result.TryGetData (FieldPattern.FieldKey, out value))
				throw new InvalidOperationException ();

			return (FieldInfo) value;
		}
Exemplo n.º 8
0
			public OptionalPattern (ILPattern optional) {
				pattern = optional;
			}
Exemplo n.º 9
0
 public FieldPattern(ILPattern pattern)
 {
     this.pattern = pattern;
 }
Exemplo n.º 10
0
 static ILPattern Field(OpCode opcode)
 {
     return(new FieldPattern(ILPattern.OpCode(opcode)));
 }
		static FieldInfo GetBackingField (MethodInfo method, ILPattern pattern)
		{
			var result = ILPattern.Match (method, pattern);
			if (!result.success)
				throw new ArgumentException ();

			object value;
			if (!result.TryGetData (FieldPattern.FieldKey, out value))
				throw new InvalidOperationException ();

			return (FieldInfo) value;
		}
			public FieldPattern (ILPattern pattern)
			{
				this.pattern = pattern;
			}
Exemplo n.º 13
0
 public OptionalPattern(ILPattern optional)
 {
     pattern = optional;
 }
Exemplo n.º 14
0
		public static MatchContext Match (MethodBase method, ILPattern pattern) {
			if (method == null)
				throw new ArgumentNullException("method");
			if (pattern == null)
				throw new ArgumentNullException("pattern");

			var instructions = method.GetInstructions();
			if (instructions.Count == 0)
				throw new ArgumentException();

			var context = new MatchContext(instructions[0]);
			pattern.Match(context);
			return context;
		}
Exemplo n.º 15
0
 public static ILPattern Either(ILPattern a, ILPattern b)
 {
     return(new EitherPattern(a, b));
 }
Exemplo n.º 16
0
		public static ILPattern Optional (ILPattern pattern) {
			return new OptionalPattern(pattern);
		}
Exemplo n.º 17
0
 public EitherPattern(ILPattern a, ILPattern b)
 {
     this.a = a;
     this.b = b;
 }
Exemplo n.º 18
0
			public SequencePattern (ILPattern[] patterns) {
				this.patterns = patterns;
			}
Exemplo n.º 19
0
			public OptionalPattern (ILPattern optional)
			{
				this.pattern = optional;
			}