def run_until_halt(vm): log = [] i = 0 push_counts = Counter() while True: try: if vm.pc.op.get_op() == OPS["spush"]: push_counts[vm.pc.path[-1][5:-1]] += 1 run = arb.run_vm_once(vm) if not run: print("Hit blocked insn") break i += 1 except Exception as err: print("Error at", vm.pc.pc - 1, vm.code[vm.pc.pc - 1]) print("Context", vm.code[vm.pc.pc - 6:vm.pc.pc + 4]) raise err if vm.halted: break for log in vm.logs: vm.output_handler(log) vm.logs = [] print("Ran VM for {} steps".format(i)) # print(push_counts) return log
def run_until_halt(vm): log = [] i = 0 push_counts = Counter() while True: # if ( # vm.pc.op.get_op() == OPS["auxpush"] or # vm.pc.op.get_op() == OPS["auxpop"] # ): # print(vm.pc, vm.aux_stack[:]) # print(vm.pc, vm.stack[:]) # log.append((vm.pc, vm.stack[:])) # print(vm.pc, vm.stack.items[:5]) try: if vm.pc.op.get_op() == OPS["spush"]: push_counts[vm.pc.path[-1][5:-1]] += 1 keep_going = arb.run_vm_once(vm) if not keep_going: break i += 1 except Exception as err: print("Error at", vm.pc.pc - 1, vm.code[vm.pc.pc - 1]) print("Context", vm.code[vm.pc.pc - 6:vm.pc.pc + 4]) raise err if vm.halted: break print("Ran VM for {} steps".format(i)) # print(push_counts) return log
def run_n_steps(vm, steps): log = [] i = 0 while i < steps: log.append((vm.pc.pc, vm.stack[:])) try: # print(vm.pc, vm.stack[:]) arb.run_vm_once(vm) i += 1 except Exception as err: print("Error at", vm.pc.pc - 1, vm.code[vm.pc.pc - 1]) print("Context", vm.code[vm.pc.pc - 6:vm.pc.pc + 4]) raise err if vm.halted: break print("Ran VM for {} steps".format(i)) return log
def run_until_block(vm, test): while True: try: run = run_vm_once(vm) if not run: break except Exception as err: test.fail("VM run hit error " + err) if vm.halted: test.fail("VM unintentionally halted")
def run_until_block(vm, test): while True: try: # print(vm.pc, vm.pc.path) run = run_vm_once(vm) if not run: break except Exception as err: test.fail("VM run hit error {}".format(err)) if vm.halted: test.fail("VM unintentionally halted")
def run_until_halt(vm): i = 0 while True: try: run = arb.run_vm_once(vm) if not run: print("Hit blocked insn") break i += 1 except Exception as err: print("Error at", vm.pc.pc - 1, vm.code[vm.pc.pc - 1]) print("Context", vm.code[vm.pc.pc - 6:vm.pc.pc + 4]) raise err if vm.halted: break logs = vm.logs vm.logs = [] print("Ran VM for {} steps".format(i)) return logs