Beispiel #1
0
        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);
            }
Beispiel #3
0
 internal override void Match(MatchContext context)
 {
     if (context.Instruction == null)
     {
         context.Success = false;
     }
     else
     {
         context.Success = context.Instruction.OpCode == _opcode;
         context.Advance();
     }
 }
Beispiel #4
0
        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;
        }
Beispiel #5
0
 internal abstract void Match(MatchContext context);
Beispiel #6
0
 internal override void Match(MatchContext context)
 {
     foreach (var pattern in _patterns)
     {
         pattern.Match(context);
         if (!context.Success)
             return;
     }
 }
Beispiel #7
0
 internal override void Match(MatchContext context)
 {
     _pattern.TryMatch(context);
 }
Beispiel #8
0
 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;
        }
Beispiel #10
0
 internal abstract void Match(MatchContext context);
Beispiel #11
0
 internal override void Match(MatchContext context)
 {
     _pattern.TryMatch(context);
 }
Beispiel #12
0
 protected static Instruction GetLastMatchingInstruction(MatchContext context)
 {
     return(context.Instruction == null ? null : context.Instruction.Previous);
 }