private void Visit(SlotExpression expr, Index start = default, Index?end = null)
        {
            LoadMachine();
            if (expr.Slot == Slots.Memory)
            {
                LoadMemory();
            }

            LoadIndex(expr, start);

            // Calculate range length
            if (end == null)
            {
                Generator.Ldc_I4(1);
            }
            else
            {
                Generator.Dup(); // Duplicate start index for GetInputs parameter

                // length = -start + end
                Generator.Neg();

                LoadIndex(expr, end.Value);

                Generator.Add();
            }

            if (expr.Slot == Slots.In)
            {
                Generator.Call(Info.OfMethod <IMachine>(nameof(IMachine.GetInputs), "System.Int32,System.Int32"));
            }
            else if (expr.Slot == Slots.Memory)
            {
                Generator.Call(Info.OfMethod <IMemory>(nameof(IMemory.Read), "System.Int32,System.Int32"));
            }
            else
            {
                throw new LogicEngineException("Invalid slot", expr);
            }

            ValueToReference();
        }
        private void LoadIndex(SlotExpression expr, Index idx)
        {
            if (idx.FromEnd)
            {
                GetSlotSize(expr);
            }

            if (idx.Value == null)
            {
                Generator.Ldc_I4(0);
            }
            else
            {
                Visit(idx.Value);
                BitsValueToNumber();
                Generator.Conv <int>();
            }

            if (idx.FromEnd)
            {
                Generator.Sub();
            }
        }