Пример #1
0
        private void EmitListIn(FleeIlGenerator ilg, IServiceProvider services, BranchManager bm)
        {
            var ce           = new CompareElement();
            var endLabel     = bm.FindLabel("endLabel");
            var trueTerminal = bm.FindLabel("trueTerminal");
            var lb           = ilg.DeclareLocal(this.myOperand.ResultType);
            var targetIndex  = lb.LocalIndex;

            this.myOperand.Emit(ilg, services);
            Utility.EmitStoreLocal(ilg, targetIndex);
            var targetShim = new LocalBasedElement(this.myOperand, targetIndex);

            this.myArguments.ForEach(argumentElement =>
            {
                ce.Initialize(targetShim, argumentElement, LogicalCompareOperation.Equal);
                ce.Emit(ilg, services);
                EmitBranchToTrueTerminal(ilg, trueTerminal, bm);
            });
            //try
            //{
            //    var enumerator = this.myArguments.GetEnumerator();
            //    while (enumerator.MoveNext())
            //    {
            //        var argumentElement = enumerator.Current;
            //        ce.Initialize(targetShim, argumentElement, LogicalCompareOperation.Equal);
            //        ce.Emit(ilg, services);
            //        EmitBranchToTrueTerminal(ilg, trueTerminal, bm);
            //    }
            //}
            //finally
            //{
            //    List<ExpressionElement>.Enumerator enumerator;
            //    ((IDisposable)enumerator).Dispose();
            //}

            ilg.Emit(OpCodes.Ldc_I4_0);
            ilg.Emit(OpCodes.Br_S, endLabel);
            bm.MarkLabel(ilg, trueTerminal);
            ilg.MarkLabel(trueTerminal);
            ilg.Emit(OpCodes.Ldc_I4_1);
            bm.MarkLabel(ilg, endLabel);
            ilg.MarkLabel(endLabel);
        }
Пример #2
0
        private void EmitConditional(FleeIlGenerator ilg, IServiceProvider services, BranchManager bm)
        {
            var falseLabel = bm.FindLabel("falseLabel");
            var endLabel   = bm.FindLabel("endLabel");

            this.myCondition.Emit(ilg, services);
            var isTemp = ilg.IsTemp;

            if (isTemp)
            {
                bm.AddBranch(ilg, falseLabel);
                ilg.Emit(OpCodes.Brfalse_S, falseLabel);
            }
            else
            {
                var flag = !bm.IsLongBranch(ilg, falseLabel);
                ilg.Emit(flag ? OpCodes.Brfalse_S : OpCodes.Brfalse, falseLabel);
            }
            this.myWhenTrue.Emit(ilg, services);
            ImplicitConverter.EmitImplicitConvert(this.myWhenTrue.ResultType, this.myResultType, ilg);
            var isTemp2 = ilg.IsTemp;

            if (isTemp2)
            {
                bm.AddBranch(ilg, endLabel);
                ilg.Emit(OpCodes.Br_S, endLabel);
            }
            else
            {
                var flag2 = !bm.IsLongBranch(ilg, endLabel);
                ilg.Emit(flag2 ? OpCodes.Br_S : OpCodes.Br, endLabel);
            }
            bm.MarkLabel(ilg, falseLabel);
            ilg.MarkLabel(falseLabel);
            this.myWhenFalse.Emit(ilg, services);
            ImplicitConverter.EmitImplicitConvert(this.myWhenFalse.ResultType, this.myResultType, ilg);
            bm.MarkLabel(ilg, endLabel);
            ilg.MarkLabel(endLabel);
        }