public void Emit(OpCode opcode, RuntimeMethodHandle meth, RuntimeTypeHandle typeContext)
        {
            if (meth.IsNullHandle())
            {
                throw new ArgumentNullException("meth");
            }
            if (typeContext.IsNullHandle())
            {
                throw new ArgumentNullException("typeContext");
            }

            // need to sort out the stack size story
            //int   stackchange = 0;
            int tempVal = m_scope.GetTokenFor(meth, typeContext);

            EnsureCapacity(7);
            InternalEmit(opcode);

            // need to sort out the stack size story

            /*
             * if (opcode.m_push == StackBehaviour.Varpush
             *  && meth.ReturnType != typeof(void)) { stackchange++; }
             * if (opcode.m_pop  == StackBehaviour.Varpop) {
             * stackchange -= meth.GetParametersNoCopy().Length; }
             * if (!meth.IsStatic && !(opcode.Equals(OpCodes.Newobj))) {stackchange--; }
             *
             * UpdateStackSize(opcode, stackchange);
             */
            // need to sort out the stack size story
            UpdateStackSize(opcode, 1);

            m_length = PutInteger4(tempVal, m_length, m_ILStream);
        }
Example #2
0
        public void Emit(OpCode opcode, RuntimeTypeHandle typeHandle)
        {
            if (typeHandle.IsNullHandle())
            {
                throw new ArgumentNullException("typeHandle");
            }
            int tokenFor = this.m_scope.GetTokenFor(typeHandle);

            base.EnsureCapacity(7);
            base.InternalEmit(opcode);
            base.PutInteger4(tokenFor);
        }
        public void Emit(OpCode opcode, RuntimeTypeHandle typeHandle)
        {
            if (typeHandle.IsNullHandle())
            {
                throw new ArgumentNullException("typeHandle");
            }

            int tempVal = m_scope.GetTokenFor(typeHandle);

            EnsureCapacity(7);
            InternalEmit(opcode);
            m_length = PutInteger4(tempVal, m_length, m_ILStream);
        }
        internal override unsafe int ParentToken(int token)
        {
            RuntimeTypeHandle owner = RuntimeTypeHandle.EmptyHandle;

            Object handle = m_scope[token];

            if (handle is RuntimeMethodHandle)
            {
                RuntimeMethodHandle method = (RuntimeMethodHandle)handle;
                owner = method.GetDeclaringType();
            }
            else if (handle is RuntimeFieldHandle)
            {
                RuntimeFieldHandle field = (RuntimeFieldHandle)handle;
                owner = field.GetApproxDeclaringType();
            }
            else if (handle is DynamicMethod)
            {
                DynamicMethod dynMeth = (DynamicMethod)handle;
                owner = dynMeth.m_method.GetDeclaringType();
            }
            else if (handle is GenericMethodInfo)
            {
                GenericMethodInfo gmi = (GenericMethodInfo)handle;
                owner = gmi.m_context;
            }
            else if (handle is VarArgMethod)
            {
                VarArgMethod varargMeth = (VarArgMethod)handle;
                if (varargMeth.m_method is DynamicMethod)
                {
                    owner = ((DynamicMethod)varargMeth.m_method).m_method.GetDeclaringType();
                }
                else if (varargMeth.m_method is DynamicMethod.RTDynamicMethod)
                {
                    owner = ((DynamicMethod.RTDynamicMethod)varargMeth.m_method).m_owner.m_method.GetDeclaringType();
                }
                else
                {
                    owner = varargMeth.m_method.MethodHandle.GetDeclaringType();
                }
            }

            if (owner.IsNullHandle())
            {
                return(-1);
            }

            return(m_scope.GetTokenFor(owner));
        }
Example #5
0
        public void Emit(OpCode opcode, RuntimeMethodHandle meth, RuntimeTypeHandle typeContext)
        {
            if (meth.IsNullHandle())
            {
                throw new ArgumentNullException("meth");
            }
            if (typeContext.IsNullHandle())
            {
                throw new ArgumentNullException("typeContext");
            }
            int tokenFor = this.m_scope.GetTokenFor(meth, typeContext);

            base.EnsureCapacity(7);
            base.InternalEmit(opcode);
            base.UpdateStackSize(opcode, 1);
            base.PutInteger4(tokenFor);
        }