Beispiel #1
0
 internal CompiledAssembly(Document rootDoc, CodeAssembly asm)
 {
     Assembly = asm;
     Units = Assembly.EnumerateModules()
         .Select(n => Assembly.GetModule(Assembly.GetModuleHandle(n)))
         .Select(m => new CompiledUnit(new VirtualDocument(m.File), m))
         .ToList();
     var root = Assembly.GetRootModule();
     MainUnit = new CompiledUnit(rootDoc, root);
 }
Beispiel #2
0
        internal CompiledAssembly(Document rootDoc, CodeAssembly asm)
        {
            Assembly = asm;
            Units    = Assembly.EnumerateModules()
                       .Select(n => Assembly.GetModule(Assembly.GetModuleHandle(n)))
                       .Select(m => new CompiledUnit(new VirtualDocument(m.File.ToFileInfo()), m))
                       .ToList();
            var root = Assembly.GetRootModule();

            MainUnit = new CompiledUnit(rootDoc, root);
        }
        public Tuple<ICompiledUnit, IEnumerable<MessageItem>> Compile(CodeDocument doc, string source)
        {
            var par = new ElaParser();
            var parRes = par.Parse(source);
            var msg = new List<MessageItem>();
            var unit = doc.Unit;
            Func<ElaMessage,MessageItem> project = m => new MessageItem(
                m.Type == MessageType.Error ? MessageItemType.Error : MessageItemType.Warning, m.Message, doc, m.Line, m.Column);

            if (parRes.Success)
            {
                var copt = new CompilerOptions();

                copt.ShowHints = false;
                copt.GenerateDebugInfo = true;
                copt.IgnoreUndefined = true;

                //TODO: hack, should be taken from options
                copt.Prelude = "prelude";
                var comp = new ElaCompiler();

                try
                {
                    var compRes = comp.Compile(parRes.Program, copt, new ExportVars());
                    msg.AddRange(compRes.Messages.Where(m => m.Type != MessageType.Hint).Select(project));

                    if (compRes.CodeFrame != null)
                        unit = new CompiledUnit(doc, compRes.CodeFrame);
                }
                catch { }
            }
            else
                msg.AddRange(parRes.Messages.Select(project));

            return Tuple.Create(unit, (IEnumerable<MessageItem>)msg);
        }
Beispiel #4
0
 internal Reference(CompiledUnit unit, ModuleReference mod)
 {
     Module = mod;
     Unit   = unit;
 }
Beispiel #5
0
 internal Reference(CompiledUnit unit, ModuleReference mod)
 {
     Module = mod;
     Unit = unit;
 }