From 4298553de48ba1a3bd9b98b4c1716674294cf4da Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 2 Oct 2014 10:52:32 +0200 Subject: system.writeFile works at compile-time --- compiler/vmops.nim | 9 +++++++++ todo.txt | 2 -- web/news.txt | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/vmops.nim b/compiler/vmops.nim index 8e75cc23a..aa25d208a 100644 --- a/compiler/vmops.nim +++ b/compiler/vmops.nim @@ -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) diff --git a/todo.txt b/todo.txt index b5d832fe0..ed09a21d1 100644 --- a/todo.txt +++ b/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 diff --git a/web/news.txt b/web/news.txt index 233a8e2c7..7edd7c9df 100644 --- a/web/news.txt +++ b/web/news.txt @@ -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 ----------------- -- cgit 1.4.1-2-gfad0