void ILinqOperator.Define(MethodBody method, Instruction jumpInstruction) { var processor = method.GetILProcessor(); var returnType = funcMethod.Method.ReturnType; converted = converted ?? InstructionHelper.ConvertFunction(funcMethod, forLoop); if (!TypeReferenceEquals(returnType, forLoop.LocalDefinition.VariableType)) { forLoop.LocalDefinition = method.AddVariable(returnType); } foreach (var instruction in converted) { processor.Append(instruction); } processor.Append(InstructionHelper.StLoc(forLoop.LocalDefinition)); }
void ILinqOperator.Define(MethodBody method, Instruction jumpInstruction) { var checkVariable = method.AddVariableDefinition(typeSystem.Boolean); var processor = method.GetILProcessor(); converted ??= InstructionHelper.ConvertFunction(funcMethod, forLoop); foreach (var instruction in converted) { processor.Append(instruction); } processor.Append(InstructionHelper.StLoc(checkVariable)); processor.Append(InstructionHelper.LdLoc(checkVariable)); //true processor.Emit(OpCodes.Brfalse_S, jumpInstruction); //continue processor.Emit(OpCodes.Br_S, forLoop.IncrementIndex); }
Instruction ILinqOperator.Next() { converted = InstructionHelper.ConvertFunction(funcMethod, forLoop); return(converted[0]); }