* implements https://github.com/nim-lang/RFCs/issues/258

* don't be too strict with custom pragma blocks

* cast pragmas: documentation

* added most missing inference query procs to effecttraits.nim
This commit is contained in:
Andreas Rumpf 2020-10-06 16:47:15 +02:00 • committed by GitHub
commit 92163fa330
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 232 additions and 68 deletions

View file

@ -262,11 +262,25 @@ proc registerAdditionalOps*(c: PCtx) =
registerCallback c, "stdlib.times.getTime", proc (a: VmArgs) {.nimcall.} =
setResult(a, times.getTime().toLit)
registerCallback c, "stdlib.effecttraits.getRaisesListImpl", proc (a: VmArgs) =
proc getEffectList(c: PCtx; a: VmArgs; effectIndex: int) =
let fn = getNode(a, 0)
if fn.typ != nil and fn.typ.n != nil and fn.typ.n[0].len >= effectListLen and
fn.typ.n[0][exceptionEffects] != nil:
fn.typ.n[0][effectIndex] != nil:
var list = newNodeI(nkBracket, fn.info)
for e in fn.typ.n[0][exceptionEffects]:
for e in fn.typ.n[0][effectIndex]:
list.add opMapTypeInstToAst(c.cache, e.typ.skipTypes({tyRef}), e.info)
setResult(a, list)
registerCallback c, "stdlib.effecttraits.getRaisesListImpl", proc (a: VmArgs) =
getEffectList(c, a, exceptionEffects)
registerCallback c, "stdlib.effecttraits.getTagsListImpl", proc (a: VmArgs) =
getEffectList(c, a, tagEffects)
registerCallback c, "stdlib.effecttraits.isGcSafeImpl", proc (a: VmArgs) =
let fn = getNode(a, 0)
setResult(a, fn.typ != nil and tfGcSafe in fn.typ.flags)
registerCallback c, "stdlib.effecttraits.hasNoSideEffectsImpl", proc (a: VmArgs) =
let fn = getNode(a, 0)
setResult(a, (fn.typ != nil and tfNoSideEffect in fn.typ.flags) or
(fn.kind == nkSym and fn.sym.kind == skFunc))