예제 #1
0
        private CompiledAssembly InternalBuild(string source, Document doc, IBuildLogger logger, params ExtendedOption[] options)
        {
            logger.WriteBuildInfo("Ela", ElaVersionInfo.Version);

            var bo   = new BuildOptionsManager(App);
            var lopt = bo.CreateLinkerOptions();
            var copt = bo.CreateCompilerOptions();

            if (options.Set(ForceRecompile.Code))
            {
                lopt.ForceRecompile = true;
            }

            if (!options.Set(NoDebug.Code))
            {
                copt.GenerateDebugInfo = true;
            }

            if (options.Set(NoWarnings.Code))
            {
                copt.NoWarnings = true;
            }

            logger.WriteBuildOptions("Compiler options: {0}", copt);
            logger.WriteBuildOptions("Linker options: {0}", lopt);
            logger.WriteBuildOptions("Module lookup directories:");
            lopt.CodeBase.Directories.ForEach(d => logger.WriteBuildOptions(d));

            var lnk = new ElaIncrementalLinker(lopt, copt, doc.FileInfo == null ? new ModuleFileInfo(doc.Title) : doc.FileInfo.ToModuleFileInfo());

            lnk.ModuleResolve += (o, e) =>
            {
                //TBD
            };

            var res      = lnk.Build(source);
            var messages = res.Messages.Take(100).ToList();

            logger.WriteMessages(messages.Select(m =>
                                                 new MessageItem(
                                                     m.Type == MessageType.Error ? MessageItemType.Error : (m.Type == MessageType.Warning ? MessageItemType.Warning : MessageItemType.Information),
                                                     String.Format("ELA{0}: {1}", m.Code, m.Message),
                                                     m.File == null || !new FileInfo(m.File.FullName).Exists ? doc : new VirtualDocument(new FileInfo(m.File.FullName)),
                                                     m.Line,
                                                     m.Column)
            {
                Tag = m.Code
            })
                                 , m => (Int32)m.Tag < 600); //Exclude linker messages
            return(res.Success ? new CompiledAssembly(doc, res.Assembly) : null);
        }
예제 #2
0
        private CodeFrame Build(ModuleReference mod, FileInfo fi)
        {
            try
            {
                var elap = new ElaParser();
                var pres = elap.Parse(fi);

                if (pres.Success)
                {
                    var elac = new ElaCompiler();
                    var copt = new BuildOptionsManager(App).CreateCompilerOptions();
                    return(elac.Compile(pres.Program,
                                        new CompilerOptions {
                        IgnoreUndefined = true, NoWarnings = true, ShowHints = false, Prelude = copt.Prelude
                    },
                                        new ExportVars()
                                        ).CodeFrame);
                }
            }
            catch { }

            return(null);
        }