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)); }
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); }
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)); }
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)); }
/// <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())); }
/// <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())); }
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); }
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); }
public CorValueResult CallResult(CorFunction func, CorValue[] args) => CallResult(func, null, args);
public CorValueResult CallResult(CorFunction func, CorValue[] args) { return(CallResult(func, null, args)); }
public bool Equals(CorFunction other) => !ReferenceEquals(other, null) && RawObject == other.RawObject;
/// <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())); }
public EvalResult CallConstructor(CorFunction ctor, CorValue[] args) { return(CallConstructor(ctor, null, args)); }
public EvalResult?Call(CorFunction func, CorType[] typeArgs, CorValue[] args, out int hr) { return(WaitForResult(hr = eval.CallParameterizedFunction(func, typeArgs, args))); }
internal override CorCode GetCode(CorFunction func) => func.ILCode;
public EvalResult?CallConstructor(CorFunction func, CorType[] typeArgs, CorValue[] args, out int hr) => WaitForResult(hr = eval.NewParameterizedObject(func, typeArgs, args));
public EvalResult Call(CorFunction func, CorValue[] args) => Call(func, null, args);
public EvalResult Call(CorFunction func, CorValue[] args) { return(Call(func, null, args)); }
/// <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())); }
internal abstract CorCode GetCode(CorFunction func);
public EvalResult CallConstructor(CorFunction ctor, CorValue[] args) => CallConstructor(ctor, null, args);
public bool Equals(CorFunction other) { return(!ReferenceEquals(other, null) && RawObject == other.RawObject); }
internal override CorCode GetCode(CorFunction func) { return(func.NativeCode); }