Example #1
0
        private void EmitLoopBeginning()
        {
            loopStartLabel     = il.DefineLabel();
            loopConditionLabel = il.DefineLabel();
            enumeratorVar      = il.DeclareLocal(enumeratorType); // IEnumerator<T> enumerator

            emitLoadCollection(il);                               // enumerator = value.GetEnumerator()
            il.Callvirt(GetEnumeratorMethod);
            il.Stloc(enumeratorVar);
            il.Br(loopConditionLabel);                          // goto loopConditionLabel
            il.MarkLabel(loopStartLabel);                       // label loopStartLabel
        }
Example #2
0
        private void EmitLoopBeginning()
        {
            loopStartLabel     = il.DefineLabel();
            loopConditionLabel = il.DefineLabel();

            iVar = il.DeclareLocal(typeof(int));        // int i

            il.Ldc_I4(0);                               // i = 0
            il.Stloc(iVar);
            il.Br(loopConditionLabel);                  // goto loopConditionLabel

            il.MarkLabel(loopStartLabel);               // label loopStartLabel
        }