Пример #1
0
        TypeSig GetThisType(CorFunction func)
        {
            if (func == null)
            {
                return(null);
            }
            var funcClass = func.Class;
            var mod       = funcClass == null ? null : funcClass.Module;
            var mdi       = mod == null ? null : mod.GetMetaDataInterface <IMetaDataImport>();

            if (mdi == null)
            {
                return(null);
            }

            int numTypeGenArgs = MetaDataUtils.GetCountGenericParameters(mdi, funcClass.Token);
            var genTypeArgs    = this.TypeParameters.Take(numTypeGenArgs).ToArray();

            var td = DebugSignatureReader.CreateTypeDef(mdi, funcClass.Token);
            // Assume it's a class for now. The code should ignore ClassSig and just use the TypeDef
            var sig = new ClassSig(td);

            if (genTypeArgs.Length == 0)
            {
                return(sig);
            }

            var genArgs = new List <TypeSig>(genTypeArgs.Length);

            for (int i = 0; i < genTypeArgs.Length; i++)
            {
                genArgs.Add(new GenericVar(i));
            }
            return(new GenericInstSig(sig, genArgs));
        }
Пример #2
0
        public CorValueResult CallResult(CorFunction func, CorType[] typeArgs, CorValue[] args, out int hr)
        {
            var res = Call(func, typeArgs, args, out hr);

            if (res == null || res.Value.WasException || res.Value.ResultOrException == null)
            {
                return(new CorValueResult());
            }
            return(res.Value.ResultOrException.Value);
        }
Пример #3
0
        public EvalResult Call(CorFunction func, CorType[] typeArgs, CorValue[] args)
        {
            int hr;
            var res = Call(func, typeArgs, args, out hr);

            if (res != null)
            {
                return(res.Value);
            }
            throw new EvalException(hr, string.Format("Could not call method {0:X8}, HR=0x{1:X8}", func.Token, hr));
        }
Пример #4
0
        public EvalResult CallConstructor(CorFunction ctor, CorType[] typeArgs, CorValue[] args)
        {
            int hr;
            var res = CallConstructor(ctor, typeArgs, args, out hr);

            if (res != null)
            {
                return(res.Value);
            }
            throw new EvalException(hr, string.Format("Could not call .ctor {0:X8}, HR=0x{1:X8}", ctor.Token, hr));
        }
Пример #5
0
 /// <summary>
 /// Sets up a call to the specified function
 /// </summary>
 /// <param name="func">Method</param>
 /// <param name="typeArgs">Type and method arguments, in that order, or null if none needed</param>
 /// <param name="args">Arguments</param>
 /// <returns></returns>
 public int CallParameterizedFunction(CorFunction func, CorType[] typeArgs, CorValue[] args)
 {
     if (eval2 == null)
     {
         if (typeArgs == null || typeArgs.Length == 0)
         {
             return(CallFunction(func, args));
         }
         return(-1);
     }
     return(eval2.CallParameterizedFunction(func.RawObject, typeArgs == null ? 0 : typeArgs.Length, typeArgs.ToCorDebugArray(), args.Length, args.ToCorDebugArray()));
 }
Пример #6
0
 /// <summary>
 /// Instantiates a new parameterized type object and calls the object's constructor method
 /// </summary>
 /// <param name="ctor">Constructor</param>
 /// <param name="typeArgs">Type args or null if none required</param>
 /// <param name="args">Constructor arguments</param>
 /// <returns></returns>
 public int NewParameterizedObject(CorFunction ctor, CorType[] typeArgs, CorValue[] args)
 {
     if (eval2 == null)
     {
         if (typeArgs == null || typeArgs.Length == 0)
         {
             return(NewObject(ctor, args));
         }
         return(-1);
     }
     return(eval2.NewParameterizedObject(ctor.RawObject, typeArgs == null ? 0 : typeArgs.Length, typeArgs.ToCorDebugArray(), args.Length, args.ToCorDebugArray()));
 }
