Пример #1
0
        protected void LoadAssembly(string filename, string platform, string includeDirectory = null)
        {
            Compiler.CompilerOptions.Architecture           = GetArchitecture(platform);
            Compiler.CompilerOptions.MultibootSpecification = MultibootSpecification.V1;

            Compiler.CompilerOptions.SearchPaths.Clear();
            Compiler.CompilerOptions.SourceFiles.Clear();

            Compiler.CompilerOptions.AddSearchPath(includeDirectory);
            Compiler.CompilerOptions.AddSearchPath(Path.GetDirectoryName(filename));

            Compiler.CompilerOptions.AddSourceFile(filename);
            Compiler.CompilerOptions.AddSourceFile("Mosa.Plug.Korlib.dll");
            Compiler.CompilerOptions.AddSourceFile("Mosa.Plug.Korlib." + platform + ".dll");

            var moduleLoader = new MosaModuleLoader();

            moduleLoader.AddSearchPaths(Compiler.CompilerOptions.SearchPaths);
            moduleLoader.LoadModuleFromFiles(Compiler.CompilerOptions.SourceFiles);

            var metadata = moduleLoader.CreateMetadata();

            var typeSystem = TypeSystem.Load(metadata);

            Compiler.Load(typeSystem);
        }
Пример #2
0
        public void Load()
        {
            lock (_lock)
            {
                var moduleLoader = new MosaModuleLoader();

                moduleLoader.AddSearchPaths(CompilerOptions.SearchPaths);
                moduleLoader.LoadModuleFromFiles(CompilerOptions.SourceFiles);

                var typeSystem = TypeSystem.Load(moduleLoader.CreateMetadata());

                Load(typeSystem);
            }
        }