parent
488f3ed085
commit
8397554315
4 changed files with 60 additions and 22 deletions
|
|
@ -62,9 +62,15 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
|
||||||
cbos listDirs:
|
cbos listDirs:
|
||||||
listDirs(a, {pcDir})
|
listDirs(a, {pcDir})
|
||||||
cbos removeDir:
|
cbos removeDir:
|
||||||
os.removeDir getString(a, 0)
|
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
|
||||||
|
discard
|
||||||
|
else:
|
||||||
|
os.removeDir getString(a, 0)
|
||||||
cbos removeFile:
|
cbos removeFile:
|
||||||
os.removeFile getString(a, 0)
|
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
|
||||||
|
discard
|
||||||
|
else:
|
||||||
|
os.removeFile getString(a, 0)
|
||||||
cbos createDir:
|
cbos createDir:
|
||||||
os.createDir getString(a, 0)
|
os.createDir getString(a, 0)
|
||||||
|
|
||||||
|
|
@ -76,20 +82,35 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
|
||||||
cbos getCurrentDir:
|
cbos getCurrentDir:
|
||||||
setResult(a, os.getCurrentDir())
|
setResult(a, os.getCurrentDir())
|
||||||
cbos moveFile:
|
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:
|
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:
|
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:
|
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:
|
cbos getLastModificationTime:
|
||||||
setResult(a, getLastModificationTime(getString(a, 0)).toUnix)
|
setResult(a, getLastModificationTime(getString(a, 0)).toUnix)
|
||||||
cbos findExe:
|
cbos findExe:
|
||||||
setResult(a, os.findExe(getString(a, 0)))
|
setResult(a, os.findExe(getString(a, 0)))
|
||||||
|
|
||||||
cbos rawExec:
|
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:
|
cbconf getEnv:
|
||||||
setResult(a, os.getEnv(a.getString 0, a.getString 1))
|
setResult(a, os.getEnv(a.getString 0, a.getString 1))
|
||||||
|
|
@ -164,11 +185,17 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
|
||||||
cbconf cppDefine:
|
cbconf cppDefine:
|
||||||
options.cppDefine(conf, a.getString(0))
|
options.cppDefine(conf, a.getString(0))
|
||||||
cbexc stdinReadLine, EOFError:
|
cbexc stdinReadLine, EOFError:
|
||||||
setResult(a, "")
|
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
|
||||||
setResult(a, stdin.readLine())
|
discard
|
||||||
|
else:
|
||||||
|
setResult(a, "")
|
||||||
|
setResult(a, stdin.readLine())
|
||||||
cbexc stdinReadAll, EOFError:
|
cbexc stdinReadAll, EOFError:
|
||||||
setResult(a, "")
|
if defined(nimsuggest) or graph.config.cmd == cmdCheck:
|
||||||
setResult(a, stdin.readAll())
|
discard
|
||||||
|
else:
|
||||||
|
setResult(a, "")
|
||||||
|
setResult(a, stdin.readAll())
|
||||||
|
|
||||||
proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
|
proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
|
||||||
freshDefines=true; conf: ConfigRef) =
|
freshDefines=true; conf: ConfigRef) =
|
||||||
|
|
|
||||||
|
|
@ -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],
|
regs[ra].node.strVal = opSlurp(regs[rb].node.strVal, c.debug[pc],
|
||||||
c.module, c.config)
|
c.module, c.config)
|
||||||
of opcGorge:
|
of opcGorge:
|
||||||
when defined(nimcore):
|
if defined(nimsuggest) or c.config.cmd == cmdCheck:
|
||||||
decodeBC(rkNode)
|
discard "don't run staticExec for 'nim suggest'"
|
||||||
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:
|
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:
|
of opcNError, opcNWarning, opcNHint:
|
||||||
decodeB(rkNode)
|
decodeB(rkNode)
|
||||||
let a = regs[ra].node
|
let a = regs[ra].node
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,14 @@ template wrap2svoid(op, modop) {.dirty.} =
|
||||||
op(getString(a, 0), getString(a, 1))
|
op(getString(a, 0), getString(a, 1))
|
||||||
modop op
|
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.} =
|
proc getCurrentExceptionMsgWrapper(a: VmArgs) {.nimcall.} =
|
||||||
setResult(a, if a.currentException.isNil: ""
|
setResult(a, if a.currentException.isNil: ""
|
||||||
else: a.currentException.sons[3].skipColon.strVal)
|
else: a.currentException.sons[3].skipColon.strVal)
|
||||||
|
|
@ -133,7 +141,7 @@ proc registerAdditionalOps*(c: PCtx) =
|
||||||
wrap2svoid(putEnv, osop)
|
wrap2svoid(putEnv, osop)
|
||||||
wrap1s(dirExists, osop)
|
wrap1s(dirExists, osop)
|
||||||
wrap1s(fileExists, osop)
|
wrap1s(fileExists, osop)
|
||||||
wrap2svoid(writeFile, ioop)
|
wrapDangerous(writeFile, ioop)
|
||||||
wrap1s(readFile, ioop)
|
wrap1s(readFile, ioop)
|
||||||
wrap2si(readLines, ioop)
|
wrap2si(readLines, ioop)
|
||||||
systemop getCurrentExceptionMsg
|
systemop getCurrentExceptionMsg
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue