From 354e49c5d3e72c4e7f909eb445b0e11e5048cf80 Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Thu, 17 Nov 2022 17:15:17 +0300 Subject: [PATCH] Add line to fann() --- src/aeso_ast_to_fcode.erl | 4 ++-- src/aeso_fcode_to_fate.erl | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/aeso_ast_to_fcode.erl b/src/aeso_ast_to_fcode.erl index bb8cb53..d73619d 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()} ]. +-type fann() :: [ {line, aeso_syntax:ann_line()} | {col, aeso_syntax:ann_col()} ]. -type fexpr() :: {lit, fann(), flit()} | {nil, fann()} @@ -389,7 +389,7 @@ 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(line, Ann) ++ proplists:lookup_all(col, Ann). -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 b227ff1..5b973a6 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -106,25 +106,25 @@ compile1(ChildContracts, FCode, SavedFreshNames, Options) -> {FateCode2, get_variables_registers(), DbglocMap}. -spec block_dbgloc_map(bcode()) -> DbglocMap when - DbglocMap :: #{integer() => integer()}. + DbglocMap :: #{integer() => {integer(), integer()}}. block_dbgloc_map(BB) -> block_dbgloc_map(BB, 0, maps:new()). -spec block_dbgloc_map(bcode(), integer(), DbglocMap) -> DbglocMap when - DbglocMap :: #{integer() => integer()}. + DbglocMap :: #{integer() => {integer(), integer()}}. block_dbgloc_map([], _, DbglocMap) -> DbglocMap; -block_dbgloc_map([{'DBGLOC', Line} | Rest], Index, DbglocMap) -> - block_dbgloc_map(Rest, Index, maps:put(Index, Line, DbglocMap)); +block_dbgloc_map([{'DBGLOC', Line, Col} | Rest], Index, DbglocMap) -> + block_dbgloc_map(Rest, Index, maps:put(Index, {Line, Col}, DbglocMap)); block_dbgloc_map([_ | Rest], Index, DbglocMap) -> block_dbgloc_map(Rest, Index + 1, DbglocMap). -spec remove_dbgloc(aeb_fate_code:fcode()) -> {aeb_fate_code:fcode(), DbglocMap} when - DbglocMap :: #{integer() => integer()}. + DbglocMap :: #{integer() => {integer(), integer()}}. remove_dbgloc(FateCode) -> RemoveDbglocFromBBs = fun(_, BB) -> - IsDbg = fun({'DBGLOC', _}) -> false; - (_) -> true + IsDbg = fun({'DBGLOC', _, _}) -> false; + (_) -> true end, lists:filter(IsDbg, BB) end, @@ -806,9 +806,12 @@ dbgloc(Env, Ann) -> case proplists:get_value(debug_info, Env#env.options, false) of false -> []; true -> - case proplists:get_value(line, Ann) of - undefined -> []; - Line -> [{'DBGLOC', Line}] + Line = proplists:get_value(line, Ann), + Col = proplists:get_value(col, Ann), + case {Line, Col} of + {undefined, _} -> []; + {_, undefined} -> []; + {Line, Col} -> [{'DBGLOC', Line, Col}] end end. @@ -947,7 +950,7 @@ attributes(I) -> loop -> Impure(pc, []); switch_body -> Pure(none, []); 'RETURN' -> Impure(pc, []); - {'DBGLOC', _} -> Impure(pc, []); + {'DBGLOC', _, _} -> Impure(pc, []); {'RETURNR', A} -> Impure(pc, A); {'CALL', A} -> Impure(?a, [A]); {'CALL_R', A, _, B, C, D} -> Impure(?a, [A, B, C, D]);