This commit is contained in:
andri lim 2019-02-22 16:05:21 +07:00 committed by zah
parent 7ff9a7f02e
commit 28245e92a2
2 changed files with 8 additions and 2 deletions

View File

@ -152,7 +152,9 @@ proc displayDecompiled*(c: CodeStream) =
for op in opcodes: for op in opcodes:
echo op[0], " ", op[1], " ", op[2] echo op[0], " ", op[1], " ", op[2]
proc hasSStore*(c: var CodeStream): bool = proc hasSStore*(c: var CodeStream): bool =
let opcodes = c.decompile() let opcodes = c.decompile()
result = opcodes.anyIt(it[1] == SSTORE) result = opcodes.anyIt(it[1] == SSTORE)
proc atEnd*(c: CodeStream): bool =
result = c.pc >= c.bytes.len

View File

@ -187,13 +187,17 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
# Add a branch for each (opcode, proc) pair # Add a branch for each (opcode, proc) pair
# We dispatch to the next instruction at the end of each branch # We dispatch to the next instruction at the end of each branch
for op, opImpl in opTable.pairs: for op, opImpl in opTable.pairs:
let asOp = quote do: Op(`op`) # TODO: unfortunately when passing to runtime, ops are transformed into int
let branchStmt = block: let branchStmt = block:
if op == Stop: if op == Stop:
quote do: quote do:
trace "op: Stop" trace "op: Stop"
if not `computation`.code.atEnd() and `computation`.tracingEnabled:
# we only trace `REAL STOP` and ignore `FAKE STOP`
let lastOpIndex = `computation`.traceOpCodeStarted(`asOp`)
`computation`.traceOpCodeEnded(`asOp`, lastOpIndex)
break break
else: else:
let asOp = quote do: Op(`op`) # TODO: unfortunately when passing to runtime, ops are transformed into int
if BaseGasCosts[op].kind == GckFixed: if BaseGasCosts[op].kind == GckFixed:
quote do: quote do:
var lastOpIndex: int var lastOpIndex: int