コード例 #1
0
		public IndirectReference(TypeReference byRefReference) :
			base(byRefReference, byRefReference.Type.GetElementType())
		{
			if (!byRefReference.Type.IsByRef)
			{
				throw new ArgumentException("Expected an IsByRef reference", "byRefReference");
			}
		}
コード例 #2
0
		// TODO: Better name
		public static TypeReference[] WrapIfByRef(TypeReference[] references)
		{
			TypeReference[] result = new TypeReference[references.Length];

			for(int i = 0; i < references.Length; i++)
			{
				result[i] = WrapIfByRef(references[i]);
			}

			return result;
		}
コード例 #3
0
		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 (int i = 0; i < parameters.Length; i++)
			{
				if (!parameters[i].ParameterType.IsByRef) continue;

				emitter.CodeBuilder.AddStatement(AssignArgument(dereferencedArguments, i, arguments));
			}
		}
コード例 #4
0
		private Expression[] GetCtorArguments(ClassEmitter @class, INamingScope namingScope, Expression proxiedMethodTokenExpression, TypeReference[] dereferencedArguments)
		{
			var selector = @class.GetField("__selector");
			if (selector != null)
			{
				return new[]
				{
					getTargetExpression(@class, MethodToOverride),
					SelfReference.Self.ToExpression(),
					interceptors.ToExpression(),
					proxiedMethodTokenExpression,
					new ReferencesToObjectArrayExpression(dereferencedArguments),
					selector.ToExpression(),
					new AddressOfReferenceExpression(BuildMethodInterceptorsField(@class, MethodToOverride, namingScope))
				};
			}
			return new[]
			{
				getTargetExpression(@class, MethodToOverride),
				SelfReference.Self.ToExpression(),
				interceptors.ToExpression(),
				proxiedMethodTokenExpression,
				new ReferencesToObjectArrayExpression(dereferencedArguments)
			};
		}
コード例 #5
0
ファイル: GeneratorUtil.cs プロジェクト: Biswo/n2cms
 private static AssignStatement AssignArgument(TypeReference[] dereferencedArguments, int i,
                                               LocalReference invocationArgs)
 {
     return new AssignStatement(dereferencedArguments[i], Argument(i, invocationArgs, dereferencedArguments));
 }
コード例 #6
0
ファイル: GeneratorUtil.cs プロジェクト: Biswo/n2cms
 private static ConvertExpression Argument(int i, LocalReference invocationArgs, TypeReference[] arguments)
 {
     return new ConvertExpression(arguments[i].Type, new LoadRefArrayElementExpression(i, invocationArgs));
 }
コード例 #7
0
		// TODO: Better name
		public static TypeReference WrapIfByRef(TypeReference reference)
		{
			return reference.Type.IsByRef ? new IndirectReference(reference) : reference;
		}
コード例 #8
0
		private static void CopyOutAndRefParameters(
			TypeReference[] dereferencedArguments, LocalReference invocationImplLocal, MethodInfo method,
			MethodEmitter methodEmitter)
		{
			ParameterInfo[] parameters = method.GetParameters();
			bool hasByRefParam = false;
			for(int i = 0; i < parameters.Length; i++)
			{
				if (parameters[i].ParameterType.IsByRef)
					hasByRefParam = true;
			}
			if (!hasByRefParam)
				return; //saving the need to create locals if there is no need
			LocalReference invocationArgs = methodEmitter.CodeBuilder.DeclareLocal(typeof(object[]));
			methodEmitter.CodeBuilder.AddStatement(
				new AssignStatement(invocationArgs,
				                    new MethodInvocationExpression(invocationImplLocal, invocation_getArgumentsMethod)
					)
				);
			for(int i = 0; i < parameters.Length; i++)
			{
				if (parameters[i].ParameterType.IsByRef)
				{
					methodEmitter.CodeBuilder.AddStatement(
						new AssignStatement(dereferencedArguments[i],
						                    new ConvertExpression(dereferencedArguments[i].Type,
						                                          new LoadRefArrayElementExpression(i, invocationArgs)
						                    	)
							));
				}
			}
		}
コード例 #9
0
		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)
			};
		}