private void TryMatch(MatchContext context) { var instruction = context.Instruction; Match(context); if (!context.Success) context.Reset(instruction); }
internal 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); }
internal override void Match(MatchContext context) { if (context.Instruction == null) { context.Success = false; } else { context.Success = context.Instruction.OpCode == _opcode; context.Advance(); } }
internal static MatchContext Match(MethodBase method, ILPattern pattern) { if (method == null) throw new ArgumentNullException("method"); if (pattern == null) throw new ArgumentNullException("pattern"); var instructions = (IList<Instruction>) MethodBodyReader.GetInstructions(method).AsReadOnly(); if (instructions.Count == 0) throw new ArgumentException(); var context = new MatchContext(instructions[0]); pattern.Match(context); return context; }
internal abstract void Match(MatchContext context);
internal override void Match(MatchContext context) { foreach (var pattern in _patterns) { pattern.Match(context); if (!context.Success) return; } }
internal override void Match(MatchContext context) { _pattern.TryMatch(context); }
protected static Instruction GetLastMatchingInstruction(MatchContext context) { return context.Instruction == null ? null : context.Instruction.Previous; }
private static FieldInfo GetFieldFromContext(MatchContext context) { object data; if (!context.TryGetData(BackingFieldPattern.BackingFieldKey, out data)) throw new NotSupportedException(); return (FieldInfo)data; }
protected static Instruction GetLastMatchingInstruction(MatchContext context) { return(context.Instruction == null ? null : context.Instruction.Previous); }