Exemplo n.º 1
0
        /// <summary>
        /// Special resolution for internal calls.
        /// </summary>
        /// <param name="method">The internal call method to resolve.</param>
        /// <returns>The virtualAddress</returns>
        protected unsafe override long ResolveInternalCall(RuntimeMethod method)
        {
            Delegate methodDelegate = null;

            if (false == this.resolvedInternals.TryGetValue(method, out methodDelegate))
            {
                ITypeSystem   ts           = RuntimeBase.Instance.TypeLoader;
                RuntimeMethod internalImpl = ts.GetImplementationForInternalCall(method);
                if (null != internalImpl)
                {
                    // Find the .NET counterpart for this method (we're not really compiling or using trampolines just yet.)
                    string typeName = String.Format(@"{0}.{1}, {2}",
                                                    internalImpl.DeclaringType.Namespace,
                                                    internalImpl.DeclaringType.Name,
                                                    internalImpl.Module.Name);
                    Type       type = Type.GetType(typeName);
                    MethodInfo mi   = type.GetMethod(internalImpl.Name);

                    methodDelegate = BuildDelegateForMethodInfo(mi);
                    this.resolvedInternals.Add(method, methodDelegate);
                }
            }

            if (null == methodDelegate)
            {
                throw new NotImplementedException(@"InternalCall implementation not loaded.");
            }

            return(Marshal.GetFunctionPointerForDelegate(methodDelegate).ToInt64());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Special resolution for internal calls.
        /// </summary>
        /// <param name="method">The internal call method to resolve.</param>
        /// <returns>The virtualAddress </returns>
        protected virtual long ResolveInternalCall(RuntimeMethod method)
        {
            long          address      = 0;
            ITypeSystem   ts           = RuntimeBase.Instance.TypeLoader;
            RuntimeMethod internalImpl = ts.GetImplementationForInternalCall(method);

            if (null != internalImpl)
            {
                address = internalImpl.Address.ToInt64();
            }
            return(address);
        }