Пример #7
0
        public CorFunction[] GetOtherMethods()
        {
            var mod    = Module;
            var tokens = MDAPI.GetEventOtherMethodTokens(mod?.GetMetaDataInterface <IMetaDataImport>(), Token);

            if (tokens.Length == 0)
            {
                return(Array.Empty <CorFunction>());
            }
            var funcs = new CorFunction[tokens.Length];

            for (int i = 0; i < tokens.Length; i++)
            {
                funcs[i] = mod.GetFunctionFromToken(tokens[i]);
            }
            return(funcs);
        }
Пример #8
0
        public CorFunction[] GetOtherMethods()
        {
            var mod    = Module;
            var mdi    = mod == null ? null : mod.GetMetaDataInterface <IMetaDataImport>();
            var tokens = MDAPI.GetEventOtherMethodTokens(mdi, token);

            if (tokens.Length == 0)
            {
                return(emptyCorFunctions);
            }
            var funcs = new CorFunction[0];

            for (int i = 0; i < tokens.Length; i++)
            {
                funcs[i] = mod.GetFunctionFromToken(tokens[i]);
            }
            return(funcs);
        }
Пример #9
0
 public CorValueResult CallResult(CorFunction func, CorValue[] args) => CallResult(func, null, args);
Пример #10
0
 public CorValueResult CallResult(CorFunction func, CorValue[] args)
 {
     return(CallResult(func, null, args));
 }
Пример #11
0
 public bool Equals(CorFunction other) => !ReferenceEquals(other, null) && RawObject == other.RawObject;
Пример #12
0
 /// <summary>
 /// Sets up a call to the specified function
 /// </summary>
 /// <param name="func">Method</param>
 /// <param name="args">Arguments</param>
 /// <returns></returns>
 public int CallFunction(CorFunction func, CorValue[] args)
 {
     // Same thing as calling CallParameterizedFunction(func, null, args)
     return(obj.CallFunction(func.RawObject, args.Length, args.ToCorDebugArray()));
 }
Пример #13
0
 public EvalResult CallConstructor(CorFunction ctor, CorValue[] args)
 {
     return(CallConstructor(ctor, null, args));
 }
Пример #14
0
 public EvalResult?Call(CorFunction func, CorType[] typeArgs, CorValue[] args, out int hr)
 {
     return(WaitForResult(hr = eval.CallParameterizedFunction(func, typeArgs, args)));
 }
Пример #15
0
 internal override CorCode GetCode(CorFunction func) => func.ILCode;
Пример #16
0
 public EvalResult?CallConstructor(CorFunction func, CorType[] typeArgs, CorValue[] args, out int hr) => WaitForResult(hr = eval.NewParameterizedObject(func, typeArgs, args));
Пример #17
0
 public EvalResult Call(CorFunction func, CorValue[] args) => Call(func, null, args);
Пример #18
0
 public EvalResult Call(CorFunction func, CorValue[] args)
 {
     return(Call(func, null, args));
 }
Пример #19
0
 /// <summary>
 /// Allocates a new object instance and calls the specified constructor method
 /// </summary>
 /// <param name="ctor">Constructor</param>
 /// <param name="args">Constructor arguments</param>
 /// <returns></returns>
 public int NewObject(CorFunction ctor, CorValue[] args)
 {
     // Same thing as calling NewParameterizedObject(ctor, null, args)
     return(obj.NewObject(ctor.RawObject, args.Length, args.ToCorDebugArray()));
 }
Пример #20
0
 internal abstract CorCode GetCode(CorFunction func);
Пример #21
0
 public EvalResult CallConstructor(CorFunction ctor, CorValue[] args) => CallConstructor(ctor, null, args);
Пример #22
0
 public bool Equals(CorFunction other)
 {
     return(!ReferenceEquals(other, null) &&
            RawObject == other.RawObject);
 }
Пример #23
0
 internal override CorCode GetCode(CorFunction func)
 {
     return(func.NativeCode);
 }