MCPcopy Create free account
hub / github.com/QuipNetwork/xquad / step

Method step

xqvm_py/executor.py:264–308  ·  view source on GitHub ↗

Execute a single instruction. Returns: True if execution should continue, False if halted or at end Raises: XQVMError: On execution errors

(self)

Source from the content-addressed store, hash-verified

262 return self.state.steps
263
264 def step(self) -> bool:
265 """
266 Execute a single instruction.
267
268 Returns:
269 True if execution should continue, False if halted or at end
270
271 Raises:
272 XQVMError: On execution errors
273 """
274 if self.program is None:
275 return False
276
277 if self.state.halted or self.state.pc >= len(self.program):
278 return False
279
280 instr = self.program[self.state.pc]
281
282 if self.tracer:
283 self.tracer.on_step_begin(self, instr)
284
285 try:
286 handler = self._dispatch.get(instr.opcode)
287 if handler is None:
288 raise InvalidOpcode(instr.opcode)
289
290 old_pc = self.state.pc
291 handler(instr)
292
293 # Advance PC only if handler didn't modify it (via jump or halt)
294 if not self.state.halted and self.state.pc == old_pc:
295 self.state.advance_pc()
296
297 except Exception as e:
298 if self.tracer:
299 self.tracer.on_error(self, instr, e)
300 raise
301
302 if self.tracer:
303 if self.state.halted:
304 self.tracer.on_halt(self)
305 else:
306 self.tracer.on_step_end(self, instr)
307
308 return not self.state.halted
309
310 # =========================================================================
311 # Helper Methods

Callers 2

executeMethod · 0.95

Calls 7

InvalidOpcodeClass · 0.85
advance_pcMethod · 0.80
on_step_beginMethod · 0.45
getMethod · 0.45
on_errorMethod · 0.45
on_haltMethod · 0.45
on_step_endMethod · 0.45

Tested by 1