Schedules type initializers and creates a hidden mosacl_main method, which runs all type initializers in sequence.
Dependencies are not resolved, it is hoped that dependencies are resolved by the high-level language compiler by placing cctors in some order in metadata.
Inheritance: BaseCompilerStage
        /// <summary>
        /// Initializes the type.
        /// </summary>
        protected virtual void InitializeType()
        {
            if (Method.IsSpecialName && Method.IsRTSpecialName && Method.IsStatic && Method.Name == ".cctor")
            {
                typeInitializer = Compiler.PostCompilePipeline.FindFirst<TypeInitializerSchedulerStage>();

                if (typeInitializer == null)
                    return;

                typeInitializer.Schedule(Method);
            }
        }
Example #2
0
        /// <summary>
        /// Initializes the type.
        /// </summary>
        protected virtual void InitializeType()
        {
            typeInitializer = Compiler.Pipeline.FindFirst<TypeInitializerSchedulerStage>();

            if (typeInitializer == null)
                return;

            // If we're compiling a type initializer, run it immediately.
            if (Method.IsSpecialName && Method.IsRTSpecialName && Method.IsStatic && Method.Name == ".cctor")
            {
                typeInitializer.Schedule(Method);
            }
        }