System.Reflection.Emit.ModuleBuilder.DefineGlobalMethod C# (CSharp) Method

DefineGlobalMethod() public method

public DefineGlobalMethod ( string name, System attributes, System returnType, System parameterTypes ) : System.Reflection.Emit.MethodBuilder
name string
attributes System
returnType System
parameterTypes System
return System.Reflection.Emit.MethodBuilder
        public System.Reflection.Emit.MethodBuilder DefineGlobalMethod(string name, System.Reflection.MethodAttributes attributes, System.Type returnType, System.Type[] parameterTypes) { throw null; }
        public System.Reflection.Emit.FieldBuilder DefineInitializedData(string name, byte[] data, System.Reflection.FieldAttributes attributes) { throw null; }

Same methods

ModuleBuilder::DefineGlobalMethod ( string name, System attributes, System callingConvention, System returnType, System parameterTypes ) : System.Reflection.Emit.MethodBuilder
ModuleBuilder::DefineGlobalMethod ( string name, System attributes, System callingConvention, System returnType, System requiredReturnTypeCustomModifiers, System optionalReturnTypeCustomModifiers, System parameterTypes, System requiredParameterTypeCustomModifiers, System optionalParameterTypeCustomModifiers ) : System.Reflection.Emit.MethodBuilder

Usage Example

        /// <summary>
        /// Compiles the signature for the procedure but not the body.
        /// This needs to be done first so that other methods can 
        /// call this method, this way we don't have problems with;
        /// dependencies between methods.
        /// </summary>
        public MethodBuilder CompileSignature(ModuleBuilder module)
        {
            Type[] argTypes = new Type[ArgumentCount];

            for (int i = 0; i < argTypes.Length; i++) {
                argTypes[i] = typeof(int);
            }

            if (HasResultArgument) {
                argTypes[argTypes.Length - 1] = typeof(int).MakeByRefType();
            }

            MethodBuilder method = module.DefineGlobalMethod(_name, MethodAttributes.HideBySig | MethodAttributes.Static | MethodAttributes.Public, typeof(void), argTypes);
            int pos = 1;
            foreach (Variable arg in ValueArguments) {
                SymbolTable.DefineArgument(arg.Name);
                method.DefineParameter(pos, ParameterAttributes.In, arg.Name);
                pos++;
            }

            if (HasResultArgument) {
                SymbolTable.DefineArgument(ResultArgument.Name);
                method.DefineParameter(pos, ParameterAttributes.Out, ResultArgument.Name);
            }
            SymbolTable.Clear();
            return method;
        }
All Usage Examples Of System.Reflection.Emit.ModuleBuilder::DefineGlobalMethod