Compile to icode when no guards are used
This commit is contained in:
parent
6fa6dfbbc0
commit
a715cccd03
@ -96,7 +96,7 @@ contract_to_icode([Decl = {type_def, _Attrib, Id = {id, _, Name}, Args, Def} | R
|
|||||||
_ -> Icode1
|
_ -> Icode1
|
||||||
end,
|
end,
|
||||||
contract_to_icode(Rest, Icode2);
|
contract_to_icode(Rest, Icode2);
|
||||||
contract_to_icode([{letfun, Attrib, Name, Args, _What, Body={typed,_,_,T}}|Rest], Icode) ->
|
contract_to_icode([{letfun, Attrib, Name, Args, _What, [{guarded, _, [], Body={typed,_,_,T}}]}|Rest], Icode) ->
|
||||||
FunAttrs = [ stateful || proplists:get_value(stateful, Attrib, false) ] ++
|
FunAttrs = [ stateful || proplists:get_value(stateful, Attrib, false) ] ++
|
||||||
[ payable || proplists:get_value(payable, Attrib, false) ] ++
|
[ payable || proplists:get_value(payable, Attrib, false) ] ++
|
||||||
[ private || is_private(Attrib, Icode) ],
|
[ private || is_private(Attrib, Icode) ],
|
||||||
@ -323,8 +323,8 @@ ast_body({list_comp, _, Yield, []}, Icode) ->
|
|||||||
ast_body({list_comp, As, Yield, [{comprehension_bind, {typed, _, Pat, ArgType}, BindExpr}|Rest]}, Icode) ->
|
ast_body({list_comp, As, Yield, [{comprehension_bind, {typed, _, Pat, ArgType}, BindExpr}|Rest]}, Icode) ->
|
||||||
Arg = "%lc",
|
Arg = "%lc",
|
||||||
Body = {switch, As, {typed, As, {id, As, Arg}, ArgType},
|
Body = {switch, As, {typed, As, {id, As, Arg}, ArgType},
|
||||||
[{'case', As, Pat, {list_comp, As, Yield, Rest}},
|
[{'case', As, Pat, [{guarded, As, [], {list_comp, As, Yield, Rest}}]},
|
||||||
{'case', As, {id, As, "_"}, {list, As, []}}]},
|
{'case', As, {id, As, "_"}, [{guarded, As, [], {list, As, []}}]}]},
|
||||||
#funcall
|
#funcall
|
||||||
{ function = #var_ref{ name = ["ListInternal", "flat_map"] }
|
{ function = #var_ref{ name = ["ListInternal", "flat_map"] }
|
||||||
, args =
|
, args =
|
||||||
@ -349,14 +349,14 @@ ast_body({switch,_,A,Cases}, Icode) ->
|
|||||||
%% patterns appear in cases.
|
%% patterns appear in cases.
|
||||||
#switch{expr=ast_body(A, Icode),
|
#switch{expr=ast_body(A, Icode),
|
||||||
cases=[{ast_body(Pat, Icode),ast_body(Body, Icode)}
|
cases=[{ast_body(Pat, Icode),ast_body(Body, Icode)}
|
||||||
|| {'case',_,Pat,Body} <- Cases]};
|
|| {'case',_,Pat,[{guarded, _, [], Body}]} <- Cases]};
|
||||||
ast_body({block, As, [{letval, _, Pat, E} | Rest]}, Icode) ->
|
ast_body({block, As, [{letval, _, Pat, E} | Rest]}, Icode) ->
|
||||||
E1 = ast_body(E, Icode),
|
E1 = ast_body(E, Icode),
|
||||||
Pat1 = ast_body(Pat, Icode),
|
Pat1 = ast_body(Pat, Icode),
|
||||||
Rest1 = ast_body({block, As, Rest}, Icode),
|
Rest1 = ast_body({block, As, Rest}, Icode),
|
||||||
#switch{expr = E1,
|
#switch{expr = E1,
|
||||||
cases = [{Pat1, Rest1}]};
|
cases = [{Pat1, Rest1}]};
|
||||||
ast_body({block, As, [{letfun, Ann, F, Args, _Type, Expr} | Rest]}, Icode) ->
|
ast_body({block, As, [{letfun, Ann, F, Args, _Type, [{guarded, _, [], Expr}]} | Rest]}, Icode) ->
|
||||||
ToArg = fun({typed, Ann1, Id, T}) -> {arg, Ann1, Id, T} end, %% Pattern matching has been desugared
|
ToArg = fun({typed, Ann1, Id, T}) -> {arg, Ann1, Id, T} end, %% Pattern matching has been desugared
|
||||||
LamArgs = lists:map(ToArg, Args),
|
LamArgs = lists:map(ToArg, Args),
|
||||||
ast_body({block, As, [{letval, Ann, F, {lam, Ann, LamArgs, Expr}} | Rest]}, Icode);
|
ast_body({block, As, [{letval, Ann, F, {lam, Ann, LamArgs, Expr}} | Rest]}, Icode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user