diff options
author | John Högberg <[email protected]> | 2019-05-24 15:26:53 +0200 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-06-12 13:33:46 +0200 |
commit | 9cfcddacc961301733619d998833e0fe345966e7 (patch) | |
tree | d56524c1d47718e3c3b7c6cf58f196c35b7d1663 /lib/compiler/src/beam_types.hrl | |
parent | 9bf77c86ec83853d321958dac3582fdc2f00b045 (diff) | |
download | otp-9cfcddacc961301733619d998833e0fe345966e7.tar.gz otp-9cfcddacc961301733619d998833e0fe345966e7.tar.bz2 otp-9cfcddacc961301733619d998833e0fe345966e7.zip |
compiler: Move "known functions" to beam_types
Diffstat (limited to 'lib/compiler/src/beam_types.hrl')
-rw-r--r-- | lib/compiler/src/beam_types.hrl | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/lib/compiler/src/beam_types.hrl b/lib/compiler/src/beam_types.hrl index dfbf104a2a..b82cdf8df2 100644 --- a/lib/compiler/src/beam_types.hrl +++ b/lib/compiler/src/beam_types.hrl @@ -25,15 +25,15 @@ %% %% any Any Erlang term (top element). %% -%% - atom An atom. -%% - {binary,Unit} A bitstring aligned to unit Unit. -%% - #t_bs_match{} A match context. -%% - #t_fun{} A fun. -%% - map A map. -%% - number A number. +%% - #t_atom{} Atom, or a set thereof. +%% - #t_bitstring{} Bitstring. +%% - #t_bs_context{} Match context. +%% - #t_fun{} Fun. +%% - #t_map{} Map. +%% - number Any number. %% -- float Floating point number. %% -- integer Integer. -%% - list A list. +%% - list Any list. %% -- cons Cons (nonempty list). %% -- nil The empty list. %% - #t_tuple{} Tuple. @@ -45,14 +45,25 @@ -record(t_atom, {elements=any :: 'any' | [atom()]}). -record(t_fun, {arity=any :: arity() | 'any'}). -record(t_integer, {elements=any :: 'any' | {integer(),integer()}}). --record(t_bs_match, {type :: type()}). +-record(t_bitstring, {unit=1 :: pos_integer()}). +-record(t_bs_context, {slots=0 :: non_neg_integer(), + valid=0 :: non_neg_integer()}). +-record(t_map, {elements=#{} :: map_elements()}). -record(t_tuple, {size=0 :: integer(), exact=false :: boolean(), - %% Known element types (1-based index), unknown elements are - %% are assumed to be 'any'. - elements=#{} :: #{ non_neg_integer() => type() }}). + elements=#{} :: tuple_elements()}). --type type() :: 'any' | 'none' | - #t_atom{} | #t_bs_match{} | #t_fun{} | #t_integer{} | - #t_tuple{} | {'binary',pos_integer()} | 'cons' | 'float' | - 'list' | 'map' | 'nil' | 'number'. +%% Known element types, unknown elements are assumed to be 'any'. The key is +%% a 1-based integer index for tuples, and a plain literal for maps (that is, +%% not wrapped in a #b_literal{}, just the value itself). + +-type tuple_elements() :: #{ Key :: pos_integer() => type() }. +-type map_elements() :: #{ Key :: term() => type() }. + +-type elements() :: tuple_elements() | map_elements(). + +-type type() :: any | none | + list | number | + #t_atom{} | #t_bitstring{} | #t_bs_context{} | #t_fun{} | + #t_integer{} | #t_map{} | #t_tuple{} | 'cons' | + 'float' | 'nil'. |