* fixes #12125
This commit is contained in:
Andreas Rumpf 2019-09-06 07:23:59 +02:00 • committed by GitHub
commit 8397554315
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 22 deletions

View file

@ -62,9 +62,15 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
cbos listDirs:
listDirs(a, {pcDir})
cbos removeDir:
os.removeDir getString(a, 0)
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
discard
else:
os.removeDir getString(a, 0)
cbos removeFile:
os.removeFile getString(a, 0)
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
discard
else:
os.removeFile getString(a, 0)
cbos createDir:
os.createDir getString(a, 0)
@ -76,20 +82,35 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
cbos getCurrentDir:
setResult(a, os.getCurrentDir())
cbos moveFile:
os.moveFile(getString(a, 0), getString(a, 1))
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
discard
else:
os.moveFile(getString(a, 0), getString(a, 1))
cbos moveDir:
os.moveDir(getString(a, 0), getString(a, 1))
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
discard
else:
os.moveDir(getString(a, 0), getString(a, 1))
cbos copyFile:
os.copyFile(getString(a, 0), getString(a, 1))
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
discard
else:
os.copyFile(getString(a, 0), getString(a, 1))
cbos copyDir:
os.copyDir(getString(a, 0), getString(a, 1))
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
discard
else:
os.copyDir(getString(a, 0), getString(a, 1))
cbos getLastModificationTime:
setResult(a, getLastModificationTime(getString(a, 0)).toUnix)
cbos findExe:
setResult(a, os.findExe(getString(a, 0)))
cbos rawExec:
setResult(a, osproc.execCmd getString(a, 0))
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
discard
else:
setResult(a, osproc.execCmd getString(a, 0))
cbconf getEnv:
setResult(a, os.getEnv(a.getString 0, a.getString 1))
@ -164,11 +185,17 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
cbconf cppDefine:
options.cppDefine(conf, a.getString(0))
cbexc stdinReadLine, EOFError:
setResult(a, "")
setResult(a, stdin.readLine())
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
discard
else:
setResult(a, "")
setResult(a, stdin.readLine())
cbexc stdinReadAll, EOFError:
setResult(a, "")
setResult(a, stdin.readAll())
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
discard
else:
setResult(a, "")
setResult(a, stdin.readAll())
proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
freshDefines=true; conf: ConfigRef) =

View file

@ -1549,17 +1549,20 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
regs[ra].node.strVal = opSlurp(regs[rb].node.strVal, c.debug[pc],
c.module, c.config)
of opcGorge:
when defined(nimcore):
decodeBC(rkNode)
inc pc
let rd = c.code[pc].regA
createStr regs[ra]
regs[ra].node.strVal = opGorge(regs[rb].node.strVal,
regs[rc].node.strVal, regs[rd].node.strVal,
c.debug[pc], c.config)[0]
if defined(nimsuggest) or c.config.cmd == cmdCheck:
discard "don't run staticExec for 'nim suggest'"
else:
globalError(c.config, c.debug[pc], "VM is not built with 'gorge' support")
when defined(nimcore):
decodeBC(rkNode)
inc pc
let rd = c.code[pc].regA
createStr regs[ra]
regs[ra].node.strVal = opGorge(regs[rb].node.strVal,
regs[rc].node.strVal, regs[rd].node.strVal,
c.debug[pc], c.config)[0]
else:
globalError(c.config, c.debug[pc], "VM is not built with 'gorge' support")
of opcNError, opcNWarning, opcNHint:
decodeB(rkNode)
let a = regs[ra].node

View file

@ -77,6 +77,14 @@ template wrap2svoid(op, modop) {.dirty.} =
op(getString(a, 0), getString(a, 1))
modop op
template wrapDangerous(op, modop) {.dirty.} =
proc `op Wrapper`(a: VmArgs) {.nimcall.} =
if defined(nimsuggest) or c.config.cmd == cmdCheck:
discard
else:
op(getString(a, 0), getString(a, 1))
modop op
proc getCurrentExceptionMsgWrapper(a: VmArgs) {.nimcall.} =
setResult(a, if a.currentException.isNil: ""
else: a.currentException.sons[3].skipColon.strVal)
@ -133,7 +141,7 @@ proc registerAdditionalOps*(c: PCtx) =
wrap2svoid(putEnv, osop)
wrap1s(dirExists, osop)
wrap1s(fileExists, osop)
wrap2svoid(writeFile, ioop)
wrapDangerous(writeFile, ioop)
wrap1s(readFile, ioop)
wrap2si(readLines, ioop)
systemop getCurrentExceptionMsg