Exemplo n.º 1
0
        internal ConstructorEmitter(
            AbstractTypeEmitter maintype,
            params ArgumentReference[] arguments
            )
        {
            this.maintype = maintype;

            var args = ArgumentsUtil.InitializeAndConvert(arguments);

            builder = maintype.TypeBuilder.DefineConstructor(
                MethodAttributes.Public,
                CallingConventions.Standard,
                args
                );
            codeBuilder = new CodeBuilder();
        }
Exemplo n.º 2
0
        internal MethodEmitter(AbstractTypeEmitter owner, string name,
                               MethodAttributes attributes, MethodInfo methodToUseAsATemplate)
            : this(owner, name, attributes)
        {
            // All code paths leading up to this constructor can be traced back to
            // proxy type generation code. At present, proxy types are never generic.
            Debug.Assert(owner.GenericTypeParams == null || owner.GenericTypeParams.Length == 0);

            var returnType           = methodToUseAsATemplate.ReturnType;
            var baseMethodParameters = methodToUseAsATemplate.GetParameters();
            var parameters           = ArgumentsUtil.GetTypes(baseMethodParameters);

            genericTypeParams = GenericUtil.CopyGenericArguments(methodToUseAsATemplate, builder);
            SetParameters(parameters);
            SetReturnType(returnType);
            SetSignature(returnType, methodToUseAsATemplate.ReturnParameter, parameters, baseMethodParameters);
            DefineParameters(baseMethodParameters);
        }
Exemplo n.º 3
0
 public void SetParameters(Type[] paramTypes)
 {
     builder.SetParameters(paramTypes);
     arguments = ArgumentsUtil.ConvertToArgumentReference(paramTypes);
     ArgumentsUtil.InitializeArgumentsByPosition(arguments, MethodBuilder.IsStatic);
 }
 public MethodEmitter CreateMethod(string name, MethodAttributes attrs, Type returnType,
                                   params ArgumentReference[] argumentReferences)
 {
     Type[] argumentTypes = ArgumentsUtil.InitializeAndConvert(argumentReferences);
     return(CreateMethod(name, attrs, returnType, argumentTypes));
 }