Add DBG_LOC op to step at function sig
This commit is contained in:
parent
ee4c0eee34
commit
864189ee5e
@ -120,7 +120,7 @@
|
||||
| any
|
||||
| {tvar, var_name()}.
|
||||
|
||||
-type fun_def() :: #{ attrs := [attribute()],
|
||||
-type fun_def() :: #{ attrs := [attribute() | fann()],
|
||||
args := [{var_name(), ftype()}],
|
||||
return := ftype(),
|
||||
body := fexpr() }.
|
||||
@ -408,8 +408,11 @@ decls_to_fcode(Env, Decls) ->
|
||||
decl_to_fcode(Env, {fun_decl, _, _, _}) -> Env;
|
||||
decl_to_fcode(Env, {type_def, _Ann, Name, Args, Def}) ->
|
||||
typedef_to_fcode(Env, Name, Args, Def);
|
||||
decl_to_fcode(Env = #{ functions := Funs }, {letfun, Ann, {id, _, Name}, Args, Ret, [{guarded, _, [], Body}]}) ->
|
||||
Attrs = get_attributes(Ann),
|
||||
decl_to_fcode(Env = #{ functions := Funs, options := Options }, {letfun, Ann, {id, _, Name}, Args, Ret, [{guarded, _, [], Body}]}) ->
|
||||
Attrs = case proplists:get_value(debug_info, Options, false) of
|
||||
true -> get_attributes_debug(Ann);
|
||||
false -> get_attributes(Ann)
|
||||
end,
|
||||
FName = lookup_fun(Env, qname(Env, Name)),
|
||||
FArgs = args_to_fcode(Env, Args),
|
||||
FRet = type_to_fcode(Env, Ret),
|
||||
@ -2199,6 +2202,10 @@ get_attributes(Ann) ->
|
||||
[payable || proplists:get_value(payable, Ann, false)] ++
|
||||
[private || not proplists:get_value(entrypoint, Ann, false)].
|
||||
|
||||
-spec get_attributes_debug(aeso_syntax:ann()) -> [stateful | payable | private | fann()].
|
||||
get_attributes_debug(Ann) ->
|
||||
get_attributes(Ann) ++ to_fann(Ann).
|
||||
|
||||
%% -- Basic utilities --
|
||||
|
||||
-spec indexed([term()]) -> [{integer(), term()}].
|
||||
|
@ -123,13 +123,19 @@ functions_to_scode(ChildContracts, ContractName, Functions, SavedFreshNames, Opt
|
||||
|
||||
function_to_scode(ChildContracts, ContractName, Functions, Name, Attrs0, Args, Body, ResType, SavedFreshNames, Options) ->
|
||||
{ArgTypes, ResType1} = typesig_to_scode(Args, ResType),
|
||||
Attrs = Attrs0 -- [stateful], %% Only track private and payable from here.
|
||||
FilterAttrs =
|
||||
fun(stateful) -> false; %% Only track private and payable from here
|
||||
({file, _}) -> false; %% This is useful only for DBG_LOC op
|
||||
({line, _}) -> false; %% This is useful only for DBG_LOC op
|
||||
(_) -> true
|
||||
end,
|
||||
Attrs = lists:filter(FilterAttrs, Attrs0),
|
||||
Env = init_env(ChildContracts, ContractName, Functions, Name, Args, SavedFreshNames, Options),
|
||||
[ add_variables_register(Env, Arg, Register) ||
|
||||
proplists:get_value(debug_info, Options, false),
|
||||
{Arg, Register} <- Env#env.vars ],
|
||||
ArgsNames = [ X || {X, _} <- lists:reverse(Env#env.vars) ],
|
||||
SCode = dbg_scoped_vars(Env, ArgsNames, to_scode(Env, Body)),
|
||||
SCode = dbg_scoped_vars(Env, ArgsNames, dbg_loc(Env, Attrs0) ++ to_scode(Env, Body)),
|
||||
{Attrs, {ArgTypes, ResType1}, SCode}.
|
||||
|
||||
get_variables_registers() ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user