Introduce debugging symbols #915
@ -64,7 +64,7 @@
|
|||||||
| nil
|
| nil
|
||||||
| {var, var_name()}
|
| {var, var_name()}
|
||||||
| {def, fun_name(), [fexpr()]}
|
| {def, fun_name(), [fexpr()]}
|
||||||
| {remote, [ftype()], ftype(), fexpr(), fun_name(), [fexpr()]}
|
| {remote, fann(), [ftype()], ftype(), fexpr(), fun_name(), [fexpr()]}
|
||||||
| {builtin, builtin(), [fexpr()]}
|
| {builtin, builtin(), [fexpr()]}
|
||||||
| {con, arities(), tag(), [fexpr()]}
|
| {con, arities(), tag(), [fexpr()]}
|
||||||
| {tuple, [fexpr()]}
|
| {tuple, [fexpr()]}
|
||||||
@ -738,7 +738,7 @@ expr_to_fcode(Env, _, {app, _, Fun = {typed, Ann, FunE, {fun_t, _, NamedArgsT, A
|
|||||||
end;
|
end;
|
||||||
{builtin_u, B, _Ar} -> builtin_to_fcode(state_layout(Env), B, FArgs);
|
{builtin_u, B, _Ar} -> builtin_to_fcode(state_layout(Env), B, FArgs);
|
||||||
{def_u, F, _Ar} -> {def, F, FArgs};
|
{def_u, F, _Ar} -> {def, F, FArgs};
|
||||||
{remote_u, Ann, RArgsT, RRetT, Ct, RFun} -> {remote, RArgsT, RRetT, Ct, RFun, FArgs};
|
{remote_u, Ann, RArgsT, RRetT, Ct, RFun} -> {remote, Ann, RArgsT, RRetT, Ct, RFun, FArgs};
|
||||||
FFun ->
|
FFun ->
|
||||||
%% FFun is a closure, with first component the function name and
|
%% FFun is a closure, with first component the function name and
|
||||||
%% second component the environment
|
%% second component the environment
|
||||||
@ -1267,13 +1267,13 @@ lambda_lift_expr(Layout, UExpr) when element(1, UExpr) == def_u; element(1, UExp
|
|||||||
def_u -> {def, F, Args}
|
def_u -> {def, F, Args}
|
||||||
end,
|
end,
|
||||||
make_closure([], Xs, Body);
|
make_closure([], Xs, Body);
|
||||||
lambda_lift_expr(Layout, {remote_u, _, ArgsT, RetT, Ct, F}) ->
|
lambda_lift_expr(Layout, {remote_u, Ann, ArgsT, RetT, Ct, F}) ->
|
||||||
FVs = free_vars(Ct),
|
FVs = free_vars(Ct),
|
||||||
Ct1 = lambda_lift_expr(Layout, Ct),
|
Ct1 = lambda_lift_expr(Layout, Ct),
|
||||||
NamedArgCount = 3,
|
NamedArgCount = 3,
|
||||||
Xs = [ lists:concat(["arg", I]) || I <- lists:seq(1, length(ArgsT) + NamedArgCount) ],
|
Xs = [ lists:concat(["arg", I]) || I <- lists:seq(1, length(ArgsT) + NamedArgCount) ],
|
||||||
Args = [{var, X} || X <- Xs],
|
Args = [{var, X} || X <- Xs],
|
||||||
make_closure(FVs, Xs, {remote, ArgsT, RetT, Ct1, F, Args});
|
make_closure(FVs, Xs, {remote, Ann, ArgsT, RetT, Ct1, F, Args});
|
||||||
lambda_lift_expr(Layout, Expr) ->
|
lambda_lift_expr(Layout, Expr) ->
|
||||||
case Expr of
|
case Expr of
|
||||||
{lit, _} -> Expr;
|
{lit, _} -> Expr;
|
||||||
@ -1282,7 +1282,7 @@ lambda_lift_expr(Layout, Expr) ->
|
|||||||
{closure, _, _, _} -> Expr;
|
{closure, _, _, _} -> Expr;
|
||||||
{def, D, As} -> {def, D, lambda_lift_exprs(Layout, As)};
|
{def, D, As} -> {def, D, lambda_lift_exprs(Layout, As)};
|
||||||
{builtin, B, As} -> {builtin, B, lambda_lift_exprs(Layout, As)};
|
{builtin, B, As} -> {builtin, B, lambda_lift_exprs(Layout, As)};
|
||||||
{remote, ArgsT, RetT, Ct, F, As} -> {remote, ArgsT, RetT, lambda_lift_expr(Layout, Ct), F, lambda_lift_exprs(Layout, As)};
|
{remote, Ann, ArgsT, RetT, Ct, F, As} -> {remote, Ann, ArgsT, RetT, lambda_lift_expr(Layout, Ct), F, lambda_lift_exprs(Layout, As)};
|
||||||
{con, Ar, C, As} -> {con, Ar, C, lambda_lift_exprs(Layout, As)};
|
{con, Ar, C, As} -> {con, Ar, C, lambda_lift_exprs(Layout, As)};
|
||||||
{tuple, As} -> {tuple, lambda_lift_exprs(Layout, As)};
|
{tuple, As} -> {tuple, lambda_lift_exprs(Layout, As)};
|
||||||
{proj, A, I} -> {proj, lambda_lift_expr(Layout, A), I};
|
{proj, A, I} -> {proj, lambda_lift_expr(Layout, A), I};
|
||||||
@ -1605,7 +1605,7 @@ read_only({builtin_u, _, _}) -> true;
|
|||||||
read_only({builtin_u, _, _, _}) -> true;
|
read_only({builtin_u, _, _, _}) -> true;
|
||||||
read_only({lam, _, _}) -> true;
|
read_only({lam, _, _}) -> true;
|
||||||
read_only({def, _, _}) -> false; %% TODO: purity analysis
|
read_only({def, _, _}) -> false; %% TODO: purity analysis
|
||||||
read_only({remote, _, _, _, _, _}) -> false;
|
read_only({remote, _, _, _, _, _, _}) -> false;
|
||||||
read_only({builtin, _, _}) -> false; %% TODO: some builtins are
|
read_only({builtin, _, _}) -> false; %% TODO: some builtins are
|
||||||
read_only({switch, Split}) -> read_only(Split);
|
read_only({switch, Split}) -> read_only(Split);
|
||||||
read_only({split, _, _, Cases}) -> read_only(Cases);
|
read_only({split, _, _, Cases}) -> read_only(Cases);
|
||||||
@ -1829,7 +1829,7 @@ free_vars(Expr) ->
|
|||||||
nil -> [];
|
nil -> [];
|
||||||
{def, _, As} -> free_vars(As);
|
{def, _, As} -> free_vars(As);
|
||||||
{def_u, _, _} -> [];
|
{def_u, _, _} -> [];
|
||||||
{remote, _, _, Ct, _, As} -> free_vars([Ct | As]);
|
{remote, _, _, _, Ct, _, As} -> free_vars([Ct | As]);
|
||||||
{remote_u, _, _, _, Ct, _} -> free_vars(Ct);
|
{remote_u, _, _, _, Ct, _} -> free_vars(Ct);
|
||||||
{builtin, _, As} -> free_vars(As);
|
{builtin, _, As} -> free_vars(As);
|
||||||
{builtin_u, _, _} -> [];
|
{builtin_u, _, _} -> [];
|
||||||
@ -1860,7 +1860,7 @@ used_defs(Expr) ->
|
|||||||
nil -> [];
|
nil -> [];
|
||||||
{def, F, As} -> lists:umerge([F], used_defs(As));
|
{def, F, As} -> lists:umerge([F], used_defs(As));
|
||||||
{def_u, F, _} -> [F];
|
{def_u, F, _} -> [F];
|
||||||
{remote, _, _, Ct, _, As} -> used_defs([Ct | As]);
|
{remote, _, _, _, Ct, _, As} -> used_defs([Ct | As]);
|
||||||
{remote_u, _, _, _, Ct, _} -> used_defs(Ct);
|
{remote_u, _, _, _, Ct, _} -> used_defs(Ct);
|
||||||
{builtin, _, As} -> used_defs(As);
|
{builtin, _, As} -> used_defs(As);
|
||||||
{builtin_u, _, _} -> [];
|
{builtin_u, _, _} -> [];
|
||||||
@ -1894,7 +1894,7 @@ bottom_up(F, Env, Expr) ->
|
|||||||
{builtin, B, Es} -> {builtin, B, [bottom_up(F, Env, E) || E <- Es]};
|
{builtin, B, Es} -> {builtin, B, [bottom_up(F, Env, E) || E <- Es]};
|
||||||
{builtin_u, _, _} -> Expr;
|
{builtin_u, _, _} -> Expr;
|
||||||
{builtin_u, _, _, _} -> Expr;
|
{builtin_u, _, _, _} -> Expr;
|
||||||
{remote, ArgsT, RetT, Ct, Fun, Es} -> {remote, ArgsT, RetT, bottom_up(F, Env, Ct), Fun, [bottom_up(F, Env, E) || E <- Es]};
|
{remote, Ann, ArgsT, RetT, Ct, Fun, Es} -> {remote, Ann, ArgsT, RetT, bottom_up(F, Env, Ct), Fun, [bottom_up(F, Env, E) || E <- Es]};
|
||||||
{remote_u, Ann, ArgsT, RetT, Ct, Fun} -> {remote_u, Ann, ArgsT, RetT, bottom_up(F, Env, Ct), Fun};
|
{remote_u, Ann, ArgsT, RetT, Ct, Fun} -> {remote_u, Ann, ArgsT, RetT, bottom_up(F, Env, Ct), Fun};
|
||||||
{con, Ar, I, Es} -> {con, Ar, I, [bottom_up(F, Env, E) || E <- Es]};
|
{con, Ar, I, Es} -> {con, Ar, I, [bottom_up(F, Env, E) || E <- Es]};
|
||||||
{tuple, Es} -> {tuple, [bottom_up(F, Env, E) || E <- Es]};
|
{tuple, Es} -> {tuple, [bottom_up(F, Env, E) || E <- Es]};
|
||||||
@ -1952,7 +1952,7 @@ rename(Ren, Expr) ->
|
|||||||
{builtin, B, Es} -> {builtin, B, [rename(Ren, E) || E <- Es]};
|
{builtin, B, Es} -> {builtin, B, [rename(Ren, E) || E <- Es]};
|
||||||
{builtin_u, _, _} -> Expr;
|
{builtin_u, _, _} -> Expr;
|
||||||
{builtin_u, _, _, _} -> Expr;
|
{builtin_u, _, _, _} -> Expr;
|
||||||
{remote, ArgsT, RetT, Ct, F, Es} -> {remote, ArgsT, RetT, rename(Ren, Ct), F, [rename(Ren, E) || E <- Es]};
|
{remote, Ann, ArgsT, RetT, Ct, F, Es} -> {remote, Ann, ArgsT, RetT, rename(Ren, Ct), F, [rename(Ren, E) || E <- Es]};
|
||||||
{remote_u, Ann, ArgsT, RetT, Ct, F} -> {remote_u, Ann, ArgsT, RetT, rename(Ren, Ct), F};
|
{remote_u, Ann, ArgsT, RetT, Ct, F} -> {remote_u, Ann, ArgsT, RetT, rename(Ren, Ct), F};
|
||||||
{con, Ar, I, Es} -> {con, Ar, I, [rename(Ren, E) || E <- Es]};
|
{con, Ar, I, Es} -> {con, Ar, I, [rename(Ren, E) || E <- Es]};
|
||||||
{tuple, Es} -> {tuple, [rename(Ren, E) || E <- Es]};
|
{tuple, Es} -> {tuple, [rename(Ren, E) || E <- Es]};
|
||||||
@ -2203,7 +2203,7 @@ pp_fexpr({builtin, B, As}) ->
|
|||||||
pp_call(pp_text(B), As);
|
pp_call(pp_text(B), As);
|
||||||
pp_fexpr({remote_u, _, ArgsT, RetT, Ct, Fun}) ->
|
pp_fexpr({remote_u, _, ArgsT, RetT, Ct, Fun}) ->
|
||||||
pp_beside([pp_fexpr(Ct), pp_text("."), pp_fun_name(Fun), pp_text(" : "), pp_ftype({function, ArgsT, RetT})]);
|
pp_beside([pp_fexpr(Ct), pp_text("."), pp_fun_name(Fun), pp_text(" : "), pp_ftype({function, ArgsT, RetT})]);
|
||||||
pp_fexpr({remote, ArgsT, RetT, Ct, Fun, As}) ->
|
pp_fexpr({remote, _, ArgsT, RetT, Ct, Fun, As}) ->
|
||||||
pp_call(pp_parens(pp_beside([pp_fexpr(Ct), pp_text("."), pp_fun_name(Fun), pp_text(" : "), pp_ftype({function, ArgsT, RetT})])), As);
|
pp_call(pp_parens(pp_beside([pp_fexpr(Ct), pp_text("."), pp_fun_name(Fun), pp_text(" : "), pp_ftype({function, ArgsT, RetT})])), As);
|
||||||
pp_fexpr({funcall, _, Fun, As}) ->
|
pp_fexpr({funcall, _, Fun, As}) ->
|
||||||
pp_call(pp_fexpr(Fun), As);
|
pp_call(pp_fexpr(Fun), As);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user