newruntime: progress to make 'async' work with --newruntime

This commit is contained in:
Araq 2019-07-15 10:56:20 +02:00
commit edbe02b4e1
3 changed files with 8 additions and 9 deletions

View file

@ -154,7 +154,7 @@ type
uninit: IntSet # set of uninit'ed vars uninit: IntSet # set of uninit'ed vars
uninitComputed: bool uninitComputed: bool
const toDebug = "" # "serverNimAsyncContinue" const toDebug = "" # "server" # "serverNimAsyncContinue"
template dbg(body) = template dbg(body) =
when toDebug.len > 0: when toDebug.len > 0:
@ -311,6 +311,8 @@ proc checkForErrorPragma(c: Con; t: PType; ri: PNode; opname: string) =
m.add "; try to make " m.add "; try to make "
m.add renderTree(ri) m.add renderTree(ri)
m.add " a 'sink' parameter" m.add " a 'sink' parameter"
m.add "; routine: "
m.add c.owner.name.s
localError(c.graph.config, ri.info, errGenerated, m) localError(c.graph.config, ri.info, errGenerated, m)
proc makePtrType(c: Con, baseType: PType): PType = proc makePtrType(c: Con, baseType: PType): PType =

View file

@ -344,7 +344,7 @@ proc createUpField(c: var DetectionPass; dest, dep: PSym; info: TLineInfo) =
# with cycles properly, so it's better to produce a weak ref (=ptr) here. # with cycles properly, so it's better to produce a weak ref (=ptr) here.
# This seems to be generally correct but since it's a bit risky it's only # This seems to be generally correct but since it's a bit risky it's only
# enabled for gcDestructors. # enabled for gcDestructors.
let fieldType = if c.graph.config.selectedGC == gcDestructors: let fieldType = if false: # c.graph.config.selectedGC == gcDestructors:
c.getEnvTypeForOwnerUp(dep, info) #getHiddenParam(dep).typ c.getEnvTypeForOwnerUp(dep, info) #getHiddenParam(dep).typ
else: else:
c.getEnvTypeForOwner(dep, info) c.getEnvTypeForOwner(dep, info)

View file

@ -25,9 +25,9 @@ proc skipStmtList(node: NimNode): NimNode {.compileTime.} =
template createCb(retFutureSym, iteratorNameSym, template createCb(retFutureSym, iteratorNameSym,
strName, identName, futureVarCompletions: untyped) = strName, identName, futureVarCompletions: untyped) =
bind finished bind finished
let retFutUnown = unown retFutureSym
var nameIterVar = iteratorNameSym var nameIterVar = iteratorNameSym
#{.push stackTrace: off.}
proc identName {.closure.} = proc identName {.closure.} =
try: try:
if not nameIterVar.finished: if not nameIterVar.finished:
@ -39,7 +39,7 @@ template createCb(retFutureSym, iteratorNameSym,
break break
if next == nil: if next == nil:
if not retFutureSym.finished: if not retFutUnown.finished:
let msg = "Async procedure ($1) yielded `nil`, are you await'ing a " & let msg = "Async procedure ($1) yielded `nil`, are you await'ing a " &
"`nil` Future?" "`nil` Future?"
raise newException(AssertionError, msg % strName) raise newException(AssertionError, msg % strName)
@ -50,16 +50,13 @@ template createCb(retFutureSym, iteratorNameSym,
{.pop.} {.pop.}
except: except:
futureVarCompletions futureVarCompletions
if retFutUnown.finished:
if retFutureSym.finished:
# Take a look at tasyncexceptions for the bug which this fixes. # Take a look at tasyncexceptions for the bug which this fixes.
# That test explains it better than I can here. # That test explains it better than I can here.
raise raise
else: else:
retFutureSym.fail(getCurrentException()) retFutUnown.fail(getCurrentException())
identName() identName()
#{.pop.}
template useVar(result: var NimNode, futureVarNode: NimNode, valueReceiver, template useVar(result: var NimNode, futureVarNode: NimNode, valueReceiver,
rootReceiver: untyped, fromNode: NimNode) = rootReceiver: untyped, fromNode: NimNode) =