From 2291f8d4c16792e91595beefb03a2ba0c1573455 Mon Sep 17 00:00:00 2001 From: Ulf Norell Date: Fri, 3 May 2019 16:54:03 +0200 Subject: [PATCH] Compile bytes(N) Compile to FATE strings for now --- src/aeso_ast_infer_types.erl | 2 +- src/aeso_ast_to_fcode.erl | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index f157eb7..a24aaea 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -359,7 +359,7 @@ global_env() -> Fun1 = fun(S, T) -> Fun([S], T) end, TVar = fun(X) -> {tvar, Ann, "'" ++ X} end, SignId = {id, Ann, "signature"}, - SignDef = {tuple, Ann, [{int, Ann, 0}, {int, Ann, 0}]}, + SignDef = {bytes, Ann, <<0:64/unit:8>>}, Signature = {named_arg_t, Ann, SignId, SignId, {typed, Ann, SignDef, SignId}}, SignFun = fun(Ts, T) -> {type_sig, Ann, [Signature], Ts, T} end, TTL = {qid, Ann, ["Chain", "ttl"]}, diff --git a/src/aeso_ast_to_fcode.erl b/src/aeso_ast_to_fcode.erl index 1fac9ba..57ab3b3 100644 --- a/src/aeso_ast_to_fcode.erl +++ b/src/aeso_ast_to_fcode.erl @@ -294,6 +294,8 @@ type_to_fcode(Env, Sub, {tuple_t, _, Types}) -> type_to_fcode(Env, Sub, {record_t, Fields}) -> FieldType = fun({field_t, _, _, Ty}) -> Ty end, type_to_fcode(Env, Sub, {tuple_t, [], lists:map(FieldType, Fields)}); +type_to_fcode(_Env, _Sub, {bytes_t, _, _N}) -> + string; %% TODO: add bytes type to FATE? type_to_fcode(_Env, Sub, {tvar, _, X}) -> maps:get(X, Sub, any); type_to_fcode(_Env, _Sub, Type) -> @@ -321,6 +323,8 @@ expr_to_fcode(_Env, _Type, {contract_pubkey, _, K}) -> {contract_pubkey, K}; expr_to_fcode(_Env, _Type, {oracle_pubkey, _, K}) -> {oracle_pubkey, K}; expr_to_fcode(_Env, _Type, {oracle_query_id, _, K}) -> {oracle_query_id, K}; +expr_to_fcode(_Env, _Type, {bytes, _, Bin}) -> {string, Bin}; + %% Variables expr_to_fcode(Env, _Type, {id, _, X}) -> resolve_var(Env, [X]); expr_to_fcode(Env, _Type, {qid, _, X}) -> resolve_var(Env, X);