示例#1
0
        public void GenerateEil()
        {
            var cfg  = app.Config <EilGeneratorConfig>();
            var opts = cfg.GenerateInDebugMode ? new ExtendedOption[] { ElaCodeBuilder.ForceRecompile }
                : new ExtendedOption[] { ElaCodeBuilder.NoDebug, ElaCodeBuilder.ForceRecompile };

            var asm = app.GetService <ICodeBuilderService>().
                      RunBuilder <CompiledAssembly>(sci.Text, app.Document(), BuildOptions.Output | BuildOptions.ErrorList, opts);

            if (asm != null)
            {
                var frame = asm.Assembly.GetRootModule();
                var gen   = new EilGeneratorHelper(app);
                gen.PrintOffsets    = cfg.IncludeCodeOffsets;
                gen.IgnoreDebugInfo = !cfg.GenerateInDebugMode;
                var src = gen.Generate(frame);

                var editor = (EditorInfo)app.GetService <IEditorService>().GetInfo("editors", "EilCode");

                var fi  = new FileInfo(app.Document().Title);
                var doc = editor.Instance.CreateDocument(fi.Name.Replace(fi.Extension, editor.FileExtension));
                app.GetService <IDocumentService>().AddDocument(doc);
                ((ITextEditor)editor.Instance).SetContent(doc, src);
            }
        }
示例#2
0
        public void GenerateEil()
        {
            var cfg = app.Config<EilGeneratorConfig>();
            var opts = cfg.GenerateInDebugMode ? new ExtendedOption[] { ElaCodeBuilder.ForceRecompile }
                : new ExtendedOption[] { ElaCodeBuilder.NoDebug, ElaCodeBuilder.ForceRecompile };

            var asm = app.GetService<ICodeBuilderService>().
                RunBuilder<CompiledAssembly>(sci.Text, app.Document(), BuildOptions.Output | BuildOptions.ErrorList, opts);

            if (asm != null)
            {
                var frame = asm.Assembly.GetRootModule();
                var gen = new EilGeneratorHelper(app);
                gen.PrintOffsets = cfg.IncludeCodeOffsets;
                gen.IgnoreDebugInfo = !cfg.GenerateInDebugMode;
                var src = gen.Generate(frame);

                var editor = (EditorInfo)app.GetService<IEditorService>().GetInfo("editors", "EilCode");

                var fi = new FileInfo(app.Document().Title);
                var doc = editor.Instance.CreateDocument(fi.Name.Replace(fi.Extension, editor.FileExtension));
                app.GetService<IDocumentService>().AddDocument(doc);
                ((ITextEditor)editor.Instance).SetContent(doc, src);
            }
        }