public static bool Match <T>(this ILNode node, GMCode code, out T operand, out ILExpression arg) { IList <ILExpression> args; if (node.Match(code, out operand, out args) && args.Count == 1) { arg = args[0]; return(true); } arg = null; return(false); }
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; }
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); }
static bool IsVariableReset(ILNode expr, ILVariable variable) { object unused; ILExpression ldloca; return expr.Match(ILCode.Initobj, out unused, out ldloca) && ldloca.MatchLdloca(variable); }