Esempio n. 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);
        }
Esempio n. 2
0
        private static void EmitElementArrayLoad(ExpressionElement[] elements, Type arrayElementType, FleeIlGenerator ilg,
                                                 IServiceProvider services)
        {
            LiteralElement.EmitLoad(elements.Length, ilg);
            ilg.Emit(OpCodes.Newarr, arrayElementType);
            var local           = ilg.DeclareLocal(arrayElementType.MakeArrayType());
            var arrayLocalIndex = local.LocalIndex;

            Utility.EmitStoreLocal(ilg, arrayLocalIndex);
            var num = elements.Length - 1;

            for (var i = 0; i <= num; i++)
            {
                Utility.EmitLoadLocal(ilg, arrayLocalIndex);
                LiteralElement.EmitLoad(i, ilg);
                var element = elements[i];
                element.Emit(ilg, services);
                ImplicitConverter.EmitImplicitConvert(element.ResultType, arrayElementType, ilg);
                Utility.EmitArrayStore(ilg, arrayElementType);
            }
            Utility.EmitLoadLocal(ilg, arrayLocalIndex);
        }