Update compiler for bytes
This commit is contained in:
parent
20aeade545
commit
4f9d4e5c07
@ -37,8 +37,7 @@
|
|||||||
|
|
||||||
-type flit() :: {int, integer()}
|
-type flit() :: {int, integer()}
|
||||||
| {string, binary()}
|
| {string, binary()}
|
||||||
| {hash, binary()}
|
| {bytes, binary()}
|
||||||
| {signature, binary()}
|
|
||||||
| {account_pubkey, binary()}
|
| {account_pubkey, binary()}
|
||||||
| {contract_pubkey, binary()}
|
| {contract_pubkey, binary()}
|
||||||
| {oracle_pubkey, binary()}
|
| {oracle_pubkey, binary()}
|
||||||
@ -90,8 +89,7 @@
|
|||||||
| {map, ftype(), ftype()}
|
| {map, ftype(), ftype()}
|
||||||
| {tuple, [ftype()]}
|
| {tuple, [ftype()]}
|
||||||
| address
|
| address
|
||||||
| hash
|
| {bytes, non_neg_integer()}
|
||||||
| signature
|
|
||||||
| contract
|
| contract
|
||||||
| {oracle, ftype(), ftype()} %% Query type, Response type
|
| {oracle, ftype(), ftype()} %% Query type, Response type
|
||||||
| oracle_query
|
| oracle_query
|
||||||
@ -320,10 +318,8 @@ type_to_fcode(Env, Sub, {tuple_t, _, Types}) ->
|
|||||||
type_to_fcode(Env, Sub, {record_t, Fields}) ->
|
type_to_fcode(Env, Sub, {record_t, Fields}) ->
|
||||||
FieldType = fun({field_t, _, _, Ty}) -> Ty end,
|
FieldType = fun({field_t, _, _, Ty}) -> Ty end,
|
||||||
type_to_fcode(Env, Sub, {tuple_t, [], lists:map(FieldType, Fields)});
|
type_to_fcode(Env, Sub, {tuple_t, [], lists:map(FieldType, Fields)});
|
||||||
type_to_fcode(_Env, _Sub, {bytes_t, _, 32}) -> hash;
|
type_to_fcode(_Env, _Sub, {bytes_t, _, N}) ->
|
||||||
type_to_fcode(_Env, _Sub, {bytes_t, _, 64}) -> signature;
|
{bytes, N};
|
||||||
type_to_fcode(_Env, _Sub, {bytes_t, _, _N}) ->
|
|
||||||
string; %% TODO: add bytes type to FATE
|
|
||||||
type_to_fcode(_Env, Sub, {tvar, _, X}) ->
|
type_to_fcode(_Env, Sub, {tvar, _, X}) ->
|
||||||
maps:get(X, Sub, {tvar, X});
|
maps:get(X, Sub, {tvar, X});
|
||||||
type_to_fcode(Env, Sub, {fun_t, _, Named, Args, Res}) ->
|
type_to_fcode(Env, Sub, {fun_t, _, Named, Args, Res}) ->
|
||||||
@ -367,10 +363,7 @@ expr_to_fcode(_Env, _Type, {account_pubkey, _, K}) -> {lit, {account_pubkey, K}
|
|||||||
expr_to_fcode(_Env, _Type, {contract_pubkey, _, K}) -> {lit, {contract_pubkey, K}};
|
expr_to_fcode(_Env, _Type, {contract_pubkey, _, K}) -> {lit, {contract_pubkey, K}};
|
||||||
expr_to_fcode(_Env, _Type, {oracle_pubkey, _, K}) -> {lit, {oracle_pubkey, K}};
|
expr_to_fcode(_Env, _Type, {oracle_pubkey, _, K}) -> {lit, {oracle_pubkey, K}};
|
||||||
expr_to_fcode(_Env, _Type, {oracle_query_id, _, K}) -> {lit, {oracle_query_id, K}};
|
expr_to_fcode(_Env, _Type, {oracle_query_id, _, K}) -> {lit, {oracle_query_id, K}};
|
||||||
|
expr_to_fcode(_Env, _Type, {bytes, _, B}) -> {lit, {bytes, B}};
|
||||||
expr_to_fcode(_Env, _Type, {bytes, _, Bin = <<_:32/binary>>}) -> {lit, {hash, Bin}};
|
|
||||||
expr_to_fcode(_Env, _Type, {bytes, _, Bin = <<_:64/binary>>}) -> {lit, {signature, Bin}};
|
|
||||||
expr_to_fcode(_Env, _Type, {bytes, _, Bin}) -> {lit, {string, Bin}};
|
|
||||||
|
|
||||||
%% Variables
|
%% Variables
|
||||||
expr_to_fcode(Env, _Type, {id, _, X}) -> resolve_var(Env, [X]);
|
expr_to_fcode(Env, _Type, {id, _, X}) -> resolve_var(Env, [X]);
|
||||||
|
@ -161,8 +161,7 @@ type_to_scode(integer) -> integer;
|
|||||||
type_to_scode(boolean) -> boolean;
|
type_to_scode(boolean) -> boolean;
|
||||||
type_to_scode(string) -> string;
|
type_to_scode(string) -> string;
|
||||||
type_to_scode(address) -> address;
|
type_to_scode(address) -> address;
|
||||||
type_to_scode(hash) -> hash;
|
type_to_scode({bytes, N}) -> {bytes, N};
|
||||||
type_to_scode(signature) -> signature;
|
|
||||||
type_to_scode(contract) -> contract;
|
type_to_scode(contract) -> contract;
|
||||||
type_to_scode({oracle, _, _}) -> oracle;
|
type_to_scode({oracle, _, _}) -> oracle;
|
||||||
type_to_scode(oracle_query) -> oracle_query;
|
type_to_scode(oracle_query) -> oracle_query;
|
||||||
@ -236,8 +235,7 @@ lit_to_fate(L) ->
|
|||||||
case L of
|
case L of
|
||||||
{int, N} -> aeb_fate_data:make_integer(N);
|
{int, N} -> aeb_fate_data:make_integer(N);
|
||||||
{string, S} -> aeb_fate_data:make_string(S);
|
{string, S} -> aeb_fate_data:make_string(S);
|
||||||
{hash, H} -> aeb_fate_data:make_hash(H);
|
{bytes, B} -> aeb_fate_data:make_bytes(B);
|
||||||
{signature, S} -> aeb_fate_data:make_signature(S);
|
|
||||||
{bool, B} -> aeb_fate_data:make_boolean(B);
|
{bool, B} -> aeb_fate_data:make_boolean(B);
|
||||||
{account_pubkey, K} -> aeb_fate_data:make_address(K);
|
{account_pubkey, K} -> aeb_fate_data:make_address(K);
|
||||||
{contract_pubkey, K} -> aeb_fate_data:make_contract(K);
|
{contract_pubkey, K} -> aeb_fate_data:make_contract(K);
|
||||||
|
@ -69,9 +69,7 @@ from_fate({id, _, "address"}, ?FATE_ADDRESS(Bin)) -> {account_pubkey, [], Bin};
|
|||||||
from_fate({app_t, _, {id, _, "oracle"}, _}, ?FATE_ORACLE(Bin)) -> {oracle_pubkey, [], Bin};
|
from_fate({app_t, _, {id, _, "oracle"}, _}, ?FATE_ORACLE(Bin)) -> {oracle_pubkey, [], Bin};
|
||||||
from_fate({app_t, _, {id, _, "oracle_query"}, _}, ?FATE_ORACLE_Q(Bin)) -> {oracle_query_id, [], Bin};
|
from_fate({app_t, _, {id, _, "oracle_query"}, _}, ?FATE_ORACLE_Q(Bin)) -> {oracle_query_id, [], Bin};
|
||||||
from_fate({con, _, _Name}, ?FATE_CONTRACT(Bin)) -> {contract_pubkey, [], Bin};
|
from_fate({con, _, _Name}, ?FATE_CONTRACT(Bin)) -> {contract_pubkey, [], Bin};
|
||||||
from_fate({bytes_t, _, 32}, ?FATE_HASH(Bin)) -> {bytes, [], Bin};
|
from_fate({bytes_t, _, N}, ?FATE_BYTES(Bin)) when byte_size(Bin) == N -> {bytes, [], Bin};
|
||||||
from_fate({bytes_t, _, 64}, ?FATE_SIGNATURE(Bin)) -> {bytes, [], Bin};
|
|
||||||
from_fate({bytes_t, _, N}, Bin) when size(Bin) == N -> {bytes, [], Bin};
|
|
||||||
from_fate({id, _, "bits"}, ?FATE_BITS(Bin)) -> error({todo, bits, Bin});
|
from_fate({id, _, "bits"}, ?FATE_BITS(Bin)) -> error({todo, bits, Bin});
|
||||||
from_fate({id, _, "int"}, N) when is_integer(N) -> {int, [], N};
|
from_fate({id, _, "int"}, N) when is_integer(N) -> {int, [], N};
|
||||||
from_fate({id, _, "bool"}, B) when is_boolean(B) -> {bool, [], B};
|
from_fate({id, _, "bool"}, B) when is_boolean(B) -> {bool, [], B};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user