Пример #1
0
        internal NsScriptProcess(NsScriptVM vm, NsScriptProcessDump dump)
        {
            VM         = vm;
            Id         = dump.Id;
            _clockBase = (int)Math.Round(Stopwatch.Frequency / 1000.0d * dump.ClockBaseMs);

            _threads             = new ArrayBuilder <NsScriptThread>(16);
            _newThreads          = new ArrayBuilder <uint>(8);
            _terminatedThreads   = new ArrayBuilder <uint>(8);
            PendingThreadActions = new Queue <ThreadAction>();

            NsScriptThread[] threads = dump.Threads
                                       .Select(x => new NsScriptThread(vm, this, x))
                                       .ToArray();
            _threads.AddRange(threads);

            foreach ((NsScriptThread thread, NsScriptThreadDump threadDump) in threads.Zip(dump.Threads))
            {
                if (threadDump.WaitingThread is uint waitingThread)
                {
                    thread.WaitingThread = threads.First(x => x.Id == waitingThread);
                }
            }

            MainThread = threads.First(x => x.Id == dump.MainThread);
            _clock     = Stopwatch.StartNew();
        }
Пример #2
0
        public TestContext()
        {
            var compCtx = new CompilationContext();

            TestModule = compCtx.TestModule;
            compCtx.Compilation.Emit(new[] { TestModule });
            using FileStream globals = File.OpenRead(
                      Path.Combine(compCtx.NsxDir, compCtx.GlobalsFileName)
                      );
            VM = new NsScriptVM(new FileSystemNsxModuleLocator(compCtx.NsxDir), globals);
            BuiltInFunctions = new MockBuiltInImpl();
        }
Пример #3
0
 public NsScriptProcess(NsScriptVM vm, uint id, NsScriptThread mainThread)
 {
     VM                   = vm;
     Id                   = id;
     MainThread           = mainThread;
     _threads             = new ArrayBuilder <NsScriptThread>(16);
     PendingThreadActions = new Queue <ThreadAction>();
     _newThreads          = new ArrayBuilder <uint>(8);
     _terminatedThreads   = new ArrayBuilder <uint>(8);
     _clockBase           = 0;
     _clock               = Stopwatch.StartNew();
     AttachThread(mainThread);
 }
Пример #4
0
 internal NsScriptThread(NsScriptVM vm, NsScriptProcess process, in NsScriptThreadDump dump)