public IndirectReference(TypeReference byRefReference) : base(byRefReference, byRefReference.Type.GetElementType()) { if (!byRefReference.Type.IsByRef) { throw new ArgumentException("Expected an IsByRef reference", "byRefReference"); } }
// TODO: Better name public static TypeReference[] WrapIfByRef(TypeReference[] references) { var result = new TypeReference[references.Length]; for (var i = 0; i < references.Length; i++) { result[i] = WrapIfByRef(references[i]); } return result; }
public static void CopyOutAndRefParameters(TypeReference[] dereferencedArguments, LocalReference invocation, MethodInfo method, MethodEmitter emitter) { var parameters = method.GetParameters(); if (!ArgumentsUtil.IsAnyByRef(parameters)) { return; //saving the need to create locals if there is no need } var arguments = StoreInvocationArgumentsInLocal(emitter, invocation); for (var i = 0; i < parameters.Length; i++) { if (!parameters[i].ParameterType.IsByRef) { continue; } emitter.CodeBuilder.AddStatement(AssignArgument(dereferencedArguments, i, arguments)); } }
private Expression[] GetCtorArguments(ClassEmitter @class, Expression proxiedMethodTokenExpression, TypeReference[] dereferencedArguments, Expression methodInterceptors) { return new[] { getTargetExpression(@class, MethodToOverride), SelfReference.Self.ToExpression(), methodInterceptors ?? interceptors.ToExpression(), proxiedMethodTokenExpression, new ReferencesToObjectArrayExpression(dereferencedArguments) }; }
public static TypeReference WrapIfByRef(TypeReference reference) { return reference.Type.IsByRef ? new IndirectReference(reference) : reference; }
private static AssignStatement AssignArgument(TypeReference[] dereferencedArguments, int i, LocalReference invocationArgs) { return new AssignStatement(dereferencedArguments[i], Argument(i, invocationArgs, dereferencedArguments)); }
private static ConvertExpression Argument(int i, LocalReference invocationArgs, TypeReference[] arguments) { return new ConvertExpression(arguments[i].Type, new LoadRefArrayElementExpression(i, invocationArgs)); }