compile output test

This commit is contained in:
Jaremy Creechley 2024-02-15 00:22:55 -07:00
parent 498b3413fa
commit 663e19a11a

View File

@ -83,6 +83,7 @@ template checkJobArgs*[T](exp: seq[T]): OpenArrayHolder[T] =
discard val.len() discard val.len()
expPtr expPtr
template checkJobArgs*(exp: typed): auto = template checkJobArgs*(exp: typed): auto =
# static: # static:
# echo "checkJobArgs:: ", $typeof(exp) # echo "checkJobArgs:: ", $typeof(exp)
@ -92,10 +93,8 @@ macro submitMacro(tp: untyped, jobs: untyped, exp: untyped): untyped =
## modifies the call expression to include the job queue and ## modifies the call expression to include the job queue and
## the job id parameters ## the job id parameters
# let jobRes = genSym(nskLet, "jobRes") let jobRes = genSym(nskLet, "jobResTmp")
# let futName = genSym(nskLet, "fut") let futName = genSym(nskLet, "fut")
let jobRes = ident("jobRes")
let futName = ident("fut")
let nm = newLit(repr(exp)) let nm = newLit(repr(exp))
# var fncall = exp # var fncall = exp
# exp.insert(1, jobRes) # exp.insert(1, jobRes)
@ -107,9 +106,9 @@ macro submitMacro(tp: untyped, jobs: untyped, exp: untyped): untyped =
result = quote do: result = quote do:
block: block:
let (`jobRes`, `futName`) = createFuture(`jobs`, `nm`) let (`jobRes`, `futName`) = createFuture(`jobs`, `nm`)
when typeof(`fncall`) isnot void: # when typeof(`fncall`) isnot void:
{.error: "Apatheia jobs cannot return values. The given proc returns type: " & $(typeof(`fncall`)) & # {.error: "Apatheia jobs cannot return values. The given proc returns type: " & $(typeof(`fncall`)) &
" for call " & astToStr(`fncall`).} # " for call " & astToStr(`fncall`).}
`jobs`.taskpool.spawn(`fncall`) `jobs`.taskpool.spawn(`fncall`)
`futName` `futName`