Ejemplo n.º 1
0
        /// <summary>
        /// Loads the address of an array element.
        /// </summary>
        private void LoadArrayElementAddress()
        {
            var idx   = CurrentBlock.PopInt();
            var array = CurrentBlock.Pop();

            Debug.Assert(array.ValueType.IsArray);
            var addr = ComputeArrayAddress(array.LLVMValue, idx.LLVMValue);

            CurrentBlock.Push(array.ValueType.GetElementType().MakePointerType(), addr);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads an array element.
        /// </summary>
        /// <param name="type">The type of element to load.</param>
        private void LoadArrayElement(Type type)
        {
            var idx   = CurrentBlock.PopInt();
            var array = CurrentBlock.Pop();

            Debug.Assert(array.ValueType.IsArray);
            var addr  = ComputeArrayAddress(array.LLVMValue, idx.LLVMValue);
            var value = BuildLoad(Builder, addr, string.Empty);

            CurrentBlock.Push(CreateConversion(new Value(array.ValueType.GetElementType(), value), type));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Stores an array element of the specified type.
        /// </summary>
        /// <param name="type">The target type.</param>
        private void StoreArrayElement(Type type)
        {
            var value = CurrentBlock.Pop(type);
            var idx   = CurrentBlock.PopInt();
            var array = CurrentBlock.Pop();

            Debug.Assert(array.ValueType.IsArray);
            var addr = ComputeArrayAddress(array.LLVMValue, idx.LLVMValue);

            BuildStore(Builder, value.LLVMValue, addr);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Realizes a switch instruction.
        /// </summary>
        /// <param name="targets">The jump targets.</param>
        private unsafe void MakeSwitch(ILInstructionBranchTargets targets)
        {
            var switchValue  = CurrentBlock.PopInt();
            var defaultBlock = bbMapping[targets.SwitchDefaultTarget.Value];
            var @switch      = BuildSwitch(
                Builder,
                switchValue.LLVMValue,
                defaultBlock.LLVMBlock,
                targets.Count - 1);

            for (int i = 1, e = targets.Count; i < e; ++i)
            {
                var block = bbMapping[targets[i]];
                AddCase(
                    @switch,
                    ConstInt(LLVMContext.Int32Type, i - 1, true), block.LLVMBlock);
            }
        }