Esempio n. 1
0
        /// <summary>
        /// Matches the specified other.
        /// </summary>
        /// <param name="other">The other signature type.</param>
        /// <returns>True, if the signature type matches.</returns>
        public override bool Matches(SigType other)
        {
            PtrSigType ptrOther = other as PtrSigType;

            // FIXME: Do we need to consider custom mods here?
            return(ptrOther != null && ptrOther.elementType.Matches(this.elementType) == true);
        }
Esempio n. 2
0
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>
        /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
        /// </returns>
        public override bool Equals(SigType other)
        {
            PtrSigType pother = other as PtrSigType;

            if (null == pother)
            {
                return(false);
            }

            return(base.Equals(other) == true && this.elementType.Matches(pother.elementType) == true && CustomMod.Equals(this.customMods, pother.customMods));
        }
Esempio n. 3
0
        /// <summary>
        /// Validates the instruction operands and creates a matching variable for the result.
        /// </summary>
        /// <param name="ctx">The context.</param>
        /// <param name="compiler">The compiler.</param>
        public override void Validate(Context ctx, IMethodCompiler compiler)
        {
            base.Validate (ctx, compiler);

            StackTypeCode result = StackTypeCode.Unknown;
            switch (_opcode) {
                case OpCode.Add:
                    result = _addTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
                    break;

                case OpCode.Sub:
                    result = _subTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
                    break;
                default:

                    result = _operandTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
                    break;
            }

            if (StackTypeCode.Unknown == result)
                throw new InvalidOperationException ("Invalid operand types passed to " + _opcode);

            SigType resultType;
            if (result != StackTypeCode.Ptr)
            {
                resultType = Operand.SigTypeFromStackType (result);
            }

            else
            {
                // Copy the pointer element type
                PtrSigType op0 = ctx.Operand1.Type as PtrSigType;
                PtrSigType op1 = ctx.Operand2.Type as PtrSigType;
                if (op0 != null)
                    resultType = new PtrSigType (op0.CustomMods, op0.ElementType);
                else if (op1 != null)
                {
                    resultType = new PtrSigType (op1.CustomMods, op1.ElementType);
                }

                else
                    throw new InvalidOperationException ();
            }

            ctx.Result = compiler.CreateTemporary (resultType);
        }