Esempio n. 1
0
        private void ResolveForListSearch()
        {
            var compareElement = new CompareElement();

            // Validate that our operand is comparable to all elements in the list
            foreach (var argumentElement in arguments)
            {
                compareElement.Initialize(operand, argumentElement, LogicalCompareOperation.Equal);
                compareElement.Validate();
            }
        }
Esempio n. 2
0
        private void EmitListIn(YaleIlGenerator ilg, ExpressionContext context, BranchManager branchManager)
        {
            var compareElement = new CompareElement();
            var endLabel       = branchManager.FindLabel("endLabel");
            var trueTerminal   = branchManager.FindLabel("trueTerminal");

            // Cache the operand since we will be comparing against it a lot
            var lb          = ilg.DeclareLocal(operand.ResultType);
            var targetIndex = lb.LocalIndex;

            operand.Emit(ilg, context);
            Utility.EmitStoreLocal(ilg, targetIndex);

            // Wrap our operand in a local shim
            var targetShim = new LocalBasedElement(operand, targetIndex);

            // Emit the compares
            foreach (var argumentElement in arguments)
            {
                compareElement.Initialize(targetShim, argumentElement, LogicalCompareOperation.Equal);
                compareElement.Emit(ilg, context);

                EmitBranchToTrueTerminal(ilg, trueTerminal, branchManager);
            }

            ilg.Emit(OpCodes.Ldc_I4_0);
            ilg.Emit(OpCodes.Br_S, endLabel);

            branchManager.MarkLabel(ilg, trueTerminal);
            ilg.MarkLabel(trueTerminal);

            ilg.Emit(OpCodes.Ldc_I4_1);

            branchManager.MarkLabel(ilg, endLabel);
            ilg.MarkLabel(endLabel);
        }