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