Exemplo n.º 1
0
 internal WorkerThread(CodeAssembly asm)
 {
     Assembly = asm;
     Module = asm.GetRootModule();
     CallStack = new CallStack();
     Context = new ExecutionContext();
 }
Exemplo n.º 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), m))
         .ToList();
     var root = Assembly.GetRootModule();
     MainUnit = new CompiledUnit(rootDoc, root);
 }
Exemplo n.º 3
0
 internal LinkerResult(CodeAssembly asm, bool success, IEnumerable <ElaMessage> messages) :
     base(success, messages)
 {
     Assembly = asm;
 }
Exemplo n.º 4
0
 internal ElaDebugger(CodeAssembly asm)
 {
     Assembly = asm;
 }
Exemplo n.º 5
0
 internal LinkerResult(CodeAssembly asm, bool success, IEnumerable<ElaMessage> messages)
     : base(success, messages)
 {
     Assembly = asm;
 }
Exemplo n.º 6
0
 //GIT
 private static void Warmup(CodeAssembly asm)
 {
     helper.PrintExecuteFirstTime();
     new ElaMachine(asm).Run();
     helper.PrintExecuteSecondTime();
 }
Exemplo n.º 7
0
        private static int Execute(CodeAssembly asm, bool interactive)
        {
            var mod = asm.GetRootModule();

            if (opt.ShowEil)
            {
                var gen = new EilGenerator(mod);
                Console.WriteLine("EIL ({0}-{1}):", lastOffset, mod.Ops.Count - 1);
                Console.Write(gen.Generate(lastOffset));
                lastOffset = mod.Ops.Count;
            }
            else if (opt.ShowSymbols != SymTables.None)
            {
                var gen = new DebugReader(mod.Symbols);
                helper.PrintSymTables(gen);
                lastOffset = mod.Ops.Count;
            }
            else
            {
                try
                {
                    if (vm == null)
                        vm = new ElaMachine(asm);
                    else
                    {
                        vm.RefreshState();
                        vm.Recover();
                    }

                    if (opt.ShowTime && !interactive)
                        Warmup(asm); //GIT

                    var os = lastOffset;
                    lastOffset = mod.Ops.Count;
                    var sw = new Stopwatch();
                    sw.Start();
                    var exer = vm.Run(os);
                    sw.Stop();

                    if (opt.ShowTime && !interactive)
                        Console.WriteLine("Execution time: {0}", sw.Elapsed);

                    if (exer.ReturnValue.TypeCode != ElaTypeCode.None && exer.ReturnValue.TypeCode != ElaTypeCode.Unit)
                        Console.WriteLine(vm.PrintValue(exer.ReturnValue));
                }
                catch (ElaException ex)
                {
                    helper.PrintError(ex.ToString());
                    return R_ERR;
                }
            }

            return R_OK;
        }
Exemplo n.º 8
0
 internal virtual ElaValue Untag(CodeAssembly asm, ExecutionContext ctx, int index)
 {
     ctx.Fail(new ElaError(ElaRuntimeError.InvalidTypeArgument, "<>", GetTypeName(), index + 1));
     return Default();
 }