Пример #1
0
 public LdftnAnnotation(ICallableMemberReference method)
     : base(VMCalls.LDFTN, VMType.Pointer)
 {
     Function  = null;
     Signature = null;
     Method    = method;
 }
Пример #2
0
        /// <summary>
        /// Determines whether two callable member references are considered equal according to their signatures.
        /// </summary>
        /// <param name="reference1">The first reference to compare.</param>
        /// <param name="reference2">The second reference to compare.</param>
        /// <returns><c>True</c> if the members are considered equal, <c>False</c> otherwise.</returns>
        public bool MatchMembers(ICallableMemberReference reference1, ICallableMemberReference reference2)
        {
            if (reference1 == null && reference2 == null)
            {
                return(true);
            }
            if (reference1 == null || reference2 == null)
            {
                return(false);
            }

            return(reference1.Name == reference2.Name &&
                   MatchParents(reference1.DeclaringType, reference2.DeclaringType) &&
                   MatchMemberSignatures(reference1.Signature, reference2.Signature));
        }
Пример #3
0
        public IList <CilExpression> RecompileCallArguments(
            ICallableMemberReference method,
            IList <ILExpression> arguments,
            VMECallOpCode opCode,
            ITypeDescriptor constrainedType = null)
        {
            var methodSig = (MethodSignature)method.Signature;
            var result    = new List <CilExpression>();

            // Emit arguments.
            for (var i = 0; i < arguments.Count; i++)
            {
                // Recompile argument.
                var cilArgument = (CilExpression)arguments[i].AcceptVisitor(Recompiler);

                // Figure out expected argument type.
                TypeSignature argumentType;
                if (methodSig.HasThis && opCode != VMECallOpCode.NEWOBJ)
                {
                    // Instance method invocation.

                    if (i == 0)
                    {
                        // First parameter is the object instance that this method is called on (implicit this parameter).
                        argumentType = constrainedType?.ToTypeSignature() ?? method.DeclaringType.ToTypeSignature();

                        // Calls on instance methods of value types need the this parameter to be passed on by-ref.
                        if (argumentType.IsValueType)
                        {
                            argumentType = new ByReferenceTypeSignature(argumentType);
                        }
                    }
                    else
                    {
                        argumentType = methodSig.Parameters[i - 1].ParameterType;
                    }
                }
                else
                {
                    // Static method invocation.
                    argumentType = methodSig.Parameters[i].ParameterType;
                }

                cilArgument.ExpectedType = argumentType.InstantiateGenericTypes(GenericContext);
                result.Add(cilArgument);
            }
            return(result);
        }
Пример #4
0
        /// <summary>
        /// Determines whether two callable member references are considered equal according to their signatures.
        /// </summary>
        /// <param name="reference1">The first reference to compare.</param>
        /// <param name="reference2">The second reference to compare.</param>
        /// <returns><c>True</c> if the members are considered equal, <c>False</c> otherwise.</returns>
        public bool Equals(ICallableMemberReference reference1, ICallableMemberReference reference2)
        {
            if (reference1 == null && reference2 == null)
            {
                return(true);
            }
            if (reference1 == null || reference2 == null)
            {
                return(false);
            }

            if (reference1 is MethodSpecification specification)
            {
                return(Equals(specification, reference2 as MethodSpecification));
            }

            return(reference1.Name == reference2.Name &&
                   Equals((IMemberRefParent)reference1.DeclaringType, reference2.DeclaringType) &&
                   Equals(reference1.Signature, reference2.Signature));
        }
Пример #5
0
 public FieldAnnotation(VMCalls vmCall, ICallableMemberReference field)
     : base(vmCall, ((FieldSignature)field.Signature).FieldType.ToVMType())
 {
     Field = field;
 }
Пример #6
0
        /// <summary>
        /// Determines whether two callable member references are considered equal according to their signatures.
        /// </summary>
        /// <param name="reference1">The first reference to compare.</param>
        /// <param name="reference2">The second reference to compare.</param>
        /// <returns><c>True</c> if the members are considered equal, <c>False</c> otherwise.</returns>
        public bool MatchMembers(ICallableMemberReference reference1, ICallableMemberReference reference2)
        {
            if (reference1 == null && reference2 == null)
                return true;
            if (reference1 == null || reference2 == null)
                return false;

            return reference1.Name == reference2.Name &&
                   MatchParents(reference1.DeclaringType, reference2.DeclaringType) &&
                   MatchMemberSignatures(reference1.Signature, reference2.Signature);
        }
Пример #7
0
 public ECallAnnotation(ICallableMemberReference method, VMECallOpCode opCode)
     : base(VMCalls.ECALL, ((MethodSignature)method.Signature).ReturnType.ToVMType())
 {
     Method = method;
     OpCode = opCode;
 }