Exemple #1
0
        static bool IsVariableReset(ILNode expr, ILVariable variable)
        {
            object       unused;
            ILExpression ldloca;

            return(expr.Match(ILCode.Initobj, out unused, out ldloca) && ldloca.MatchLdloca(variable));
        }
Exemple #2
0
        public static bool Match <T>(this ILNode node, ILCode code, out T operand, out ILExpression arg)
        {
            List <ILExpression> args;

            if (node.Match(code, out operand, out args) && args.Count == 1)
            {
                arg = args[0];
                return(true);
            }
            arg = null;
            return(false);
        }
Exemple #3
0
        static bool MatchStFld(ILNode stfld, ILVariable stateMachineVar, out FieldDefinition field, out ILExpression expr)
        {
            field = null;
            FieldReference fieldRef;
            ILExpression   ldloca;

            if (!stfld.Match(ILCode.Stfld, out fieldRef, out ldloca, out expr))
            {
                return(false);
            }
            field = fieldRef.ResolveWithinSameModule();
            return(field != null && ldloca.MatchLdloca(stateMachineVar));
        }
Exemple #4
0
        bool MatchStateAssignment(ILNode stfld, out int stateID)
        {
            // stfld(StateMachine::<>1__state, ldloc(this), ldc.i4(-2))
            stateID = 0;
            FieldReference fieldRef;
            ILExpression   target, val;

            if (stfld.Match(ILCode.Stfld, out fieldRef, out target, out val))
            {
                return(fieldRef.ResolveWithinSameModule() == stateField &&
                       target.MatchThis() &&
                       val.Match(ILCode.Ldc_I4, out stateID));
            }
            return(false);
        }
Exemple #5
0
        public static bool MatchStloc(this ILNode node, ILVariable expectedVar, out ILExpression expr)
        {
            ILVariable v;

            return(node.Match(ILCode.Stloc, out v, out expr) && v == expectedVar);
        }
Exemple #6
0
        public static bool MatchLdloca(this ILNode node, ILVariable expectedVar)
        {
            ILVariable v;

            return(node.Match(ILCode.Ldloca, out v) && v == expectedVar);
        }
Exemple #7
0
        public static bool MatchThis(this ILNode node)
        {
            ILVariable v;

            return(node.Match(ILCode.Ldloc, out v) && v.IsParameter && v.OriginalParameter.Index == -1);
        }