blob: ff0d27340c95b5ce17d9386d8a4c6e42f8985b0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import "macro-todo" as $
import "macro-todo" as {$, :$todo}
export macro config = (debugging = true)->
global debugMode = debugging == "true"
global debugMacro = true
""
export macro showMacro = (name, res)->
if debugMacro then "
do
txt = #{res}
print '[macro ' .. #{name} .. ']'
print txt
txt
"
else
res
export macro asserts = (cond)->
if debugMode
$showMacro "assert", "assert #{cond}"
else
""
export macro assert = (cond)->
if debugMode
$showMacro "assert", "assert #{cond}"
else
"#{cond}"
export macro copy = (src, dst, ...)->
assert(
src != "_src_" and src != "_dst_" and dst != "_src_" and dst != "_dst_"
"copy targets can not be _src_ or _dst_"
)
"
do
local _src_, _dst_
with _dst_ = #{dst}
with _src_ = #{src}
#{table.concat for field in *{...} do "
_dst_.#{field} = _src_.#{field}
"}"
$ ->
global debugMode = true
global debugMacro = true
|