From 793a6829f61fc215b28f0de534ae7c3ca12dd8cf Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Sun, 4 Dec 2022 12:18:46 +0300 Subject: [PATCH] Save debug locations for child contracts --- src/aeso_fcode_to_fate.erl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index df9778b..050d8c9 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -84,7 +84,8 @@ compile(ChildContracts, FCode, SavedFreshNames, Options) -> try compile1(ChildContracts, FCode, SavedFreshNames, Options) after - put(variables_registers, undefined) + put(variables_registers, undefined), + put(instructions_locations, undefined) end. compile1(ChildContracts, FCode, SavedFreshNames, Options) -> @@ -98,12 +99,13 @@ compile1(ChildContracts, FCode, SavedFreshNames, Options) -> true -> remove_dbgloc(FateCode); false -> {FateCode, #{}} end, + add_instructions_locations(ContractName, DbglocMap), ?debug(compile, Options, "~s\n", [aeb_fate_asm:pp(FateCode1)]), FateCode2 = case proplists:get_value(include_child_contract_symbols, Options, false) of false -> FateCode1; true -> add_child_symbols(ChildContracts, FateCode1) end, - {FateCode2, get_variables_registers(), DbglocMap}. + {FateCode2, get_variables_registers(), get_instructions_locations()}. -spec block_dbgloc_map(bcode()) -> DbglocMap when DbglocMap :: #{integer() => {aeso_syntax:ann_file(), aeso_syntax:ann_line(), aeso_syntax:ann_col()}}. @@ -182,6 +184,16 @@ get_variables_registers() -> Vs -> Vs end. +get_instructions_locations() -> + case get(instructions_locations) of + undefined -> #{}; + IL -> IL + end. + +add_instructions_locations(Contract, Map) -> + Old = get_instructions_locations(), + put(instructions_locations, Old#{Contract => Map}). + add_variables_register(Env = #env{saved_fresh_names = SavedFreshNames}, Name, Register) -> Olds = get_variables_registers(), RealName = maps:get(Name, SavedFreshNames, Name),