Fix dialyzer things
This commit is contained in:
parent
ff58ec0cba
commit
96bff0c32f
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
%% -- Type definitions -------------------------------------------------------
|
%% -- Type definitions -------------------------------------------------------
|
||||||
|
|
||||||
-type option() :: none().
|
-type option() :: term().
|
||||||
|
|
||||||
-type attribute() :: stateful | pure.
|
-type attribute() :: stateful | pure.
|
||||||
|
|
||||||
@ -44,8 +44,21 @@
|
|||||||
| {tuple, [var_name()]}
|
| {tuple, [var_name()]}
|
||||||
| {var, var_name()}.
|
| {var, var_name()}.
|
||||||
|
|
||||||
-type ftype() :: aeb_fate_data:fate_type_type().
|
-type ftype() :: integer
|
||||||
|
| boolean
|
||||||
|
| {list, ftype()}
|
||||||
|
| {map, ftype(), ftype()}
|
||||||
|
| {tuple, [ftype()]}
|
||||||
|
| address
|
||||||
|
| hash
|
||||||
|
| signature
|
||||||
|
| contract
|
||||||
|
| oracle
|
||||||
|
| oracle_query
|
||||||
|
| name
|
||||||
|
| channel
|
||||||
|
| bits
|
||||||
|
| {variant, [[ftype()]]}.
|
||||||
|
|
||||||
-type fun_def() :: #{ attrs := [attribute()],
|
-type fun_def() :: #{ attrs := [attribute()],
|
||||||
args := [{var_name(), ftype()}],
|
args := [{var_name(), ftype()}],
|
||||||
@ -66,7 +79,7 @@
|
|||||||
|
|
||||||
-type env() :: #{ type_env := type_env(),
|
-type env() :: #{ type_env := type_env(),
|
||||||
fun_env := fun_env(),
|
fun_env := fun_env(),
|
||||||
options := [],
|
options := [option()],
|
||||||
context => context(),
|
context => context(),
|
||||||
functions := #{ fun_name() => fun_def() } }.
|
functions := #{ fun_name() => fun_def() } }.
|
||||||
|
|
||||||
@ -390,13 +403,13 @@ next_split(Pats) ->
|
|||||||
alt_to_fcode(Env, {'case', _, Pat, Expr}) ->
|
alt_to_fcode(Env, {'case', _, Pat, Expr}) ->
|
||||||
{'case', [pat_to_fcode(Env, Pat)], expr_to_fcode(Env, Expr)}.
|
{'case', [pat_to_fcode(Env, Pat)], expr_to_fcode(Env, Expr)}.
|
||||||
|
|
||||||
-spec pat_to_fcode(env(), aeso_syntax:pattern()) -> fpat().
|
-spec pat_to_fcode(env(), aeso_syntax:pat()) -> fpat().
|
||||||
pat_to_fcode(Env, {typed, _, Pat, Type}) ->
|
pat_to_fcode(Env, {typed, _, Pat, Type}) ->
|
||||||
pat_to_fcode(Env, type_to_fcode(Env, Type), Pat);
|
pat_to_fcode(Env, type_to_fcode(Env, Type), Pat);
|
||||||
pat_to_fcode(Env, Pat) ->
|
pat_to_fcode(Env, Pat) ->
|
||||||
pat_to_fcode(Env, no_type, Pat).
|
pat_to_fcode(Env, no_type, Pat).
|
||||||
|
|
||||||
-spec pat_to_fcode(env(), ftype() | no_type, aeso_syntax:pattern()) -> fpat().
|
-spec pat_to_fcode(env(), ftype() | no_type, aeso_syntax:pat()) -> fpat().
|
||||||
pat_to_fcode(_Env, _Type, {id, _, X}) -> {var, X};
|
pat_to_fcode(_Env, _Type, {id, _, X}) -> {var, X};
|
||||||
pat_to_fcode(Env, _Type, {tuple, _, Pats}) ->
|
pat_to_fcode(Env, _Type, {tuple, _, Pats}) ->
|
||||||
{tuple, [ pat_to_fcode(Env, Pat) || Pat <- Pats ]};
|
{tuple, [ pat_to_fcode(Env, Pat) || Pat <- Pats ]};
|
||||||
@ -435,7 +448,7 @@ lookup_type(Env, Name, Args) ->
|
|||||||
Type -> Type
|
Type -> Type
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec lookup_type(env(), sophia_name(), [ftype()], ftype()) -> ftype().
|
-spec lookup_type(env(), sophia_name(), [ftype()], ftype() | A) -> ftype() | A.
|
||||||
lookup_type(#{ type_env := TypeEnv }, Name, Args, Default) ->
|
lookup_type(#{ type_env := TypeEnv }, Name, Args, Default) ->
|
||||||
case maps:get(Name, TypeEnv, false) of
|
case maps:get(Name, TypeEnv, false) of
|
||||||
false -> Default;
|
false -> Default;
|
||||||
@ -444,7 +457,7 @@ lookup_type(#{ type_env := TypeEnv }, Name, Args, Default) ->
|
|||||||
|
|
||||||
%% -- Names --
|
%% -- Names --
|
||||||
|
|
||||||
-spec add_fun_env(env(), [aeso_syntax:decl()]) -> fun_env().
|
-spec add_fun_env(env(), [aeso_syntax:decl()]) -> env().
|
||||||
add_fun_env(#{ context := {abstract_contract, _} }, _) -> #{}; %% no functions from abstract contracts
|
add_fun_env(#{ context := {abstract_contract, _} }, _) -> #{}; %% no functions from abstract contracts
|
||||||
add_fun_env(Env = #{ fun_env := FunEnv }, Decls) ->
|
add_fun_env(Env = #{ fun_env := FunEnv }, Decls) ->
|
||||||
Entry = fun({letfun, Ann, {id, _, Name}, _, _, _}) ->
|
Entry = fun({letfun, Ann, {id, _, Name}, _, _, _}) ->
|
||||||
|
@ -14,18 +14,20 @@
|
|||||||
|
|
||||||
%% -- Preamble ---------------------------------------------------------------
|
%% -- Preamble ---------------------------------------------------------------
|
||||||
|
|
||||||
-type scode() :: {switch, stype(), [maybe_scode()], maybe_scode()} %% last arg is catch-all
|
-type scode() :: [sinstr()].
|
||||||
| switch_body
|
-type sinstr() :: {switch, stype(), [maybe_scode()], maybe_scode()} %% last arg is catch-all
|
||||||
| tuple(). %% FATE instruction
|
| switch_body
|
||||||
|
| tuple(). %% FATE instruction
|
||||||
|
|
||||||
%% Annotated scode
|
%% Annotated scode
|
||||||
-type scode_a() :: {switch, stype(), [maybe_scode_a()], maybe_scode_a()} %% last arg is catch-all
|
-type scode_a() :: [sinstr_a()].
|
||||||
| switch_body
|
-type sinstr_a() :: {switch, stype(), [maybe_scode_a()], maybe_scode_a()} %% last arg is catch-all
|
||||||
| {i, ann(), tuple()}. %% FATE instruction
|
| switch_body
|
||||||
|
| {i, ann(), tuple()}. %% FATE instruction
|
||||||
|
|
||||||
-type ann() :: #{ live_in := vars(), live_out := vars() }.
|
-type ann() :: #{ live_in := vars(), live_out := vars() }.
|
||||||
-type var() :: {var, integer()}.
|
-type var() :: {var, integer()}.
|
||||||
-type vars() :: ordsets:set(var()).
|
-type vars() :: ordsets:ordset(var()).
|
||||||
|
|
||||||
-type stype() :: tuple | boolean.
|
-type stype() :: tuple | boolean.
|
||||||
-type maybe_scode() :: missing | scode().
|
-type maybe_scode() :: missing | scode().
|
||||||
@ -612,8 +614,7 @@ r_swap_write(Pre, I, Code0 = [J | Code]) ->
|
|||||||
true ->
|
true ->
|
||||||
{J1, I1} = swap_instrs(I, J),
|
{J1, I1} = swap_instrs(I, J),
|
||||||
r_swap_write([J1 | Pre], I1, Code)
|
r_swap_write([J1 | Pre], I1, Code)
|
||||||
end;
|
end
|
||||||
_ -> false
|
|
||||||
end;
|
end;
|
||||||
r_swap_write(_, _, _) -> false.
|
r_swap_write(_, _, _) -> false.
|
||||||
|
|
||||||
@ -683,7 +684,9 @@ r_write_to_dead_var(_, _) -> false.
|
|||||||
|
|
||||||
|
|
||||||
%% Desugar and specialize and remove annotations
|
%% Desugar and specialize and remove annotations
|
||||||
-spec unannotate(scode_a()) -> scode().
|
-spec unannotate(scode_a()) -> scode();
|
||||||
|
(sinstr_a()) -> sinstr();
|
||||||
|
(missing) -> missing.
|
||||||
unannotate(switch_body) -> [switch_body];
|
unannotate(switch_body) -> [switch_body];
|
||||||
unannotate({switch, Type, Alts, Def}) ->
|
unannotate({switch, Type, Alts, Def}) ->
|
||||||
[{switch, Type, [unannotate(A) || A <- Alts], unannotate(Def)}];
|
[{switch, Type, [unannotate(A) || A <- Alts], unannotate(Def)}];
|
||||||
@ -744,7 +747,7 @@ blocks([], Acc) ->
|
|||||||
blocks([Blk | Blocks], Acc) ->
|
blocks([Blk | Blocks], Acc) ->
|
||||||
block(Blk, [], Blocks, Acc).
|
block(Blk, [], Blocks, Acc).
|
||||||
|
|
||||||
-spec block(#blk{}, bcode(), [#blk{}], [bb()]) -> bb().
|
-spec block(#blk{}, bcode(), [#blk{}], [bb()]) -> [bb()].
|
||||||
block(#blk{ref = Ref, code = []}, CodeAcc, Blocks, BlockAcc) ->
|
block(#blk{ref = Ref, code = []}, CodeAcc, Blocks, BlockAcc) ->
|
||||||
blocks(Blocks, [{Ref, lists:reverse(CodeAcc)} | BlockAcc]);
|
blocks(Blocks, [{Ref, lists:reverse(CodeAcc)} | BlockAcc]);
|
||||||
block(Blk = #blk{code = [switch_body | Code]}, Acc, Blocks, BlockAcc) ->
|
block(Blk = #blk{code = [switch_body | Code]}, Acc, Blocks, BlockAcc) ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user