Added std/effecttraits.nim (#15462)

This commit is contained in:
Andreas Rumpf 2020-10-02 17:22:31 +02:00 • committed by GitHub
commit 1f4b9cebd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 1 deletions

View file

@ -261,3 +261,12 @@ proc registerAdditionalOps*(c: PCtx) =
a.setResult osproc.execCmdEx(getString(a, 0), options).toLit
registerCallback c, "stdlib.times.getTime", proc (a: VmArgs) {.nimcall.} =
setResult(a, times.getTime().toLit)
registerCallback c, "stdlib.effecttraits.getRaisesListImpl", proc (a: VmArgs) =
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:
var list = newNodeI(nkBracket, fn.info)
for e in fn.typ.n[0][exceptionEffects]:
list.add opMapTypeInstToAst(c.cache, e.typ.skipTypes({tyRef}), e.info)
setResult(a, list)