예제 #1
0
        private void Compile()
        {
            IAssemblyLoader assemblyLoader = new AssemblyLoader();

            assemblyLoader.InitializePrivatePaths(this.GetInputFileNames());

            foreach (string file in this.GetInputFileNames())
            {
                assemblyLoader.LoadModule(file);
            }

            ITypeSystem typeSystem = new TypeSystem();

            typeSystem.LoadModules(assemblyLoader.Modules);

            int nativePointerSize;
            int nativePointerAlignment;

            this.architectureSelector.Architecture.GetTypeRequirements(BuiltInSigType.IntPtr, out nativePointerSize, out nativePointerAlignment);

            TypeLayout typeLayout = new TypeLayout(typeSystem, nativePointerSize, nativePointerAlignment);

            // Create the compiler
            using (AotCompiler aot = new AotCompiler(this.architectureSelector.Architecture, typeSystem, typeLayout))
            {
                aot.Pipeline.AddRange(new IAssemblyCompilerStage[]
                {
                    this.bootFormatStage,
                    new InterruptBuilderStage(),
                    new AssemblyCompilationStage(),
                    //new FakeSystemObjectGenerationStage(),
                    new MethodCompilerSchedulerStage(),
                    new TypeInitializers.TypeInitializerSchedulerStage(),
                    this.bootFormatStage,
                    new CilHeaderBuilderStage(),
                    new ObjectFileLayoutStage(),
                    this.linkerStage,
                    this.mapFileWrapper
                });

                aot.Run();
            }
        }
