Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

envPairs works in vm, nims #18615

Merged
merged 2 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions compiler/vmops.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ from std/math import sqrt, ln, log10, log2, exp, round, arccos, arcsin,
arctan, arctan2, cos, cosh, hypot, sinh, sin, tan, tanh, pow, trunc,
floor, ceil, `mod`, cbrt, arcsinh, arccosh, arctanh, erf, erfc, gamma,
lgamma

from std/sequtils import toSeq
when declared(math.copySign):
# pending bug #18762, avoid renaming math
from std/math as math2 import copySign
Expand All @@ -22,8 +22,8 @@ when declared(math.signbit):
# ditto
from std/math as math3 import signbit

from std/os import getEnv, existsEnv, delEnv, putEnv, dirExists, fileExists, walkDir,
getAppFilename, raiseOSError, osLastError
from std/os import getEnv, existsEnv, delEnv, putEnv, envPairs,
dirExists, fileExists, walkDir, getAppFilename, raiseOSError, osLastError

from std/md5 import getMD5
from std/times import cpuTime
Expand Down Expand Up @@ -156,6 +156,12 @@ proc stackTrace2(c: PCtx, msg: string, n: PNode) =
stackTrace(c, PStackFrame(prc: c.prc.sym, comesFrom: 0, next: nil), c.exceptionInstr, msg, n.info)

proc registerAdditionalOps*(c: PCtx) =

template wrapIterator(fqname: string, iter: untyped) =
registerCallback c, fqname, proc(a: VmArgs) =
setResult(a, toLit(toSeq(iter)))


proc gorgeExWrapper(a: VmArgs) =
let ret = opGorge(getString(a, 0), getString(a, 1), getString(a, 2),
a.currentLineInfo, c.config)
Expand Down Expand Up @@ -341,3 +347,5 @@ proc registerAdditionalOps*(c: PCtx) =
let p = a.getVar(0)
let x = a.getFloat(1)
addFloatSprintf(p.strVal, x)

wrapIterator("stdlib.os.envPairsImplSeq"): envPairs()
Loading