mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-14 23:33:28 +00:00
system.writeFile works at compile-time
This commit is contained in:
@@ -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)
|
||||
|
||||
2
todo.txt
2
todo.txt
@@ -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
|
||||
|
||||
@@ -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
|
||||
-----------------
|
||||
|
||||
Reference in New Issue
Block a user