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

            return(expr.Match(ILCode.Initobj, out unused, out ldloca) && ldloca.MatchLdloca(variable));
        }
Exemplo n.º 2
0
		static bool MatchStFld(ILNode stfld, ILVariable stateMachineVar, out FieldDef field, out ILExpression expr)
		{
			field = null;
			IField fieldRef;
			ILExpression ldloca;
			if (!stfld.Match(ILCode.Stfld, out fieldRef, out ldloca, out expr))
				return false;
			field = fieldRef.ResolveFieldWithinSameModule();
			return field != null && ldloca.MatchLdloca(stateMachineVar);
		}
Exemplo n.º 3
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);
        }
        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));
        }
Exemplo n.º 5
0
		bool MatchStateAssignment(ILNode stfld, out int stateID)
		{
			// stfld(StateMachine::<>1__state, ldloc(this), ldc.i4(stateId))
			stateID = 0;
			IField fieldRef;
			ILExpression target, val;
			if (stfld.Match(ILCode.Stfld, out fieldRef, out target, out val)) {
				return fieldRef.ResolveFieldWithinSameModule() == stateField
					&& target.MatchThis()
					&& val.Match(ILCode.Ldc_I4, out stateID);
			}
			return false;
		}
Exemplo n.º 6
0
        public static bool MatchLdloc(this ILNode node, ILVariable expectedVar)
        {
            ILVariable v;

            return(node.Match(ILCode.Ldloc, out v) && v == expectedVar);
        }
Exemplo n.º 7
0
        public static bool MatchThis(this ILNode node)
        {
            ILVariable v;

            return(node.Match(ILCode.Ldloc, out v) && v.IsParameter && v.OriginalParameter.Index == -1);
        }
Exemplo n.º 8
0
        public static bool MatchLdcI4(this ILNode node, int expectedValue)
        {
            int v;

            return(node.Match(ILCode.Ldc_I4, out v) && v == expectedValue);
        }
Exemplo n.º 9
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);
        }