Rename to library standard.
This commit is contained in:
parent
e6623bd252
commit
c5a9878bd9
@ -5,7 +5,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
%%%=============================================================================
|
%%%=============================================================================
|
||||||
|
|
||||||
-module(aeblake2).
|
-module(aeb_blake2).
|
||||||
|
|
||||||
-export([ blake2b/2
|
-export([ blake2b/2
|
||||||
, blake2b/3
|
, blake2b/3
|
@ -41,7 +41,7 @@
|
|||||||
%%% Created : 21 Dec 2017
|
%%% Created : 21 Dec 2017
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aefa_asm).
|
-module(aeb_fate_asm).
|
||||||
|
|
||||||
-export([ assemble_file/3
|
-export([ assemble_file/3
|
||||||
, asm_to_bytecode/2
|
, asm_to_bytecode/2
|
||||||
@ -51,12 +51,12 @@
|
|||||||
, to_hexstring/1
|
, to_hexstring/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-include_lib("aebytecode/include/aefa_opcodes.hrl").
|
-include_lib("aebytecode/include/aeb_fate_opcodes.hrl").
|
||||||
-define(HASH_BYTES, 32).
|
-define(HASH_BYTES, 32).
|
||||||
|
|
||||||
assemble_file(InFile, OutFile, Options) ->
|
assemble_file(InFile, OutFile, Options) ->
|
||||||
Asm = read_file(InFile),
|
Asm = read_file(InFile),
|
||||||
{Env, BC} = aefa_asm: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) ->
|
||||||
@ -68,7 +68,7 @@ format(Asm) -> format(Asm, 0).
|
|||||||
format([{comment, Comment} | Rest], Address) ->
|
format([{comment, Comment} | Rest], Address) ->
|
||||||
";; " ++ Comment ++ "\n" ++ format(Rest, Address);
|
";; " ++ Comment ++ "\n" ++ format(Rest, Address);
|
||||||
format([Mnemonic | Rest], Address) ->
|
format([Mnemonic | Rest], Address) ->
|
||||||
_Op = aefa_opcodes:m_to_op(Mnemonic),
|
_Op = aeb_fate_opcodes:m_to_op(Mnemonic),
|
||||||
" " ++ atom_to_list(Mnemonic) ++ "\n"
|
" " ++ atom_to_list(Mnemonic) ++ "\n"
|
||||||
++ format(Rest, Address + 1);
|
++ format(Rest, Address + 1);
|
||||||
format([],_) -> [].
|
format([],_) -> [].
|
||||||
@ -79,7 +79,7 @@ read_file(Filename) ->
|
|||||||
binary_to_list(File).
|
binary_to_list(File).
|
||||||
|
|
||||||
asm_to_bytecode(AssemblerCode, Options) ->
|
asm_to_bytecode(AssemblerCode, Options) ->
|
||||||
{ok, Tokens, _} = aefa_asm_scan:scan(AssemblerCode),
|
{ok, Tokens, _} = aeb_fate_asm_scan:scan(AssemblerCode),
|
||||||
|
|
||||||
case proplists:lookup(pp_tokens, Options) of
|
case proplists:lookup(pp_tokens, Options) of
|
||||||
{pp_tokens, true} ->
|
{pp_tokens, true} ->
|
||||||
@ -148,7 +148,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 aefa_opcodes:end_bb(Op) of
|
case aebe_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 => []
|
||||||
@ -176,40 +176,40 @@ deserialize(<<>>, #{ function := F
|
|||||||
deserialize_op(?ELEMENT, Rest, Code) ->
|
deserialize_op(?ELEMENT, Rest, Code) ->
|
||||||
{Type, Rest2} = deserialize_type(Rest),
|
{Type, Rest2} = deserialize_type(Rest),
|
||||||
<<ArgType:8, Rest3/binary>> = Rest2,
|
<<ArgType:8, Rest3/binary>> = Rest2,
|
||||||
{Arg0, Rest4} = aefa_encoding:deserialize_one(Rest3),
|
{Arg0, Rest4} = aeb_fate_encoding:deserialize_one(Rest3),
|
||||||
{Arg1, Rest5} = aefa_encoding:deserialize_one(Rest4),
|
{Arg1, Rest5} = aeb_fate_encoding:deserialize_one(Rest4),
|
||||||
{Arg2, Rest6} = aefa_encoding:deserialize_one(Rest5),
|
{Arg2, Rest6} = aeb_fate_encoding:deserialize_one(Rest5),
|
||||||
Modifier0 = bits_to_modifier(ArgType band 2#11),
|
Modifier0 = bits_to_modifier(ArgType band 2#11),
|
||||||
Modifier1 = bits_to_modifier((ArgType bsr 2) band 2#11),
|
Modifier1 = bits_to_modifier((ArgType bsr 2) band 2#11),
|
||||||
Modifier2 = bits_to_modifier((ArgType bsr 4) band 2#11),
|
Modifier2 = bits_to_modifier((ArgType bsr 4) band 2#11),
|
||||||
{Rest6, [{ aefa_opcodes:mnemonic(?ELEMENT)
|
{Rest6, [{ aeb_fate_opcodes:mnemonic(?ELEMENT)
|
||||||
, Type
|
, Type
|
||||||
, {Modifier0, Arg0}
|
, {Modifier0, Arg0}
|
||||||
, {Modifier1, Arg1}
|
, {Modifier1, Arg1}
|
||||||
, {Modifier2, Arg2}}
|
, {Modifier2, Arg2}}
|
||||||
| Code]};
|
| Code]};
|
||||||
deserialize_op(Op, Rest, Code) ->
|
deserialize_op(Op, Rest, Code) ->
|
||||||
OpName = aefa_opcodes:mnemonic(Op),
|
OpName = aeb_fate_opcodes:mnemonic(Op),
|
||||||
case aefa_opcodes:args(Op) of
|
case aeb_fate_opcodes:args(Op) of
|
||||||
0 -> {Rest, [OpName | Code]};
|
0 -> {Rest, [OpName | Code]};
|
||||||
1 ->
|
1 ->
|
||||||
<<ArgType:8, Rest2/binary>> = Rest,
|
<<ArgType:8, Rest2/binary>> = Rest,
|
||||||
{Arg, Rest3} = aefa_encoding:deserialize_one(Rest2),
|
{Arg, Rest3} = aeb_fate_encoding:deserialize_one(Rest2),
|
||||||
Modifier = bits_to_modifier(ArgType),
|
Modifier = bits_to_modifier(ArgType),
|
||||||
{Rest3, [{OpName, {Modifier, Arg}} | Code]};
|
{Rest3, [{OpName, {Modifier, Arg}} | Code]};
|
||||||
2 ->
|
2 ->
|
||||||
<<ArgType:8, Rest2/binary>> = Rest,
|
<<ArgType:8, Rest2/binary>> = Rest,
|
||||||
{Arg0, Rest3} = aefa_encoding:deserialize_one(Rest2),
|
{Arg0, Rest3} = aeb_fate_encoding:deserialize_one(Rest2),
|
||||||
{Arg1, Rest4} = aefa_encoding:deserialize_one(Rest3),
|
{Arg1, Rest4} = aeb_fate_encoding:deserialize_one(Rest3),
|
||||||
Modifier0 = bits_to_modifier(ArgType band 2#11),
|
Modifier0 = bits_to_modifier(ArgType band 2#11),
|
||||||
Modifier1 = bits_to_modifier((ArgType bsr 2) band 2#11),
|
Modifier1 = bits_to_modifier((ArgType bsr 2) band 2#11),
|
||||||
{Rest4, [{OpName, {Modifier0, Arg0},
|
{Rest4, [{OpName, {Modifier0, Arg0},
|
||||||
{Modifier1, Arg1}} | Code]};
|
{Modifier1, Arg1}} | Code]};
|
||||||
3 ->
|
3 ->
|
||||||
<<ArgType:8, Rest2/binary>> = Rest,
|
<<ArgType:8, Rest2/binary>> = Rest,
|
||||||
{Arg0, Rest3} = aefa_encoding:deserialize_one(Rest2),
|
{Arg0, Rest3} = aeb_fate_encoding:deserialize_one(Rest2),
|
||||||
{Arg1, Rest4} = aefa_encoding:deserialize_one(Rest3),
|
{Arg1, Rest4} = aeb_fate_encoding:deserialize_one(Rest3),
|
||||||
{Arg2, Rest5} = aefa_encoding:deserialize_one(Rest4),
|
{Arg2, Rest5} = aeb_fate_encoding:deserialize_one(Rest4),
|
||||||
Modifier0 = bits_to_modifier(ArgType band 2#11),
|
Modifier0 = bits_to_modifier(ArgType band 2#11),
|
||||||
Modifier1 = bits_to_modifier((ArgType bsr 2) band 2#11),
|
Modifier1 = bits_to_modifier((ArgType bsr 2) band 2#11),
|
||||||
Modifier2 = bits_to_modifier((ArgType bsr 4) band 2#11),
|
Modifier2 = bits_to_modifier((ArgType bsr 4) band 2#11),
|
||||||
@ -220,10 +220,10 @@ deserialize_op(Op, Rest, Code) ->
|
|||||||
| Code]};
|
| Code]};
|
||||||
4 ->
|
4 ->
|
||||||
<<ArgType:8, Rest2/binary>> = Rest,
|
<<ArgType:8, Rest2/binary>> = Rest,
|
||||||
{Arg0, Rest3} = aefa_encoding:deserialize_one(Rest2),
|
{Arg0, Rest3} = aeb_fate_encoding:deserialize_one(Rest2),
|
||||||
{Arg1, Rest4} = aefa_encoding:deserialize_one(Rest3),
|
{Arg1, Rest4} = aeb_fate_encoding:deserialize_one(Rest3),
|
||||||
{Arg2, Rest5} = aefa_encoding:deserialize_one(Rest4),
|
{Arg2, Rest5} = aeb_fate_encoding:deserialize_one(Rest4),
|
||||||
{Arg3, Rest6} = aefa_encoding:deserialize_one(Rest5),
|
{Arg3, Rest6} = aeb_fate_encoding:deserialize_one(Rest5),
|
||||||
Modifier0 = bits_to_modifier(ArgType band 2#11),
|
Modifier0 = bits_to_modifier(ArgType band 2#11),
|
||||||
Modifier1 = bits_to_modifier((ArgType bsr 2) band 2#11),
|
Modifier1 = bits_to_modifier((ArgType bsr 2) band 2#11),
|
||||||
Modifier2 = bits_to_modifier((ArgType bsr 4) band 2#11),
|
Modifier2 = bits_to_modifier((ArgType bsr 4) band 2#11),
|
||||||
@ -323,7 +323,7 @@ bits_to_modifier(2#01) -> arg;
|
|||||||
bits_to_modifier(2#00) -> stack.
|
bits_to_modifier(2#00) -> stack.
|
||||||
|
|
||||||
serialize_data(_, Data) ->
|
serialize_data(_, Data) ->
|
||||||
aefa_encoding:serialize(Data).
|
aeb_fate_encoding:serialize(Data).
|
||||||
|
|
||||||
serialize_signature({Args, RetType}) ->
|
serialize_signature({Args, RetType}) ->
|
||||||
[serialize_type({tuple, Args}) |
|
[serialize_type({tuple, Args}) |
|
||||||
@ -379,11 +379,11 @@ to_bytecode([{function,_line, 'FUNCTION'}|Rest], Address, Env, Code, Opts) ->
|
|||||||
{Fun, Rest2} = to_fun_def(Rest),
|
{Fun, Rest2} = to_fun_def(Rest),
|
||||||
to_bytecode(Rest2, Fun, Env2, [], Opts);
|
to_bytecode(Rest2, Fun, Env2, [], Opts);
|
||||||
to_bytecode([{mnemonic,_line, 'ELEMENT'}|Rest], Address, Env, Code, Opts) ->
|
to_bytecode([{mnemonic,_line, 'ELEMENT'}|Rest], Address, Env, Code, Opts) ->
|
||||||
OpCode = aefa_opcodes:m_to_op('ELEMENT'),
|
OpCode = aeb_fate_opcodes:m_to_op('ELEMENT'),
|
||||||
{RetType, Rest2} = to_type(Rest),
|
{RetType, Rest2} = to_type(Rest),
|
||||||
to_bytecode(Rest2, Address, Env, [RetType, OpCode|Code], Opts);
|
to_bytecode(Rest2, Address, Env, [RetType, OpCode|Code], Opts);
|
||||||
to_bytecode([{mnemonic,_line, Op}|Rest], Address, Env, Code, Opts) ->
|
to_bytecode([{mnemonic,_line, Op}|Rest], Address, Env, Code, Opts) ->
|
||||||
OpCode = aefa_opcodes:m_to_op(Op),
|
OpCode = aeb_fate_opcodes:m_to_op(Op),
|
||||||
to_bytecode(Rest, Address, Env, [OpCode|Code], Opts);
|
to_bytecode(Rest, Address, Env, [OpCode|Code], Opts);
|
||||||
to_bytecode([{arg,_line, N}|Rest], Address, Env, Code, Opts) ->
|
to_bytecode([{arg,_line, N}|Rest], Address, Env, Code, Opts) ->
|
||||||
to_bytecode(Rest, Address, Env, [{arg, N}|Code], Opts);
|
to_bytecode(Rest, Address, Env, [{arg, N}|Code], Opts);
|
||||||
@ -467,7 +467,7 @@ insert_fun({Name, Type, RetType}, Code, #{functions := Functions} = Env) ->
|
|||||||
|
|
||||||
insert_symbol(Id, Env) ->
|
insert_symbol(Id, Env) ->
|
||||||
%% Use first 4 bytes of blake hash
|
%% Use first 4 bytes of blake hash
|
||||||
{ok, <<A:8, B:8, C:8, D:8,_/binary>> } = aeblake2:blake2b(?HASH_BYTES, list_to_binary(Id)),
|
{ok, <<A:8, B:8, C:8, D:8,_/binary>> } = aeb_blake2:blake2b(?HASH_BYTES, list_to_binary(Id)),
|
||||||
insert_symbol(Id, <<A,B,C,D>>, Env).
|
insert_symbol(Id, <<A,B,C,D>>, Env).
|
||||||
|
|
||||||
insert_symbol(Id, Hash, #{symbols := Symbols} = Env) ->
|
insert_symbol(Id, Hash, #{symbols := Symbols} = Env) ->
|
@ -170,7 +170,7 @@ Erlang code.
|
|||||||
|
|
||||||
-ignore_xref([format_error/1, string/2, token/2, token/3, tokens/2, tokens/3]).
|
-ignore_xref([format_error/1, string/2, token/2, token/3, tokens/2, tokens/3]).
|
||||||
|
|
||||||
-include_lib("aebytecode/include/aefa_opcodes.hrl").
|
-include_lib("aebytecode/include/aeb_fate_opcodes.hrl").
|
||||||
|
|
||||||
|
|
||||||
parse_hex("0x" ++ Chars) -> list_to_integer(Chars, 16).
|
parse_hex("0x" ++ Chars) -> list_to_integer(Chars, 16).
|
@ -1,9 +1,8 @@
|
|||||||
%% First draft of FATE data representation.
|
%% FATE data representation.
|
||||||
%% Very likely to change.
|
|
||||||
%%
|
%%
|
||||||
-include("aefa_data.hrl").
|
-include("aeb_fate_data.hrl").
|
||||||
|
|
||||||
-module(aefa_data).
|
-module(aeb_fate_data).
|
||||||
|
|
||||||
-type fate_integer() :: ?FATE_INTEGER_T.
|
-type fate_integer() :: ?FATE_INTEGER_T.
|
||||||
-type fate_boolean() :: ?FATE_BOOLEAN_T.
|
-type fate_boolean() :: ?FATE_BOOLEAN_T.
|
@ -33,14 +33,14 @@
|
|||||||
%% * Handle instructions.
|
%% * Handle instructions.
|
||||||
%%
|
%%
|
||||||
%% ------------------------------------------------------------------------
|
%% ------------------------------------------------------------------------
|
||||||
-module(aefa_encoding).
|
-module(aeb_fate_encoding).
|
||||||
|
|
||||||
-export([ deserialize/1
|
-export([ deserialize/1
|
||||||
, deserialize_one/1
|
, deserialize_one/1
|
||||||
, serialize/1
|
, serialize/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-include("aefa_data.hrl").
|
-include("aeb_fate_data.hrl").
|
||||||
|
|
||||||
%% Definition of tag scheme.
|
%% Definition of tag scheme.
|
||||||
%% This has to follow the protocol specification.
|
%% This has to follow the protocol specification.
|
||||||
@ -85,7 +85,7 @@
|
|||||||
%% Serialized a Fate data value into a sequence of bytes
|
%% Serialized a Fate data value into a sequence of bytes
|
||||||
%% according to the Fate serialization specification.
|
%% according to the Fate serialization specification.
|
||||||
%% TODO: The type Fate Data is not final yet.
|
%% TODO: The type Fate Data is not final yet.
|
||||||
-spec serialize(aefa_data:fate_type()) -> binary().
|
-spec serialize(aeb_fate_data:fate_type()) -> binary().
|
||||||
serialize(?FATE_TRUE) -> <<?TRUE>>;
|
serialize(?FATE_TRUE) -> <<?TRUE>>;
|
||||||
serialize(?FATE_FALSE) -> <<?FALSE>>;
|
serialize(?FATE_FALSE) -> <<?FALSE>>;
|
||||||
serialize(?FATE_NIL) -> <<?NIL>>; %% ! Untyped
|
serialize(?FATE_NIL) -> <<?NIL>>; %% ! Untyped
|
||||||
@ -104,9 +104,9 @@ serialize(String) when ?IS_FATE_STRING(String),
|
|||||||
?FATE_STRING_SIZE(String) > 0,
|
?FATE_STRING_SIZE(String) > 0,
|
||||||
?FATE_STRING_SIZE(String) >= ?SHORT_STRING_SIZE ->
|
?FATE_STRING_SIZE(String) >= ?SHORT_STRING_SIZE ->
|
||||||
Bytes = ?FATE_STRING_VALUE(String),
|
Bytes = ?FATE_STRING_VALUE(String),
|
||||||
<<?LONG_STRING, (ae_rlp:encode(Bytes))/binary>>;
|
<<?LONG_STRING, (aeb_rlp:encode(Bytes))/binary>>;
|
||||||
serialize(?FATE_ADDRESS(Address)) when is_binary(Address) ->
|
serialize(?FATE_ADDRESS(Address)) when is_binary(Address) ->
|
||||||
<<?ADDRESS, (ae_rlp:encode(Address))/binary>>;
|
<<?ADDRESS, (aeb_rlp:encode(Address))/binary>>;
|
||||||
serialize(?FATE_TUPLE(T)) when size(T) > 0 ->
|
serialize(?FATE_TUPLE(T)) when size(T) > 0 ->
|
||||||
S = size(T),
|
S = size(T),
|
||||||
L = tuple_to_list(T),
|
L = tuple_to_list(T),
|
||||||
@ -148,7 +148,7 @@ serialize(?FATE_VARIANT(Size, Tag, Values)) when 0 =< Size
|
|||||||
%% -----------------------------------------------------
|
%% -----------------------------------------------------
|
||||||
|
|
||||||
rlp_integer(S) when S >= 0 ->
|
rlp_integer(S) when S >= 0 ->
|
||||||
ae_rlp:encode(binary:encode_unsigned(S)).
|
aeb_rlp:encode(binary:encode_unsigned(S)).
|
||||||
|
|
||||||
serialize_integer(I) when ?IS_FATE_INTEGER(I) ->
|
serialize_integer(I) when ?IS_FATE_INTEGER(I) ->
|
||||||
V = ?FATE_INTEGER_VALUE(I),
|
V = ?FATE_INTEGER_VALUE(I),
|
||||||
@ -175,7 +175,7 @@ serialize_bits(B) when is_integer(B) ->
|
|||||||
Sign =:= ?POS_SIGN -> <<?POS_BITS, (rlp_integer(Abs))/binary>>
|
Sign =:= ?POS_SIGN -> <<?POS_BITS, (rlp_integer(Abs))/binary>>
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec deserialize(binary()) -> aefa_data:fate_type().
|
-spec deserialize(binary()) -> aeb_fate_data:fate_type().
|
||||||
deserialize(B) ->
|
deserialize(B) ->
|
||||||
{T, <<>>} = deserialize2(B),
|
{T, <<>>} = deserialize2(B),
|
||||||
T.
|
T.
|
||||||
@ -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>>) ->
|
deserialize2(<<?NEG_SIGN:1, I:6, ?SMALL_INT:1, Rest/binary>>) ->
|
||||||
{?MAKE_FATE_INTEGER(-I), Rest};
|
{?MAKE_FATE_INTEGER(-I), Rest};
|
||||||
deserialize2(<<?NEG_BIG_INT, Rest/binary>>) ->
|
deserialize2(<<?NEG_BIG_INT, Rest/binary>>) ->
|
||||||
{Bint, Rest2} = ae_rlp:decode_one(Rest),
|
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
|
||||||
{?MAKE_FATE_INTEGER(-binary:decode_unsigned(Bint) - ?SMALL_INT_SIZE),
|
{?MAKE_FATE_INTEGER(-binary:decode_unsigned(Bint) - ?SMALL_INT_SIZE),
|
||||||
Rest2};
|
Rest2};
|
||||||
deserialize2(<<?POS_BIG_INT, Rest/binary>>) ->
|
deserialize2(<<?POS_BIG_INT, Rest/binary>>) ->
|
||||||
{Bint, Rest2} = ae_rlp:decode_one(Rest),
|
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
|
||||||
{?MAKE_FATE_INTEGER(binary:decode_unsigned(Bint) + ?SMALL_INT_SIZE),
|
{?MAKE_FATE_INTEGER(binary:decode_unsigned(Bint) + ?SMALL_INT_SIZE),
|
||||||
Rest2};
|
Rest2};
|
||||||
deserialize2(<<?NEG_BITS, Rest/binary>>) ->
|
deserialize2(<<?NEG_BITS, Rest/binary>>) ->
|
||||||
{Bint, Rest2} = ae_rlp:decode_one(Rest),
|
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
|
||||||
{?FATE_BITS(-binary:decode_unsigned(Bint)), Rest2};
|
{?FATE_BITS(-binary:decode_unsigned(Bint)), Rest2};
|
||||||
deserialize2(<<?POS_BITS, Rest/binary>>) ->
|
deserialize2(<<?POS_BITS, Rest/binary>>) ->
|
||||||
{Bint, Rest2} = ae_rlp:decode_one(Rest),
|
{Bint, Rest2} = aeb_rlp:decode_one(Rest),
|
||||||
{?FATE_BITS(binary:decode_unsigned(Bint)), Rest2};
|
{?FATE_BITS(binary:decode_unsigned(Bint)), Rest2};
|
||||||
deserialize2(<<?LONG_STRING, Rest/binary>>) ->
|
deserialize2(<<?LONG_STRING, Rest/binary>>) ->
|
||||||
{String, Rest2} = ae_rlp:decode_one(Rest),
|
{String, Rest2} = aeb_rlp:decode_one(Rest),
|
||||||
{?MAKE_FATE_STRING(String), Rest2};
|
{?MAKE_FATE_STRING(String), Rest2};
|
||||||
deserialize2(<<S:6, ?SHORT_STRING:2, Rest/binary>>) ->
|
deserialize2(<<S:6, ?SHORT_STRING:2, Rest/binary>>) ->
|
||||||
String = binary:part(Rest, 0, S),
|
String = binary:part(Rest, 0, S),
|
||||||
Rest2 = binary:part(Rest, byte_size(Rest), - (byte_size(Rest) - S)),
|
Rest2 = binary:part(Rest, byte_size(Rest), - (byte_size(Rest) - S)),
|
||||||
{?MAKE_FATE_STRING(String), Rest2};
|
{?MAKE_FATE_STRING(String), Rest2};
|
||||||
deserialize2(<<?ADDRESS, Rest/binary>>) ->
|
deserialize2(<<?ADDRESS, Rest/binary>>) ->
|
||||||
{A, Rest2} = ae_rlp:decode_one(Rest),
|
{A, Rest2} = aeb_rlp:decode_one(Rest),
|
||||||
{?FATE_ADDRESS(A), Rest2};
|
{?FATE_ADDRESS(A), Rest2};
|
||||||
deserialize2(<<?TRUE, Rest/binary>>) ->
|
deserialize2(<<?TRUE, Rest/binary>>) ->
|
||||||
{?FATE_TRUE, Rest};
|
{?FATE_TRUE, Rest};
|
||||||
@ -223,7 +223,7 @@ deserialize2(<<?EMPTY_MAP, Rest/binary>>) ->
|
|||||||
deserialize2(<<?EMPTY_STRING, Rest/binary>>) ->
|
deserialize2(<<?EMPTY_STRING, Rest/binary>>) ->
|
||||||
{?FATE_EMPTY_STRING, Rest};
|
{?FATE_EMPTY_STRING, Rest};
|
||||||
deserialize2(<<?LONG_TUPLE, Rest/binary>>) ->
|
deserialize2(<<?LONG_TUPLE, Rest/binary>>) ->
|
||||||
{BSize, Rest1} = ae_rlp:decode_one(Rest),
|
{BSize, Rest1} = aeb_rlp:decode_one(Rest),
|
||||||
N = binary:decode_unsigned(BSize) + ?SHORT_TUPLE_SIZE,
|
N = binary:decode_unsigned(BSize) + ?SHORT_TUPLE_SIZE,
|
||||||
{List, Rest2} = deserialize_elements(N, Rest1),
|
{List, Rest2} = deserialize_elements(N, Rest1),
|
||||||
{?FATE_TUPLE(list_to_tuple(List)), Rest2};
|
{?FATE_TUPLE(list_to_tuple(List)), Rest2};
|
||||||
@ -231,7 +231,7 @@ deserialize2(<<S:4, ?SHORT_TUPLE:4, Rest/binary>>) ->
|
|||||||
{List, Rest1} = deserialize_elements(S, Rest),
|
{List, Rest1} = deserialize_elements(S, Rest),
|
||||||
{?FATE_TUPLE(list_to_tuple(List)), Rest1};
|
{?FATE_TUPLE(list_to_tuple(List)), Rest1};
|
||||||
deserialize2(<<?LONG_LIST, Rest/binary>>) ->
|
deserialize2(<<?LONG_LIST, Rest/binary>>) ->
|
||||||
{BLength, Rest1} = ae_rlp:decode_one(Rest),
|
{BLength, Rest1} = aeb_rlp:decode_one(Rest),
|
||||||
Length = binary:decode_unsigned(BLength) + ?SHORT_LIST_SIZE,
|
Length = binary:decode_unsigned(BLength) + ?SHORT_LIST_SIZE,
|
||||||
{List, Rest2} = deserialize_elements(Length, Rest1),
|
{List, Rest2} = deserialize_elements(Length, Rest1),
|
||||||
{?MAKE_FATE_LIST(List), Rest2};
|
{?MAKE_FATE_LIST(List), Rest2};
|
||||||
@ -239,7 +239,7 @@ deserialize2(<<S:4, ?SHORT_LIST:4, Rest/binary>>) ->
|
|||||||
{List, Rest1} = deserialize_elements(S, Rest),
|
{List, Rest1} = deserialize_elements(S, Rest),
|
||||||
{?MAKE_FATE_LIST(List), Rest1};
|
{?MAKE_FATE_LIST(List), Rest1};
|
||||||
deserialize2(<<?MAP, Rest/binary>>) ->
|
deserialize2(<<?MAP, Rest/binary>>) ->
|
||||||
{BSize, Rest1} = ae_rlp:decode_one(Rest),
|
{BSize, Rest1} = aeb_rlp:decode_one(Rest),
|
||||||
Size = binary:decode_unsigned(BSize),
|
Size = binary:decode_unsigned(BSize),
|
||||||
{List, Rest2} = deserialize_elements(2*Size, Rest1),
|
{List, Rest2} = deserialize_elements(2*Size, Rest1),
|
||||||
Map = insert_kv(List, #{}),
|
Map = insert_kv(List, #{}),
|
@ -5,7 +5,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(aefa_opcodes).
|
-module(aeb_fate_opcodes).
|
||||||
|
|
||||||
-export([ args/1
|
-export([ args/1
|
||||||
, end_bb/1
|
, end_bb/1
|
||||||
@ -14,7 +14,7 @@
|
|||||||
, opcode/1
|
, opcode/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-include_lib("aebytecode/include/aefa_opcodes.hrl").
|
-include_lib("aebytecode/include/aeb_fate_opcodes.hrl").
|
||||||
|
|
||||||
|
|
||||||
%%====================================================================
|
%%====================================================================
|
@ -8,7 +8,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
|
|
||||||
-module(ae_rlp).
|
-module(aeb_rlp).
|
||||||
-export([ decode/1
|
-export([ decode/1
|
||||||
, decode_one/1
|
, decode_one/1
|
||||||
, encode/1
|
, encode/1
|
@ -43,8 +43,8 @@ assemble(File, Opts) ->
|
|||||||
Verbose = proplists:get_value(verbose, Opts, false),
|
Verbose = proplists:get_value(verbose, Opts, false),
|
||||||
case proplists:get_value(outfile, Opts, undefined) of
|
case proplists:get_value(outfile, Opts, undefined) of
|
||||||
undefined ->
|
undefined ->
|
||||||
Asm = aefa_asm:read_file(File),
|
Asm = aeb_fate_asm:read_file(File),
|
||||||
{Env, BC} = aefa_asm:asm_to_bytecode(Asm, Opts),
|
{Env, BC} = aeb_fate_asm:asm_to_bytecode(Asm, Opts),
|
||||||
case Verbose of
|
case Verbose of
|
||||||
true ->
|
true ->
|
||||||
io:format("Env: ~0p~n", [Env]);
|
io:format("Env: ~0p~n", [Env]);
|
||||||
@ -52,7 +52,7 @@ assemble(File, Opts) ->
|
|||||||
end,
|
end,
|
||||||
io:format("Code: ~0p~n", [BC]);
|
io:format("Code: ~0p~n", [BC]);
|
||||||
OutFile ->
|
OutFile ->
|
||||||
aefa_asm:assemble_file(File, OutFile, Opts)
|
aeb_fate_asm:assemble_file(File, OutFile, Opts)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user