PixelMagic.CodeGenContext.EmitLoopStart C# (CSharp) Method

EmitLoopStart() private method

private EmitLoopStart ( ) : void
return void
        void EmitLoopStart()
        {
            colorOut0 = DeclareLocal (typeof (Vector4f), "colorOut0");

            //tex0.x = wq / 2;
            if (tex0 != null) {
                ilgen.Emit (OpCodes.Ldloca, tex0);
                ilgen.Emit (OpCodes.Ldloc, wq);
                ilgen.Emit (OpCodes.Ldc_R4, 2f);
                ilgen.Emit (OpCodes.Div);
                ilgen.Emit (OpCodes.Call, typeof (Vector4f).GetMethod ("set_X"));
            }

            loop_i = DeclareLocal (typeof (int), "i");
            loop_j = DeclareLocal (typeof (int), "j");

            body_i = ilgen.DefineLabel ();
            body_j = ilgen.DefineLabel ();
            cond_i = ilgen.DefineLabel ();
            cond_j = ilgen.DefineLabel ();

            //i = 0;
            ilgen.Emit (OpCodes.Ldc_I4_0);
            ilgen.Emit (OpCodes.Stloc, loop_i);

            //goto loop step
            ilgen.Emit (OpCodes.Br, cond_i);
            ilgen.MarkLabel (body_i);

            //tex0.y = hq / 2;
            if (tex0 != null) {
                ilgen.Emit (OpCodes.Ldloca, tex0);
                ilgen.Emit (OpCodes.Ldloc, hq);
                ilgen.Emit (OpCodes.Ldc_R4, 2f);
                ilgen.Emit (OpCodes.Div);
                ilgen.Emit (OpCodes.Call, typeof (Vector4f).GetMethod ("set_Y"));
            }

            //j = 0;
            ilgen.Emit (OpCodes.Ldc_I4_0);
            ilgen.Emit (OpCodes.Stloc, loop_j);

            //goto loop step
            ilgen.Emit (OpCodes.Br, cond_j);
            ilgen.MarkLabel (body_j);

            ilgen.Emit (OpCodes.Ldloca, colorOut0);
            ilgen.Emit (OpCodes.Initobj, typeof (Vector4f));
        }