Fix erros found by dialyzer and warnings.
This commit is contained in:
parent
c5a9878bd9
commit
afdb78b933
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,6 +9,6 @@ rel/example_project
|
||||
.concrete/DEV_MODE
|
||||
.rebar
|
||||
aeb_asm_scan.erl
|
||||
aefa_asm_scan.erl
|
||||
aeb_fate_asm_scan.erl
|
||||
_build/
|
||||
aefateasm
|
||||
|
@ -24,7 +24,7 @@
|
||||
{dialyzer, [
|
||||
{warnings, [unknown]},
|
||||
{plt_apps, all_deps},
|
||||
{base_plt_apps, [erts, kernel, stdlib, crypto]}
|
||||
{base_plt_apps, [erts, kernel, stdlib, crypto, getopt]}
|
||||
]}.
|
||||
|
||||
|
||||
|
@ -10,6 +10,10 @@
|
||||
%%% DUP
|
||||
%%% Identifiers start with a lower case letter
|
||||
%%% an_identifier
|
||||
%%% References to function arguments start with arg
|
||||
%%% arg0
|
||||
%%% References to variables/registers start with var
|
||||
%%% var0
|
||||
%%% Immediates can be of 9 types:
|
||||
%%% 1. Integers
|
||||
%%% 42
|
||||
@ -56,7 +60,7 @@
|
||||
|
||||
assemble_file(InFile, OutFile, Options) ->
|
||||
Asm = read_file(InFile),
|
||||
{Env, BC} = asm_to_bytecode(Asm, Options),
|
||||
{_Env, BC} = asm_to_bytecode(Asm, Options),
|
||||
ok = file:write_file(OutFile, BC).
|
||||
|
||||
pp(Asm) ->
|
||||
@ -148,7 +152,7 @@ deserialize(<<Op:8, Rest/binary>>,
|
||||
, current_bb_code := Code
|
||||
, code := Program} = Env) ->
|
||||
{Rest2, OpCode} = deserialize_op(Op, Rest, Code),
|
||||
case aebe_fate_opcodes:end_bb(Op) of
|
||||
case aeb_fate_opcodes:end_bb(Op) of
|
||||
true ->
|
||||
deserialize(Rest2, Env#{ bb => BB+1
|
||||
, current_bb_code => []
|
||||
@ -402,9 +406,10 @@ to_bytecode([{id,_line, ID}|Rest], Address, Env, Code, Opts) ->
|
||||
to_bytecode(Rest, Address, Env2, [{immediate, Hash}|Code], Opts);
|
||||
to_bytecode([], Address, Env, Code, Opts) ->
|
||||
Env2 = insert_fun(Address, Code, Env),
|
||||
#{functions := Funs} = Env2,
|
||||
case proplists:lookup(pp_opcodes, Opts) of
|
||||
{pp_opcodes, true} ->
|
||||
Ops = [C || {_Name, {_Sig, C}} <- maps:to_list(Env2)],
|
||||
Ops = [C || {_Name, {_Sig, C}} <- maps:to_list(Funs)],
|
||||
io:format("opcodes ~p~n", [Ops]);
|
||||
none ->
|
||||
ok
|
||||
@ -480,5 +485,4 @@ insert_symbol(Id, Hash, #{symbols := Symbols} = Env) ->
|
||||
{Hash, Env#{symbols => Symbols#{ Id => Hash
|
||||
, Hash => Id}}}
|
||||
end.
|
||||
lookup_symbol(Id, #{symbols := Symbols} = Env) ->
|
||||
maps:find(Id, Symbols).
|
||||
|
||||
|
@ -129,7 +129,7 @@ format(M) when ?IS_FATE_MAP(M) ->
|
||||
"#{ "
|
||||
++ format_kvs(maps:to_list(?FATE_MAP_VALUE(M)))
|
||||
++" }";
|
||||
format(?FATE_ADDRESS(Address)) -> base58:binary_to_base58(Address);
|
||||
format(?FATE_ADDRESS(Address)) -> address_to_base58(Address);
|
||||
format(V) -> exit({not_a_fate_type, V}).
|
||||
|
||||
format_list([]) -> " ]";
|
||||
@ -167,6 +167,9 @@ base58_to_address(Base58) ->
|
||||
Bin = <<I:256>>,
|
||||
Bin.
|
||||
|
||||
address_to_base58(<<A:256>>) ->
|
||||
integer_to_base58(A).
|
||||
|
||||
integer_to_base58(0) -> <<"1">>;
|
||||
integer_to_base58(Integer) ->
|
||||
Base58String = integer_to_base58(Integer, []),
|
||||
|
Loading…
x
Reference in New Issue
Block a user