Mosa.Compiler.Framework.BaseCompiler.Initialize C# (CSharp) Method

Initialize() public method

public Initialize ( MosaCompiler compiler ) : void
compiler MosaCompiler
return void
        public void Initialize(MosaCompiler compiler)
        {
            if (compiler == null)
                throw new ArgumentNullException(@"compiler");

            Compiler = compiler;

            Architecture = Compiler.CompilerOptions.Architecture;
            TypeSystem = Compiler.TypeSystem;
            TypeLayout = Compiler.TypeLayout;
            CompilerTrace = Compiler.CompilerTrace;
            CompilerOptions = Compiler.CompilerOptions;
            CompilationScheduler = Compiler.CompilationScheduler;
            Linker = compiler.Linker;

            CompilePipeline = new CompilerPipeline();
            GlobalCounters = new Counters();
            PlugSystem = new PlugSystem();
            CompilerData = new CompilerData();

            // Create new dictionary
            IntrinsicTypes = new Dictionary<string, Type>();

            foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (type.IsClass && typeof(IIntrinsicInternalMethod).IsAssignableFrom(type))
                {
                    // Now get all the ReplacementTarget attributes
                    var attributes = (ReplacementTargetAttribute[])type.GetCustomAttributes(typeof(ReplacementTargetAttribute), true);
                    for (int i = 0; i < attributes.Length; i++)
                    {
                        // Finally add the dictionary entry mapping the target string and the type
                        IntrinsicTypes.Add(attributes[i].Target, type);
                    }
                }
            }

            PlatformInternalRuntimeType = GetPlatformInternalRuntimeType();
            InternalRuntimeType = GeInternalRuntimeType();

            // Extended Setup
            ExtendCompilerSetup();

            // Build the default pre-compiler pipeline
            Architecture.ExtendCompilerPipeline(CompilePipeline);
        }

Usage Example

Example #1
0
        public void Initialize()
        {
            Linker = new BaseLinker(CompilerOptions.BaseAddress, CompilerOptions.Architecture.Endianness, CompilerOptions.Architecture.MachineType, CompilerOptions.EmitSymbols, CompilerOptions.LinkerFormatType);

            BaseCompiler = CompilerFactory();

            BaseCompiler.Initialize(this);
        }
All Usage Examples Of Mosa.Compiler.Framework.BaseCompiler::Initialize