Exemple #1
0
        /// <summary>
        /// Adds an entry point as a global method.
        /// </summary>
        /// <returns>A method info representing the entry point.</returns>
        private MethodInfo CreateEntryPoint()
        {
            // public static void Run([string[] args]);
            MethodBuilder entry_method = globalTypeEmitter.TypeBuilder.DefineMethod(
                ScriptAssembly.EntryPointHelperName,
                MethodAttributes.Public | MethodAttributes.Static,
                Types.Void,
                (kind == AssemblyKinds.ConsoleApplication) ? new Type[] { typeof(string[]) } : Type.EmptyTypes);


            // marks entry point as STA/MTA to enable using COM:
            entry_method.SetCustomAttribute(new CustomAttributeBuilder(
                                                isMTA ? Constructors.MTAThread : Constructors.STAThread, ArrayUtils.EmptyStrings));

            EmitEntryPoint(entry_method);

            // sets assembly entry point:
            RealAssemblyBuilder.SetEntryPoint(entry_method, Enums.ToPEFileKind(kind));

            // user entry point can be defined only on module which is in debug mode:
            if (debuggable)
            {
                ReflectionUtils.SetUserEntryPoint(RealModuleBuilder, GetUserEntryPointMethod());
            }

            return(entry_method);
        }
Exemple #2
0
        public override void EmitCustomAttribute(CustomAttributeBuilder /*!*/ builder, AST.CustomAttribute.TargetSelectors selector)
        {
            switch (selector)
            {
            case AST.CustomAttribute.TargetSelectors.Assembly:
                RealAssemblyBuilder.SetCustomAttribute(builder);
                break;

            case AST.CustomAttribute.TargetSelectors.Module:
                RealModuleBuilder.SetCustomAttribute(builder);
                break;
            }
        }