Skip to content

Commit

Permalink
read globals, size and text as well as test
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzthekid committed Dec 18, 2023
1 parent a2425e7 commit 8db96b2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions log/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
!.gitignore
*

24 changes: 22 additions & 2 deletions src/rvsreadasm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ just_text(Filename) ->

just_globals_and_size(Text) ->
G=grep_globals(Text),
SZ=size_of_globals(Text,"size",G),
{G,SZ}.
SM=maps:from_list(size_of_globals(Text,G)),
TM=maps:from_list(type_of_globals(Text,G)),
maps:from_list(lists:foldl(fun(SG,Acc)->
Acc++[{SG,maps:from_list(
[{size,maps:get(SG,SM)},
{type,maps:get(SG,TM)}]
)
}
]
end, [], G)).

print_text(Text) ->
lists:foreach(fun({I,L}) -> io:format("~p: ~s~n",[I,L]) end, lists:zip(lists:seq(1,length(Text)),Text)).

Expand Down Expand Up @@ -109,3 +118,14 @@ type_of_globals(OAcc,[G|T],Text) ->
end, OAcc,Text),
type_of_globals(NAcc,T,Text).

-ifdef(REBARTEST).
-include_lib("eunit/include/eunit.hrl").
globals_test() ->
G = just_globals_and_size(just_text("data/func-with-globals.s")),
?assertEqual("4000",maps:get(size,maps:get("buffer",G))),
ok.
list_text_test() ->
Text = just_text("data/func-with-globals.s"),
?assertEqual(19,length(list_text(Text,3,22))),
print_text(Text).
-endif.

0 comments on commit 8db96b2

Please sign in to comment.