We should not deserialize function blocks only containing opcodes, but not a function
This commit is contained in:
parent
25ef7e7fe3
commit
41860b041e
@ -302,6 +302,9 @@ deserialize_functions(<<?FUNCTION:8, A, B, C, D, Rest/binary>>,
|
|||||||
Program#{ BB => lists:reverse(Code)}}}},
|
Program#{ BB => lists:reverse(Code)}}}},
|
||||||
deserialize_functions(Rest2, Env2)
|
deserialize_functions(Rest2, Env2)
|
||||||
end;
|
end;
|
||||||
|
deserialize_functions(<<Op:8, Rest/binary>>,
|
||||||
|
#{ function := none }) ->
|
||||||
|
error({code_without_function});
|
||||||
deserialize_functions(<<Op:8, Rest/binary>>,
|
deserialize_functions(<<Op:8, Rest/binary>>,
|
||||||
#{ bb := BB
|
#{ bb := BB
|
||||||
, current_bb_code := Code
|
, current_bb_code := Code
|
||||||
@ -343,6 +346,7 @@ deserialize_op(Op, Rest, Code) ->
|
|||||||
|
|
||||||
deserialize_n_args(N, <<M3:2, M2:2, M1:2, M0:2, Rest/binary>>) when N =< 4 ->
|
deserialize_n_args(N, <<M3:2, M2:2, M1:2, M0:2, Rest/binary>>) when N =< 4 ->
|
||||||
ArgMods = lists:sublist([M0, M1, M2, M3], N),
|
ArgMods = lists:sublist([M0, M1, M2, M3], N),
|
||||||
|
%% If N == 1 then we take M0 and don't care about the others. Should we check that the others are 0??
|
||||||
lists:mapfoldl(fun(M, Acc) ->
|
lists:mapfoldl(fun(M, Acc) ->
|
||||||
case bits_to_modifier(M) of
|
case bits_to_modifier(M) of
|
||||||
stack ->
|
stack ->
|
||||||
|
@ -269,12 +269,18 @@ deserialize_types(N, Binary, Acc) ->
|
|||||||
rlp_encode_int(S) when S >= 0 ->
|
rlp_encode_int(S) when S >= 0 ->
|
||||||
aeser_rlp:encode(binary:encode_unsigned(S)).
|
aeser_rlp:encode(binary:encode_unsigned(S)).
|
||||||
|
|
||||||
|
|
||||||
|
%% first byte of the binary gives the number of bytes we need <<129>> is 1, <<130>> = 2,
|
||||||
|
%% so <<129, 0>> is <<0>> and <<130, 0, 0>> is <<0, 0>>
|
||||||
rlp_decode_int(Binary) ->
|
rlp_decode_int(Binary) ->
|
||||||
case aeser_rlp:decode_one(Binary) of
|
{Bin1, Rest} = aeser_rlp:decode_one(Binary),
|
||||||
{<<>>, _} ->
|
Int = binary:decode_unsigned(Bin1),
|
||||||
error({illegal_integer_encoding, Binary});
|
ReEncode = rlp_encode_int(Int),
|
||||||
{Bin1, Rest} ->
|
case <<ReEncode/binary, Rest/binary>> == Binary of
|
||||||
{binary:decode_unsigned(Bin1), Rest}
|
true ->
|
||||||
|
{Int, Rest};
|
||||||
|
false ->
|
||||||
|
error({none_unique_encoding, Bin1, ReEncode})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
serialize_integer(I) when ?IS_FATE_INTEGER(I) ->
|
serialize_integer(I) when ?IS_FATE_INTEGER(I) ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user