Beispiel #1
0
        CallSite GetCallSiteAt(int token, GenericContext context)
        {
            StandAloneSigTable sasTable = m_reflectReader.TableReader.GetStandAloneSigTable();
            MethodSig          ms       = m_reflectReader.SigReader.GetStandAloneMethodSig(
                sasTable [(int)GetRid(token) - 1].Signature);
            CallSite cs = new CallSite(ms.HasThis, ms.ExplicitThis,
                                       ms.MethCallConv, m_reflectReader.GetMethodReturnType(ms, context));

            cs.MetadataToken = new MetadataToken(token);

            for (int i = 0; i < ms.ParamCount; i++)
            {
                Param p = ms.Parameters [i];
                cs.Parameters.Add(m_reflectReader.BuildParameterDefinition(
                                      string.Concat("A_", i),
                                      i, (ParameterAttributes)0,
                                      p, context));
            }

            MethodRefSig refSig = ms as MethodRefSig;

            if (refSig != null && refSig.Sentinel >= 0)
            {
                ReflectionReader.CreateSentinel(cs, refSig.Sentinel);
            }

            return(cs);
        }
Beispiel #2
0
		public virtual void VisitMethodRefSig (MethodRefSig methodRef)
		{
		}
Beispiel #3
0
 public virtual void VisitMethodRefSig(MethodRefSig methodRef)
 {
 }
Beispiel #4
0
        public TypeReference GetTypeRefFromSig(SigType t, GenericContext context)
        {
            switch (t.ElementType)
            {
            case ElementType.Class:
                CLASS c = t as CLASS;
                return(GetTypeDefOrRef(c.Type, context));

            case ElementType.ValueType:
                VALUETYPE     vt  = t as VALUETYPE;
                TypeReference vtr = GetTypeDefOrRef(vt.Type, context);
                vtr.IsValueType = true;
                return(vtr);

            case ElementType.String:
                return(SearchCoreType(Constants.String));

            case ElementType.Object:
                return(SearchCoreType(Constants.Object));

            case ElementType.Void:
                return(SearchCoreType(Constants.Void));

            case ElementType.Boolean:
                return(SearchCoreType(Constants.Boolean));

            case ElementType.Char:
                return(SearchCoreType(Constants.Char));

            case ElementType.I1:
                return(SearchCoreType(Constants.SByte));

            case ElementType.U1:
                return(SearchCoreType(Constants.Byte));

            case ElementType.I2:
                return(SearchCoreType(Constants.Int16));

            case ElementType.U2:
                return(SearchCoreType(Constants.UInt16));

            case ElementType.I4:
                return(SearchCoreType(Constants.Int32));

            case ElementType.U4:
                return(SearchCoreType(Constants.UInt32));

            case ElementType.I8:
                return(SearchCoreType(Constants.Int64));

            case ElementType.U8:
                return(SearchCoreType(Constants.UInt64));

            case ElementType.R4:
                return(SearchCoreType(Constants.Single));

            case ElementType.R8:
                return(SearchCoreType(Constants.Double));

            case ElementType.I:
                return(SearchCoreType(Constants.IntPtr));

            case ElementType.U:
                return(SearchCoreType(Constants.UIntPtr));

            case ElementType.TypedByRef:
                return(SearchCoreType(Constants.TypedReference));

            case ElementType.Array:
                ARRAY ary = t as ARRAY;
                return(new ArrayType(GetTypeRefFromSig(ary.Type, context), ary.Shape));

            case ElementType.SzArray:
                SZARRAY   szary = t as SZARRAY;
                ArrayType at    = new ArrayType(GetTypeRefFromSig(szary.Type, context));
                return(at);

            case ElementType.Ptr:
                PTR pointer = t as PTR;
                if (pointer.Void)
                {
                    return(new PointerType(SearchCoreType(Constants.Void)));
                }
                return(new PointerType(GetTypeRefFromSig(pointer.PtrType, context)));

            case ElementType.FnPtr:
                FNPTR funcptr             = t as FNPTR;
                FunctionPointerType fnptr = new FunctionPointerType(funcptr.Method.HasThis, funcptr.Method.ExplicitThis,
                                                                    funcptr.Method.MethCallConv, GetMethodReturnType(funcptr.Method, context));

                for (int i = 0; i < funcptr.Method.ParamCount; i++)
                {
                    Param p = funcptr.Method.Parameters [i];
                    fnptr.Parameters.Add(BuildParameterDefinition(
                                             string.Concat("A_", i),
                                             i, (ParameterAttributes)0,
                                             p, context));
                }

                MethodRefSig refSig = funcptr.Method as MethodRefSig;
                if (refSig != null && refSig.Sentinel >= 0)
                {
                    CreateSentinel(fnptr, refSig.Sentinel);
                }

                return(fnptr);

            case ElementType.Var:
                VAR var = t as VAR;
                if (context.AllowCreation)
                {
                    CheckGenericParameters(context, var);
                }

                if (context.Type is GenericInstanceType)
                {
                    return((context.Type as GenericInstanceType).GenericArguments [var.Index]);
                }
                else
                {
                    return(context.Type.GenericParameters [var.Index]);
                }

            case ElementType.MVar:
                MVAR mvar = t as MVAR;
                if (context.Method is GenericInstanceMethod)
                {
                    return((context.Method as GenericInstanceMethod).GenericArguments [mvar.Index]);
                }
                else
                {
                    return(context.Method.GenericParameters [mvar.Index]);
                }

            case ElementType.GenericInst:
                GENERICINST         ginst    = t as GENERICINST;
                GenericInstanceType instance = new GenericInstanceType(GetTypeDefOrRef(ginst.Type, context));
                instance.IsValueType = ginst.ValueType;

                for (int i = 0; i < ginst.Signature.Arity; i++)
                {
                    instance.GenericArguments.Add(GetGenericArg(
                                                      ginst.Signature.Types [i], context));
                }

                return(instance);

            default:
                break;
            }
            return(null);
        }