From eb16d2f77bcdca84349a30d0ff4319d837f7c590 Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Thu, 17 Nov 2022 17:23:42 +0300 Subject: [PATCH] Add file to fann() --- src/aeso_ast_to_fcode.erl | 7 +++++-- src/aeso_fcode_to_fate.erl | 13 +++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/aeso_ast_to_fcode.erl b/src/aeso_ast_to_fcode.erl index d73619d..0eab963 100644 --- a/src/aeso_ast_to_fcode.erl +++ b/src/aeso_ast_to_fcode.erl @@ -58,7 +58,7 @@ | {contract_code, string()} %% for CREATE, by name | {typerep, ftype()}. --type fann() :: [ {line, aeso_syntax:ann_line()} | {col, aeso_syntax:ann_col()} ]. +-type fann() :: [ {file, string() | no_file} | {line, aeso_syntax:ann_line()} | {col, aeso_syntax:ann_col()} ]. -type fexpr() :: {lit, fann(), flit()} | {nil, fann()} @@ -389,7 +389,10 @@ to_fcode(Env, [{namespace, _, {con, _, Con}, Decls} | Code]) -> -spec to_fann(aeso_syntax:ann()) -> fann(). to_fann(Ann) -> - proplists:lookup_all(line, Ann) ++ proplists:lookup_all(col, Ann). + File = proplists:lookup_all(file, Ann), + Line = proplists:lookup_all(line, Ann), + Col = proplists:lookup_all(col, Ann), + lists:flatten([File, Line, Col]). -spec get_fann(fexpr()) -> fann(). get_fann(FExpr) -> element(2, FExpr). diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index e971bb5..83701de 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -113,8 +113,8 @@ block_dbgloc_map(BB) -> block_dbgloc_map(BB, 0, maps:new()). DbglocMap :: #{integer() => {integer(), integer()}}. block_dbgloc_map([], _, DbglocMap) -> DbglocMap; -block_dbgloc_map([{'DBGLOC', Line, Col} | Rest], Index, DbglocMap) -> - block_dbgloc_map(Rest, Index, maps:put(Index, {Line, Col}, DbglocMap)); +block_dbgloc_map([{'DBGLOC', File, Line, Col} | Rest], Index, DbglocMap) -> + block_dbgloc_map(Rest, Index, maps:put(Index, {File, Line, Col}, DbglocMap)); block_dbgloc_map([_ | Rest], Index, DbglocMap) -> block_dbgloc_map(Rest, Index + 1, DbglocMap). @@ -123,8 +123,8 @@ block_dbgloc_map([_ | Rest], Index, DbglocMap) -> remove_dbgloc(FateCode) -> RemoveDbglocFromBBs = fun(_, BB) -> - IsDbg = fun({'DBGLOC', _, _}) -> false; - (_) -> true + IsDbg = fun({'DBGLOC', _, _, _}) -> false; + (_) -> true end, lists:filter(IsDbg, BB) end, @@ -806,12 +806,13 @@ dbgloc(Env, Ann) -> case proplists:get_value(debug_info, Env#env.options, false) of false -> []; true -> + File = proplists:get_value(file, Ann), Line = proplists:get_value(line, Ann), Col = proplists:get_value(col, Ann), case {Line, Col} of {undefined, _} -> []; {_, undefined} -> []; - {Line, Col} -> [{'DBGLOC', Line, Col}] + {Line, Col} -> [{'DBGLOC', File, Line, Col}] end end. @@ -950,7 +951,7 @@ attributes(I) -> loop -> Impure(pc, []); switch_body -> Pure(none, []); 'RETURN' -> Impure(pc, []); - {'DBGLOC', _, _} -> Pure(none, []); + {'DBGLOC', _, _, _} -> Pure(none, []); {'RETURNR', A} -> Impure(pc, A); {'CALL', A} -> Impure(?a, [A]); {'CALL_R', A, _, B, C, D} -> Impure(?a, [A, B, C, D]);