From c9dcc815dc9ddce0981bf004453214e3d5aab929 Mon Sep 17 00:00:00 2001 From: Mike J Innes Date: Wed, 3 May 2017 18:33:23 +0100 Subject: [PATCH] add this for convenience --- src/compiler/code.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/code.jl b/src/compiler/code.jl index a5413501..11e3e611 100644 --- a/src/compiler/code.jl +++ b/src/compiler/code.jl @@ -83,10 +83,16 @@ function process_anon(ex) :(Capacitor($(DataFlow.constructor(mapconst(esc, makegraph(body, args)[1]))))) end +function process_def(ex) + # TODO: make a singleton net type + @capture(ex, f_(xs__) = body_) + :($(esc(f)) = @net $(esc(:(($(xs...),) -> $body)))) +end + macro net(ex) ex = shortdef(ex) isexpr(ex, :type) ? process_type(ex) : @capture(ex, (__,) -> _) ? process_anon(ex) : - @capture(ex, _(__) = _) ? error("@net functions not implemented") : + @capture(ex, _(__) = _) ? process_def(ex) : error("Unsupported model expression $ex") end