예제 #2
0
파일: Compiler.cs 프로젝트: djlw78/Mosa
        private void Compile()
        {
            using (CompilationRuntime runtime = new CompilationRuntime()) {
                // Append the paths of the folder to the loader path
                List <string> paths = new List <string>();
                foreach (FileInfo assembly in this.inputFiles)
                {
                    string path = Path.GetDirectoryName(assembly.FullName);
                    if (!paths.Contains(path))
                    {
                        paths.Add(path);
                    }
                }

                // Append the search paths
                foreach (string path in paths)
                {
                    runtime.AssemblyLoader.AppendPrivatePath(path);
                }
                paths = null;

                /* FIXME: This only compiles the very first assembly, but we want to
                 * potentially merge multiple assemblies into our kernel. This will
                 * need an extension/modification of the assembly compiler method.
                 *
                 * // Load all input assemblies
                 * foreach (FileInfo assembly in this.inputFiles)
                 * {
                 *      IMetadataModule module = runtime.AssemblyLoader.Load(assembly.FullName);
                 * }
                 */

                IMetadataModule assemblyModule;
                FileInfo        file = null;

                try {
                    file           = this.inputFiles[0];
                    assemblyModule = runtime.AssemblyLoader.Load(file.FullName);

                    // Try to load debug information for the compilation
                    string dbgFile;
                    dbgFile = Path.Combine(Path.GetDirectoryName(file.FullName), Path.GetFileNameWithoutExtension(file.FullName) + ".pdb");
                    //dbgFile = Path.Combine(Path.GetDirectoryName(file.FullName), "mosacl.pdb");
                    if (File.Exists(dbgFile) == true)
                    {
                        using (FileStream fileStream = new FileStream(dbgFile, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                            using (PdbReader reader = new PdbReader(fileStream)) {
                                Debug.WriteLine(@"Global symbols:");
                                foreach (CvSymbol symbol in reader.GlobalSymbols)
                                {
                                    Debug.WriteLine("\t" + symbol.ToString());
                                }

                                Debug.WriteLine(@"Types:");
                                foreach (PdbType type in reader.Types)
                                {
                                    Debug.WriteLine("\t" + type.Name);
                                    Debug.WriteLine("\t\tSymbols:");
                                    foreach (CvSymbol symbol in type.Symbols)
                                    {
                                        Debug.WriteLine("\t\t\t" + symbol.ToString());
                                    }

                                    Debug.WriteLine("\t\tLines:");
                                    foreach (CvLine line in type.LineNumbers)
                                    {
                                        Debug.WriteLine("\t\t\t" + line.ToString());
                                    }
                                }
                            }
                        }
                    }
                }
                catch (BadImageFormatException) {
                    ShowError(String.Format("Couldn't load input file {0} (invalid format).", file.FullName));
                    return;
                }

                // Create the compiler
                using (AotCompiler aot = new AotCompiler(this.architectureSelector.Architecture, assemblyModule)) {
                    aot.Pipeline.AddRange(new IAssemblyCompilerStage[] {
                        bootFormatStage,
                        new TypeLayoutStage(),
                        new MethodCompilerBuilderStage(),
                        new MethodCompilerRunnerStage(),
                        new TypeInitializers.TypeInitializerSchedulerStage(),
                        bootFormatStage,
                        new MetadataBuilderStage(),
                        new CilHeaderBuilderStage(),
                        new ObjectFileLayoutStage(),
                        linkerStage,
                        mapFileWrapper
                    });

                    aot.Run();
                }
            }
        }
예제 #3
0
        private void Compile()
        {
            using (CompilationRuntime runtime = new CompilationRuntime())
            {
                runtime.InitializePrivatePaths(this.GetInputFileNames());

                // Create the compiler
                using (AotCompiler aot = new AotCompiler(this.architectureSelector.Architecture, this.GetMainAssembly()))
                {
                    aot.Pipeline.AddRange(
                        new IAssemblyCompilerStage[]
                    {
                        this.bootFormatStage,
                        new x86.InterruptBuilderStage(),
                        new AssemblyCompilationStage(this.GetInputFileNames()),
                        new FakeSystemObjectGenerationStage(),
                        new MethodCompilerSchedulerStage(),
                        new TypeInitializers.TypeInitializerSchedulerStage(),
                        this.bootFormatStage,
                        new Metadata.MetadataBuilderStage(),
                        new CilHeaderBuilderStage(),
                        new ObjectFileLayoutStage(),
                        this.linkerStage,
                        this.mapFileWrapper
                    });

                    aot.Run();
                }
            }
        }
예제 #4
0
        private void Compile()
        {
            using (CompilationRuntime runtime = new CompilationRuntime()) {

                // Append the paths of the folder to the loader path
                List<string> paths = new List<string>();
                foreach (FileInfo assembly in this.inputFiles) {

                    string path = Path.GetDirectoryName(assembly.FullName);
                    if (!paths.Contains(path))
                        paths.Add(path);
                }

                // Append the search paths
                foreach (string path in paths)
                    runtime.AssemblyLoader.AppendPrivatePath(path);
                paths = null;

                /* FIXME: This only compiles the very first assembly, but we want to
                 * potentially merge multiple assemblies into our kernel. This will
                 * need an extension/modification of the assembly compiler method.
                 *
                // Load all input assemblies
                foreach (FileInfo assembly in this.inputFiles)
                {
                    IMetadataModule module = runtime.AssemblyLoader.Load(assembly.FullName);
                }
                 */

                IMetadataModule assemblyModule;
                FileInfo file = null;

                try {
                    file = this.inputFiles[0];
                    assemblyModule = runtime.AssemblyLoader.Load(file.FullName);

                    // Try to load debug information for the compilation
                    string dbgFile;
                    dbgFile = Path.Combine(Path.GetDirectoryName(file.FullName), Path.GetFileNameWithoutExtension(file.FullName) + ".pdb");
                    //dbgFile = Path.Combine(Path.GetDirectoryName(file.FullName), "mosacl.pdb");
                    if (File.Exists(dbgFile) == true) {
                        using (FileStream fileStream = new FileStream(dbgFile, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                            using (PdbReader reader = new PdbReader(fileStream)) {
                                Debug.WriteLine(@"Global symbols:");
                                foreach (CvSymbol symbol in reader.GlobalSymbols) {
                                    Debug.WriteLine("\t" + symbol.ToString());
                                }

                                Debug.WriteLine(@"Types:");
                                foreach (PdbType type in reader.Types) {
                                    Debug.WriteLine("\t" + type.Name);
                                    Debug.WriteLine("\t\tSymbols:");
                                    foreach (CvSymbol symbol in type.Symbols) {
                                        Debug.WriteLine("\t\t\t" + symbol.ToString());
                                    }

                                    Debug.WriteLine("\t\tLines:");
                                    foreach (CvLine line in type.LineNumbers) {
                                        Debug.WriteLine("\t\t\t" + line.ToString());
                                    }
                                }
                            }
                        }
                    }
                }
                catch (BadImageFormatException) {
                    ShowError(String.Format("Couldn't load input file {0} (invalid format).", file.FullName));
                    return;
                }

                // Create the compiler
                using (AotCompiler aot = new AotCompiler(this.architectureSelector.Architecture, assemblyModule)) {
                    aot.Pipeline.AddRange(new IAssemblyCompilerStage[] {
                        bootFormatStage,
                        new TypeLayoutStage(),
                        new MethodCompilerBuilderStage(),
                        new MethodCompilerRunnerStage(),
                        new TypeInitializers.TypeInitializerSchedulerStage(),
                        new x86.InterruptStage(),
                        bootFormatStage,
                        new MetadataBuilderStage(),
                        new CilHeaderBuilderStage(),
                        new ObjectFileLayoutStage(),
                        linkerStage,
                        mapFileWrapper
                    });

                    aot.Run();
                }
            }
        }
예제 #5
0
        private void Compile()
        {
            IAssemblyLoader assemblyLoader = new AssemblyLoader();
            assemblyLoader.InitializePrivatePaths(this.GetInputFileNames());

            ITypeSystem typeSystem = new DefaultTypeSystem(assemblyLoader);
            typeSystem.LoadModules(this.GetInputFileNames());

            // Create the compiler
            using (AotCompiler aot = new AotCompiler(this.architectureSelector.Architecture, typeSystem))
            {
                aot.Pipeline.AddRange(new IAssemblyCompilerStage[]
                    {
                        this.bootFormatStage,
                        new InterruptBuilderStage(),
                        new AssemblyCompilationStage(),
                        //new FakeSystemObjectGenerationStage(),
                        new MethodCompilerSchedulerStage(),
                        new TypeInitializers.TypeInitializerSchedulerStage(),
                        this.bootFormatStage,
                        new Metadata.MetadataBuilderStage(),
                        new CilHeaderBuilderStage(),
                        new ObjectFileLayoutStage(),
                        this.linkerStage,
                        this.mapFileWrapper
                    });

                aot.Run();
            }
        }
예제 #6
0
        private void Compile()
        {
            IAssemblyLoader assemblyLoader = new AssemblyLoader();
            assemblyLoader.InitializePrivatePaths(this.GetInputFileNames());

            foreach (string file in this.GetInputFileNames())
            {
                assemblyLoader.LoadModule(file);
            }

            ITypeSystem typeSystem = new TypeSystem();
            typeSystem.LoadModules(assemblyLoader.Modules);

            int nativePointerSize;
            int nativePointerAlignment;

            this.architectureSelector.Architecture.GetTypeRequirements(BuiltInSigType.IntPtr, out nativePointerSize, out nativePointerAlignment);

            TypeLayout typeLayout = new TypeLayout(typeSystem, nativePointerSize, nativePointerAlignment);

            // Create the compiler
            using (AotCompiler aot = new AotCompiler(this.architectureSelector.Architecture, typeSystem, typeLayout))
            {
                aot.Pipeline.AddRange(new IAssemblyCompilerStage[]
                    {
                        this.bootFormatStage,
                        new InterruptBuilderStage(),
                        new AssemblyCompilationStage(),
                        //new FakeSystemObjectGenerationStage(),
                        new MethodCompilerSchedulerStage(),
                        new TypeInitializers.TypeInitializerSchedulerStage(),
                        this.bootFormatStage,
                        new CilHeaderBuilderStage(),
                        new ObjectFileLayoutStage(),
                        this.linkerStage,
                        this.mapFileWrapper
                    });

                aot.Run();
            }
        }