Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 Instruction ILinqOperator.Next()
 {
     converted = InstructionHelper.ConvertFunction(funcMethod, forLoop);
     return(converted[0]);
 }