more on continuation passsing

This commit is contained in:
andri lim 2019-04-04 15:21:24 +07:00
parent 60df7ea5e2
commit 039256de6a
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
4 changed files with 5 additions and 1 deletions

View File

@ -213,7 +213,6 @@ proc applyMessage*(computation: BaseComputation, opCode: static[Op]) =
postExecuteVM(computation) postExecuteVM(computation)
executeOpcodes(computation) executeOpcodes(computation)
computation.nextProc()
proc addChildComputation*(computation: BaseComputation, child: BaseComputation) = proc addChildComputation*(computation: BaseComputation, child: BaseComputation) =
if child.isError: if child.isError:

View File

@ -593,6 +593,7 @@ op create, inline = false, value, startPosition, size:
var childComp = setupCreate(computation, memPos, len, value) var childComp = setupCreate(computation, memPos, len, value)
if childComp.isNil: return if childComp.isNil: return
computation.child = childComp
continuation(childComp): continuation(childComp):
computation.addChildComputation(childComp) computation.addChildComputation(childComp)
@ -763,6 +764,7 @@ template genCall(callName: untyped, opCode: Op): untyped =
## STATICCALL, 0xfa, Static message-call into an account. ## STATICCALL, 0xfa, Static message-call into an account.
var childComp = `callName Setup`(computation, callName.astToStr) var childComp = `callName Setup`(computation, callName.astToStr)
computation.child = childComp
continuation(childComp): continuation(childComp):
addChildComputation(computation, childComp) addChildComputation(computation, childComp)

View File

@ -234,6 +234,7 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
try: try:
let fork = `computation`.getFork let fork = `computation`.getFork
if `computation`.execPrecompiles(fork): if `computation`.execPrecompiles(fork):
computation.nextProc()
return return
if `computation`.tracingEnabled: if `computation`.tracingEnabled:
@ -248,6 +249,7 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
let msg = getCurrentExceptionMsg() let msg = getCurrentExceptionMsg()
let errorMsg = "Opcode Dispatch Error msg=" & msg & ", depth=" & $computation.msg.depth let errorMsg = "Opcode Dispatch Error msg=" & msg & ", depth=" & $computation.msg.depth
`computation`.setError(errorMsg, true) `computation`.setError(errorMsg, true)
computation.nextProc()
macro genFrontierDispatch(computation: BaseComputation): untyped = macro genFrontierDispatch(computation: BaseComputation): untyped =
result = opTableToCaseStmt(FrontierOpDispatch, computation) result = opTableToCaseStmt(FrontierOpDispatch, computation)

View File

@ -71,6 +71,7 @@ type
nextProc*: proc() nextProc*: proc()
memOutLen*: int memOutLen*: int
memOutPos*: int memOutPos*: int
child*: BaseComputation
Error* = ref object Error* = ref object
info*: string info*: string