Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 84 lines (68 sloc) 1.349 kb
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
-module(ex_codegen).

-compile({parse_transform, parse_trans_codegen}).

-export([f/1, g/2, h/0, i/0, j/2, k/0, k/1, gen/2, fs/0]).

%%-pt_pp_forms(true).
-pt_pp_src(true).

f(Name) ->
    codegen:gen_function(
      Name,
      fun(1,2,3) ->
foo;
(A,B,C) ->
{A,B,C}
      end).



g(Name, V) ->
    codegen:gen_function(
      Name,
      fun(L) ->
member({'$var',V}, L)
      end).

h() ->
    codegen:gen_function(
      funny,
      fun() ->
fun gen/2
      end).

i() ->
    codegen:exprs(fun(X) ->
case X of 1 ->
is_1;
Other ->
{is_other,Other}
end
end).

j(Name, Form) ->
    codegen:gen_function(
      Name,
      fun(L) ->
member({'$form',Form}, L)
      end).

x() ->
    [(fun(X) ->
X
      end)(X1) || X1 <- [1,2]].

k() ->
    codegen:gen_function(
      lcf,
      [fun({'$var',X}) ->
{'$var',Y}
       end || {X, Y} <- [{1,a},{2,b},{3,c}]]).

k(L) ->
    codegen:gen_function(
      lcf,
      [fun({'$var',X}) ->
{'$var',Y}
       end || {X, Y} <- L]).

gen(Name, X) ->
    codegen:gen_function(Name, fun(L) -> lists:member({'$var',X}, L) end).

fs() ->
    V = local_V,
    codegen:gen_functions(
      [{foo, fun() ->
foo
end},
       {h1, fun h/0},
       {g1, fun g/2},
       {bar, fun() ->
bar
end}]).
Something went wrong with that request. Please try again.