コード例 #1
0
        private static void SplitFromNonConstantOperand(Operand operand, out Operand operandLow, out Operand operandHigh)
        {
            SigType HighType = (operand.Type.Type == CilElementType.I8) ? new SigType(CilElementType.I4) : new SigType(CilElementType.U4);
            SigType U4 = new SigType(CilElementType.U4);

            // No, could be a member or a plain memory operand
            MemberOperand memberOperand = operand as MemberOperand;
            if (memberOperand != null)
            {
                // We need to keep the member reference, otherwise the linker can't fixup
                // the member address.
                operandLow = new MemberOperand(memberOperand.Member, U4, memberOperand.Offset);
                operandHigh = new MemberOperand(memberOperand.Member, HighType, new IntPtr(memberOperand.Offset.ToInt64() + 4));
            }
            else
            {
                // Plain memory, we can handle it here
                MemoryOperand memoryOperand = (MemoryOperand)operand;
                operandLow = new MemoryOperand(U4, memoryOperand.Base, memoryOperand.Offset);
                operandHigh = new MemoryOperand(HighType, memoryOperand.Base, new IntPtr(memoryOperand.Offset.ToInt64() + 4));
            }
        }
コード例 #2
0
        /// <summary>
        /// Visitation function for <see cref="ICILVisitor.Ldsfld"/>.
        /// </summary>
        /// <param name="ctx">The context.</param>
        public void Ldsfld(Context ctx)
        {
            SigType sigType = ctx.RuntimeField.SignatureType;
            Operand source = new MemberOperand(ctx.RuntimeField);
            Operand destination = ctx.Result;

            IInstruction loadInstruction = Instruction.MoveInstruction;
            if (MustSignExtendOnLoad(sigType.Type))
            {
                loadInstruction = Instruction.SignExtendedMoveInstruction;
            }
            else if (MustZeroExtendOnLoad(sigType.Type))
            {
                loadInstruction = Instruction.ZeroExtendedMoveInstruction;
            }

            ctx.SetInstruction(loadInstruction, destination, source);
        }