Esempio n. 1
0
        public IVMModuleArtifact GetVMModuleArtifact()
        {
            List <Module> modules = _input.GetModuleArtifacts().ConvertAll(m => (Module)m);

            Module mainModule = null;

            foreach (Module module in modules)
            {
                if (mainModule == null)
                {
                    mainModule = module;
                }
                else if (mainModule.LinkInModule(module))
                {
                    Diagnostics.Report(Diagnostics.Severity.Error, "Error linking module");
                }
            }

            return(ExecutionEngine.CreateForModule(mainModule !));
        }
Esempio n. 2
0
        public IVMModuleArtifact GetVMModuleArtifact()
        {
            List <ILModule> modules = _input.GetModuleArtifacts().ConvertAll(m => (ILModule)m);

            List <LinkError> linkErrors = new List <LinkError>();
            Linker           linker     = new Linker(linkErrors);

            foreach (ILModule module in modules)
            {
                linker.AddModule(module, export: true);
            }

            foreach (Binding binding in _job.InteropResolver.Bindings)
            {
                linker.AddFunctionBinding(binding.Prototype.Name, binding.Implementation, export: false);
            }

            VMModule vmModule = linker.Link();

            foreach (LinkError error in linkErrors)
            {
                Diagnostics.Report(Diagnostics.Severity.Error, $"Link error: {error.Message}");
            }

            Diagnostics.ThrowIfErrors();

            List <string> loadErrors = new List <string>();

            if (!_job.InteropResolver.PrepareForExecution(vmModule, loadErrors))
            {
                foreach (string error in loadErrors)
                {
                    Diagnostics.Report(Diagnostics.Severity.Error, $"Load error: {error}");
                }

                Diagnostics.ThrowIfErrors();
            }

            return(vmModule);
        }