diff options
author | John Högberg <[email protected]> | 2019-06-18 10:34:33 +0200 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-06-18 10:34:33 +0200 |
commit | 48c6ae50648009218b91ae9cbc87890bbe0addb2 (patch) | |
tree | ea1dc463cd176417e6a636e84960fc8b1773006c /lib/compiler/src/beam_ssa_type.erl | |
parent | 63dec44359b45e735a8328a84ecc1d3826ee82f1 (diff) | |
parent | d7b6e2ef74c28bc60058b110bdefe5c54d1da058 (diff) | |
download | otp-48c6ae50648009218b91ae9cbc87890bbe0addb2.tar.gz otp-48c6ae50648009218b91ae9cbc87890bbe0addb2.tar.bz2 otp-48c6ae50648009218b91ae9cbc87890bbe0addb2.zip |
Merge branch 'john/compiler/cuddle-type-representation'
* john/compiler/cuddle-type-representation:
compiler: Add common method for literal -> type conversion
Diffstat (limited to 'lib/compiler/src/beam_ssa_type.erl')
-rw-r--r-- | lib/compiler/src/beam_ssa_type.erl | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/lib/compiler/src/beam_ssa_type.erl b/lib/compiler/src/beam_ssa_type.erl index 79ed0d7885..c348dc68d3 100644 --- a/lib/compiler/src/beam_ssa_type.erl +++ b/lib/compiler/src/beam_ssa_type.erl @@ -1210,36 +1210,7 @@ get_type(#b_var{}=V, Ts) -> #{V:=T} = Ts, T; get_type(#b_literal{val=Val}, _Ts) -> - if - is_atom(Val) -> - beam_types:make_atom(Val); - is_float(Val) -> - float; - is_function(Val) -> - {arity,Arity} = erlang:fun_info(Val, arity), - #t_fun{arity=Arity}; - is_integer(Val) -> - beam_types:make_integer(Val); - is_list(Val), Val =/= [] -> - cons; - is_map(Val) -> - #t_map{}; - Val =:= {} -> - beam_types:make_tuple(0, true); - is_tuple(Val) -> - {Es, _} = foldl(fun(E, {Es0, Index}) -> - Type = get_type(#b_literal{val=E}, #{}), - Es = beam_types:set_element_type(Index, - Type, - Es0), - {Es, Index + 1} - end, {#{}, 1}, tuple_to_list(Val)), - beam_types:make_tuple(tuple_size(Val), true, Es); - Val =:= [] -> - nil; - true -> - any - end. + beam_types:make_type_from_value(Val). %% infer_types(Var, Types, #d{}) -> {SuccTypes,FailTypes} %% Looking at the expression that defines the variable Var, infer |