Beispiel #1
0
 internal WorkerThread(CodeAssembly asm)
 {
     Assembly = asm;
     Module = asm.GetRootModule();
     CallStack = new CallStack();
     Context = new ExecutionContext();
 }
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), m))
         .ToList();
     var root = Assembly.GetRootModule();
     MainUnit = new CompiledUnit(rootDoc, root);
 }
Beispiel #3
0
 internal LinkerResult(CodeAssembly asm, bool success, IEnumerable <ElaMessage> messages) :
     base(success, messages)
 {
     Assembly = asm;
 }
Beispiel #4
0
 internal ElaDebugger(CodeAssembly asm)
 {
     Assembly = asm;
 }
Beispiel #5
0
 internal LinkerResult(CodeAssembly asm, bool success, IEnumerable<ElaMessage> messages)
     : base(success, messages)
 {
     Assembly = asm;
 }
Beispiel #6
0
 //GIT
 private static void Warmup(CodeAssembly asm)
 {
     helper.PrintExecuteFirstTime();
     new ElaMachine(asm).Run();
     helper.PrintExecuteSecondTime();
 }
Beispiel #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;
        }
Beispiel #8
0
 internal virtual ElaValue Untag(CodeAssembly asm, ExecutionContext ctx, int index)
 {
     ctx.Fail(new ElaError(ElaRuntimeError.InvalidTypeArgument, "<>", GetTypeName(), index + 1));
     return Default();
 }