Пример #1
0
			public override void Match (MatchContext context) {
				foreach (var pattern in patterns) {
					pattern.Match(context);

					if (!context.success)
						break;
				}
			}
Пример #2
0
			public override void Match(MatchContext context)
			{
				pattern.Match (context);
				if (!context.IsMatch) return;

				var match = GetLastMatchingInstruction(context);
				var field = (FieldInfo)match.Operand;
				context.AddData(BackingFieldKey, field);
			}
Пример #3
0
			public override void Match(MatchContext context)
			{
				pattern.Match(context);
				if (!context.IsMatch) return;

				var match = GetLastMatchingInstruction(context);
				var method = (MethodInfo)match.Operand;
				if (!IsActivateCall(method)) context.IsMatch = false;
			}
Пример #4
0
			public override void Match (MatchContext context) {
				if (context.instruction == null) {
					context.success = false;
					return;
				}

				context.success = context.instruction.OpCode == opcode;
				context.Advance();
			}
Пример #5
0
			public override void Match (MatchContext context) {
				pattern.TryMatch(context);
			}
Пример #6
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;
		}
Пример #7
0
		public bool TryMatch (MatchContext context) {
			var instruction = context.instruction;
			Match(context);

			if (context.success)
				return true;

			context.Reset(instruction);
			return false;
		}
Пример #8
0
		protected static Instruction GetLastMatchingInstruction (MatchContext context) {
			if (context.instruction == null)
				return null;

			return context.instruction.Previous;
		}
Пример #9
0
		public abstract void Match (MatchContext context);
Пример #10
0
			public override void Match (MatchContext context) {
				if (!a.TryMatch(context))
					b.Match(context);
			}
Пример #11
0
		private static FieldInfo GetFieldFromContext(MatchContext context)
		{
			object data;
			if (!context.TryGetData(BackingFieldPattern.BackingFieldKey, out data)) throw new NotSupportedException();

			return (FieldInfo)data;
		}
Пример #12
0
 public override void Match(MatchContext context)
 {
     pattern.TryMatch(context);
 }
Пример #13
0
 public abstract void Match(MatchContext context);