Refactor `stackTrace` in the `vm` implementation
haxscramper opened this issue · comments
VM rawExecute
uses an implicitly injected return
statement that is added by template stackTrace()
. This makes code much harder to read, since you can't properly see where the loop is terminated.
template stackTrace(
c: PCtx,
tos: PStackFrame,
pc: int,
sem: ReportTypes,
) =
stackTraceImpl(c, tos, pc, c.debug[pc], instLoc())
localReport(c.config, c.debug[pc], sem)
- return
Remove implicitly injected return
and add it in a way that is visible to the reader.
of opcLdArr:
# a = b[c]
decodeBC(rkNode)
if regs[rc].intVal > high(int):
stackTrace(c, tos, pc, reportVmIdx(regs[rc].intVal, high(int)))
+ return
Hint: in order to track all the usages of the stackTrace
template, you can add {.hint: "used here".}
or {.warning: "used here".}