From a14fa93920ba2171cc69ca60c9998ecdef84f0e9 Mon Sep 17 00:00:00 2001 From: Hans Svensson Date: Tue, 11 Jun 2019 09:21:44 +0200 Subject: [PATCH] Add contract_to_address to FATE --- rebar.config | 2 +- rebar.lock | 2 +- src/aeso_ast_to_fcode.erl | 4 ++-- src/aeso_fcode_to_fate.erl | 4 +++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/rebar.config b/rebar.config index c654952..15fb233 100644 --- a/rebar.config +++ b/rebar.config @@ -2,7 +2,7 @@ {erl_opts, [debug_info]}. -{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {ref, "876e850"}}} +{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git", {ref, "29b5ee3"}}} , {getopt, "1.0.1"} , {jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}} diff --git a/rebar.lock b/rebar.lock index cfb336d..4d651bc 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,7 +1,7 @@ {"1.1.0", [{<<"aebytecode">>, {git,"https://github.com/aeternity/aebytecode.git", - {ref,"876e8504c84ca8c2be787f203db1c742ebd746a0"}}, + {ref,"29b5ee3e68086e0f0170d3c70e92bbfa210cbae6"}}, 0}, {<<"aeserialization">>, {git,"https://github.com/aeternity/aeserialization.git", diff --git a/src/aeso_ast_to_fcode.erl b/src/aeso_ast_to_fcode.erl index f519be0..e7cb013 100644 --- a/src/aeso_ast_to_fcode.erl +++ b/src/aeso_ast_to_fcode.erl @@ -32,7 +32,7 @@ map_delete | map_member | map_size | string_length | string_concat | bits_set | bits_clear | bits_test | bits_sum | bits_intersection | bits_union | bits_difference | - contract_address | crypto_ecverify | crypto_ecverify_secp256k1 | + contract_to_address | crypto_ecverify | crypto_ecverify_secp256k1 | crypto_sha3 | crypto_sha256 | crypto_blake2b. -type flit() :: {int, integer()} @@ -390,7 +390,7 @@ expr_to_fcode(Env, _Type, {tuple, _, Es}) -> expr_to_fcode(Env, Type, {proj, _Ann, Rec = {typed, _, _, RecType}, {id, _, X}}) -> case RecType of {con, _, _} when X == "address" -> - {op, contract_address, [expr_to_fcode(Env, Rec)]}; + {op, contract_to_address, [expr_to_fcode(Env, Rec)]}; {con, _, _} -> {fun_t, _, Named, Args, _} = Type, Arity = length(Named) + length(Args), diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index 80791dc..1efc581 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -100,6 +100,7 @@ Op =:= 'BLAKE2B' orelse Op =:= 'ECVERIFY' orelse Op =:= 'ECVERIFY_SECP256K1' orelse + Op =:= 'CONTRACT_TO_ADDRESS' orelse false)). -record(env, { contract, vars = [], locals = [], tailpos = true }). @@ -535,7 +536,7 @@ op_to_scode(bits_union) -> aeb_fate_ops:bits_or(?a, ?a, ?a); op_to_scode(bits_difference) -> aeb_fate_ops:bits_diff(?a, ?a, ?a); op_to_scode(address_to_str) -> aeb_fate_ops:addr_to_str(?a, ?a); op_to_scode(int_to_str) -> aeb_fate_ops:int_to_str(?a, ?a); -op_to_scode(contract_address) -> ?TODO(fate_contract_to_address_conversion); +op_to_scode(contract_to_address) -> aeb_fate_ops:contract_to_address(?a, ?a); op_to_scode(crypto_ecverify) -> aeb_fate_ops:ecverify(?a, ?a, ?a, ?a); op_to_scode(crypto_ecverify_secp256k1) -> aeb_fate_ops:ecverify_secp256k1(?a, ?a, ?a, ?a); op_to_scode(crypto_sha3) -> aeb_fate_ops:sha3(?a, ?a); @@ -767,6 +768,7 @@ attributes(I) -> {'BLAKE2B', A, B} -> Pure(A, [B]); {'ECVERIFY', A, B, C, D} -> Pure(A, [B, C, D]); {'ECVERIFY_SECP256K1', A, B, C, D} -> Pure(A, [B, C, D]); + {'CONTRACT_TO_ADDRESS', A, B} -> Pure(A, [B]); {'ADDRESS', A} -> Pure(A, []); {'BALANCE', A} -> Impure(A, []); {'BALANCE_OTHER', A, B} -> Impure(A, [B]);