implements https://github.com/nim-lang/RFCs/issues/258 (#15503)
* 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:
parent
acd71dd6bb
commit
92163fa330
16 changed files with 232 additions and 68 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue