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