Add fann() to remote_u
This commit is contained in:
parent
1043473696
commit
dd57fd9abe
@ -81,7 +81,7 @@
|
|||||||
%% lambdas) are generated by the fcode compiler, but translated
|
%% lambdas) are generated by the fcode compiler, but translated
|
||||||
%% to closures by the lambda lifter.
|
%% to closures by the lambda lifter.
|
||||||
| {def_u, fun_name(), arity()}
|
| {def_u, fun_name(), arity()}
|
||||||
| {remote_u, [ftype()], ftype(), fexpr(), fun_name()}
|
| {remote_u, fann(), [ftype()], ftype(), fexpr(), fun_name()}
|
||||||
| {builtin_u, builtin(), arity()}
|
| {builtin_u, builtin(), arity()}
|
||||||
| {builtin_u, builtin(), arity(), [fexpr()]} %% Typerep arguments to be added after normal args.
|
| {builtin_u, builtin(), arity(), [fexpr()]} %% Typerep arguments to be added after normal args.
|
||||||
| {lam, [var_name()], fexpr()}.
|
| {lam, [var_name()], fexpr()}.
|
||||||
@ -595,14 +595,14 @@ expr_to_fcode(Env, _Type, {tuple, _, Es}) ->
|
|||||||
make_tuple([expr_to_fcode(Env, E) || E <- Es]);
|
make_tuple([expr_to_fcode(Env, E) || E <- Es]);
|
||||||
|
|
||||||
%% Records
|
%% Records
|
||||||
expr_to_fcode(Env, Type, {proj, _Ann, Rec = {typed, _, _, RecType}, {id, _, X}}) ->
|
expr_to_fcode(Env, Type, {proj, Ann, Rec = {typed, _, _, RecType}, {id, _, X}}) ->
|
||||||
case RecType of
|
case RecType of
|
||||||
{con, _, _} when X == "address" ->
|
{con, _, _} when X == "address" ->
|
||||||
{op, contract_to_address, [expr_to_fcode(Env, Rec)]};
|
{op, contract_to_address, [expr_to_fcode(Env, Rec)]};
|
||||||
{con, _, _} ->
|
{con, _, _} ->
|
||||||
{fun_t, _, _, Args, Ret} = Type,
|
{fun_t, _, _, Args, Ret} = Type,
|
||||||
FArgs = [type_to_fcode(Env, Arg) || Arg <- Args],
|
FArgs = [type_to_fcode(Env, Arg) || Arg <- Args],
|
||||||
{remote_u, FArgs, type_to_fcode(Env, Ret), expr_to_fcode(Env, Rec),
|
{remote_u, to_fann(Ann), FArgs, type_to_fcode(Env, Ret), expr_to_fcode(Env, Rec),
|
||||||
{entrypoint, list_to_binary(X)}};
|
{entrypoint, list_to_binary(X)}};
|
||||||
{record_t, [_]} -> expr_to_fcode(Env, Rec); %% Singleton record
|
{record_t, [_]} -> expr_to_fcode(Env, Rec); %% Singleton record
|
||||||
{record_t, _} ->
|
{record_t, _} ->
|
||||||
@ -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, RArgsT, RRetT, Ct, RFun} -> {remote, RArgsT, RRetT, Ct, RFun, FArgs};
|
{remote_u, Ann, RArgsT, RRetT, Ct, RFun} -> {remote, 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,7 +1267,7 @@ 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, _, 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,
|
||||||
@ -1600,7 +1600,7 @@ read_only({op, _, Es}) -> read_only(Es);
|
|||||||
read_only({get_state, _}) -> true;
|
read_only({get_state, _}) -> true;
|
||||||
read_only({set_state, _, _, _}) -> false;
|
read_only({set_state, _, _, _}) -> false;
|
||||||
read_only({def_u, _, _}) -> true;
|
read_only({def_u, _, _}) -> true;
|
||||||
read_only({remote_u, _, _, _, _}) -> true;
|
read_only({remote_u, _, _, _, _, _}) -> true;
|
||||||
read_only({builtin_u, _, _}) -> true;
|
read_only({builtin_u, _, _}) -> true;
|
||||||
read_only({builtin_u, _, _, _}) -> true;
|
read_only({builtin_u, _, _, _}) -> true;
|
||||||
read_only({lam, _, _}) -> true;
|
read_only({lam, _, _}) -> true;
|
||||||
@ -1830,7 +1830,7 @@ free_vars(Expr) ->
|
|||||||
{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, _, _} -> [];
|
||||||
{builtin_u, _, _, _} -> []; %% Typereps are always literals
|
{builtin_u, _, _, _} -> []; %% Typereps are always literals
|
||||||
@ -1861,7 +1861,7 @@ used_defs(Expr) ->
|
|||||||
{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, _, _} -> [];
|
||||||
{builtin_u, _, _, _} -> [];
|
{builtin_u, _, _, _} -> [];
|
||||||
@ -1895,7 +1895,7 @@ bottom_up(F, Env, Expr) ->
|
|||||||
{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, ArgsT, RetT, Ct, Fun, Es} -> {remote, ArgsT, RetT, bottom_up(F, Env, Ct), Fun, [bottom_up(F, Env, E) || E <- Es]};
|
||||||
{remote_u, ArgsT, RetT, Ct, Fun} -> {remote_u, 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]};
|
||||||
{proj, E, I} -> {proj, bottom_up(F, Env, E), I};
|
{proj, E, I} -> {proj, bottom_up(F, Env, E), I};
|
||||||
@ -1953,7 +1953,7 @@ rename(Ren, Expr) ->
|
|||||||
{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, ArgsT, RetT, Ct, F, Es} -> {remote, ArgsT, RetT, rename(Ren, Ct), F, [rename(Ren, E) || E <- Es]};
|
||||||
{remote_u, ArgsT, RetT, Ct, F} -> {remote_u, 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]};
|
||||||
{proj, E, I} -> {proj, rename(Ren, E), I};
|
{proj, E, I} -> {proj, rename(Ren, E), I};
|
||||||
@ -2201,7 +2201,7 @@ pp_fexpr({builtin_u, B, N, TypeArgs}) ->
|
|||||||
pp_beside([pp_text(B), pp_text("@"), pp_fexpr({tuple, TypeArgs}), pp_text("/"), pp_text(N)]);
|
pp_beside([pp_text(B), pp_text("@"), pp_fexpr({tuple, TypeArgs}), pp_text("/"), pp_text(N)]);
|
||||||
pp_fexpr({builtin, B, As}) ->
|
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user