Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

{erl_opts, [debug_info]}.

{deps, [ {getopt, "1.0.1"}
{deps, [ {eblake2, "1.0.0"}
, {aeserialization, {git, "https://github.com/aeternity/aeserialization.git",
{ref, "b55c372"}}}
, {getopt, "1.0.1"}
]}.

{escript_incl_apps, [aebytecode, getopt]}.
{escript_incl_apps, [aebytecode, eblake2, aeserialization, getopt]}.
{escript_main_app, aebytecode}.
{escript_name, aefateasm}.
{escript_emu_args, "%%!"}.
Expand All @@ -19,16 +22,19 @@
]}.


{relx, [{release, {aessembler, "0.0.1"},
[aebytecode, getopt]},
{relx, [{release, {aebytecode, "2.0.1"},
[aebytecode, eblake2, getopt]},

{dev_mode, true},
{include_erts, false},

{extended_start_script, true}]}.

{profiles, [{binary, [
{deps, [ {getopt, "1.0.1"}
{deps, [ {eblake2, "1.0.0"}
, {aeserialization, {git, "https://github.com/aeternity/aeserialization.git",
{ref, "b55c372"}}}
, {getopt, "1.0.1"}
]},

{post_hooks, [{"(linux|darwin|solaris|freebsd|netbsd|openbsd)",
Expand Down
12 changes: 9 additions & 3 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{"1.1.0",
[{<<"enacl">>,
{git,"https://github.com/aeternity/enacl.git",
{ref,"26180f42c0b3a450905d2efd8bc7fd5fd9cece75"}},
[{<<"aeserialization">>,
{git,"https://github.com/aeternity/aeserialization.git",
{ref,"b55c3726f4a21063721c68d6fa7fda39121edf11"}},
0},
{<<"base58">>,
{git,"https://github.com/aeternity/erl-base58.git",
{ref,"60a335668a60328a29f9731b67c4a0e9e3d50ab6"}},
1},
{<<"eblake2">>,{pkg,<<"eblake2">>,<<"1.0.0">>},0},
{<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},0}]}.
[
{pkg_hash,[
{<<"eblake2">>, <<"EC8AD20E438AAB3F2E8D5D118C366A0754219195F8A0F536587440F8F9BCF2EF">>},
{<<"getopt">>, <<"C73A9FA687B217F2FF79F68A3B637711BB1936E712B521D8CE466B29CBF7808A">>}]}
].
148 changes: 0 additions & 148 deletions src/aeb_blake2.erl

This file was deleted.

20 changes: 10 additions & 10 deletions src/aeb_fate_asm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ asm_to_bytecode(AssemblerCode, Options) ->
Signatures = serialize_sigs(Env),
SymbolTable = serialize_symbol_table(Env),
Annotatations = serialize_annotations(Env),
ByteCode = << (aeb_rlp:encode(list_to_binary(ByteList)))/binary,
(aeb_rlp:encode(list_to_binary(Signatures)))/binary,
(aeb_rlp:encode(SymbolTable))/binary,
(aeb_rlp:encode(Annotatations))/binary
ByteCode = << (aeser_rlp:encode(list_to_binary(ByteList)))/binary,
(aeser_rlp:encode(list_to_binary(Signatures)))/binary,
(aeser_rlp:encode(SymbolTable))/binary,
(aeser_rlp:encode(Annotatations))/binary
>>,

case proplists:lookup(pp_hex_string, Options) of
Expand All @@ -366,14 +366,14 @@ asm_to_bytecode(AssemblerCode, Options) ->
{Env, ByteCode}.

strip(ByteCode) ->
{Code, _Rest} = aeb_rlp:decode_one(ByteCode),
{Code, _Rest} = aeser_rlp:decode_one(ByteCode),
Code.

bytecode_to_fate_code(Bytes, _Options) ->
{ByteCode, Rest1} = aeb_rlp:decode_one(Bytes),
{Signatures, Rest2} = aeb_rlp:decode_one(Rest1),
{SymbolTable, Rest3} = aeb_rlp:decode_one(Rest2),
{Annotations, <<>>} = aeb_rlp:decode_one(Rest3),
{ByteCode, Rest1} = aeser_rlp:decode_one(Bytes),
{Signatures, Rest2} = aeser_rlp:decode_one(Rest1),
{SymbolTable, Rest3} = aeser_rlp:decode_one(Rest2),
{Annotations, <<>>} = aeser_rlp:decode_one(Rest3),

Env1 = deserialize(ByteCode, #{ function => none
, bb => 0
Expand Down Expand Up @@ -844,7 +844,7 @@ insert_fun({Name, Type, RetType}, Code, #{functions := Functions} = Env) ->

mk_hash(Id) ->
%% Use first 4 bytes of blake hash
{ok, <<A:8, B:8, C:8, D:8,_/binary>> } = aeb_blake2:blake2b(?HASH_BYTES, list_to_binary(Id)),
{ok, <<A:8, B:8, C:8, D:8,_/binary>> } = eblake2:blake2b(?HASH_BYTES, list_to_binary(Id)),
<<A,B,C,D>>.

%% Handle annotations
Expand Down
24 changes: 12 additions & 12 deletions src/aeb_fate_encoding.erl
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ serialize(String) when ?IS_FATE_STRING(String),
?FATE_STRING_SIZE(String) > 0,
?FATE_STRING_SIZE(String) >= ?SHORT_STRING_SIZE ->
Bytes = ?FATE_STRING_VALUE(String),
<<?LONG_STRING, (aeb_rlp:encode(Bytes))/binary>>;
<<?LONG_STRING, (aeser_rlp:encode(Bytes))/binary>>;
serialize(?FATE_ADDRESS(Address)) when is_binary(Address) ->
<<?ADDRESS, (aeb_rlp:encode(Address))/binary>>;
<<?ADDRESS, (aeser_rlp:encode(Address))/binary>>;
serialize(?FATE_TUPLE(T)) when size(T) > 0 ->
S = size(T),
L = tuple_to_list(T),
Expand Down Expand Up @@ -148,7 +148,7 @@ serialize(?FATE_VARIANT(Size, Tag, Values)) when 0 =< Size
%% -----------------------------------------------------

rlp_integer(S) when S >= 0 ->
aeb_rlp:encode(binary:encode_unsigned(S)).
aeser_rlp:encode(binary:encode_unsigned(S)).

serialize_integer(I) when ?IS_FATE_INTEGER(I) ->
V = ?FATE_INTEGER_VALUE(I),
Expand Down Expand Up @@ -187,28 +187,28 @@ deserialize2(<<?POS_SIGN:1, I:6, ?SMALL_INT:1, Rest/binary>>) ->
deserialize2(<<?NEG_SIGN:1, I:6, ?SMALL_INT:1, Rest/binary>>) ->
{?MAKE_FATE_INTEGER(-I), Rest};
deserialize2(<<?NEG_BIG_INT, Rest/binary>>) ->
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
{Bint, Rest2} = aeser_rlp:decode_one(Rest),
{?MAKE_FATE_INTEGER(-binary:decode_unsigned(Bint) - ?SMALL_INT_SIZE),
Rest2};
deserialize2(<<?POS_BIG_INT, Rest/binary>>) ->
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
{Bint, Rest2} = aeser_rlp:decode_one(Rest),
{?MAKE_FATE_INTEGER(binary:decode_unsigned(Bint) + ?SMALL_INT_SIZE),
Rest2};
deserialize2(<<?NEG_BITS, Rest/binary>>) ->
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
{Bint, Rest2} = aeser_rlp:decode_one(Rest),
{?FATE_BITS(-binary:decode_unsigned(Bint)), Rest2};
deserialize2(<<?POS_BITS, Rest/binary>>) ->
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
{Bint, Rest2} = aeser_rlp:decode_one(Rest),
{?FATE_BITS(binary:decode_unsigned(Bint)), Rest2};
deserialize2(<<?LONG_STRING, Rest/binary>>) ->
{String, Rest2} = aeb_rlp:decode_one(Rest),
{String, Rest2} = aeser_rlp:decode_one(Rest),
{?MAKE_FATE_STRING(String), Rest2};
deserialize2(<<S:6, ?SHORT_STRING:2, Rest/binary>>) ->
String = binary:part(Rest, 0, S),
Rest2 = binary:part(Rest, byte_size(Rest), - (byte_size(Rest) - S)),
{?MAKE_FATE_STRING(String), Rest2};
deserialize2(<<?ADDRESS, Rest/binary>>) ->
{A, Rest2} = aeb_rlp:decode_one(Rest),
{A, Rest2} = aeser_rlp:decode_one(Rest),
{?FATE_ADDRESS(A), Rest2};
deserialize2(<<?TRUE, Rest/binary>>) ->
{?FATE_TRUE, Rest};
Expand All @@ -223,23 +223,23 @@ deserialize2(<<?EMPTY_MAP, Rest/binary>>) ->
deserialize2(<<?EMPTY_STRING, Rest/binary>>) ->
{?FATE_EMPTY_STRING, Rest};
deserialize2(<<?LONG_TUPLE, Rest/binary>>) ->
{BSize, Rest1} = aeb_rlp:decode_one(Rest),
{BSize, Rest1} = aeser_rlp:decode_one(Rest),
N = binary:decode_unsigned(BSize) + ?SHORT_TUPLE_SIZE,
{List, Rest2} = deserialize_elements(N, Rest1),
{?FATE_TUPLE(list_to_tuple(List)), Rest2};
deserialize2(<<S:4, ?SHORT_TUPLE:4, Rest/binary>>) ->
{List, Rest1} = deserialize_elements(S, Rest),
{?FATE_TUPLE(list_to_tuple(List)), Rest1};
deserialize2(<<?LONG_LIST, Rest/binary>>) ->
{BLength, Rest1} = aeb_rlp:decode_one(Rest),
{BLength, Rest1} = aeser_rlp:decode_one(Rest),
Length = binary:decode_unsigned(BLength) + ?SHORT_LIST_SIZE,
{List, Rest2} = deserialize_elements(Length, Rest1),
{?MAKE_FATE_LIST(List), Rest2};
deserialize2(<<S:4, ?SHORT_LIST:4, Rest/binary>>) ->
{List, Rest1} = deserialize_elements(S, Rest),
{?MAKE_FATE_LIST(List), Rest1};
deserialize2(<<?MAP, Rest/binary>>) ->
{BSize, Rest1} = aeb_rlp:decode_one(Rest),
{BSize, Rest1} = aeser_rlp:decode_one(Rest),
Size = binary:decode_unsigned(BSize),
{List, Rest2} = deserialize_elements(2*Size, Rest1),
Map = insert_kv(List, #{}),
Expand Down
Loading