diff --git a/src/aeso_ast_to_fcode.erl b/src/aeso_ast_to_fcode.erl index 91ea6d7..0e06cac 100644 --- a/src/aeso_ast_to_fcode.erl +++ b/src/aeso_ast_to_fcode.erl @@ -80,6 +80,7 @@ -type ftype() :: integer | boolean + | string | {list, ftype()} | {map, ftype(), ftype()} | {tuple, [ftype()]} @@ -268,7 +269,7 @@ decl_to_fcode(Env = #{ functions := Funs }, {letfun, Ann, {id, _, Name}, Args, R NewFuns = Funs#{ FName => Def }, Env#{ functions := NewFuns }. --spec typedef_to_fcode(env(), aeso_syntax:id(), [aeso_syntax:tvar()], aeso_syntax:type_def()) -> env(). +-spec typedef_to_fcode(env(), aeso_syntax:id(), [aeso_syntax:tvar()], aeso_syntax:typedef()) -> env(). typedef_to_fcode(Env, {id, _, Name}, Xs, Def) -> Q = qname(Env, Name), FDef = fun(Args) -> @@ -659,8 +660,9 @@ pat_to_fcode(Env, Pat) -> -spec pat_to_fcode(env(), aeso_syntax:type() | no_type, aeso_syntax:pat()) -> fpat(). pat_to_fcode(_Env, _Type, {id, _, X}) -> {var, X}; -pat_to_fcode(Env, Type, {C, _, _} = Con) when C == con; C == qcon -> - pat_to_fcode(Env, Type, {app, [], {typed, [], Con, Type}, []}); +pat_to_fcode(Env, _Type, {C, _, _} = Con) when C == con; C == qcon -> + #con_tag{tag = I, arities = As} = lookup_con(Env, Con), + {con, As, I, []}; pat_to_fcode(Env, _Type, {app, _, {typed, _, {C, _, _} = Con, _}, Pats}) when C == con; C == qcon -> #con_tag{tag = I, arities = As} = lookup_con(Env, Con), {con, As, I, [pat_to_fcode(Env, Pat) || Pat <- Pats]}; diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index 10ab077..d70f2cb 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -18,7 +18,7 @@ | switch_body | tuple(). %% FATE instruction --type arg() :: aeb_fate_code:fate_arg(). +-type arg() :: tuple(). %% Not exported: aeb_fate_code:fate_arg(). %% Annotated scode -type scode_a() :: [sinstr_a()]. @@ -97,7 +97,7 @@ debug(Tag, Options, Fmt, Args) -> Tags = proplists:get_value(debug, Options, []), - case Tags == all orelse lists:member(Tag, Tags) orelse Tag == any andalso Tags /= [] of + case Tags == all orelse lists:member(Tag, Tags) of true -> io:format(Fmt, Args); false -> ok end. @@ -185,7 +185,7 @@ to_scode(_Env, {lit, L}) -> {account_pubkey, K} -> [push(?i(aeb_fate_data:make_address(K)))]; {contract_pubkey, K} -> [push(?i(aeb_fate_data:make_address(K)))]; {oracle_pubkey, K} -> [push(?i(aeb_fate_data:make_oracle(K)))]; - {oracle_query_id, K} -> [push(?i(aeb_fate_data:make_oracle_query(K)))] %% TODO: Not actually in FATE yet + {oracle_query_id, _} -> ?TODO(fate_oracle_query_id_value) end; to_scode(_Env, nil) -> @@ -743,9 +743,10 @@ var_writes(I) -> _ -> [] end. -independent({switch, _, _, _, _}, _) -> false; +-spec independent(sinstr_a(), sinstr_a()) -> boolean(). +%% independent({switch, _, _, _, _}, _) -> false; %% Commented due to Dialyzer whinging independent(_, {switch, _, _, _, _}) -> false; -independent(switch_body, _) -> true; +%% independent(switch_body, _) -> true; independent(_, switch_body) -> true; independent({i, _, I}, {i, _, J}) -> #{ write := WI, read := RI, pure := PureI } = attributes(I), @@ -768,7 +769,7 @@ merge_ann(#{ live_in := LiveIn }, #{ live_out := LiveOut }) -> %% Swap two instructions. Precondition: the instructions are independent/2. swap_instrs(I, switch_body) -> {switch_body, I}; -swap_instrs(switch_body, I) -> {I, switch_body}; +%% swap_instrs(switch_body, I) -> {I, switch_body}; %% Commented due to Dialyzer whinging swap_instrs({i, #{ live_in := Live1 }, I}, {i, #{ live_in := Live2, live_out := Live3 }, J}) -> %% Since I and J are independent the J can't read or write anything in %% that I writes.