system.writeFile works at compile-time

This commit is contained in:
Araq
2014-10-02 10:52:32 +02:00
parent c99ec16544
commit 4298553de4
3 changed files with 10 additions and 3 deletions

View File

@@ -21,6 +21,9 @@ template mathop(op) {.immediate, dirty.} =
template osop(op) {.immediate, dirty.} =
registerCallback(c, "stdlib.os." & astToStr(op), `op Wrapper`)
template systemop(op) {.immediate, dirty.} =
registerCallback(c, "stdlib.system." & astToStr(op), `op Wrapper`)
template wrap1f(op) {.immediate, dirty.} =
proc `op Wrapper`(a: VmArgs) {.nimcall.} =
setResult(a, op(getFloat(a, 0)))
@@ -36,6 +39,11 @@ template wrap1s(op) {.immediate, dirty.} =
setResult(a, op(getString(a, 0)))
osop op
template wrap2svoid(op) {.immediate, dirty.} =
proc `op Wrapper`(a: VmArgs) {.nimcall.} =
op(getString(a, 0), getString(a, 1))
systemop op
proc registerAdditionalOps*(c: PCtx) =
wrap1f(sqrt)
wrap1f(ln)
@@ -64,3 +72,4 @@ proc registerAdditionalOps*(c: PCtx) =
wrap1s(existsEnv)
wrap1s(dirExists)
wrap1s(fileExists)
wrap2svoid(writeFile)

View File

@@ -1,10 +1,8 @@
version 0.10
============
- document the new concurrency system
- Test nimfix on various babel packages
- deprecate recursive tuples; tuple needs laxer type checking
- string case should require an 'else'
- # echo type.int
- VM: try does not work at all
- VM: Pegs do not work at compile-time

View File

@@ -57,7 +57,7 @@ News
- There is a new ``parallel`` statement for safe fork&join parallel computing.
- ``guard`` and ``lock`` pragmas have been implemented to support safer
concurrent programming.
- ``system.writeFile`` can be used at compile-time.
Library Additions
-----------------