Exemplo n.º 1
0
        public IDisposable Build(ICollection <Instruction> instructions)
        {
            _instructions = instructions;
            if (_variable == null)
            {
                instructions.Add(_instance != null
                    ? Instruction.Create(OpCodes.Ldloc, _instance)
                    : Instruction.Create(OpCodes.Ldarg_0));
            }

            if (_index != null)
            {
                if (_variable != null)
                {
                    _instructions.Add(_variable.CreateLoadInstruction());
                }
                else if (_property != null)
                {
                    instructions.Add(_property.CreateGetInstruction());
                }
                _instructions.Add(Instruction.Create(OpCodes.Ldloc, _index));

                return(this);
            }

            return(this);
        }