Exemplo n.º 1
0
        public void StoreElement()
        {
            var value           = _evaluator.Pop();
            var index           = _evaluator.Pop();
            var array           = (LocalVariable)_evaluator.Pop();
            var setArrayElement = new SetArrayElement
            {
                Instance = array,
                Index    = index,
                Right    = value
            };

            AddOperation(setArrayElement);
        }
Exemplo n.º 2
0
        public void SetArrayElementValue()
        {
            var right           = _evaluator.Pop();
            var index           = _evaluator.Pop();
            var instance        = (LocalVariable)_evaluator.Pop();
            var setArrayElement = new SetArrayElement
            {
                Instance = instance,
                Index    = index,
                Right    = right
            };

            AddOperation(setArrayElement);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Lowers set element values.
        /// </summary>
        private static void Lower(
            RewriterContext context,
            TypeLowering <ArrayType> _,
            SetArrayElement value)
        {
            var linearAddress = GetLinearAddress(
                context,
                value.ObjectValue,
                value.Index,
                out var ptr);

            var builder = context.Builder;
            var address = builder.CreateLoadElementAddress(
                value.Location,
                ptr,
                linearAddress);
            var newStore = builder.CreateStore(
                value.Location,
                address,
                value.Value);

            context.ReplaceAndRemove(value, newStore);
        }
Exemplo n.º 4
0
 /// <summary cref="IValueVisitor.Visit(SetArrayElement)"/>
 public void Visit(SetArrayElement value) =>
 throw new InvalidCodeGenerationException();