diff options
Diffstat (limited to 'lib/hipe')
26 files changed, 272 insertions, 2724 deletions
diff --git a/lib/hipe/Makefile b/lib/hipe/Makefile index 2294f98158..a9e24f4d17 100644 --- a/lib/hipe/Makefile +++ b/lib/hipe/Makefile @@ -57,20 +57,20 @@ edocs: fi all-subdirs: - for dir in $(SUB_DIRECTORIES); do \ + $(V_at)for dir in $(SUB_DIRECTORIES); do \ (cd $$dir; $(MAKE) $(MAKETARGET) EBIN=$(EBIN); cd ..); \ done # distclean and realclean should clean the bootstrap files all-subdirs-x: - for dir in $(SUB_DIRECTORIES); do \ + $(V_at)for dir in $(SUB_DIRECTORIES); do \ (cd $$dir; $(MAKE) $(MAKETARGET) EBIN=../boot_ebin; cd ..); \ done clean: - $(MAKE) MAKETARGET="clean" all-subdirs all-subdirs-x + $(V_at)$(MAKE) MAKETARGET="clean" all-subdirs all-subdirs-x distclean: - $(MAKE) MAKETARGET="distclean" all-subdirs all-subdirs-x + $(V_at)$(MAKE) MAKETARGET="distclean" all-subdirs all-subdirs-x realclean: - $(MAKE) MAKETARGET="realclean" all-subdirs all-subdirs-x + $(V_at)$(MAKE) MAKETARGET="realclean" all-subdirs all-subdirs-x diff --git a/lib/hipe/amd64/hipe_amd64_encode.erl b/lib/hipe/amd64/hipe_amd64_encode.erl index ee68dfb3b8..cbdab25b25 100644 --- a/lib/hipe/amd64/hipe_amd64_encode.erl +++ b/lib/hipe/amd64/hipe_amd64_encode.erl @@ -1,7 +1,7 @@ %%% %%% %CopyrightBegin% %%% -%%% Copyright Ericsson AB 2004-2009. All Rights Reserved. +%%% Copyright Ericsson AB 2004-2012. All Rights Reserved. %%% %%% The contents of this file are subject to the Erlang Public License, %%% Version 1.1, (the "License"); you may not use this file except in @@ -373,16 +373,16 @@ sse2_arith_binop_encode(Prefix, Opcode, {{xmm, XMM64}, {rm64fp, RM64}}) -> [Prefix, 16#0F, Opcode | encode_rm(RM64, XMM64, [])]. sse2_cvtsi2sd_encode({{xmm,XMM64}, {rm64,RM64}}) -> - [rex([{w, 1}]), 16#F2, 16#0F, 16#2A�| encode_rm(RM64, XMM64, [])]. + [rex([{w, 1}]), 16#F2, 16#0F, 16#2A | encode_rm(RM64, XMM64, [])]. sse2_mov_encode(Opnds) -> case Opnds of {{xmm, XMM64}, {rm64fp, RM64}} -> % movsd - [16#F2, 16#0F, 16#10�| encode_rm(RM64, XMM64, [])]; + [16#F2, 16#0F, 16#10 | encode_rm(RM64, XMM64, [])]; {{rm64fp, RM64}, {xmm, XMM64}} -> % movsd - [16#F2, 16#0F, 16#11�| encode_rm(RM64, XMM64, [])] + [16#F2, 16#0F, 16#11 | encode_rm(RM64, XMM64, [])] % {{xmm, XMM64}, {rm64, RM64}} -> % cvtsi2sd -% [rex([{w, 1}]), 16#F2, 16#0F, 16#2A�| encode_rm(RM64, XMM64, [])] +% [rex([{w, 1}]), 16#F2, 16#0F, 16#2A | encode_rm(RM64, XMM64, [])] end. %% arith_binop_sizeof(Opnds) -> diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl index c97de59701..0a2c6e822f 100644 --- a/lib/hipe/cerl/erl_bif_types.erl +++ b/lib/hipe/cerl/erl_bif_types.erl @@ -2,7 +2,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2012. All Rights Reserved. +%% Copyright Ericsson AB 2003-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -45,11 +45,9 @@ t_atom_vals/1, t_binary/0, t_bitstr/0, - t_bitstrlist/0, t_boolean/0, t_byte/0, t_char/0, - t_charlist/0, t_cons/0, t_cons/2, t_cons_hd/1, @@ -72,8 +70,6 @@ t_non_neg_integer/0, t_pos_integer/0, t_integers/1, - t_iodata/0, - t_iolist/0, t_is_any/1, t_is_atom/1, t_is_binary/1, @@ -85,7 +81,6 @@ t_is_fun/1, t_is_integer/1, t_is_integer/1, - t_is_list/1, t_is_nil/1, t_is_none/1, t_is_none_or_unit/1, @@ -118,14 +113,11 @@ t_subtract/2, t_sup/1, t_sup/2, - t_tid/0, - t_timeout/0, t_tuple/0, t_tuple/1, t_tuple_args/1, t_tuple_size/1, - t_tuple_subtypes/1, - t_unicode_string/0 + t_tuple_subtypes/1 ]). -ifdef(DO_ERL_BIF_TYPES_TEST). @@ -144,111 +136,14 @@ type(M, F, A) -> -spec type(atom(), atom(), arity(), [erl_types:erl_type()]) -> erl_types:erl_type(). -%%-- binary ------------------------------------------------------------------- -type(binary, at, 2, Xs) -> - strict(arg_types(binary, at, 2), Xs, fun(_) -> t_integer() end); -type(binary, bin_to_list, Arity, Xs) when 1 =< Arity, Arity =< 3 -> - strict(arg_types(binary, bin_to_list, Arity), Xs, - fun(_) -> t_list(t_integer()) end); -type(binary, compile_pattern, 1, Xs) -> - strict(arg_types(binary, compile_pattern, 1), Xs, - fun(_) -> t_binary_compiled_pattern() end); -type(binary, copy, Arity, Xs) when Arity =:= 1; Arity =:= 2 -> - strict(arg_types(binary, copy, Arity), Xs, - fun(_) -> t_binary() end); -type(binary, decode_unsigned, Arity, Xs) when Arity =:= 1; Arity =:= 2 -> - strict(arg_types(binary, decode_unsigned, Arity), Xs, - fun(_) -> t_non_neg_integer() end); -type(binary, encode_unsigned, Arity, Xs) when Arity =:= 1; Arity =:= 2 -> - strict(arg_types(binary, encode_unsigned, Arity), Xs, - fun(_) -> t_binary() end); -type(binary, first, 1, Xs) -> - strict(arg_types(binary, first, 1), Xs, fun(_) -> t_non_neg_integer() end); -type(binary, last, 1, Xs) -> - strict(arg_types(binary, last, 1), Xs, fun(_) -> t_non_neg_integer() end); -type(binary, list_to_bin, 1, Xs) -> - type(erlang, list_to_binary, 1, Xs); -type(binary, longest_common_prefix, 1, Xs) -> - strict(arg_types(binary, longest_common_prefix, 1), Xs, - fun(_) -> t_integer() end); -type(binary, longest_common_suffix, 1, Xs) -> - strict(arg_types(binary, longest_common_suffix, 1), Xs, - fun(_) -> t_integer() end); -type(binary, match, Arity, Xs) when Arity =:= 2; Arity =:= 3 -> - strict(arg_types(binary, match, Arity), Xs, - fun(_) -> - t_sup(t_atom('nomatch'), t_binary_canonical_part()) - end); -type(binary, matches, Arity, Xs) when Arity =:= 2; Arity =:= 3 -> - strict(arg_types(binary, matches, Arity), Xs, - fun(_) -> t_list(t_binary_canonical_part()) end); -type(binary, part, 2, Xs) -> - type(erlang, binary_part, 2, Xs); -type(binary, part, 3, Xs) -> - type(erlang, binary_part, 3, Xs); -type(binary, referenced_byte_size, 1, Xs) -> - strict(arg_types(binary, referenced_byte_size, 1), Xs, - fun(_) -> t_non_neg_integer() end); -%%-- code --------------------------------------------------------------------- -type(code, get_chunk, 2, Xs) -> - strict(arg_types(code, get_chunk, 2), Xs, - fun (_) -> t_sup(t_binary(), t_atom('undefined')) end); -type(code, is_module_native, 1, Xs) -> - strict(arg_types(code, is_module_native, 1), Xs, - fun (_) -> t_sup(t_boolean(), t_atom('undefined')) end); -type(code, module_md5, 1, Xs) -> - strict(arg_types(code, module_md5, 1), Xs, - fun (_) -> t_sup(t_binary(), t_atom('undefined')) end); -type(code, make_stub_module, 3, Xs) -> - strict(arg_types(code, make_stub_module, 3), Xs, fun ([Mod,_,_]) -> Mod end); -type(code, rehash, 0, _) -> - t_atom('ok'); -%%-- erl_ddll ----------------------------------------------------------------- -type(erl_ddll, demonitor, 1, Xs) -> - type(erlang, demonitor, 1, Xs); -type(erl_ddll, format_error_int, 1, Xs) -> - strict(arg_types(erl_ddll, format_error_int, 1), Xs, - fun (_) -> t_string() end); -type(erl_ddll, info, 2, Xs) -> - strict(arg_types(erl_ddll, info, 2), Xs, fun (_) -> t_atom() end); -type(erl_ddll, loaded_drivers, 0, _) -> - t_tuple([t_atom('ok'), t_list(t_string())]); -type(erl_ddll, monitor, 2, Xs) -> % return type is the same, though args are not - type(erlang, monitor, 2, Xs); -type(erl_ddll, try_load, 3, Xs) -> - strict(arg_types(erl_ddll, try_load, 3), Xs, - fun (_) -> - t_sup([t_tuple([t_atom('ok'), t_atom('already_loaded')]), - t_tuple([t_atom('ok'), t_atom('loaded')]), - t_tuple([t_atom('ok'), - t_atom('pending_driver'), t_reference()]), - t_tuple([t_atom('error'), t_atom('inconsistent')]), - t_tuple([t_atom('error'), t_atom('permanent')])]) - end); -type(erl_ddll, try_unload, 2, Xs) -> - strict(arg_types(erl_ddll, try_unload, 2), Xs, - fun (_) -> - t_sup([t_tuple([t_atom('ok'), t_atom('pending_process')]), - t_tuple([t_atom('ok'), t_atom('unloaded')]), - t_tuple([t_atom('ok'), t_atom('pending_driver')]), - t_tuple([t_atom('ok'), - t_atom('pending_driver'), t_reference()]), - t_tuple([t_atom('error'), t_atom('permanent')]), - t_tuple([t_atom('error'), t_atom('not_loaded')]), - t_tuple([t_atom('error'), - t_atom('not_loaded_by_this_process')])]) - end); %%-- erlang ------------------------------------------------------------------- type(erlang, halt, 0, _) -> t_none(); type(erlang, halt, 1, _) -> t_none(); type(erlang, halt, 2, _) -> t_none(); type(erlang, exit, 1, _) -> t_none(); -%% Note that exit/2 sends an exit signal to another process. -type(erlang, exit, 2, _) -> t_atom('true'); type(erlang, error, 1, _) -> t_none(); type(erlang, error, 2, _) -> t_none(); type(erlang, throw, 1, _) -> t_none(); -type(erlang, hibernate, 3, _) -> t_none(); type(erlang, '==', 2, Xs = [X1, X2]) -> case t_is_atom(X1) andalso t_is_atom(X2) of true -> type(erlang, '=:=', 2, Xs); @@ -600,20 +495,12 @@ type(erlang, 'bnot', 1, Xs) -> {ok, T} -> T end end); -%% This returns (-X)-1, so it often gives a negative result. -%% strict(arg_types(erlang, 'bnot', 1), Xs, fun (_) -> t_integer() end); +%% Guard bif, needs to be here. type(erlang, abs, 1, Xs) -> strict(arg_types(erlang, abs, 1), Xs, fun ([X]) -> X end); -type(erlang, adler32, 1, Xs) -> - strict(arg_types(erlang, adler32, 1), Xs, fun (_) -> t_adler32() end); -type(erlang, adler32, 2, Xs) -> - strict(arg_types(erlang, adler32, 2), Xs, fun (_) -> t_adler32() end); -type(erlang, adler32_combine, 3, Xs) -> - strict(arg_types(erlang, adler32_combine, 3), Xs, - fun (_) -> t_adler32() end); +%% This returns (-X)-1, so it often gives a negative result. +%% strict(arg_types(erlang, 'bnot', 1), Xs, fun (_) -> t_integer() end); type(erlang, append, 2, Xs) -> type(erlang, '++', 2, Xs); % alias -type(erlang, append_element, 2, Xs) -> - strict(arg_types(erlang, append_element, 2), Xs, fun (_) -> t_tuple() end); type(erlang, apply, 2, Xs) -> Fun = fun ([X, _Y]) -> case t_is_fun(X) of @@ -626,111 +513,24 @@ type(erlang, apply, 2, Xs) -> strict(arg_types(erlang, apply, 2), Xs, Fun); type(erlang, apply, 3, Xs) -> strict(arg_types(erlang, apply, 3), Xs, fun (_) -> t_any() end); -type(erlang, atom_to_binary, 2, Xs) -> - strict(arg_types(erlang, atom_to_binary, 2), Xs, fun (_) -> t_binary() end); -type(erlang, atom_to_list, 1, Xs) -> - strict(arg_types(erlang, atom_to_list, 1), Xs, fun (_) -> t_string() end); +%% Guard bif, needs to be here. type(erlang, binary_part, 2, Xs) -> strict(arg_types(erlang, binary_part, 2), Xs, fun (_) -> t_binary() end); +%% Guard bif, needs to be here. type(erlang, binary_part, 3, Xs) -> strict(arg_types(erlang, binary_part, 3), Xs, fun (_) -> t_binary() end); -type(erlang, binary_to_atom, 2, Xs) -> - strict(arg_types(erlang, binary_to_atom, 2), Xs, fun (_) -> t_atom() end); -type(erlang, binary_to_existing_atom, 2, Xs) -> - type(erlang, binary_to_atom, 2, Xs); -type(erlang, binary_to_list, 1, Xs) -> - strict(arg_types(erlang, binary_to_list, 1), Xs, - fun (_) -> t_list(t_byte()) end); -type(erlang, binary_to_list, 3, Xs) -> - strict(arg_types(erlang, binary_to_list, 3), Xs, - fun (_) -> t_list(t_byte()) end); -type(erlang, binary_to_term, 1, Xs) -> - strict(arg_types(erlang, binary_to_term, 1), Xs, fun (_) -> t_any() end); -type(erlang, binary_to_term, 2, Xs) -> - strict(arg_types(erlang, binary_to_term, 2), Xs, fun (_) -> t_any() end); -type(erlang, bitsize, 1, Xs) -> % XXX: TAKE OUT - type(erlang, bit_size, 1, Xs); +%% Guard bif, needs to be here. type(erlang, bit_size, 1, Xs) -> strict(arg_types(erlang, bit_size, 1), Xs, fun (_) -> t_non_neg_integer() end); -type(erlang, bitstr_to_list, 1, Xs) -> % XXX: TAKE OUT - type(erlang, bitstring_to_list, 1, Xs); -type(erlang, bitstring_to_list, 1, Xs) -> - strict(arg_types(erlang, bitstring_to_list, 1), Xs, - fun (_) -> t_list(t_sup(t_byte(), t_bitstr())) end); -type(erlang, bump_reductions, 1, Xs) -> - strict(arg_types(erlang, bump_reductions, 1), Xs, - fun (_) -> t_atom('true') end); +%% Guard bif, needs to be here. type(erlang, byte_size, 1, Xs) -> strict(arg_types(erlang, byte_size, 1), Xs, fun (_) -> t_non_neg_integer() end); -type(erlang, call_on_load_function, 1, Xs) -> - %% Internal BIF used by on_load. - strict(arg_types(erlang, call_on_load_function, 1), Xs, - fun (_) -> t_any() end); -type(erlang, cancel_timer, 1, Xs) -> - strict(arg_types(erlang, cancel_timer, 1), Xs, - fun (_) -> t_sup(t_integer(), t_atom('false')) end); -type(erlang, check_old_code, 1, Xs) -> - strict(arg_types(erlang, check_old_code, 1), Xs, - fun (_) -> t_boolean() end); -type(erlang, check_process_code, 2, Xs) -> - strict(arg_types(erlang, check_process_code, 2), Xs, - fun (_) -> t_boolean() end); -type(erlang, crc32, 1, Xs) -> - strict(arg_types(erlang, crc32, 1), Xs, fun (_) -> t_crc32() end); -type(erlang, crc32, 2, Xs) -> - strict(arg_types(erlang, crc32, 2), Xs, fun (_) -> t_crc32() end); -type(erlang, crc32_combine, 3, Xs) -> - strict(arg_types(erlang, crc32_combine, 3), Xs, fun (_) -> t_crc32() end); -type(erlang, date, 0, _) -> - t_date(); -type(erlang, decode_packet, 3, Xs) -> - strict(arg_types(erlang, decode_packet, 3), Xs, - fun (_) -> - t_sup([t_tuple([t_atom('ok'), t_packet(), t_binary()]), - t_tuple([t_atom('more'), t_sup([t_non_neg_integer(), - t_atom('undefined')])]), - t_tuple([t_atom('error'), t_any()])]) - end); -type(erlang, delete_module, 1, Xs) -> - strict(arg_types(erlang, delete_module, 1), Xs, - fun (_) -> t_sup(t_atom('true'), t_atom('undefined')) end); -type(erlang, demonitor, 1, Xs) -> - strict(arg_types(erlang, demonitor, 1), Xs, fun (_) -> t_atom('true') end); -%% TODO: overapproximation -- boolean only if 'info' is part of arg2 otherwise 'true' -type(erlang, demonitor, 2, Xs) -> - strict(arg_types(erlang, demonitor, 2), Xs, fun (_) -> t_boolean() end); type(erlang, disconnect_node, 1, Xs) -> strict(arg_types(erlang, disconnect_node, 1), Xs, fun (_) -> t_sup([t_boolean(), t_atom('ignored')]) end); -type(erlang, display, 1, _) -> t_atom('true'); -type(erlang, display_string, 1, Xs) -> - strict(arg_types(erlang, display_string, 1), Xs, fun(_) -> t_atom('true') end); -type(erlang, display_nl, 0, _) -> - t_atom('true'); -type(erlang, dist_exit, 3, Xs) -> - strict(arg_types(erlang, dist_exit, 3), Xs, fun (_) -> t_atom('true') end); -type(erlang, dt_append_vm_tag_data, 1, Xs) -> - strict(arg_types(erlang, dt_append_vm_tag_data, 1), - Xs, - fun(_) -> t_iodata() end); -type(erlang, dt_get_tag, 0, _) -> - t_sup(t_binary(), t_atom('undefined')); -type(erlang, dt_get_tag_data, 0, _) -> - t_sup(t_binary(), t_atom('undefined')); -type(erlang, dt_prepend_vm_tag_data, 1, Xs) -> - strict(arg_types(erlang, dt_prepend_vm_tag_data, 1), - Xs, - fun(_) -> t_iodata() end); -type(erlang, dt_put_tag, 1, Xs) -> - strict(arg_types(erlang, dt_put_tag, 1), Xs, - fun(_) -> t_sup(t_binary(), t_atom('undefined')) end); -type(erlang, dt_restore_tag, 1, Xs) -> - strict(arg_types(erlang, dt_restore_tag, 1), Xs, fun(_) -> t_atom('true') end); -type(erlang, dt_spread_tag, 1, Xs) -> - strict(arg_types(erlang, dt_spread_tag, 1), Xs, - fun(_) -> t_sup(t_tuple([t_non_neg_integer(), t_sup(t_binary(), t_nil())]), - t_atom('true')) end); +%% Guard bif, needs to be here. +%% Also much more expressive than anything you could write in a spec... type(erlang, element, 2, Xs) -> strict(arg_types(erlang, element, 2), Xs, fun ([X1, X2]) -> @@ -754,95 +554,22 @@ type(erlang, element, 2, Xs) -> t_sup([type(erlang, element, 2, [X1, Y]) || Y <- Ts]) end end); -type(erlang, erase, 0, _) -> t_any(); -type(erlang, erase, 1, _) -> t_any(); -type(erlang, external_size, 1, _) -> t_integer(); -type(erlang, external_size, 2, _) -> t_integer(); -type(erlang, finish_after_on_load, 2, Xs) -> - %% Internal BIF used by on_load. - strict(arg_types(erlang, finish_after_on_load, 2), Xs, - fun (_) -> t_atom('true') end); +%% Guard bif, needs to be here. type(erlang, float, 1, Xs) -> strict(arg_types(erlang, float, 1), Xs, fun (_) -> t_float() end); -type(erlang, float_to_list, 1, Xs) -> - strict(arg_types(erlang, float_to_list, 1), Xs, fun (_) -> t_string() end); -type(erlang, function_exported, 3, Xs) -> - strict(arg_types(erlang, function_exported, 3), Xs, - fun (_) -> t_boolean() end); type(erlang, fun_info, 1, Xs) -> strict(arg_types(erlang, fun_info, 1), Xs, fun (_) -> t_list(t_tuple([t_atom(), t_any()])) end); -type(erlang, fun_info, 2, Xs) -> - strict(arg_types(erlang, fun_info, 2), Xs, - fun (_) -> t_tuple([t_atom(), t_any()]) end); -type(erlang, fun_to_list, 1, Xs) -> - strict(arg_types(erlang, fun_to_list, 1), Xs, fun (_) -> t_string() end); -type(erlang, garbage_collect, 0, _) -> t_atom('true'); -type(erlang, garbage_collect, 1, Xs) -> - strict(arg_types(erlang, garbage_collect, 1), Xs, fun (_) -> t_boolean() end); -type(erlang, garbage_collect_message_area, 0, _) -> - t_boolean(); -type(erlang, get, 0, _) -> t_list(t_tuple(2)); -type(erlang, get, 1, _) -> t_any(); % | t_atom('undefined') type(erlang, get_cookie, 0, _) -> t_atom(); % | t_atom('nocookie') -type(erlang, get_keys, 1, _) -> t_list(); -type(erlang, get_module_info, 1, Xs) -> - strict(arg_types(erlang, get_module_info, 1), Xs, - fun (_) -> - t_list(t_tuple([t_atom(), t_list(t_tuple([t_atom(), t_any()]))])) - end); -type(erlang, get_module_info, 2, Xs) -> - T_module_info_2_returns = - t_sup([t_atom(), - t_list(t_tuple([t_atom(), t_any()])), - t_list(t_tuple([t_atom(), t_arity(), t_integer()]))]), - strict(arg_types(erlang, get_module_info, 2), Xs, - fun ([Module, Item]) -> - case t_is_atom(Item) of - true -> - case t_atom_vals(Item) of - ['module'] -> t_inf(t_atom(), Module); - ['imports'] -> t_nil(); - ['exports'] -> t_list(t_tuple([t_atom(), t_arity()])); - ['functions'] -> t_list(t_tuple([t_atom(), t_arity()])); - ['attributes'] -> t_list(t_tuple([t_atom(), t_any()])); - ['compile'] -> t_list(t_tuple([t_atom(), t_any()])); - ['native_addresses'] -> % [{FunName, Arity, Address}] - t_list(t_tuple([t_atom(), t_arity(), t_integer()])); - List when is_list(List) -> - T_module_info_2_returns; - unknown -> - T_module_info_2_returns - end; - false -> - T_module_info_2_returns - end - end); -type(erlang, get_stacktrace, 0, _) -> - t_list(t_tuple([t_atom(), t_atom(), t_sup([t_arity(), t_list()]), - t_list()])); -type(erlang, group_leader, 0, _) -> t_pid(); -type(erlang, group_leader, 2, Xs) -> - strict(arg_types(erlang, group_leader, 2), Xs, - fun (_) -> t_atom('true') end); -type(erlang, hash, 2, Xs) -> - strict(arg_types(erlang, hash, 2), Xs, fun (_) -> t_integer() end); +%% Guard bif, needs to be here. type(erlang, hd, 1, Xs) -> strict(arg_types(erlang, hd, 1), Xs, fun ([X]) -> t_cons_hd(X) end); -type(erlang, integer_to_list, 1, Xs) -> - strict(arg_types(erlang, integer_to_list, 1), Xs, - fun (_) -> t_string() end); type(erlang, integer_to_list, 2, Xs) -> strict(arg_types(erlang, integer_to_list, 2), Xs, fun (_) -> t_string() end); type(erlang, info, 1, Xs) -> type(erlang, system_info, 1, Xs); % alias -type(erlang, iolist_size, 1, Xs) -> - strict(arg_types(erlang, iolist_size, 1), Xs, - fun (_) -> t_non_neg_integer() end); -type(erlang, iolist_to_binary, 1, Xs) -> - strict(arg_types(erlang, iolist_to_binary, 1), Xs, - fun (_) -> t_binary() end); -type(erlang, is_alive, 0, _) -> t_boolean(); +%% All type tests are guard BIF's and may be implemented in ways that +%% cannot be expressed in a type spec, why they are kept in erl_bif_types. type(erlang, is_atom, 1, Xs) -> Fun = fun (X) -> check_guard(X, fun (Y) -> t_is_atom(Y) end, t_atom()) end, strict(arg_types(erlang, is_atom, 1), Xs, Fun); @@ -851,8 +578,6 @@ type(erlang, is_binary, 1, Xs) -> check_guard(X, fun (Y) -> t_is_binary(Y) end, t_binary()) end, strict(arg_types(erlang, is_binary, 1), Xs, Fun); -type(erlang, is_bitstr, 1, Xs) -> % XXX: TAKE OUT - type(erlang, is_bitstring, 1, Xs); type(erlang, is_bitstring, 1, Xs) -> Fun = fun (X) -> check_guard(X, fun (Y) -> t_is_bitstr(Y) end, t_bitstr()) @@ -863,8 +588,6 @@ type(erlang, is_boolean, 1, Xs) -> check_guard(X, fun (Y) -> t_is_boolean(Y) end, t_boolean()) end, strict(arg_types(erlang, is_boolean, 1), Xs, Fun); -type(erlang, is_builtin, 3, Xs) -> - strict(arg_types(erlang, is_builtin, 3), Xs, fun (_) -> t_boolean() end); type(erlang, is_float, 1, Xs) -> Fun = fun (X) -> check_guard(X, fun (Y) -> t_is_float(Y) end, t_float()) @@ -909,9 +632,6 @@ type(erlang, is_pid, 1, Xs) -> type(erlang, is_port, 1, Xs) -> Fun = fun (X) -> check_guard(X, fun (Y) -> t_is_port(Y) end, t_port()) end, strict(arg_types(erlang, is_port, 1), Xs, Fun); -type(erlang, is_process_alive, 1, Xs) -> - strict(arg_types(erlang, is_process_alive, 1), Xs, - fun (_) -> t_boolean() end); type(erlang, is_record, 2, Xs) -> Fun = fun ([X, Y]) -> case t_is_tuple(X) of @@ -1013,68 +733,9 @@ type(erlang, is_tuple, 1, Xs) -> check_guard(X, fun (Y) -> t_is_tuple(Y) end, t_tuple()) end, strict(arg_types(erlang, is_tuple, 1), Xs, Fun); +%% Guard bif, needs to be here. type(erlang, length, 1, Xs) -> strict(arg_types(erlang, length, 1), Xs, fun (_) -> t_non_neg_fixnum() end); -type(erlang, link, 1, Xs) -> - strict(arg_types(erlang, link, 1), Xs, fun (_) -> t_atom('true') end); -type(erlang, list_to_atom, 1, Xs) -> - strict(arg_types(erlang, list_to_atom, 1), Xs, fun (_) -> t_atom() end); -type(erlang, list_to_binary, 1, Xs) -> - strict(arg_types(erlang, list_to_binary, 1), Xs, - fun (_) -> t_binary() end); -type(erlang, list_to_bitstr, 1, Xs) -> - type(erlang, list_to_bitstring, 1, Xs); -type(erlang, list_to_bitstring, 1, Xs) -> - strict(arg_types(erlang, list_to_bitstring, 1), Xs, - fun (_) -> t_bitstr() end); -type(erlang, list_to_existing_atom, 1, Xs) -> - strict(arg_types(erlang, list_to_existing_atom, 1), Xs, - fun (_) -> t_atom() end); -type(erlang, list_to_float, 1, Xs) -> - strict(arg_types(erlang, list_to_float, 1), Xs, fun (_) -> t_float() end); -type(erlang, list_to_integer, 1, Xs) -> - strict(arg_types(erlang, list_to_integer, 1), Xs, - fun (_) -> t_integer() end); -type(erlang, list_to_integer, 2, Xs) -> - strict(arg_types(erlang, list_to_integer, 2), Xs, - fun (_) -> t_integer() end); -type(erlang, list_to_pid, 1, Xs) -> - strict(arg_types(erlang, list_to_pid, 1), Xs, fun (_) -> t_pid() end); -type(erlang, list_to_tuple, 1, Xs) -> - strict(arg_types(erlang, list_to_tuple, 1), Xs, fun (_) -> t_tuple() end); -type(erlang, load_module, 2, Xs) -> - strict(arg_types(erlang, load_module, 2), Xs, - fun ([Mod,_Bin]) -> t_code_load_return(Mod) end); -type(erlang, load_nif, 2, Xs) -> - strict(arg_types(erlang, load_nif, 2), Xs, - fun (_) -> - Reason = t_atoms(['load_failed', 'bad_lib', 'load', - 'reload', 'upgrade', 'old_code']), - RsnPair = t_tuple([Reason, t_string()]), - t_sup(t_atom('ok'), t_tuple([t_atom('error'), RsnPair])) - end); -type(erlang, loaded, 0, _) -> - t_list(t_atom()); -type(erlang, localtime, 0, Xs) -> - type(erlang, universaltime, 0, Xs); % same -type(erlang, localtime_to_universaltime, 1, Xs) -> - type(erlang, universaltime_to_localtime, 1, Xs); % same -type(erlang, localtime_to_universaltime, 2, Xs) -> - strict(arg_types(erlang, localtime_to_universaltime, 2), Xs, % typecheck - fun ([X,_]) -> type(erlang, localtime_to_universaltime, 1, [X]) end); -type(erlang, make_fun, 3, Xs) -> - strict(arg_types(erlang, make_fun, 3), Xs, - fun ([_, _, Arity]) -> - case t_number_vals(Arity) of - [N] -> - case is_integer(N) andalso 0 =< N andalso N =< 255 of - true -> t_fun(N, t_any()); - false -> t_none() - end; - _Other -> t_fun() - end - end); -type(erlang, make_ref, 0, _) -> t_reference(); type(erlang, make_tuple, 2, Xs) -> strict(arg_types(erlang, make_tuple, 2), Xs, fun ([Int, _]) -> @@ -1091,290 +752,21 @@ type(erlang, make_tuple, 3, Xs) -> _Other -> t_tuple() end end); -type(erlang, match_spec_test, 3, Xs) -> - strict(arg_types(erlang, match_spec_test, 3), Xs, - fun (_) -> t_sup(t_tuple([t_atom('ok'), - t_any(), % it can be any term - t_list(t_atom('return_trace')), - t_match_spec_test_errors()]), - t_tuple([t_atom('error'), - t_match_spec_test_errors()])) end); -type(erlang, md5, 1, Xs) -> - strict(arg_types(erlang, md5, 1), Xs, fun (_) -> t_binary() end); -type(erlang, md5_final, 1, Xs) -> - strict(arg_types(erlang, md5_final, 1), Xs, fun (_) -> t_binary() end); -type(erlang, md5_init, 0, _) -> t_binary(); -type(erlang, md5_update, 2, Xs) -> - strict(arg_types(erlang, md5_update, 2), Xs, fun (_) -> t_binary() end); type(erlang, memory, 0, _) -> t_list(t_tuple([t_atom(), t_non_neg_fixnum()])); -type(erlang, memory, 1, Xs) -> - strict(arg_types(erlang, memory, 1), Xs, - fun ([Type]) -> - case t_is_atom(Type) of - true -> t_non_neg_fixnum(); - false -> - case t_is_list(Type) of - true -> t_list(t_tuple([t_atom(), t_non_neg_fixnum()])); - false -> - t_sup(t_non_neg_fixnum(), - t_list(t_tuple([t_atom(), t_non_neg_fixnum()]))) - end - end - end); -type(erlang, module_loaded, 1, Xs) -> - strict(arg_types(erlang, module_loaded, 1), Xs, fun (_) -> t_boolean() end); -type(erlang, monitor, 2, Xs) -> - strict(arg_types(erlang, monitor, 2), Xs, fun (_) -> t_reference() end); -type(erlang, monitor_node, 2, Xs) -> - strict(arg_types(erlang, monitor_node, 2), Xs, - fun (_) -> t_atom('true') end); -type(erlang, monitor_node, 3, Xs) -> - strict(arg_types(erlang, monitor_node, 3), Xs, - fun (_) -> t_atom('true') end); type(erlang, nif_error, 1, _) -> t_any(); % this BIF and the next one are stubs for NIFs and never return type(erlang, nif_error, 2, Xs) -> strict(arg_types(erlang, nif_error, 2), Xs, fun (_) -> t_any() end); +%% Guard bif, needs to be here. type(erlang, node, 0, _) -> t_node(); +%% Guard bif, needs to be here. type(erlang, node, 1, Xs) -> strict(arg_types(erlang, node, 1), Xs, fun (_) -> t_node() end); -type(erlang, nodes, 0, _) -> t_list(t_node()); -type(erlang, nodes, 1, Xs) -> - strict(arg_types(erlang, nodes, 1), Xs, fun (_) -> t_list(t_node()) end); -type(erlang, now, 0, _) -> - t_timestamp(); -type(erlang, open_port, 2, Xs) -> - strict(arg_types(erlang, open_port, 2), Xs, fun (_) -> t_port() end); -type(erlang, phash, 2, Xs) -> - strict(arg_types(erlang, phash, 2), Xs, fun (_) -> t_pos_integer() end); -type(erlang, phash2, 1, Xs) -> - strict(arg_types(erlang, phash2, 1), Xs, fun (_) -> t_non_neg_integer() end); -type(erlang, phash2, 2, Xs) -> - strict(arg_types(erlang, phash2, 2), Xs, fun (_) -> t_non_neg_integer() end); -type(erlang, pid_to_list, 1, Xs) -> - strict(arg_types(erlang, pid_to_list, 1), Xs, fun (_) -> t_string() end); -type(erlang, port_call, Arity, Xs) when Arity =:= 2; Arity =:= 3 -> - strict(arg_types(erlang, port_call, Arity), Xs, fun (_) -> t_any() end); -type(erlang, port_close, 1, Xs) -> - strict(arg_types(erlang, port_close, 1), Xs, - fun (_) -> t_atom('true') end); -type(erlang, port_command, 2, Xs) -> - strict(arg_types(erlang, port_command, 2), Xs, - fun (_) -> t_atom('true') end); -type(erlang, port_command, 3, Xs) -> - strict(arg_types(erlang, port_command, 3), Xs, - fun (_) -> t_boolean() end); -type(erlang, port_connect, 2, Xs) -> - strict(arg_types(erlang, port_connect, 2), Xs, - fun (_) -> t_atom('true') end); -type(erlang, port_control, 3, Xs) -> - strict(arg_types(erlang, port_control, 3), Xs, - fun (_) -> t_sup(t_string(), t_binary()) end); -type(erlang, port_get_data, 1, Xs) -> - strict(arg_types(erlang, port_get_data, 1), Xs, fun (_) -> t_any() end); -type(erlang, port_info, 1, Xs) -> - strict(arg_types(erlang, port_info, 1), Xs, - fun (_) -> t_sup(t_atom('undefined'), t_list()) end); -type(erlang, port_info, 2, Xs) -> - strict(arg_types(erlang, port_info, 2), Xs, - fun ([_Port, Item]) -> - t_sup(t_atom('undefined'), - case t_atom_vals(Item) of - ['connected'] -> t_tuple([Item, t_pid()]); - ['id'] -> t_tuple([Item, t_integer()]); - ['input'] -> t_tuple([Item, t_integer()]); - ['links'] -> t_tuple([Item, t_list(t_pid())]); - ['name'] -> t_tuple([Item, t_string()]); - ['output'] -> t_tuple([Item, t_integer()]); - ['os_pid'] -> t_tuple([Item, t_sup(t_non_neg_integer(),t_atom('undefined'))]); - ['registered_name'] -> t_tuple([Item, t_atom()]); - List when is_list(List) -> - t_tuple([t_sup([t_atom(A) || A <- List]), - t_sup([t_atom(), t_integer(), - t_pid(), t_list(t_pid()), - t_string()])]); - unknown -> - [_, PosItem] = arg_types(erlang, port_info, 2), - t_tuple([PosItem, - t_sup([t_atom(), t_integer(), - t_pid(), t_list(t_pid()), - t_string()])]) - end) - end); -type(erlang, port_to_list, 1, Xs) -> - strict(arg_types(erlang, port_to_list, 1), Xs, fun (_) -> t_string() end); -type(erlang, ports, 0, _) -> t_list(t_port()); -type(erlang, port_set_data, 2, Xs) -> - strict(arg_types(erlang, port_set_data, 2), Xs, - fun (_) -> t_atom('true') end); -type(erlang, pre_loaded, 0, _) -> t_list(t_atom()); -type(erlang, process_display, 2, _) -> t_atom('true'); -type(erlang, process_flag, 2, Xs) -> - T_process_flag_returns = t_sup([t_boolean(), t_atom(), t_non_neg_integer()]), - strict(arg_types(erlang, process_flag, 2), Xs, - fun ([Flag, _Option]) -> - case t_is_atom(Flag) of - true -> - case t_atom_vals(Flag) of - ['error_handler'] -> t_atom(); - ['min_heap_size'] -> t_non_neg_integer(); - ['min_bin_vheap_size'] -> t_non_neg_integer(); - ['scheduler'] -> t_non_neg_integer(); - ['monitor_nodes'] -> t_boolean(); - ['priority'] -> t_process_priority_level(); - ['save_calls'] -> t_non_neg_integer(); - ['trap_exit'] -> t_boolean(); - ['sensitive'] -> t_boolean(); - List when is_list(List) -> - T_process_flag_returns; - unknown -> - T_process_flag_returns - end; - false -> % XXX: over-approximation if Flag is tuple - T_process_flag_returns - end - end); -type(erlang, process_flag, 3, Xs) -> - strict(arg_types(erlang, process_flag, 3), Xs, - fun (_) -> t_non_neg_integer() end); -type(erlang, process_info, 1, Xs) -> - strict(arg_types(erlang, process_info, 1), Xs, - fun (_) -> - t_sup(t_list(t_tuple([t_pinfo(), t_any()])), - t_atom('undefined')) - end); -type(erlang, process_info, 2, Xs) -> - %% we define all normal return values: the return when the process exists - %% t_nil() is the return for 'registered_name'; perhaps for more - T_process_info_2_normal_returns = - t_sup([t_tuple([t_pinfo_item(), t_any()]), t_nil()]), - strict(arg_types(erlang, process_info, 2), Xs, - fun ([_Pid, InfoItem]) -> - Ret = case t_is_atom(InfoItem) of - true -> - case t_atom_vals(InfoItem) of - ['backtrace'] -> t_tuple([InfoItem, t_binary()]); - ['current_function'] -> t_tuple([InfoItem, t_mfa()]); - ['dictionary'] -> t_tuple([InfoItem, t_list()]); - ['error_handler'] -> t_tuple([InfoItem, t_atom()]); - ['garbage_collection'] -> - t_tuple([InfoItem, t_list()]); - ['group_leader'] -> t_tuple([InfoItem, t_pid()]); - ['heap_size'] -> - t_tuple([InfoItem, t_non_neg_integer()]); - ['initial_call'] -> t_tuple([InfoItem, t_mfa()]); - ['last_calls'] -> - t_tuple([InfoItem, - t_sup(t_atom('false'), t_list())]); - ['links'] -> t_tuple([InfoItem, t_list(t_sup(t_pid(),t_port()))]); - ['memory'] -> - t_tuple([InfoItem, t_non_neg_integer()]); - ['message_queue_len'] -> - t_tuple([InfoItem, t_non_neg_integer()]); - ['messages'] -> t_tuple([InfoItem, t_list()]); - ['monitored_by'] -> - t_tuple([InfoItem, t_list(t_pid())]); - ['monitors'] -> - t_tuple([InfoItem, - t_list(t_sup(t_tuple([t_atom('process'), - t_pid()]), - t_tuple([t_atom('process'), - t_tuple([t_atom(), - t_atom()])])))]); - ['priority'] -> - t_tuple([InfoItem, t_process_priority_level()]); - ['reductions'] -> - t_tuple([InfoItem, t_non_neg_integer()]); - ['registered_name'] -> - t_sup(t_tuple([InfoItem, t_atom()]), t_nil()); - ['sequential_trace_token'] -> - t_tuple([InfoItem, t_any()]); %% Underspecified - ['stack_size'] -> - t_tuple([InfoItem, t_non_neg_integer()]); - ['status'] -> - t_tuple([InfoItem, t_process_status()]); - ['suspending'] -> - t_tuple([InfoItem, - t_list(t_tuple([t_pid(), - t_non_neg_integer(), - t_non_neg_integer()]))]); - ['total_heap_size'] -> - t_tuple([InfoItem, t_non_neg_integer()]); - ['trap_exit'] -> - t_tuple([InfoItem, t_boolean()]); - List when is_list(List) -> - T_process_info_2_normal_returns; - unknown -> - T_process_info_2_normal_returns - end; - false -> - case t_is_list(InfoItem) of - true -> - t_list(t_tuple([t_pinfo_item(), t_any()])); - false -> - t_sup(T_process_info_2_normal_returns, - t_list(t_tuple([t_pinfo_item(), t_any()]))) - end - end, - t_sup([Ret, t_atom('undefined')]) - end); -type(erlang, processes, 0, _) -> t_list(t_pid()); -type(erlang, purge_module, 1, Xs) -> - strict(arg_types(erlang, purge_module, 1), Xs, - fun (_) -> t_atom('true') end); -type(erlang, put, 2, Xs) -> - strict(arg_types(erlang, put, 2), Xs, fun (_) -> t_any() end); -type(erlang, raise, 3, _) -> t_none(); -type(erlang, read_timer, 1, Xs) -> - strict(arg_types(erlang, read_timer, 1), Xs, - fun (_) -> t_sup(t_non_neg_integer(), t_atom('false')) end); -type(erlang, ref_to_list, 1, Xs) -> - strict(arg_types(erlang, ref_to_list, 1), Xs, fun (_) -> t_string() end); -type(erlang, register, 2, Xs) -> - strict(arg_types(erlang, register, 2), Xs, fun (_) -> t_atom('true') end); -type(erlang, registered, 0, _) -> t_list(t_atom()); -type(erlang, resume_process, 1, Xs) -> - strict(arg_types(erlang, resume_process, 1), Xs, - fun (_) -> t_any() end); %% TODO: overapproximation -- fix this +%% Guard bif, needs to be here. type(erlang, round, 1, Xs) -> strict(arg_types(erlang, round, 1), Xs, fun (_) -> t_integer() end); -type(erlang, posixtime_to_universaltime, 1, Xs) -> - strict(arg_types(erlang, posixtime_to_universaltime, 1), Xs, - fun(_) -> t_tuple([t_date(), t_time()]) end); +%% Guard bif, needs to be here. type(erlang, self, 0, _) -> t_pid(); -type(erlang, send, 2, Xs) -> type(erlang, '!', 2, Xs); % alias -type(erlang, send, 3, Xs) -> - strict(arg_types(erlang, send, 3), Xs, - fun (_) -> t_sup(t_atom('ok'), t_sendoptions()) end); -type(erlang, send_after, 3, Xs) -> - strict(arg_types(erlang, send_after, 3), Xs, fun (_) -> t_reference() end); -type(erlang, seq_trace, 2, Xs) -> - strict(arg_types(erlang, seq_trace, 2), Xs, - fun (_) -> t_sup(t_seq_trace_info_returns(), t_tuple(5)) end); -type(erlang, seq_trace_info, 1, Xs) -> - strict(arg_types(erlang, seq_trace_info, 1), Xs, - fun ([Item]) -> - case t_atom_vals(Item) of - ['label'] -> - t_sup(t_tuple([Item, t_non_neg_integer()]), t_nil()); - ['serial'] -> - t_sup(t_tuple([Item, t_tuple([t_non_neg_integer(), - t_non_neg_integer()])]), - t_nil()); - ['send'] -> t_tuple([Item, t_boolean()]); - ['receive'] -> t_tuple([Item, t_boolean()]); - ['print'] -> t_tuple([Item, t_boolean()]); - ['timestamp'] -> t_tuple([Item, t_boolean()]); - List when is_list(List) -> - t_seq_trace_info_returns(); - unknown -> - t_seq_trace_info_returns() - end - end); -type(erlang, seq_trace_print, 1, Xs) -> - strict(arg_types(erlang, seq_trace_print, 1), Xs, fun (_) -> t_boolean() end); -type(erlang, seq_trace_print, 2, Xs) -> - strict(arg_types(erlang, seq_trace_print, 2), Xs, fun (_) -> t_boolean() end); type(erlang, set_cookie, 2, Xs) -> strict(arg_types(erlang, set_cookie, 2), Xs, fun (_) -> t_atom('true') end); type(erlang, setelement, 3, Xs) -> @@ -1408,148 +800,22 @@ type(erlang, setelement, 3, Xs) -> t_sup([type(erlang, setelement, 3, [X1, Y, X3]) || Y <- Ts]) end end); -type(erlang, setnode, 2, Xs) -> - strict(arg_types(erlang, setnode, 2), Xs, fun (_) -> t_atom('true') end); -type(erlang, setnode, 3, Xs) -> - strict(arg_types(erlang, setnode, 3), Xs, fun (_) -> t_atom('true') end); +%% Guard bif, needs to be here. type(erlang, size, 1, Xs) -> strict(arg_types(erlang, size, 1), Xs, fun (_) -> t_non_neg_integer() end); type(erlang, spawn, 1, Xs) -> strict(arg_types(erlang, spawn, 1), Xs, fun (_) -> t_pid() end); type(erlang, spawn, 2, Xs) -> strict(arg_types(erlang, spawn, 2), Xs, fun (_) -> t_pid() end); -type(erlang, spawn, 3, Xs) -> - strict(arg_types(erlang, spawn, 3), Xs, fun (_) -> t_pid() end); type(erlang, spawn, 4, Xs) -> strict(arg_types(erlang, spawn, 4), Xs, fun (_) -> t_pid() end); type(erlang, spawn_link, 1, Xs) -> type(erlang, spawn, 1, Xs); % same type(erlang, spawn_link, 2, Xs) -> type(erlang, spawn, 2, Xs); % same -type(erlang, spawn_link, 3, Xs) -> type(erlang, spawn, 3, Xs); % same type(erlang, spawn_link, 4, Xs) -> type(erlang, spawn, 4, Xs); % same -type(erlang, spawn_opt, 1, Xs) -> - strict(arg_types(erlang, spawn_opt, 1), Xs, - fun ([Tuple]) -> - Fun = fun (TS) -> - [_, _, _, List] = t_tuple_args(TS), - t_spawn_opt_return(List) - end, - t_sup([Fun(TS) || TS <- t_tuple_subtypes(Tuple)]) - end); -type(erlang, spawn_opt, 2, Xs) -> - strict(arg_types(erlang, spawn_opt, 2), Xs, - fun ([_, List]) -> t_spawn_opt_return(List) end); -type(erlang, spawn_opt, 3, Xs) -> - strict(arg_types(erlang, spawn_opt, 3), Xs, - fun ([_, _, List]) -> t_spawn_opt_return(List) end); -type(erlang, spawn_opt, 4, Xs) -> - strict(arg_types(erlang, spawn_opt, 4), Xs, - fun ([_, _, _, List]) -> t_spawn_opt_return(List) end); -type(erlang, split_binary, 2, Xs) -> - strict(arg_types(erlang, split_binary, 2), Xs, - fun (_) -> t_tuple([t_binary(), t_binary()]) end); -type(erlang, start_timer, 3, Xs) -> - strict(arg_types(erlang, start_timer, 3), Xs, fun (_) -> t_reference() end); -type(erlang, statistics, 1, Xs) -> - strict(arg_types(erlang, statistics, 1), Xs, - fun ([Type]) -> - T_statistics_1 = t_sup([t_non_neg_integer(), - t_tuple([t_non_neg_integer(), - t_non_neg_integer()]), - %% When called with the argument 'io'. - t_tuple([t_tuple([t_atom('input'), - t_non_neg_integer()]), - t_tuple([t_atom('output'), - t_non_neg_integer()])]), - t_tuple([t_non_neg_integer(), - t_non_neg_integer(), - t_non_neg_integer()])]), - case t_atom_vals(Type) of - ['context_switches'] -> - t_tuple([t_non_neg_integer(), t_integer(0)]); - ['exact_reductions'] -> - t_tuple([t_non_neg_integer(), t_non_neg_integer()]); - ['garbage_collection'] -> - t_tuple([t_non_neg_integer(), - t_non_neg_integer(), - t_integer(0)]); - ['io'] -> - t_tuple([t_tuple([t_atom('input'), t_non_neg_integer()]), - t_tuple([t_atom('output'), t_non_neg_integer()])]); - ['reductions'] -> - t_tuple([t_non_neg_integer(), t_non_neg_integer()]); - ['run_queue'] -> - t_non_neg_integer(); - ['runtime'] -> - t_tuple([t_non_neg_integer(), t_integer(0)]); - ['wall_clock'] -> - t_tuple([t_non_neg_integer(), t_integer(0)]); - ['scheduler_wall_time'] -> - t_list(t_tuple([t_integer(), t_number(), t_number()])); - List when is_list(List) -> - T_statistics_1; - unknown -> - T_statistics_1 - end - end); type(erlang, subtract, 2, Xs) -> type(erlang, '--', 2, Xs); % alias type(erlang, suspend_process, 1, Xs) -> strict(arg_types(erlang, suspend_process, 1), Xs, fun (_) -> t_atom('true') end); -type(erlang, suspend_process, 2, Xs) -> - strict(arg_types(erlang, suspend_process, 2), Xs, - fun (_) -> t_boolean() end); -type(erlang, system_flag, 2, Xs) -> - strict(arg_types(erlang, system_flag, 2), Xs, - fun ([Flag,_Value]) -> - %% this provides an overapproximation of all return values - T_system_flag_2 = t_sup([t_boolean(), - t_integer(), - t_sequential_tracer(), - t_system_cpu_topology(), - t_system_multi_scheduling()]), - case t_is_atom(Flag) of - true -> - case t_atom_vals(Flag) of - ['backtrace_depth'] -> - t_non_neg_fixnum(); - ['cpu_topology'] -> - t_system_cpu_topology(); - ['debug_flags'] -> - t_atom('true'); - ['display_items'] -> - t_non_neg_fixnum(); - ['fullsweep_after'] -> - t_non_neg_fixnum(); - ['min_heap_size'] -> - t_non_neg_fixnum(); - ['min_bin_vheap_size'] -> - t_non_neg_fixnum(); - ['multi_scheduling'] -> - t_system_multi_scheduling(); - ['schedulers_online'] -> - t_pos_fixnum(); - ['scheduler_bind_type'] -> - t_scheduler_bind_type_results(); - ['sequential_tracer'] -> - t_sequential_tracer(); - ['trace_control_word'] -> - t_integer(); - ['scheduler_wall_time'] -> - t_boolean(); - List when is_list(List) -> - T_system_flag_2; - unknown -> - T_system_flag_2 - end; - false -> - case t_is_integer(Flag) of % SHOULD BE: t_is_fixnum - true -> - t_atom('true'); - false -> - T_system_flag_2 - end - end - end); type(erlang, system_info, 1, Xs) -> strict(arg_types(erlang, system_info, 1), Xs, fun ([Type]) -> @@ -1569,12 +835,8 @@ type(erlang, system_info, 1, Xs) -> t_list(t_tuple([t_atom(), t_list(t_tuple([t_atom(), t_any()]))]))]); - ['build_type'] -> - t_system_build_type_return(); ['break_ignored'] -> t_boolean(); - ['c_compiler_used'] -> - t_tuple([t_atom(), t_any()]); ['cpu_topology'] -> t_system_cpu_topology(); ['compat_rel'] -> @@ -1586,9 +848,7 @@ type(erlang, system_info, 1, Xs) -> ['dist'] -> t_binary(); ['dist_ctrl'] -> - t_list(t_tuple([t_atom(), t_sup([t_pid(), t_port])])); - ['driver_version'] -> - t_string(); + t_list(t_tuple([t_atom(), t_sup([t_pid(), t_port()])])); %% elib_malloc is intentionally not included, %% because it scheduled for removal in R15. ['endian'] -> @@ -1608,27 +868,18 @@ type(erlang, system_info, 1, Xs) -> t_binary(); ['internal_cpu_topology'] -> %% Undocumented internal feature t_internal_cpu_topology(); - ['kernel_poll'] -> - t_boolean(); ['loaded'] -> t_binary(); ['logical_processors'] -> t_non_neg_fixnum(); ['machine'] -> t_string(); - ['min_heap_size'] -> - t_tuple([t_atom('min_heap_size'), - t_non_neg_integer()]); - ['min_bin_vheap_size'] -> - t_tuple([t_atom('min_bin_vheap_size'), - t_non_neg_integer()]); ['multi_scheduling'] -> t_system_multi_scheduling(); ['multi_scheduling_blockers'] -> t_list(t_pid()); ['os_type'] -> t_tuple([t_sup([t_atom('unix'), - t_atom('vxworks'), t_atom('win32')]), t_atom()]); ['os_version'] -> @@ -1638,6 +889,12 @@ type(erlang, system_info, 1, Xs) -> t_string()); ['otp_release'] -> t_string(); + ['port_parallelism'] -> + t_boolean(); + ['port_count'] -> + t_non_neg_fixnum(); + ['port_limit'] -> + t_non_neg_fixnum(); ['process_count'] -> t_non_neg_fixnum(); ['process_limit'] -> @@ -1667,8 +924,6 @@ type(erlang, system_info, 1, Xs) -> t_non_neg_fixnum(); ['trace_control_word'] -> t_integer(); - ['update_cpu_info'] -> - t_sup([t_atom('changed'), t_atom('unchanged')]); ['version'] -> t_string(); ['wordsize'] -> @@ -1682,56 +937,13 @@ type(erlang, system_info, 1, Xs) -> t_any() %% overapproximation as the return value might change end end); -type(erlang, system_monitor, 0, Xs) -> - strict(arg_types(erlang, system_monitor, 0), Xs, - fun (_) -> t_system_monitor_settings() end); -type(erlang, system_monitor, 1, Xs) -> - strict(arg_types(erlang, system_monitor, 1), Xs, - fun (_) -> t_system_monitor_settings() end); -type(erlang, system_monitor, 2, Xs) -> - strict(arg_types(erlang, system_monitor, 2), Xs, - fun (_) -> t_system_monitor_settings() end); -type(erlang, system_profile, 0, _) -> - t_system_profile_return(); -type(erlang, system_profile, 2, Xs) -> - strict(arg_types(erlang, system_profile, 2), Xs, - fun (_) -> t_system_profile_return() end); -type(erlang, term_to_binary, 1, Xs) -> - strict(arg_types(erlang, term_to_binary, 1), Xs, fun (_) -> t_binary() end); -type(erlang, term_to_binary, 2, Xs) -> - strict(arg_types(erlang, term_to_binary, 2), Xs, fun (_) -> t_binary() end); -type(erlang, time, 0, _) -> - t_tuple([t_non_neg_integer(), t_non_neg_integer(), t_non_neg_integer()]); +%% Guard bif, needs to be here. type(erlang, tl, 1, Xs) -> strict(arg_types(erlang, tl, 1), Xs, fun ([X]) -> t_cons_tl(X) end); -type(erlang, trace, 3, Xs) -> - strict(arg_types(erlang, trace, 3), Xs, fun (_) -> t_integer() end); -type(erlang, trace_delivered, 1, Xs) -> - strict(arg_types(erlang, trace_delivered, 1), Xs, - fun (_) -> t_reference() end); -type(erlang, trace_info, 2, Xs) -> - strict(arg_types(erlang, trace_info, 2), Xs, - fun (_) -> - t_tuple([t_atom(), - t_sup([%% the following is info about a PID - t_list(t_atom()), t_pid(), t_port(), - %% the following is info about a func - t_atom('global'), t_atom('local'), - t_atom('false'), t_atom('true'), - t_list(), t_pid(), t_port(), - t_integer(), - t_list(t_tuple([t_atom(), t_any()])), - %% and this is the 'not found' value - t_atom('undefined')])]) - end); -type(erlang, trace_pattern, 2, Xs) -> - strict(arg_types(erlang, trace_pattern, 2), Xs, - fun (_) -> t_non_neg_fixnum() end); %% num of MFAs that match pattern -type(erlang, trace_pattern, 3, Xs) -> - strict(arg_types(erlang, trace_pattern, 3), Xs, - fun (_) -> t_non_neg_fixnum() end); %% num of MFAs that match pattern +%% Guard bif, needs to be here. type(erlang, trunc, 1, Xs) -> strict(arg_types(erlang, trunc, 1), Xs, fun (_) -> t_integer() end); +%% Guard bif, needs to be here. type(erlang, tuple_size, 1, Xs) -> strict(arg_types(erlang, tuple_size, 1), Xs, fun (_) -> t_non_neg_integer() end); type(erlang, tuple_to_list, 1, Xs) -> @@ -1754,266 +966,10 @@ type(erlang, tuple_to_list, 1, Xs) -> end end end); -type(erlang, universaltime, 0, _) -> - t_tuple([t_date(), t_time()]); -type(erlang, universaltime_to_localtime, 1, Xs) -> - strict(arg_types(erlang, universaltime_to_localtime, 1), Xs, - fun ([T]) -> T end); -type(erlang, universaltime_to_posixtime, 1, Xs) -> - strict(arg_types(erlang, universaltime_to_posixtime,1), Xs, - fun(_) -> t_integer() end); -type(erlang, unlink, 1, Xs) -> - strict(arg_types(erlang, unlink, 1), Xs, fun (_) -> t_atom('true') end); -type(erlang, unregister, 1, Xs) -> - strict(arg_types(erlang, unregister, 1), Xs, fun (_) -> t_atom('true') end); -type(erlang, whereis, 1, Xs) -> - strict(arg_types(erlang, whereis, 1), Xs, - fun (_) -> t_sup([t_pid(), t_port(), t_atom('undefined')]) end); type(erlang, yield, 0, _) -> t_atom('true'); -%%-- erl_prim_loader ---------------------------------------------------------- -type(erl_prim_loader, get_file, 1, Xs) -> - strict(arg_types(erl_prim_loader, get_file, 1), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_binary(), t_string()]), - t_atom('error')) - end); -type(erl_prim_loader, get_path, 0, _) -> - t_tuple([t_atom('ok'), t_list(t_string())]); -type(erl_prim_loader, set_path, 1, Xs) -> - strict(arg_types(erl_prim_loader, set_path, 1), Xs, - fun (_) -> t_atom('ok') end); -%%-- error_logger ------------------------------------------------------------- -type(error_logger, warning_map, 0, _) -> - t_sup([t_atom('info'), t_atom('warning'), t_atom('error')]); -%%-- erts_debug --------------------------------------------------------------- -type(erts_debug, breakpoint, 2, Xs) -> - strict(arg_types(erts_debug, breakpoint, 2), Xs, fun (_) -> t_fixnum() end); -type(erts_debug, disassemble, 1, Xs) -> - strict(arg_types(erts_debug, disassemble, 1), Xs, - fun (_) -> t_sup([t_atom('false'), - t_atom('undef'), - t_tuple([t_integer(), t_binary(), t_mfa()])]) end); -type(erts_debug, display, 1, _) -> - t_string(); -type(erts_debug, dist_ext_to_term, 2, Xs) -> - strict(arg_types(erts_debug, dist_ext_to_term, 2), Xs, - fun (_) -> t_any() end); -type(erts_debug, dump_monitors, 1, Xs) -> - strict(arg_types(erts_debug, dump_monitors, 1), Xs, - fun(_) -> t_atom('true') end); -type(erts_debug, dump_links, 1, Xs) -> - strict(arg_types(erts_debug, dump_links, 1), Xs, - fun(_) -> t_atom('true') end); -type(erts_debug, flat_size, 1, Xs) -> - strict(arg_types(erts_debug, flat_size, 1), Xs, fun (_) -> t_integer() end); -type(erts_debug, get_internal_state, 1, _) -> - t_any(); -type(erts_debug, instructions, 0, _) -> - t_list(t_list(t_byte())); -type(erts_debug, lock_counters, 1, Xs) -> - strict(arg_types(erts_debug, lock_counters, 1), Xs, - fun ([Arg]) -> - case t_is_atom(Arg) of - true -> - case t_atom_vals(Arg) of - ['enabled'] -> t_boolean(); - ['info'] -> t_any(); - ['clear'] -> t_atom(ok); - _ -> t_sup([t_boolean(), t_any(), t_atom('ok')]) - end; - false -> - case t_is_tuple(Arg) of - true -> t_boolean(); - false -> t_sup([t_boolean(), t_any(), t_atom('ok')]) - end - end - end); -type(erts_debug, same, 2, Xs) -> - strict(arg_types(erts_debug, same, 2), Xs, fun (_) -> t_boolean() end); -type(erts_debug, set_internal_state, 2, _) -> - t_any(); %%-- ets ---------------------------------------------------------------------- -type(ets, all, 0, _) -> - t_list(t_tab()); -type(ets, delete, 1, Xs) -> - strict(arg_types(ets, delete, 1), Xs, fun (_) -> t_atom('true') end); -type(ets, delete, 2, Xs) -> - strict(arg_types(ets, delete, 2), Xs, fun (_) -> t_atom('true') end); -type(ets, delete_all_objects, 1, Xs) -> - strict(arg_types(ets, delete_all_objects, 1), Xs, - fun (_) -> t_atom('true') end); -type(ets, delete_object, 2, Xs) -> - strict(arg_types(ets, delete_object, 2), Xs, fun (_) -> t_atom('true') end); -type(ets, first, 1, Xs) -> - strict(arg_types(ets, first, 1), Xs, fun (_) -> t_any() end); -type(ets, give_away, 3, Xs) -> - strict(arg_types(ets, give_away, 3), Xs, fun (_) -> t_atom('true') end); -type(ets, info, 1, Xs) -> - strict(arg_types(ets, info, 1), Xs, - fun (_) -> - t_sup(t_list(t_tuple([t_ets_info_items(), t_any()])), - t_atom('undefined')) - end); -type(ets, info, 2, Xs) -> - strict(arg_types(ets, info, 2), Xs, fun (_) -> t_any() end); -type(ets, insert, 2, Xs) -> - strict(arg_types(ets, insert, 2), Xs, fun (_) -> t_atom('true') end); -type(ets, insert_new, 2, Xs) -> - strict(arg_types(ets, insert_new, 2), Xs, fun (_) -> t_boolean() end); -type(ets, is_compiled_ms, 1, Xs) -> - strict(arg_types(ets, is_compiled_ms, 1), Xs, fun (_) -> t_boolean() end); -type(ets, last, 1, Xs) -> - type(ets, first, 1, Xs); -type(ets, lookup, 2, Xs) -> - strict(arg_types(ets, lookup, 2), Xs, fun (_) -> t_list(t_tuple()) end); -type(ets, lookup_element, 3, Xs) -> - strict(arg_types(ets, lookup_element, 3), Xs, fun (_) -> t_any() end); -type(ets, match, 1, Xs) -> - strict(arg_types(ets, match, 1), Xs, fun (_) -> t_matchres() end); -type(ets, match, 2, Xs) -> - strict(arg_types(ets, match, 2), Xs, fun (_) -> t_list() end); -type(ets, match, 3, Xs) -> - strict(arg_types(ets, match, 3), Xs, fun (_) -> t_matchres() end); -type(ets, match_object, 1, Xs) -> type(ets, match, 1, Xs); -type(ets, match_object, 2, Xs) -> type(ets, match, 2, Xs); -type(ets, match_object, 3, Xs) -> type(ets, match, 3, Xs); -type(ets, match_spec_compile, 1, Xs) -> - strict(arg_types(ets, match_spec_compile, 1), Xs, fun (_) -> t_any() end); -type(ets, match_spec_run_r, 3, Xs) -> - strict(arg_types(ets, match_spec_run_r, 3), Xs, fun (_) -> t_list() end); -type(ets, member, 2, Xs) -> - strict(arg_types(ets, member, 2), Xs, fun (_) -> t_boolean() end); -type(ets, new, 2, Xs) -> - strict(arg_types(ets, new, 2), Xs, fun (_) -> t_tab() end); -type(ets, next, 2, Xs) -> - strict(arg_types(ets, next, 2), Xs, - %% t_any below stands for: term() | '$end_of_table' - fun (_) -> t_any() end); -type(ets, prev, 2, Xs) -> type(ets, next, 2, Xs); type(ets, rename, 2, Xs) -> strict(arg_types(ets, rename, 2), Xs, fun ([_, Name]) -> Name end); -type(ets, safe_fixtable, 2, Xs) -> - strict(arg_types(ets, safe_fixtable, 2), Xs, fun (_) -> t_atom('true') end); -type(ets, select, 1, Xs) -> - strict(arg_types(ets, select, 1), Xs, fun (_) -> t_matchres() end); -type(ets, select, 2, Xs) -> - strict(arg_types(ets, select, 2), Xs, fun (_) -> t_list() end); -type(ets, select, 3, Xs) -> - strict(arg_types(ets, select, 3), Xs, fun (_) -> t_matchres() end); -type(ets, select_count, 2, Xs) -> - strict(arg_types(ets, select_count, 2), Xs, - fun (_) -> t_non_neg_fixnum() end); -type(ets, select_delete, 2, Xs) -> - strict(arg_types(ets, select_delete, 2), Xs, - fun (_) -> t_non_neg_fixnum() end); -type(ets, select_reverse, 1, Xs) -> type(ets, select, 1, Xs); -type(ets, select_reverse, 2, Xs) -> type(ets, select, 2, Xs); -type(ets, select_reverse, 3, Xs) -> type(ets, select, 3, Xs); -type(ets, setopts, 2, Xs) -> - strict(arg_types(ets, setopts, 2), Xs, fun (_) -> t_atom('true') end); -type(ets, slot, 2, Xs) -> - strict(arg_types(ets, slot, 2), Xs, - fun (_) -> t_sup(t_list(t_tuple()), t_atom('$end_of_table')) end); -type(ets, update_counter, 3, Xs) -> - strict(arg_types(ets, update_counter, 3), Xs, - fun ([_, _, Op]) -> - case t_is_integer(Op) of - true -> t_integer(); - false -> - case t_is_tuple(Op) of - true -> t_integer(); - false -> - case t_is_list(Op) of - true -> t_list(t_integer()); - false -> - case t_is_nil(Op) of - true -> t_nil(); - false -> t_sup([t_integer(), t_list(t_integer())]) - end - end - end - end - end); -type(ets, update_element, 3, Xs) -> - strict(arg_types(ets, update_element, 3), Xs, fun (_) -> t_boolean() end); -%%-- file --------------------------------------------------------------------- -type(file, native_name_encoding, 0, _) -> - t_file_encoding(); -%%-- prim_file ---------------------------------------------------------------- -type(prim_file, internal_name2native, 1, Xs) -> - strict(arg_types(prim_file, internal_name2native, 1), Xs, - fun (_) -> t_binary() end); -type(prim_file, internal_native2name, 1, Xs) -> - strict(arg_types(prim_file, internal_native2name, 1), Xs, - fun (_) -> t_prim_file_name() end); -type(prim_file, internal_normalize_utf8, 1, Xs) -> - strict(arg_types(prim_file, internal_normalize_utf8, 1), Xs, - fun (_) -> t_unicode_string() end); -%%-- gen_tcp ------------------------------------------------------------------ -%% NOTE: All type information for this module added to avoid loss of precision -type(gen_tcp, accept, 1, Xs) -> - strict(arg_types(gen_tcp, accept, 1), Xs, fun (_) -> t_gen_tcp_accept() end); -type(gen_tcp, accept, 2, Xs) -> - strict(arg_types(gen_tcp, accept, 2), Xs, fun (_) -> t_gen_tcp_accept() end); -type(gen_tcp, connect, 3, Xs) -> - strict(arg_types(gen_tcp, connect, 3), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_tcp, connect, 4, Xs) -> - strict(arg_types(gen_tcp, connect, 4), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_tcp, listen, 2, Xs) -> - strict(arg_types(gen_tcp, listen, 2), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_tcp, recv, 2, Xs) -> - strict(arg_types(gen_tcp, recv, 2), Xs, fun (_) -> t_gen_tcp_recv() end); -type(gen_tcp, recv, 3, Xs) -> - strict(arg_types(gen_tcp, recv, 3), Xs, fun (_) -> t_gen_tcp_recv() end); -type(gen_tcp, send, 2, Xs) -> - strict(arg_types(gen_tcp, send, 2), Xs, - fun (_) -> - t_sup(t_atom('ok'), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_tcp, shutdown, 2, Xs) -> - strict(arg_types(gen_tcp, shutdown, 2), Xs, - fun (_) -> - t_sup(t_atom('ok'), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -%%-- gen_udp ------------------------------------------------------------------ -%% NOTE: All type information for this module added to avoid loss of precision -type(gen_udp, open, 1, Xs) -> - strict(arg_types(gen_udp, open, 1), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_udp, open, 2, Xs) -> - strict(arg_types(gen_udp, open, 2), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_inet_posix_error()])) - end); -type(gen_udp, recv, 2, Xs) -> - strict(arg_types(gen_udp, recv, 2), Xs, fun (_) -> t_gen_udp_recv() end); -type(gen_udp, recv, 3, Xs) -> - strict(arg_types(gen_udp, recv, 3), Xs, fun (_) -> t_gen_udp_recv() end); -type(gen_udp, send, 4, Xs) -> - strict(arg_types(gen_udp, send, 4), Xs, - fun (_) -> - t_sup(t_atom('ok'), - t_tuple([t_atom('error'), t_sup(t_atom('not_owner'), - t_inet_posix_error())])) - end); %%-- hipe_bifs ---------------------------------------------------------------- type(hipe_bifs, add_ref, 2, Xs) -> strict(arg_types(hipe_bifs, add_ref, 2), Xs, fun (_) -> t_nil() end); @@ -2115,7 +1071,7 @@ type(hipe_bifs, ref_set, 2, Xs) -> strict(arg_types(hipe_bifs, ref_set, 2), Xs, fun (_) -> t_nil() end); type(hipe_bifs, remove_refs_from, 1, Xs) -> strict(arg_types(hipe_bifs, remove_refs_from, 1), Xs, - fun (_) -> t_nil() end); + fun (_) -> t_atom('ok') end); type(hipe_bifs, set_funinfo_native_address, 3, Xs) -> strict(arg_types(hipe_bifs, set_funinfo_native_address, 3), Xs, fun (_) -> t_nil() end); @@ -2136,26 +1092,6 @@ type(hipe_bifs, write_u32, 2, Xs) -> strict(arg_types(hipe_bifs, write_u32, 2), Xs, fun (_) -> t_nil() end); type(hipe_bifs, write_u64, 2, Xs) -> strict(arg_types(hipe_bifs, write_u64, 2), Xs, fun (_) -> t_nil() end); -%%-- io ----------------------------------------------------------------------- -type(io, format, 1, Xs) -> - strict(arg_types(io, format, 1), Xs, fun (_) -> t_atom('ok') end); -type(io, format, 2, Xs) -> - strict(arg_types(io, format, 2), Xs, fun (_) -> t_atom('ok') end); -type(io, format, 3, Xs) -> - strict(arg_types(io, format, 3), Xs, fun (_) -> t_atom('ok') end); -type(io, fwrite, 1, Xs) -> type(io, format, 1, Xs); % same -type(io, fwrite, 2, Xs) -> type(io, format, 2, Xs); % same -type(io, fwrite, 3, Xs) -> type(io, format, 3, Xs); % same -type(io, put_chars, 1, Xs) -> - strict(arg_types(io, put_chars, 1), Xs, fun (_) -> t_atom('ok') end); -type(io, put_chars, 2, Xs) -> - strict(arg_types(io, put_chars, 2), Xs, fun (_) -> t_atom('ok') end); -%%-- io_lib ------------------------------------------------------------------- -type(io_lib, format, 2, Xs) -> - strict(arg_types(io_lib, format, 2), Xs, - %% t_list() because the character list might be arbitrarily nested - fun (_) -> t_list(t_sup(t_char(), t_list())) end); -type(io_lib, fwrite, 2, Xs) -> type(io_lib, format, 2, Xs); % same %%-- lists -------------------------------------------------------------------- type(lists, all, 2, Xs) -> strict(arg_types(lists, all, 2), Xs, @@ -2525,8 +1461,6 @@ type(lists, merge, 2, Xs) -> end end end); -%% type(lists, merge, 3, Xs) -> -%% type(lists, merge3, 3, Xs) -> type(lists, min, 1, Xs) -> strict(arg_types(lists, min, 1), Xs, fun ([L]) -> t_list_elements(L) end); type(lists, nth, 2, Xs) -> @@ -2563,10 +1497,6 @@ type(lists, reverse, 1, Xs) -> strict(arg_types(lists, reverse, 1), Xs, fun ([X]) -> X end); type(lists, reverse, 2, Xs) -> type(erlang, '++', 2, Xs); % reverse-onto is just like append -type(lists, seq, 2, Xs) -> - strict(arg_types(lists, seq, 2), Xs, fun (_) -> t_list(t_integer()) end); -type(lists, seq, 3, Xs) -> - strict(arg_types(lists, seq, 3), Xs, fun (_) -> t_list(t_integer()) end); type(lists, sort, 1, Xs) -> strict(arg_types(lists, sort, 1), Xs, fun ([X]) -> X end); type(lists, sort, 2, Xs) -> @@ -2673,95 +1603,7 @@ type(lists, zipwith, 3, Xs) -> type(lists, zipwith3, 4, Xs) -> strict(arg_types(lists, zipwith3, 4), Xs, fun ([F,_As,_Bs,_Cs]) -> t_sup(t_list(t_fun_range(F)), t_nil()) end); -%%-- math --------------------------------------------------------------------- -type(math, acos, 1, Xs) -> - strict(arg_types(math, acos, 1), Xs, fun (_) -> t_float() end); -type(math, acosh, 1, Xs) -> - strict(arg_types(math, acosh, 1), Xs, fun (_) -> t_float() end); -type(math, asin, 1, Xs) -> - strict(arg_types(math, asin, 1), Xs, fun (_) -> t_float() end); -type(math, asinh, 1, Xs) -> - strict(arg_types(math, asinh, 1), Xs, fun (_) -> t_float() end); -type(math, atan, 1, Xs) -> - strict(arg_types(math, atan, 1), Xs, fun (_) -> t_float() end); -type(math, atan2, 2, Xs) -> - strict(arg_types(math, atan2, 2), Xs, fun (_) -> t_float() end); -type(math, atanh, 1, Xs) -> - strict(arg_types(math, atanh, 1), Xs, fun (_) -> t_float() end); -type(math, cos, 1, Xs) -> - strict(arg_types(math, cos, 1), Xs, fun (_) -> t_float() end); -type(math, cosh, 1, Xs) -> - strict(arg_types(math, cosh, 1), Xs, fun (_) -> t_float() end); -type(math, erf, 1, Xs) -> - strict(arg_types(math, erf, 1), Xs, fun (_) -> t_float() end); -type(math, erfc, 1, Xs) -> - strict(arg_types(math, erfc, 1), Xs, fun (_) -> t_float() end); -type(math, exp, 1, Xs) -> - strict(arg_types(math, exp, 1), Xs, fun (_) -> t_float() end); -type(math, log, 1, Xs) -> - strict(arg_types(math, log, 1), Xs, fun (_) -> t_float() end); -type(math, log10, 1, Xs) -> - strict(arg_types(math, log10, 1), Xs, fun (_) -> t_float() end); -type(math, pi, 0, _) -> t_float(); -type(math, pow, 2, Xs) -> - strict(arg_types(math, pow, 2), Xs, fun (_) -> t_float() end); -type(math, sin, 1, Xs) -> - strict(arg_types(math, sin, 1), Xs, fun (_) -> t_float() end); -type(math, sinh, 1, Xs) -> - strict(arg_types(math, sinh, 1), Xs, fun (_) -> t_float() end); -type(math, sqrt, 1, Xs) -> - strict(arg_types(math, sqrt, 1), Xs, fun (_) -> t_float() end); -type(math, tan, 1, Xs) -> - strict(arg_types(math, tan, 1), Xs, fun (_) -> t_float() end); -type(math, tanh, 1, Xs) -> - strict(arg_types(math, tanh, 1), Xs, fun (_) -> t_float() end); -%%-- net_kernel --------------------------------------------------------------- -type(net_kernel, dflag_unicode_io, 1, Xs) -> - strict(arg_types(net_kernel, dflag_unicode_io, 1), Xs, - fun (_) -> t_boolean() end); -%%-- ordsets ------------------------------------------------------------------ -type(ordsets, filter, 2, Xs) -> - type(lists, filter, 2, Xs); -type(ordsets, fold, 3, Xs) -> - type(lists, foldl, 3, Xs); -%%-- os ----------------------------------------------------------------------- -type(os, getenv, 0, _) -> t_list(t_string()); -type(os, getenv, 1, Xs) -> - strict(arg_types(os, getenv, 1), Xs, - fun (_) -> t_sup(t_string(), t_atom('false')) end); -type(os, getpid, 0, _) -> t_string(); -type(os, putenv, 2, Xs) -> - strict(arg_types(os, putenv, 2), Xs, fun (_) -> t_atom('true') end); -type(os, timestamp, 0, _) -> - t_timestamp(); -%%-- re ----------------------------------------------------------------------- -type(re, compile, 1, Xs) -> - strict(arg_types(re, compile, 1), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_re_MP()]), - t_tuple([t_atom('error'), t_re_ErrorSpec()])) - end); -type(re, compile, 2, Xs) -> - strict(arg_types(re, compile, 2), Xs, - fun (_) -> - t_sup(t_tuple([t_atom('ok'), t_re_MP()]), - t_tuple([t_atom('error'), t_re_ErrorSpec()])) - end); -type(re, run, 2, Xs) -> - strict(arg_types(re, run, 2), Xs, - fun (_) -> - t_sup([t_tuple([t_atom('match'), t_re_Captured()]), - t_atom('nomatch'), - t_tuple([t_atom('error'), t_re_ErrorSpec()])]) - end); -type(re, run, 3, Xs) -> - strict(arg_types(re, run, 3), Xs, - fun (_) -> - t_sup([t_tuple([t_atom('match'), t_re_Captured()]), - t_atom('match'), - t_atom('nomatch'), - t_tuple([t_atom('error'), t_re_ErrorSpec()])]) - end); + %%-- string ------------------------------------------------------------------- type(string, chars, 2, Xs) -> % NOTE: added to avoid loss of information strict(arg_types(string, chars, 2), Xs, fun (_) -> t_string() end); @@ -2780,41 +1622,6 @@ type(string, chars, 3, Xs) -> % NOTE: added to avoid loss of information end end end); -type(string, concat, 2, Xs) -> % NOTE: added to avoid loss of information - strict(arg_types(string, concat, 2), Xs, fun (_) -> t_string() end); -type(string, equal, 2, Xs) -> % NOTE: added to avoid loss of information - strict(arg_types(string, equal, 2), Xs, fun (_) -> t_boolean() end); -type(string, to_float, 1, Xs) -> - strict(arg_types(string, to_float, 1), Xs, - fun (_) -> t_sup(t_tuple([t_float(), t_string()]), - t_tuple([t_atom('error'), - t_sup(t_atom('no_float'), - t_atom('not_a_list'))])) - end); -type(string, to_integer, 1, Xs) -> - strict(arg_types(string, to_integer, 1), Xs, - fun (_) -> t_sup(t_tuple([t_integer(), t_string()]), - t_tuple([t_atom('error'), - t_sup(t_atom('no_integer'), - t_atom('not_a_list'))])) - end); -%%-- unicode ------------------------------------------------------------------ -type(unicode, characters_to_binary, 2, Xs) -> - strict(arg_types(unicode, characters_to_binary, 2), Xs, - fun (_) -> - t_sup([t_binary(), - t_tuple([t_atom('error'), t_binary(), t_ML()]), - t_tuple([t_atom('incomplete'), t_binary(), t_ML()])]) - end); -type(unicode, characters_to_list, 2, Xs) -> - strict(arg_types(unicode, characters_to_list, 2), Xs, - fun (_) -> - t_sup([t_string(), - t_tuple([t_atom('error'), t_string(), t_ML()]), - t_tuple([t_atom('incomplete'), t_string(), t_ML()])]) - end); -type(unicode, bin_is_7bit, 1, Xs) -> - strict(arg_types(unicode, bin_is_7bit, 1), Xs, fun (_) -> t_boolean() end); %%----------------------------------------------------------------------------- type(M, F, A, Xs) when is_atom(M), is_atom(F), @@ -3269,107 +2076,6 @@ key_comparisons_fail(X0, KeyPos, TupleList) -> -spec arg_types(atom(), atom(), arity()) -> [erl_types:erl_type()] | 'unknown'. -%%------- binary -------------------------------------------------------------- -arg_types(binary, at, 2) -> - [t_binary(), t_non_neg_integer()]; -arg_types(binary, bin_to_list, 1) -> - [t_binary()]; -arg_types(binary, bin_to_list, 2) -> - [t_binary(), t_binary_part()]; -arg_types(binary, bin_to_list, 3) -> - [t_binary(), t_integer(), t_non_neg_integer()]; -arg_types(binary, compile_pattern, 1) -> - [t_sup(t_binary(), t_list(t_binary()))]; -arg_types(binary, copy, 1) -> - [t_binary()]; -arg_types(binary, copy, 2) -> - [t_binary(), t_non_neg_integer()]; -arg_types(binary, decode_unsigned, 1) -> - [t_binary()]; -arg_types(binary, decode_unsigned, 2) -> - [t_binary(), t_endian()]; -arg_types(binary, encode_unsigned, 1) -> - [t_non_neg_integer()]; -arg_types(binary, encode_unsigned, 2) -> - [t_non_neg_integer(), t_endian()]; -arg_types(binary, first, 1) -> - [t_binary()]; -arg_types(binary, last, 1) -> - [t_binary()]; -arg_types(binary, list_to_bin, 1) -> - arg_types(erlang, list_to_binary, 1); -arg_types(binary, longest_common_prefix, 1) -> - [t_list(t_binary())]; -arg_types(binary, longest_common_suffix, 1) -> - [t_list(t_binary())]; -arg_types(binary, match, 2) -> - [t_binary(), t_binary_pattern()]; -arg_types(binary, match, 3) -> - [t_binary(), t_binary_pattern(), t_binary_options()]; -arg_types(binary, matches, 2) -> - [t_binary(), t_binary_pattern()]; -arg_types(binary, matches, 3) -> - [t_binary(), t_binary_pattern(), t_binary_options()]; -arg_types(binary, part, 2) -> - arg_types(erlang, binary_part, 2); -arg_types(binary, part, 3) -> - arg_types(erlang, binary_part, 3); -arg_types(binary, referenced_byte_size, 1) -> - [t_binary()]; -%%------- code ---------------------------------------------------------------- -arg_types(code, get_chunk, 2) -> - [t_binary(), t_string()]; -arg_types(code, is_module_native, 1) -> - [t_atom()]; -arg_types(code, module_md5, 1) -> - [t_binary()]; -arg_types(code, make_stub_module, 3) -> - [t_atom(), t_binary(), t_tuple([t_list(), t_list()])]; -arg_types(code, rehash, 0) -> - []; -%%------- erl_ddll ------------------------------------------------------------ -arg_types(erl_ddll, demonitor, 1) -> - arg_types(erlang, demonitor, 1); -arg_types(erl_ddll, format_error_int, 1) -> - [t_sup([t_atom('inconsistent'), - t_atom('linked_in_driver'), - t_atom('permanent'), - t_atom('not_loaded'), - t_atom('not_loaded_by_this_process'), - t_atom('not_pending'), - t_atom('already_loaded'), - t_atom('unloading')])]; -arg_types(erl_ddll, info, 2) -> - [t_sup([t_atom(), t_string()]), - t_sup([t_atom('awaiting_load'), - t_atom('awaiting_unload'), - t_atom('driver_options'), - t_atom('linked_in_driver'), - t_atom('permanent'), - t_atom('port_count'), - t_atom('processes')])]; -arg_types(erl_ddll, loaded_drivers, 0) -> - []; -arg_types(erl_ddll, monitor, 2) -> - [t_atom('driver'), - t_tuple([t_atom(), t_sup([t_atom('loaded'), t_atom('unloaded')])])]; -arg_types(erl_ddll, try_load, 3) -> - [t_sup([t_atom(), t_string(), t_nonempty_list(t_sup([t_atom(), t_string()]))]), - t_sup([t_atom(), t_string()]), - t_list(t_sup([t_tuple([t_atom('driver_options'), - t_list(t_atom('kill_ports'))]), - t_tuple([t_atom('monitor'), - t_sup([t_atom('pending_driver'), - t_atom('pending')])]), - t_tuple([t_atom('reload'), - t_sup([t_atom('pending_driver'), - t_atom('pending')])])]))]; -arg_types(erl_ddll, try_unload, 2) -> - [t_sup([t_atom(), t_string(), t_nonempty_list(t_sup([t_atom(), t_string()]))]), - t_list(t_sup([t_atom('kill_ports'), - t_tuple([t_atom('monitor'), - t_sup([t_atom('pending_driver'), - t_atom('pending')])])]))]; %%------- erlang -------------------------------------------------------------- arg_types(erlang, '!', 2) -> Pid = t_sup([t_pid(), t_port(), t_atom(), @@ -3431,18 +2137,11 @@ arg_types(erlang, 'bsl', 2) -> [t_integer(), t_integer()]; arg_types(erlang, 'bnot', 1) -> [t_integer()]; +%% Guard bif, needs to be here. arg_types(erlang, abs, 1) -> [t_number()]; -arg_types(erlang, adler32, 1) -> - [t_iodata()]; -arg_types(erlang, adler32, 2) -> - [t_adler32(), t_iodata()]; -arg_types(erlang, adler32_combine, 3) -> - [t_adler32(), t_adler32(), t_non_neg_integer()]; arg_types(erlang, append, 2) -> arg_types(erlang, '++', 2); -arg_types(erlang, append_element, 2) -> - [t_tuple(), t_any()]; arg_types(erlang, apply, 2) -> [t_sup(t_tuple([t_module(), t_atom()]), @@ -3450,179 +2149,58 @@ arg_types(erlang, apply, 2) -> t_list()]; arg_types(erlang, apply, 3) -> [t_sup(t_atom(), t_tuple()), t_atom(), t_list()]; -arg_types(erlang, atom_to_binary, 2) -> - [t_atom(), t_encoding_a2b()]; -arg_types(erlang, atom_to_list, 1) -> - [t_atom()]; +%% Guard bif, needs to be here. arg_types(erlang, binary_part, 2) -> [t_binary(), t_tuple([t_non_neg_integer(), t_integer()])]; +%% Guard bif, needs to be here. arg_types(erlang, binary_part, 3) -> [t_binary(), t_non_neg_integer(), t_integer()]; -arg_types(erlang, binary_to_atom, 2) -> - [t_binary(), t_encoding_a2b()]; -arg_types(erlang, binary_to_existing_atom, 2) -> - arg_types(erlang, binary_to_atom, 2); -arg_types(erlang, binary_to_list, 1) -> - [t_binary()]; -arg_types(erlang, binary_to_list, 3) -> - [t_binary(), t_pos_integer(), t_pos_integer()]; % I want fixnum, but cannot -arg_types(erlang, binary_to_term, 1) -> - [t_binary()]; -arg_types(erlang, binary_to_term, 2) -> - [t_binary(), t_list(t_atom('safe'))]; -arg_types(erlang, bitsize, 1) -> % XXX: TAKE OUT - arg_types(erlang, bit_size, 1); +%% Guard bif, needs to be here. arg_types(erlang, bit_size, 1) -> [t_bitstr()]; -arg_types(erlang, bitstr_to_list, 1) -> % XXX: TAKE OUT - arg_types(erlang, bitstring_to_list, 1); -arg_types(erlang, bitstring_to_list, 1) -> - [t_bitstr()]; -arg_types(erlang, bump_reductions, 1) -> - [t_pos_fixnum()]; +%% Guard bif, needs to be here. arg_types(erlang, byte_size, 1) -> [t_binary()]; -arg_types(erlang, call_on_load_function, 1) -> - [t_atom()]; -arg_types(erlang, cancel_timer, 1) -> - [t_reference()]; -arg_types(erlang, check_old_code, 1) -> - [t_atom()]; -arg_types(erlang, check_process_code, 2) -> - [t_pid(), t_atom()]; -arg_types(erlang, crc32, 1) -> - [t_iodata()]; -arg_types(erlang, crc32, 2) -> - [t_crc32(), t_iodata()]; -arg_types(erlang, crc32_combine, 3) -> - [t_crc32(), t_crc32(), t_non_neg_integer()]; -arg_types(erlang, date, 0) -> - []; -arg_types(erlang, decode_packet, 3) -> - [t_decode_packet_type(), t_binary(), t_list(t_decode_packet_option())]; -arg_types(erlang, delete_module, 1) -> - [t_atom()]; -arg_types(erlang, demonitor, 1) -> - [t_reference()]; -arg_types(erlang, demonitor, 2) -> - [t_reference(), t_list(t_atoms(['flush', 'info']))]; arg_types(erlang, disconnect_node, 1) -> [t_node()]; -arg_types(erlang, display, 1) -> - [t_any()]; -arg_types(erlang, display_nl, 0) -> - []; -arg_types(erlang, display_string, 1) -> - [t_string()]; -arg_types(erlang, dist_exit, 3) -> - [t_pid(), t_dist_exit(), t_sup(t_pid(), t_port())]; -arg_types(erlang, dt_append_vm_tag_data, 1) -> - [t_iodata()]; -arg_types(erlang, dt_get_tag, 0) -> - []; -arg_types(erlang, dt_get_tag_data, 0) -> - []; -arg_types(erlang, dt_prepend_vm_tag_data, 1) -> - [t_iodata()]; -arg_types(erlang, dt_put_tag, 1) -> - [t_sup(t_binary(), t_atom('undefined'))]; -arg_types(erlang, dt_restore_tag, 1) -> - [t_sup(t_tuple([t_non_neg_integer(), t_sup(t_binary(), t_nil())]), t_atom('true'))]; -arg_types(erlang, dt_spread_tag, 1) -> - [t_boolean()]; -arg_types(erlang, element, 2) -> - [t_pos_fixnum(), t_tuple()]; -arg_types(erlang, erase, 0) -> +arg_types(erlang, halt, 0) -> []; -arg_types(erlang, erase, 1) -> - [t_any()]; +arg_types(erlang, halt, 1) -> + [t_sup([t_non_neg_fixnum(), t_atom('abort'), t_string()])]; +arg_types(erlang, halt, 2) -> + [t_sup([t_non_neg_fixnum(), t_atom('abort'), t_string()]), + t_list(t_tuple([t_atom('flush'), t_boolean()]))]; arg_types(erlang, error, 1) -> [t_any()]; arg_types(erlang, error, 2) -> [t_any(), t_list()]; arg_types(erlang, exit, 1) -> [t_any()]; -arg_types(erlang, exit, 2) -> - [t_sup(t_pid(), t_port()), t_any()]; -arg_types(erlang, external_size, 1) -> - [t_any()]; % takes any term as input -arg_types(erlang, external_size, 2) -> - [t_any(), t_list()]; % takes any term as input and a list of options -arg_types(erlang, finish_after_on_load, 2) -> - [t_atom(), t_boolean()]; +%% Guard bif, needs to be here. +arg_types(erlang, element, 2) -> + [t_pos_fixnum(), t_tuple()]; +%% Guard bif, needs to be here. arg_types(erlang, float, 1) -> [t_number()]; -arg_types(erlang, float_to_list, 1) -> - [t_float()]; -arg_types(erlang, function_exported, 3) -> - [t_atom(), t_atom(), t_arity()]; arg_types(erlang, fun_info, 1) -> [t_fun()]; -arg_types(erlang, fun_info, 2) -> - [t_fun(), t_atom()]; -arg_types(erlang, fun_to_list, 1) -> - [t_fun()]; -arg_types(erlang, garbage_collect, 0) -> - []; -arg_types(erlang, garbage_collect, 1) -> - [t_pid()]; -arg_types(erlang, garbage_collect_message_area, 0) -> - []; -arg_types(erlang, get, 0) -> - []; -arg_types(erlang, get, 1) -> - [t_any()]; arg_types(erlang, get_cookie, 0) -> []; -arg_types(erlang, get_keys, 1) -> - [t_any()]; -arg_types(erlang, get_stacktrace, 0) -> - []; -arg_types(erlang, get_module_info, 1) -> - [t_atom()]; -arg_types(erlang, get_module_info, 2) -> - [t_atom(), t_module_info_2()]; -arg_types(erlang, group_leader, 0) -> - []; -arg_types(erlang, group_leader, 2) -> - [t_pid(), t_pid()]; -arg_types(erlang, halt, 0) -> - []; -arg_types(erlang, halt, 1) -> - [t_sup([t_non_neg_fixnum(), t_atom('abort'), t_string()])]; -arg_types(erlang, halt, 2) -> - [t_sup([t_non_neg_fixnum(), t_atom('abort'), t_string()]), - t_list(t_tuple([t_atom('flush'), t_boolean()]))]; -arg_types(erlang, hash, 2) -> - [t_any(), t_integer()]; +%% Guard bif, needs to be here. arg_types(erlang, hd, 1) -> [t_cons()]; -arg_types(erlang, hibernate, 3) -> - [t_atom(), t_atom(), t_list()]; arg_types(erlang, info, 1) -> arg_types(erlang, system_info, 1); % alias -arg_types(erlang, iolist_to_binary, 1) -> - [t_sup(t_iolist(), t_binary())]; -arg_types(erlang, iolist_size, 1) -> - [t_sup(t_iolist(), t_binary())]; -arg_types(erlang, integer_to_list, 1) -> - [t_integer()]; arg_types(erlang, integer_to_list, 2) -> [t_integer(), t_from_range(2, 36)]; -arg_types(erlang, is_alive, 0) -> - []; arg_types(erlang, is_atom, 1) -> [t_any()]; arg_types(erlang, is_binary, 1) -> [t_any()]; -arg_types(erlang, is_bitstr, 1) -> % XXX: TAKE OUT - arg_types(erlang, is_bitstring, 1); arg_types(erlang, is_bitstring, 1) -> [t_any()]; arg_types(erlang, is_boolean, 1) -> [t_any()]; -arg_types(erlang, is_builtin, 3) -> - [t_atom(), t_atom(), t_arity()]; arg_types(erlang, is_float, 1) -> [t_any()]; arg_types(erlang, is_function, 1) -> @@ -3639,8 +2217,6 @@ arg_types(erlang, is_pid, 1) -> [t_any()]; arg_types(erlang, is_port, 1) -> [t_any()]; -arg_types(erlang, is_process_alive, 1) -> - [t_pid()]; arg_types(erlang, is_record, 2) -> [t_any(), t_atom()]; arg_types(erlang, is_record, 3) -> @@ -3649,553 +2225,77 @@ arg_types(erlang, is_reference, 1) -> [t_any()]; arg_types(erlang, is_tuple, 1) -> [t_any()]; +%% Guard bif, needs to be here. arg_types(erlang, length, 1) -> [t_list()]; -arg_types(erlang, link, 1) -> - [t_sup(t_pid(), t_port())]; -arg_types(erlang, list_to_atom, 1) -> - [t_string()]; -arg_types(erlang, list_to_binary, 1) -> - [t_iolist()]; -arg_types(erlang, list_to_bitstr, 1) -> % XXX: TAKE OUT - arg_types(erlang, list_to_bitstring, 1); -arg_types(erlang, list_to_bitstring, 1) -> - [t_bitstrlist()]; -arg_types(erlang, list_to_existing_atom, 1) -> - [t_string()]; -arg_types(erlang, list_to_float, 1) -> - [t_list(t_byte())]; -arg_types(erlang, list_to_integer, 1) -> - [t_list(t_byte())]; -arg_types(erlang, list_to_integer, 2) -> - [t_list(t_byte()), t_from_range(2, 36)]; -arg_types(erlang, list_to_pid, 1) -> - [t_string()]; -arg_types(erlang, list_to_tuple, 1) -> - [t_list()]; -arg_types(erlang, load_module, 2) -> - [t_atom(), t_binary()]; -arg_types(erlang, load_nif, 2) -> - [t_string(), t_any()]; -arg_types(erlang, loaded, 0) -> - []; -arg_types(erlang, localtime, 0) -> - []; -arg_types(erlang, localtime_to_universaltime, 1) -> - [t_tuple([t_date(), t_time()])]; -arg_types(erlang, localtime_to_universaltime, 2) -> - arg_types(erlang, localtime_to_universaltime, 1) ++ - [t_sup(t_boolean(), t_atom('undefined'))]; -arg_types(erlang, make_fun, 3) -> - [t_atom(), t_atom(), t_arity()]; -arg_types(erlang, make_ref, 0) -> - []; arg_types(erlang, make_tuple, 2) -> [t_non_neg_fixnum(), t_any()]; % the value 0 is OK as first argument arg_types(erlang, make_tuple, 3) -> [t_non_neg_fixnum(), t_any(), t_list(t_tuple([t_pos_integer(), t_any()]))]; -arg_types(erlang, match_spec_test, 3) -> - [t_sup(t_list(), t_tuple()), - t_any(), - t_sup(t_atom('table'), t_atom('trace'))]; -arg_types(erlang, md5, 1) -> - [t_sup(t_iolist(), t_binary())]; -arg_types(erlang, md5_final, 1) -> - [t_binary()]; -arg_types(erlang, md5_init, 0) -> - []; -arg_types(erlang, md5_update, 2) -> - [t_binary(), t_sup(t_iolist(), t_binary())]; arg_types(erlang, memory, 0) -> []; -arg_types(erlang, memory, 1) -> - Arg = t_atoms(['total', 'processes', 'processes_used', 'system', - 'atom', 'atom_used', 'binary', 'code', 'ets', - 'maximum']), - [t_sup(Arg, t_list(Arg))]; -arg_types(erlang, module_loaded, 1) -> - [t_atom()]; -arg_types(erlang, monitor, 2) -> - [t_atom(), t_sup([t_pid(), t_atom(), t_tuple([t_atom(), t_node()])])]; -arg_types(erlang, monitor_node, 2) -> - [t_node(), t_boolean()]; -arg_types(erlang, monitor_node, 3) -> - [t_node(), t_boolean(), t_list(t_atom('allow_passive_connect'))]; arg_types(erlang, nif_error, 1) -> [t_any()]; arg_types(erlang, nif_error, 2) -> [t_any(), t_list()]; +%% Guard bif, needs to be here. arg_types(erlang, node, 0) -> []; +%% Guard bif, needs to be here. arg_types(erlang, node, 1) -> [t_identifier()]; -arg_types(erlang, nodes, 0) -> - []; -arg_types(erlang, nodes, 1) -> - NodesArg = t_atoms(['visible', 'hidden', 'connected', 'this', 'known']), - [t_sup(NodesArg, t_list(NodesArg))]; -arg_types(erlang, now, 0) -> - []; -arg_types(erlang, open_port, 2) -> - ArgT = t_sup(t_unicode_string(), t_binary()), - [t_sup(t_atom(), t_sup([t_tuple([t_atom('spawn'), t_string()]), - t_tuple([t_atom('spawn_driver'), t_string()]), - t_tuple([t_atom('spawn_executable'), ArgT]), - t_tuple([t_atom('fd'), t_integer(), t_integer()])])), - t_list(t_sup(t_sup([t_atom('stream'), - t_atom('exit_status'), - t_atom('use_stdio'), - t_atom('nouse_stdio'), - t_atom('stderr_to_stdout'), - t_atom('in'), - t_atom('out'), - t_atom('binary'), - t_atom('eof'), - t_atom('hide')]), - t_sup([t_tuple([t_atom('packet'), t_integer()]), - t_tuple([t_atom('line'), t_integer()]), - t_tuple([t_atom('cd'), t_string()]), - t_tuple([t_atom('env'), t_list(t_tuple(2))]), % XXX: More - t_tuple([t_atom('args'), t_list(ArgT)]), - t_tuple([t_atom('arg0'), ArgT])])))]; -arg_types(erlang, phash, 2) -> - [t_any(), t_pos_integer()]; -arg_types(erlang, phash2, 1) -> - [t_any()]; -arg_types(erlang, phash2, 2) -> - [t_any(), t_pos_integer()]; -arg_types(erlang, pid_to_list, 1) -> - [t_pid()]; -arg_types(erlang, port_call, 2) -> - [t_sup(t_port(), t_atom()), t_any()]; -arg_types(erlang, port_call, 3) -> - [t_sup(t_port(), t_atom()), t_integer(), t_any()]; -arg_types(erlang, port_close, 1) -> - [t_sup(t_port(), t_atom())]; -arg_types(erlang, port_command, 2) -> - [t_sup(t_port(), t_atom()), t_sup(t_iolist(), t_binary())]; -arg_types(erlang, port_command, 3) -> - [t_sup(t_port(), t_atom()), - t_sup(t_iolist(), t_binary()), - t_list(t_atoms(['force', 'nosuspend']))]; -arg_types(erlang, port_connect, 2) -> - [t_sup(t_port(), t_atom()), t_pid()]; -arg_types(erlang, port_control, 3) -> - [t_sup(t_port(), t_atom()), t_integer(), t_sup(t_iolist(), t_binary())]; -arg_types(erlang, port_get_data, 1) -> - [t_sup(t_port(), t_atom())]; -arg_types(erlang, port_info, 1) -> - [t_sup(t_port(), t_atom())]; -arg_types(erlang, port_info, 2) -> - [t_sup(t_port(), t_atom()), - t_atoms(['registered_name', 'id', 'connected', - 'links', 'name', 'input', 'output', 'os_pid'])]; -arg_types(erlang, port_to_list, 1) -> - [t_port()]; -arg_types(erlang, ports, 0) -> - []; -arg_types(erlang, port_set_data, 2) -> - [t_sup(t_port(), t_atom()), t_any()]; -arg_types(erlang, pre_loaded, 0) -> - []; -arg_types(erlang, process_display, 2) -> - [t_pid(), t_atom('backtrace')]; -arg_types(erlang, process_flag, 2) -> - [t_sup([t_atom('trap_exit'), - t_atom('error_handler'), - t_atom('min_heap_size'), - t_atom('min_bin_vheap_size'), - t_atom('priority'), - t_atom('save_calls'), - t_atom('sensitive'), - t_atom('scheduler'), % undocumented - t_atom('monitor_nodes'), % undocumented - t_tuple([t_atom('monitor_nodes'), t_list()])]), % undocumented - t_sup([t_boolean(), t_atom(), t_non_neg_integer()])]; -arg_types(erlang, process_flag, 3) -> - [t_pid(), t_atom('save_calls'), t_non_neg_integer()]; -arg_types(erlang, process_info, 1) -> - [t_pid()]; -arg_types(erlang, process_info, 2) -> - [t_pid(), t_pinfo()]; -arg_types(erlang, processes, 0) -> - []; -arg_types(erlang, purge_module, 1) -> - [t_atom()]; -arg_types(erlang, put, 2) -> - [t_any(), t_any()]; -arg_types(erlang, raise, 3) -> - OldStyleType = t_list(t_tuple([t_atom(), t_atom(), - t_sup([t_arity(), t_list()])])), - NewStyleType = type(erlang, get_stacktrace, 0, []), - [t_raise_errorclass(), t_any(), t_sup(OldStyleType, NewStyleType)]; -arg_types(erlang, read_timer, 1) -> - [t_reference()]; -arg_types(erlang, ref_to_list, 1) -> - [t_reference()]; -arg_types(erlang, register, 2) -> - [t_atom(), t_sup(t_port(), t_pid())]; -arg_types(erlang, registered, 0) -> - []; -arg_types(erlang, resume_process, 1) -> - [t_pid()]; % intended for debugging only +%% Guard bif, needs to be here. arg_types(erlang, round, 1) -> [t_number()]; -arg_types(erlang, posixtime_to_universaltime, 1) -> - [t_integer()]; +%% Guard bif, needs to be here. arg_types(erlang, self, 0) -> []; -arg_types(erlang, send, 2) -> - arg_types(erlang, '!', 2); % alias -arg_types(erlang, send, 3) -> - arg_types(erlang, send, 2) ++ [t_list(t_sendoptions())]; -arg_types(erlang, send_after, 3) -> - [t_non_neg_integer(), t_sup(t_pid(), t_atom()), t_any()]; -arg_types(erlang, seq_trace, 2) -> - [t_atom(), t_sup([t_boolean(), t_tuple([t_fixnum(), t_fixnum()]), t_fixnum(), t_nil()])]; -arg_types(erlang, seq_trace_info, 1) -> - [t_seq_trace_info()]; -arg_types(erlang, seq_trace_print, 1) -> - [t_any()]; -arg_types(erlang, seq_trace_print, 2) -> - [t_sup(t_atom(), t_fixnum()), t_any()]; arg_types(erlang, set_cookie, 2) -> [t_node(), t_atom()]; arg_types(erlang, setelement, 3) -> [t_pos_integer(), t_tuple(), t_any()]; -arg_types(erlang, setnode, 2) -> - [t_atom(), t_integer()]; -arg_types(erlang, setnode, 3) -> - [t_atom(), t_port(), t_tuple(4)]; +%% Guard bif, needs to be here. arg_types(erlang, size, 1) -> [t_sup(t_tuple(), t_binary())]; arg_types(erlang, spawn, 1) -> %% TODO: Tuple? [t_fun()]; arg_types(erlang, spawn, 2) -> %% TODO: Tuple? [t_node(), t_fun()]; -arg_types(erlang, spawn, 3) -> %% TODO: Tuple? - [t_atom(), t_atom(), t_list()]; arg_types(erlang, spawn, 4) -> %% TODO: Tuple? [t_node(), t_atom(), t_atom(), t_list()]; arg_types(erlang, spawn_link, 1) -> arg_types(erlang, spawn, 1); % same arg_types(erlang, spawn_link, 2) -> arg_types(erlang, spawn, 2); % same -arg_types(erlang, spawn_link, 3) -> - arg_types(erlang, spawn, 3); % same arg_types(erlang, spawn_link, 4) -> arg_types(erlang, spawn, 4); % same -arg_types(erlang, spawn_opt, 1) -> - [t_tuple([t_atom(), t_atom(), t_list(), t_list(t_spawn_options())])]; -arg_types(erlang, spawn_opt, 2) -> - [t_fun(), t_list(t_spawn_options())]; -arg_types(erlang, spawn_opt, 3) -> - [t_atom(), t_fun(), t_list(t_spawn_options())]; -arg_types(erlang, spawn_opt, 4) -> - [t_node(), t_atom(), t_list(), t_list(t_spawn_options())]; -arg_types(erlang, split_binary, 2) -> - [t_binary(), t_non_neg_integer()]; -arg_types(erlang, start_timer, 3) -> - [t_non_neg_integer(), t_sup(t_pid(), t_atom()), t_any()]; -arg_types(erlang, statistics, 1) -> - [t_sup([t_atom('context_switches'), - t_atom('exact_reductions'), - t_atom('garbage_collection'), - t_atom('io'), - t_atom('reductions'), - t_atom('run_queue'), - t_atom('runtime'), - t_atom('scheduler_wall_time'), - t_atom('wall_clock')])]; arg_types(erlang, subtract, 2) -> arg_types(erlang, '--', 2); arg_types(erlang, suspend_process, 1) -> [t_pid()]; -arg_types(erlang, suspend_process, 2) -> - [t_pid(), t_list(t_sup([t_atom('unless_suspending'), - t_atom('asynchronous')]))]; -arg_types(erlang, system_flag, 2) -> - [t_sup([t_atom('backtrace_depth'), - t_atom('cpu_topology'), - t_atom('debug_flags'), % undocumented - t_atom('display_items'), % undocumented - t_atom('fullsweep_after'), - t_atom('min_heap_size'), - t_atom('min_bin_vheap_size'), - t_atom('multi_scheduling'), - t_atom('schedulers_online'), - t_atom('scheduler_bind_type'), - %% Undocumented; used to implement (the documented) seq_trace module. - t_atom('sequential_tracer'), - t_atom('trace_control_word'), - %% 'internal_cpu_topology' is an undocumented internal feature. - t_atom('internal_cpu_topology'), - t_atom('scheduler_wall_time'), - t_integer()]), - t_sup([t_integer(), - %% 'cpu_topology' - t_system_cpu_topology(), - %% 'scheduler_bind_type' - t_scheduler_bind_type_args(), - %% Undocumented: the following is for 'debug_flags' that - %% takes any erlang term as flags and currently ignores it. - %% t_any(), % commented out since it destroys the type signature - %% - %% Again undocumented; the following are for 'sequential_tracer' - t_sequential_tracer(), - %% The following two are for 'multi_scheduling' - t_atom('block'), - t_atom('unblock'), - %% For 'scheduler_wall_time' - t_atom('true'), - t_atom('false'), - %% The following is for 'internal_cpu_topology' - t_internal_cpu_topology()])]; arg_types(erlang, system_info, 1) -> [t_sup([t_atom(), % documented t_tuple([t_atom(), t_any()]), % documented t_tuple([t_atom(), t_atom(), t_any()]), t_tuple([t_atom(allocator_sizes), t_reference(), t_any()])])]; -arg_types(erlang, system_monitor, 0) -> - []; -arg_types(erlang, system_monitor, 1) -> - [t_system_monitor_settings()]; -arg_types(erlang, system_monitor, 2) -> - [t_pid(), t_system_monitor_options()]; -arg_types(erlang, system_profile, 0) -> - []; -arg_types(erlang, system_profile, 2) -> - [t_sup([t_pid(), t_port(), t_atom('undefined')]), - t_system_profile_options()]; -arg_types(erlang, term_to_binary, 1) -> - [t_any()]; -arg_types(erlang, term_to_binary, 2) -> - [t_any(), t_list(t_sup([t_atom('compressed'), - t_tuple([t_atom('compressed'), t_from_range(0, 9)]), - t_tuple([t_atom('minor_version'), t_integers([0, 1])])]))]; arg_types(erlang, throw, 1) -> [t_any()]; -arg_types(erlang, time, 0) -> - []; +%% Guard bif, needs to be here. arg_types(erlang, tl, 1) -> [t_cons()]; -arg_types(erlang, trace, 3) -> - [t_sup(t_pid(), t_sup([t_atom('existing'), t_atom('new'), t_atom('all')])), - t_boolean(), - t_list(t_sup(t_atom(), t_tuple(2)))]; -arg_types(erlang, trace_delivered, 1) -> - [t_sup(t_pid(), t_atom('all'))]; -arg_types(erlang, trace_info, 2) -> - [t_sup([%% the following two get info about a PID - t_pid(), t_atom('new'), - %% while the following two get info about a func - t_mfa(), t_atom('on_load')]), - t_sup([%% the following are items about a PID - t_atom('flags'), t_atom('tracer'), - %% while the following are items about a func - t_atom('traced'), t_atom('match_spec'), t_atom('meta'), - t_atom('meta_match_spec'), t_atom('call_count'), - t_atom('call_time'), t_atom('all')])]; -arg_types(erlang, trace_pattern, 2) -> - [t_sup(t_tuple([t_atom(), t_atom(), t_sup(t_arity(), t_atom('_'))]), - t_atom('on_load')), - t_sup([t_boolean(), t_list(), t_atom('restart'), t_atom('pause')])]; -arg_types(erlang, trace_pattern, 3) -> - arg_types(erlang, trace_pattern, 2) ++ - [t_list(t_sup([t_atom('global'), t_atom('local'), - t_atom('meta'), t_tuple([t_atom('meta'), t_pid()]), - t_atom('call_count'), t_atom('call_time')]))]; +%% Guard bif, needs to be here. arg_types(erlang, trunc, 1) -> [t_number()]; +%% Guard bif, needs to be here. arg_types(erlang, tuple_size, 1) -> [t_tuple()]; arg_types(erlang, tuple_to_list, 1) -> [t_tuple()]; -arg_types(erlang, universaltime, 0) -> - []; -arg_types(erlang, universaltime_to_localtime, 1) -> - [t_tuple([t_date(), t_time()])]; -arg_types(erlang, universaltime_to_posixtime, 1) -> - [t_tuple([t_date(), t_time()])]; -arg_types(erlang, unlink, 1) -> - [t_sup(t_pid(), t_port())]; -arg_types(erlang, unregister, 1) -> - [t_atom()]; -arg_types(erlang, whereis, 1) -> - [t_atom()]; arg_types(erlang, yield, 0) -> []; -%%------- erl_prim_loader ----------------------------------------------------- -arg_types(erl_prim_loader, get_file, 1) -> - [t_sup(t_atom(), t_string())]; -arg_types(erl_prim_loader, get_path, 0) -> - []; -arg_types(erl_prim_loader, set_path, 1) -> - [t_list(t_string())]; -%%------- error_logger -------------------------------------------------------- -arg_types(error_logger, warning_map, 0) -> - []; -%%------- erts_debug ---------------------------------------------------------- -arg_types(erts_debug, breakpoint, 2) -> - [t_tuple([t_atom(), t_atom(), t_sup(t_integer(), t_atom('_'))]), t_boolean()]; -arg_types(erts_debug, disassemble, 1) -> - [t_sup(t_mfa(), t_integer())]; -arg_types(erts_debug, display, 1) -> - [t_any()]; -arg_types(erts_debug, dist_ext_to_term, 2) -> - [t_tuple(), t_binary()]; -arg_types(erts_debug, dump_monitors, 1) -> - [t_sup([t_pid(),t_atom()])]; -arg_types(erts_debug, dump_links, 1) -> - [t_sup([t_pid(),t_atom(),t_port()])]; -arg_types(erts_debug, flat_size, 1) -> - [t_any()]; -arg_types(erts_debug, get_internal_state, 1) -> - [t_any()]; -arg_types(erts_debug, instructions, 0) -> - []; -arg_types(erts_debug, lock_counters, 1) -> - [t_sup([t_atom(enabled), - t_atom(info), - t_atom(clear), - t_tuple([t_atom(copy_save), t_boolean()]), - t_tuple([t_atom(process_locks), t_boolean()])])]; -arg_types(erts_debug, same, 2) -> - [t_any(), t_any()]; -arg_types(erts_debug, set_internal_state, 2) -> - [t_any(), t_any()]; %%------- ets ----------------------------------------------------------------- -arg_types(ets, all, 0) -> - []; -arg_types(ets, delete, 1) -> - [t_tab()]; -arg_types(ets, delete, 2) -> - [t_tab(), t_any()]; -arg_types(ets, delete_all_objects, 1) -> - [t_tab()]; -arg_types(ets, delete_object, 2) -> - [t_tab(), t_tuple()]; -arg_types(ets, first, 1) -> - [t_tab()]; -arg_types(ets, give_away, 3) -> - [t_tab(), t_pid(), t_any()]; -arg_types(ets, info, 1) -> - [t_tab()]; -arg_types(ets, info, 2) -> - [t_tab(), t_ets_info_items()]; -arg_types(ets, insert, 2) -> - [t_tab(), t_sup(t_tuple(), t_list(t_tuple()))]; -arg_types(ets, insert_new, 2) -> - [t_tab(), t_sup(t_tuple(), t_list(t_tuple()))]; -arg_types(ets, is_compiled_ms, 1) -> - [t_any()]; -arg_types(ets, last, 1) -> - arg_types(ets, first, 1); -arg_types(ets, lookup, 2) -> - [t_tab(), t_any()]; -arg_types(ets, lookup_element, 3) -> - [t_tab(), t_any(), t_pos_fixnum()]; -arg_types(ets, match, 1) -> - [t_any()]; -arg_types(ets, match, 2) -> - [t_tab(), t_match_pattern()]; -arg_types(ets, match, 3) -> - [t_tab(), t_match_pattern(), t_pos_fixnum()]; -arg_types(ets, match_object, 1) -> - arg_types(ets, match, 1); -arg_types(ets, match_object, 2) -> - arg_types(ets, match, 2); -arg_types(ets, match_object, 3) -> - arg_types(ets, match, 3); -arg_types(ets, match_spec_compile, 1) -> - [t_matchspecs()]; -arg_types(ets, match_spec_run_r, 3) -> - [t_list(t_tuple()),t_matchspecs(), t_list()]; -arg_types(ets, member, 2) -> - [t_tab(), t_any()]; -arg_types(ets, new, 2) -> - [t_atom(), t_ets_new_options()]; -arg_types(ets, next, 2) -> - [t_tab(), t_any()]; -arg_types(ets, prev, 2) -> - [t_tab(), t_any()]; arg_types(ets, rename, 2) -> [t_atom(), t_atom()]; -arg_types(ets, safe_fixtable, 2) -> - [t_tab(), t_boolean()]; -arg_types(ets, select, 1) -> - [t_any()]; -arg_types(ets, select, 2) -> - [t_tab(), t_matchspecs()]; -arg_types(ets, select, 3) -> - [t_tab(), t_matchspecs(), t_pos_fixnum()]; -arg_types(ets, select_count, 2) -> - [t_tab(), t_matchspecs()]; -arg_types(ets, select_delete, 2) -> - [t_tab(), t_matchspecs()]; -arg_types(ets, select_reverse, 1) -> - arg_types(ets, select, 1); -arg_types(ets, select_reverse, 2) -> - arg_types(ets, select, 2); -arg_types(ets, select_reverse, 3) -> - arg_types(ets, select, 3); -arg_types(ets, slot, 2) -> - [t_tab(), t_non_neg_fixnum()]; % 2nd arg can be 0 -arg_types(ets, setopts, 2) -> - Opt = t_sup([t_tuple([t_atom('heir'), t_pid(), t_any()]), - t_tuple([t_atom('heir'), t_atom('none')]), - t_tuple([t_atom('protection'), - t_sup([t_atom('protected'), - t_atom('private'), - t_atom('public')])])]), - [t_tab(), t_sup(Opt, t_list(Opt))]; -arg_types(ets, update_counter, 3) -> - Int = t_integer(), - UpdateOp = t_sup(t_tuple([Int, Int]), t_tuple([Int, Int, Int, Int])), - [t_tab(), t_any(), t_sup([UpdateOp, t_list(UpdateOp), Int])]; -arg_types(ets, update_element, 3) -> - PosValue = t_tuple([t_integer(), t_any()]), - [t_tab(), t_any(), t_sup(PosValue, t_list(PosValue))]; -%%------- file ---------------------------------------------------------------- -arg_types(file, native_name_encoding, 0) -> - []; -%%-- prim_file ---------------------------------------------------------------- -arg_types(prim_file, internal_name2native, 1) -> - [t_prim_file_name()]; -arg_types(prim_file, internal_native2name, 1) -> - [t_binary()]; -arg_types(prim_file, internal_normalize_utf8, 1) -> - [t_binary()]; -%%------- gen_tcp ------------------------------------------------------------- -arg_types(gen_tcp, accept, 1) -> - [t_socket()]; -arg_types(gen_tcp, accept, 2) -> - [t_socket(), t_timeout()]; -arg_types(gen_tcp, connect, 3) -> - [t_gen_tcp_address(), t_gen_tcp_port(), t_list(t_gen_tcp_connect_option())]; -arg_types(gen_tcp, connect, 4) -> - arg_types(gen_tcp, connect, 3) ++ [t_timeout()]; -arg_types(gen_tcp, listen, 2) -> - [t_gen_tcp_port(), t_list(t_gen_tcp_listen_option())]; -arg_types(gen_tcp, recv, 2) -> - [t_socket(), t_non_neg_integer()]; -arg_types(gen_tcp, recv, 3) -> - arg_types(gen_tcp, recv, 2) ++ [t_timeout()]; -arg_types(gen_tcp, send, 2) -> - [t_socket(), t_packet()]; -arg_types(gen_tcp, shutdown, 2) -> - [t_socket(), t_sup([t_atom('read'), t_atom('write'), t_atom('read_write')])]; -%%------- gen_udp ------------------------------------------------------------- -arg_types(gen_udp, open, 1) -> - [t_gen_tcp_port()]; -arg_types(gen_udp, open, 2) -> - [t_gen_tcp_port(), t_list(t_gen_udp_connect_option())]; -arg_types(gen_udp, recv, 2) -> - arg_types(gen_tcp, recv, 2); -arg_types(gen_udp, recv, 3) -> - arg_types(gen_tcp, recv, 3); -arg_types(gen_udp, send, 4) -> - [t_socket(), t_gen_tcp_address(), t_gen_tcp_port(), t_packet()]; %%------- hipe_bifs ----------------------------------------------------------- arg_types(hipe_bifs, add_ref, 2) -> [t_mfa(), t_tuple([t_mfa(), @@ -4242,7 +2342,7 @@ arg_types(hipe_bifs, check_crc, 1) -> arg_types(hipe_bifs, enter_code, 2) -> [t_binary(), t_sup(t_nil(), t_tuple())]; arg_types(hipe_bifs, enter_sdesc, 1) -> - [t_tuple([t_integer(), t_integer(), t_integer(), t_integer(), t_integer()])]; + [t_tuple([t_integer(), t_integer(), t_integer(), t_integer(), t_integer(), t_mfa()])]; arg_types(hipe_bifs, find_na_or_make_stub, 2) -> [t_mfa(), t_boolean()]; arg_types(hipe_bifs, fun_to_address, 1) -> @@ -4293,28 +2393,6 @@ arg_types(hipe_bifs, write_u32, 2) -> [t_integer(), t_integer()]; arg_types(hipe_bifs, write_u64, 2) -> [t_integer(), t_integer()]; -%%------- io ------------------------------------------------------------------ -arg_types(io, format, 1) -> - [t_io_format_string()]; -arg_types(io, format, 2) -> - [t_io_format_string(), t_list()]; -arg_types(io, format, 3) -> - [t_io_device(), t_io_format_string(), t_list()]; -arg_types(io, fwrite, 1) -> - arg_types(io, format, 1); -arg_types(io, fwrite, 2) -> - arg_types(io, format, 2); -arg_types(io, fwrite, 3) -> - arg_types(io, format, 3); -arg_types(io, put_chars, 1) -> - [t_iodata()]; -arg_types(io, put_chars, 2) -> - [t_io_device(), t_iodata()]; -%%------- io_lib -------------------------------------------------------------- -arg_types(io_lib, format, 2) -> - arg_types(io, format, 2); -arg_types(io_lib, fwrite, 2) -> - arg_types(io_lib, format, 2); %%------- lists --------------------------------------------------------------- arg_types(lists, all, 2) -> [t_fun([t_any()], t_boolean()), t_list()]; @@ -4386,10 +2464,6 @@ arg_types(lists, reverse, 1) -> [t_list()]; arg_types(lists, reverse, 2) -> [t_list(), t_any()]; -arg_types(lists, seq, 2) -> - [t_integer(), t_integer()]; -arg_types(lists, seq, 3) -> - [t_integer(), t_integer(), t_integer()]; arg_types(lists, sort, 1) -> [t_list()]; arg_types(lists, sort, 2) -> @@ -4418,97 +2492,12 @@ arg_types(lists, zipwith, 3) -> [t_fun([t_any(), t_any()], t_any()), t_list(), t_list()]; arg_types(lists, zipwith3, 4) -> [t_fun([t_any(), t_any(), t_any()], t_any()), t_list(), t_list(), t_list()]; -%%------- math ---------------------------------------------------------------- -arg_types(math, acos, 1) -> - [t_number()]; -arg_types(math, acosh, 1) -> - [t_number()]; -arg_types(math, asin, 1) -> - [t_number()]; -arg_types(math, asinh, 1) -> - [t_number()]; -arg_types(math, atan, 1) -> - [t_number()]; -arg_types(math, atan2, 2) -> - [t_number(), t_number()]; -arg_types(math, atanh, 1) -> - [t_number()]; -arg_types(math, cos, 1) -> - [t_number()]; -arg_types(math, cosh, 1) -> - [t_number()]; -arg_types(math, erf, 1) -> - [t_number()]; -arg_types(math, erfc, 1) -> - [t_number()]; -arg_types(math, exp, 1) -> - [t_number()]; -arg_types(math, log, 1) -> - [t_number()]; -arg_types(math, log10, 1) -> - [t_number()]; -arg_types(math, pi, 0) -> - []; -arg_types(math, pow, 2) -> - [t_number(), t_number()]; -arg_types(math, sin, 1) -> - [t_number()]; -arg_types(math, sinh, 1) -> - [t_number()]; -arg_types(math, sqrt, 1) -> - [t_number()]; -arg_types(math, tan, 1) -> - [t_number()]; -arg_types(math, tanh, 1) -> - [t_number()]; -%%-- net_kernel --------------------------------------------------------------- -arg_types(net_kernel, dflag_unicode_io, 1) -> - [t_pid()]; -%%------- ordsets ------------------------------------------------------------- -arg_types(ordsets, filter, 2) -> - arg_types(lists, filter, 2); -arg_types(ordsets, fold, 3) -> - arg_types(lists, foldl, 3); -%%------- os ------------------------------------------------------------------ -arg_types(os, getenv, 0) -> - []; -arg_types(os, getenv, 1) -> - [t_string()]; -arg_types(os, getpid, 0) -> - []; -arg_types(os, putenv, 2) -> - [t_string(), t_string()]; -arg_types(os, timestamp, 0) -> - []; -%%-- re ----------------------------------------------------------------------- -arg_types(re, compile, 1) -> - [t_iodata()]; -arg_types(re, compile, 2) -> - [t_sup(t_iodata(), t_charlist()), t_list(t_re_compile_option())]; -arg_types(re, run, 2) -> - [t_sup(t_iodata(), t_charlist()), t_re_RE()]; -arg_types(re, run, 3) -> - [t_sup(t_iodata(), t_charlist()), t_re_RE(), t_list(t_re_run_option())]; + %%------- string -------------------------------------------------------------- arg_types(string, chars, 2) -> [t_char(), t_non_neg_integer()]; arg_types(string, chars, 3) -> [t_char(), t_non_neg_integer(), t_any()]; -arg_types(string, concat, 2) -> - [t_string(), t_string()]; -arg_types(string, equal, 2) -> - [t_string(), t_string()]; -arg_types(string, to_float, 1) -> - [t_string()]; -arg_types(string, to_integer, 1) -> - [t_string()]; -%%------- unicode ------------------------------------------------------------- -arg_types(unicode, characters_to_binary, 2) -> - [t_ML(), t_encoding()]; -arg_types(unicode, characters_to_list, 2) -> - [t_ML(), t_encoding()]; -arg_types(unicode, bin_is_7bit, 1) -> - [t_binary()]; %%----------------------------------------------------------------------------- arg_types(M, F, A) when is_atom(M), is_atom(F), is_integer(A), 0 =< A, A =< 255 -> @@ -4568,244 +2557,22 @@ check_fun_application(Fun, Args) -> %% ===================================================================== -%% These are basic types that should probably be moved to erl_types -%% ===================================================================== - -t_socket() -> t_port(). % alias - -t_ip_address() -> - T_int16 = t_from_range(0, 16#FFFF), - t_sup(t_tuple([t_byte(), t_byte(), t_byte(), t_byte()]), - t_tuple([T_int16, T_int16, T_int16, T_int16, - T_int16, T_int16, T_int16, T_int16])). - -%% ===================================================================== %% Some basic types used in various parts of the system %% ===================================================================== -t_date() -> - t_tuple([t_pos_fixnum(), t_pos_fixnum(), t_pos_fixnum()]). - -t_time() -> - t_tuple([t_non_neg_fixnum(), t_non_neg_fixnum(), t_non_neg_fixnum()]). - -t_timestamp() -> - t_tuple([t_non_neg_fixnum(), t_non_neg_fixnum(), t_non_neg_fixnum()]). - -t_packet() -> - t_sup([t_binary(), t_iolist(), t_httppacket()]). - -t_httppacket() -> - t_sup([t_HttpRequest(), t_HttpResponse(), - t_HttpHeader(), t_atom('http_eoh'), t_HttpError()]). - t_endian() -> t_sup(t_atom('big'), t_atom('little')). %% ===================================================================== -%% HTTP types documented in R12B-4 -%% ===================================================================== - -t_HttpRequest() -> - t_tuple([t_atom('http_request'), t_HttpMethod(), t_HttpUri(), t_HttpVersion()]). - -t_HttpResponse() -> - t_tuple([t_atom('http_response'), t_HttpVersion(), t_integer(), t_HttpString()]). - -t_HttpHeader() -> - t_tuple([t_atom('http_header'), t_integer(), t_HttpField(), t_any(), t_HttpString()]). - -t_HttpError() -> - t_tuple([t_atom('http_error'), t_HttpString()]). - -t_HttpMethod() -> - t_sup(t_HttpMethodAtom(), t_HttpString()). - -t_HttpMethodAtom() -> - t_atoms(['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE']). - -t_HttpUri() -> - t_sup([t_atom('*'), - t_tuple([t_atom('absoluteURI'), - t_sup(t_atom('http'), t_atom('https')), - t_HttpString(), - t_sup(t_non_neg_integer(), t_atom('undefined')), - t_HttpString()]), - t_tuple([t_atom('scheme'), t_HttpString(), t_HttpString()]), - t_tuple([t_atom('abs_path'), t_HttpString()]), - t_HttpString()]). - -t_HttpVersion() -> - t_tuple([t_non_neg_integer(), t_non_neg_integer()]). - -t_HttpField() -> - t_sup(t_HttpFieldAtom(), t_HttpString()). - -t_HttpFieldAtom() -> - t_atoms(['Cache-Control', 'Connection', 'Date', 'Pragma', 'Transfer-Encoding', - 'Upgrade', 'Via', 'Accept', 'Accept-Charset', 'Accept-Encoding', - 'Accept-Language', 'Authorization', 'From', 'Host', - 'If-Modified-Since', 'If-Match', 'If-None-Match', 'If-Range', - 'If-Unmodified-Since', 'Max-Forwards', 'Proxy-Authorization', - 'Range', 'Referer', 'User-Agent', 'Age', 'Location', - 'Proxy-Authenticate', 'Public', 'Retry-After', 'Server', 'Vary', - 'Warning', 'Www-Authenticate', 'Allow', 'Content-Base', - 'Content-Encoding', 'Content-Language', 'Content-Length', - 'Content-Location', 'Content-Md5', 'Content-Range', 'Content-Type', - 'Etag', 'Expires', 'Last-Modified', 'Accept-Ranges', - 'Set-Cookie', 'Set-Cookie2', 'X-Forwarded-For', 'Cookie', - 'Keep-Alive', 'Proxy-Connection']). - -t_HttpString() -> - t_sup(t_string(), t_binary()). - -%% ===================================================================== -%% These are used for the built-in functions of 'binary' -%% ===================================================================== - -t_binary_part() -> - t_tuple([t_non_neg_integer(), t_integer()]). - -t_binary_canonical_part() -> - t_tuple([t_non_neg_integer(), t_non_neg_integer()]). - -t_binary_pattern() -> - t_sup([t_binary(), - t_list(t_binary()), - t_binary_compiled_pattern()]). - -t_binary_compiled_pattern() -> - t_tuple([t_sup(t_atom('bm'), t_atom('ac')), t_binary()]). - -t_binary_options() -> - t_list(t_tuple([t_atom('scope'), t_binary_part()])). - -%% ===================================================================== -%% These are used for the built-in functions of 'code' -%% ===================================================================== - -t_code_load_return(Mod) -> - t_sup(t_tuple([t_atom('module'), case t_is_atom(Mod) of - true -> Mod; - false -> t_atom() - end]), - t_tuple([t_atom('error'), t_code_load_error_rsn()])). - -t_code_load_error_rsn() -> % also used in erlang:load_module/2 - t_sup([t_atom('badfile'), - t_atom('nofile'), - t_atom('not_purged'), - t_atom('native_code'), - t_atom('on_load'), - t_atom('sticky_directory')]). % only for the 'code' functions - -%% ===================================================================== %% These are used for the built-in functions of 'erlang' %% ===================================================================== -t_adler32() -> - t_non_neg_integer(). - t_crc32() -> t_non_neg_integer(). -t_decode_packet_option() -> - t_sup([t_tuple([t_atom('packet_size'), t_non_neg_integer()]), - t_tuple([t_atom('line_length'), t_non_neg_integer()])]). - -t_decode_packet_type() -> - t_sup([t_inet_setoption_packettype(), t_atom('httph'), t_atom('httph_bin')]). - -t_dist_exit() -> - t_sup([t_atom('kill'), t_atom('noconnection'), t_atom('normal')]). - -t_match_spec_test_errors() -> - t_list(t_sup(t_tuple([t_atom('error'), t_string()]), - t_tuple([t_atom('warning'), t_string()]))). - -t_module_info_2() -> - t_sup([t_atom('module'), - t_atom('imports'), - t_atom('exports'), - t_atom('functions'), - t_atom('attributes'), - t_atom('compile'), - t_atom('native_addresses')]). - -t_pinfo() -> - t_sup([t_pinfo_item(), t_list(t_pinfo_item())]). - -t_pinfo_item() -> - t_sup([t_atom('backtrace'), - t_atom('current_function'), - t_atom('dictionary'), - t_atom('error_handler'), - t_atom('garbage_collection'), - t_atom('group_leader'), - t_atom('heap_size'), - t_atom('initial_call'), - t_atom('last_calls'), - t_atom('links'), - t_atom('memory'), - t_atom('message_queue_len'), - t_atom('messages'), - t_atom('monitored_by'), - t_atom('monitors'), - t_atom('priority'), - t_atom('reductions'), - t_atom('registered_name'), - t_atom('sequential_trace_token'), - t_atom('stack_size'), - t_atom('status'), - t_atom('suspending'), - t_atom('total_heap_size'), - t_atom('trap_exit')]). - -t_process_priority_level() -> - t_sup([t_atom('max'), t_atom('high'), t_atom('normal'), t_atom('low')]). - -t_process_status() -> - t_sup([t_atom('exiting'), t_atom('garbage_collecting'), - t_atom('runnable'), t_atom('running'), - t_atom('suspended'), t_atom('waiting')]). - -t_raise_errorclass() -> - t_sup([t_atom('error'), t_atom('exit'), t_atom('throw')]). - -t_sendoptions() -> - t_sup(t_atom('noconnect'), t_atom('nosuspend')). - -t_seq_trace_info() -> - t_sup([t_atom('send'), - t_atom('receive'), - t_atom('print'), - t_atom('timestamp'), - t_atom('label'), - t_atom('serial')]). - -%% XXX: Better if we also maintain correspondencies between infos and values -t_seq_trace_info_returns() -> - Values = t_sup([t_non_neg_integer(), t_boolean(), - t_tuple([t_non_neg_integer(), t_non_neg_integer()])]), - t_sup(t_tuple([t_seq_trace_info(), Values]), t_nil()). - t_sequential_tracer() -> t_sup([t_atom('false'), t_pid(), t_port()]). -t_spawn_options() -> - t_sup([t_atom('link'), - t_atom('monitor'), - t_tuple([t_atom('priority'), t_process_priority_level()]), - t_tuple([t_atom('min_heap_size'), t_fixnum()]), - t_tuple([t_atom('min_bin_vheap_size'), t_fixnum()]), - t_tuple([t_atom('fullsweep_after'), t_fixnum()])]). - -t_spawn_opt_return(List) -> - case t_is_none(t_inf(t_list(t_atom('monitor')), List)) of - true -> t_pid(); - false -> t_sup(t_pid(), t_tuple([t_pid(), t_reference()])) - end. - t_system_cpu_topology() -> t_sup(t_atom('undefined'), t_system_cpu_topology_level_entry_list()). @@ -4842,17 +2609,6 @@ t_internal_cpu_topology() -> %% Internal undocumented type t_non_neg_fixnum()])), t_atom('undefined')). -t_scheduler_bind_type_args() -> - t_sup([t_atom('default_bind'), - t_atom('no_node_processor_spread'), - t_atom('no_node_thread_spread'), - t_atom('no_spread'), - t_atom('processor_spread'), - t_atom('spread'), - t_atom('thread_spread'), - t_atom('thread_no_node_processor_spread'), - t_atom('unbound')]). - t_scheduler_bind_type_results() -> t_sup([t_atom('no_node_processor_spread'), t_atom('no_node_thread_spread'), @@ -4863,160 +2619,9 @@ t_scheduler_bind_type_results() -> t_atom('thread_no_node_processor_spread'), t_atom('unbound')]). -t_system_monitor_settings() -> - t_sup([t_atom('undefined'), - t_tuple([t_pid(), t_system_monitor_options()])]). - -t_system_monitor_options() -> - t_list(t_sup([t_atom('busy_port'), - t_atom('busy_dist_port'), - t_tuple([t_atom('long_gc'), t_integer()]), - t_tuple([t_atom('large_heap'), t_integer()])])). - t_system_multi_scheduling() -> t_sup([t_atom('blocked'), t_atom('disabled'), t_atom('enabled')]). -t_system_profile_options() -> - t_list(t_sup([t_atom('exclusive'), - t_atom('runnable_ports'), - t_atom('runnable_procs'), - t_atom('scheduler')])). - -t_system_profile_return() -> - t_sup(t_atom('undefined'), - t_tuple([t_sup(t_pid(), t_port()), t_system_profile_options()])). - -t_system_build_type_return() -> - t_sup([t_atom('opt'), - t_atom('debug'), - t_atom('purify'), - t_atom('quantify'), - t_atom('purecov'), - t_atom('gcov'), - t_atom('valgrind'), - t_atom('gprof'), - t_atom('lcnt')]). - -%% ===================================================================== -%% These are used for the built-in functions of 'ets' -%% ===================================================================== - -t_tab() -> - t_sup(t_tid(), t_atom()). - -t_match_pattern() -> - t_sup(t_atom(), t_tuple()). - -t_matchspecs() -> - t_list(t_tuple([t_match_pattern(), t_list(), t_list()])). - -t_matchres() -> - t_sup(t_tuple([t_list(), t_any()]), t_atom('$end_of_table')). - -%% From the 'ets' documentation -%%----------------------------- -%% Option = Type | Access | named_table | {keypos,Pos} -%% | {heir,pid(),HeirData} | {heir,none} | Tweaks -%% Type = set | ordered_set | bag | duplicate_bag -%% Access = public | protected | private -%% Tweaks = {write_concurrency,boolean()} -%% | {read_concurrency,boolean()} | compressed -%% Pos = integer() -%% HeirData = term() -t_ets_new_options() -> - t_list(t_sup([t_atom('set'), - t_atom('ordered_set'), - t_atom('bag'), - t_atom('duplicate_bag'), - t_atom('public'), - t_atom('protected'), - t_atom('private'), - t_atom('named_table'), - t_tuple([t_atom('keypos'), t_integer()]), - t_tuple([t_atom('heir'), t_pid(), t_any()]), - t_tuple([t_atom('heir'), t_atom('none')]), - t_tuple([t_atom('write_concurrency'), t_boolean()]), - t_tuple([t_atom('read_concurrency'), t_boolean()]), - t_atom('compressed')])). - -t_ets_info_items() -> - t_sup([t_atom('fixed'), - t_atom('safe_fixed'), - t_atom('keypos'), - t_atom('memory'), - t_atom('name'), - t_atom('named_table'), - t_atom('node'), - t_atom('owner'), - t_atom('protection'), - t_atom('size'), - t_atom('compressed'), - t_atom('heir'), - t_atom('stats'), - t_atom('type')]). - -%% ===================================================================== -%% These are used for the built-in functions of 'gen_tcp' -%% ===================================================================== - -t_gen_tcp_accept() -> - t_sup(t_tuple([t_atom('ok'), t_socket()]), - t_tuple([t_atom('error'), t_sup([t_atom('closed'), - t_atom('timeout'), - t_inet_posix_error()])])). - -t_gen_tcp_address() -> - t_sup([t_string(), t_atom(), t_ip_address()]). - -t_gen_tcp_port() -> - t_from_range(0, 16#FFFF). - -t_gen_tcp_connect_option() -> - t_sup([t_atom('list'), - t_atom('binary'), - t_tuple([t_atom('ip'), t_ip_address()]), - t_tuple([t_atom('port'), t_gen_tcp_port()]), - t_tuple([t_atom('fd'), t_integer()]), - t_atom('inet6'), - t_atom('inet'), - t_inet_setoption()]). - -t_gen_tcp_listen_option() -> - t_sup([t_atom('list'), - t_atom('binary'), - t_tuple([t_atom('backlog'), t_non_neg_integer()]), - t_tuple([t_atom('ip'), t_ip_address()]), - t_tuple([t_atom('fd'), t_integer()]), - t_atom('inet6'), - t_atom('inet'), - t_inet_setoption()]). - -t_gen_tcp_recv() -> - t_sup(t_tuple([t_atom('ok'), t_packet()]), - t_tuple([t_atom('error'), t_sup([t_atom('closed'), - t_inet_posix_error()])])). - -%% ===================================================================== -%% These are used for the built-in functions of 'gen_udp' -%% ===================================================================== - -t_gen_udp_connect_option() -> - t_sup([t_atom('list'), - t_atom('binary'), - t_tuple([t_atom('ip'), t_ip_address()]), - t_tuple([t_atom('fd'), t_integer()]), - t_atom('inet6'), - t_atom('inet'), - t_inet_setoption()]). - -t_gen_udp_recv() -> - t_sup(t_tuple([t_atom('ok'), - t_tuple([t_ip_address(), - t_gen_tcp_port(), - t_packet()])]), - t_tuple([t_atom('error'), - t_sup(t_atom('not_owner'), t_inet_posix_error())])). - %% ===================================================================== %% These are used for the built-in functions of 'hipe_bifs' %% ===================================================================== @@ -5049,131 +2654,6 @@ t_insn_type() -> t_atom('closure')]). %% ===================================================================== -%% These are used for the built-in functions of 'inet' -%% ===================================================================== - -t_inet_setoption() -> - t_sup([%% first the 2-tuple options - t_tuple([t_atom('active'), t_sup(t_boolean(), t_atom('once'))]), - t_tuple([t_atom('broadcast'), t_boolean()]), - t_tuple([t_atom('delay_send'), t_boolean()]), - t_tuple([t_atom('dontroute'), t_boolean()]), - t_tuple([t_atom('exit_on_close'), t_boolean()]), - t_tuple([t_atom('header'), t_non_neg_integer()]), - t_tuple([t_atom('keepalive'), t_boolean()]), - t_tuple([t_atom('nodelay'), t_boolean()]), - t_tuple([t_atom('packet'), t_inet_setoption_packettype()]), - t_tuple([t_atom('packet_size'), t_non_neg_integer()]), - t_tuple([t_atom('read_packets'), t_non_neg_integer()]), - t_tuple([t_atom('recbuf'), t_non_neg_integer()]), - t_tuple([t_atom('reuseaddr'), t_boolean()]), - t_tuple([t_atom('send_timeout'), t_non_neg_integer()]), - t_tuple([t_atom('sndbuf'), t_non_neg_integer()]), - t_tuple([t_atom('priority'), t_non_neg_integer()]), - t_tuple([t_atom('tos'), t_non_neg_integer()]), - %% and a 4-tuple option - t_tuple([t_atom('raw'), - t_non_neg_integer(), % protocol level - t_non_neg_integer(), % option number - t_binary()])]). % actual option value - -t_inet_setoption_packettype() -> - t_sup([t_atom('raw'), - t_integers([0,1,2,4]), - t_atom('asn1'), t_atom('cdr'), t_atom('sunrm'), - t_atom('fcgi'), t_atom('tpkt'), t_atom('line'), - t_atom('http'), - t_atom('http_bin')]). %% but t_atom('httph') is not needed - -t_inet_posix_error() -> - t_atom(). %% XXX: Very underspecified - -%% ===================================================================== -%% These are used for the built-in functions of 'io' -%% ===================================================================== - -t_io_device() -> - t_sup(t_atom(), t_pid()). - -%% The documentation in R11B-4 reads -%% Format ::= atom() | string() | binary() -%% but the Format can also be a (deep) list, hence the type below -t_io_format_string() -> - t_sup([t_atom(), t_list(), t_binary()]). - -%% ===================================================================== -%% These are used for the built-in functions of 're'; the functions -%% whose last name component starts with a capital letter are types -%% ===================================================================== - -t_re_MP() -> %% it's supposed to be an opaque data type - t_tuple([t_atom('re_pattern'), t_integer(), t_integer(), t_binary()]). - -t_re_RE() -> - t_sup([t_re_MP(), t_iodata(), t_charlist()]). - -t_re_compile_option() -> - t_sup([t_atoms(['unicode', 'anchored', 'caseless', 'dollar_endonly', - 'dotall', 'extended', 'firstline', 'multiline', - 'no_auto_capture', 'dupnames', 'ungreedy']), - t_tuple([t_atom('newline'), t_re_NLSpec()]), - t_atoms(['bsr_anycrlf', 'bsr_unicode'])]). - -t_re_run_option() -> - t_sup([t_atoms(['anchored', 'global', 'notbol', 'noteol', 'notempty']), - t_tuple([t_atom('offset'), t_integer()]), - t_tuple([t_atom('newline'), t_re_NLSpec()]), - t_tuple([t_atom('capture'), t_re_ValueSpec()]), - t_tuple([t_atom('capture'), t_re_ValueSpec(), t_re_Type()]), - t_re_compile_option()]). - -t_re_ErrorSpec() -> - t_tuple([t_string(), t_non_neg_integer()]). - -t_re_Type() -> - t_atoms(['index', 'list', 'binary']). - -t_re_NLSpec() -> - t_atoms(['cr', 'crlf', 'lf', 'anycrlf', 'any']). - -t_re_ValueSpec() -> - t_sup(t_atoms(['all', 'all_but_first', 'first', 'none']), t_re_ValueList()). - -t_re_ValueList() -> - t_list(t_sup([t_integer(), t_string(), t_atom()])). - -t_re_Captured() -> - t_list(t_sup(t_re_CapturedData(), t_list(t_re_CapturedData()))). - -t_re_CapturedData() -> - t_sup([t_tuple([t_integer(), t_integer()]), t_string(), t_binary()]). - -%% ===================================================================== -%% These are used for the built-in functions of 'prim_file' -%% ===================================================================== - -t_prim_file_name() -> - t_sup(t_unicode_string(), t_binary()). - -%% ===================================================================== -%% These are used for the built-in functions of 'unicode' -%% ===================================================================== - -t_ML() -> % a binary or a possibly deep list of integers or binaries - t_sup(t_list(t_sup([t_integer(), t_binary(), t_list()])), t_binary()). - -t_encoding() -> - t_sup([t_atoms(['latin1', 'unicode', 'utf8', 'utf16', 'utf32']), - t_tuple([t_atom('utf16'), t_endian()]), - t_tuple([t_atom('utf32'), t_endian()])]). - -t_file_encoding() -> - t_atoms(['latin1', 'utf8']). - -t_encoding_a2b() -> % for the 2nd arg of atom_to_binary/2 and binary_to_atom/2 - t_atoms(['latin1', 'unicode', 'utf8']). - -%% ===================================================================== %% Some testing code for ranges below %% ===================================================================== diff --git a/lib/hipe/cerl/erl_types.erl b/lib/hipe/cerl/erl_types.erl index bc7ea17077..d1243b2325 100644 --- a/lib/hipe/cerl/erl_types.erl +++ b/lib/hipe/cerl/erl_types.erl @@ -2,7 +2,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2012. All Rights Reserved. +%% Copyright Ericsson AB 2003-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -63,7 +63,6 @@ t_boolean/0, t_byte/0, t_char/0, - t_charlist/0, t_collect_vars/1, t_cons/0, t_cons/2, @@ -197,7 +196,6 @@ t_tuple_size/1, t_tuple_sizes/1, t_tuple_subtypes/1, - t_unicode_string/0, t_unify/2, t_unify/3, t_unit/0, @@ -207,7 +205,7 @@ t_var/1, t_var_name/1, %% t_assign_variables_to_subtype/2, - type_is_defined/3, + type_is_defined/4, record_field_diffs_to_string/2, subst_all_vars_to_any/1, lift_list_to_pos_empty/1, @@ -546,12 +544,12 @@ t_opaque_from_records(RecDict) -> OpaqueRecDict = dict:filter(fun(Key, _Value) -> case Key of - {opaque, _Name} -> true; + {opaque, _Name, _Arity} -> true; _ -> false end end, RecDict), OpaqueTypeDict = - dict:map(fun({opaque, Name}, {Module, Type, ArgNames}) -> + dict:map(fun({opaque, Name, _Arity}, {Module, Type, ArgNames}) -> case ArgNames of [] -> t_opaque(Module, Name, [], t_from_form(Type, RecDict)); @@ -709,8 +707,8 @@ t_solve_remote_type(#remote{mod = RemMod, name = Name, args = Args} = RemType, MFA = {RemMod, Name, ArgsLen}, case sets:is_element(MFA, ET) of true -> - case lookup_type(Name, RemDict) of - {type, {_Mod, Type, ArgNames}} when ArgsLen =:= length(ArgNames) -> + case lookup_type(Name, ArgsLen, RemDict) of + {type, {_Mod, Type, ArgNames}} -> {NewType, NewCycle, NewRR} = case can_unfold_more(RemType, C) of true -> @@ -728,7 +726,7 @@ t_solve_remote_type(#remote{mod = RemMod, name = Name, args = Args} = RemType, false -> RT end, {RT1, RetRR}; - {opaque, {Mod, Type, ArgNames}} when ArgsLen =:= length(ArgNames) -> + {opaque, {Mod, Type, ArgNames}} -> List = lists:zip(ArgNames, Args), TmpVarDict = dict:from_list(List), {Rep, NewCycle, NewRR} = @@ -748,12 +746,6 @@ t_solve_remote_type(#remote{mod = RemMod, name = Name, args = Args} = RemType, {t_from_form({opaque, -1, Name, {Mod, Args, RT1}}, RemDict, TmpVarDict), RetRR}; - {type, _} -> - Msg = io_lib:format("Unknown remote type ~w\n", [Name]), - throw({error, Msg}); - {opaque, _} -> - Msg = io_lib:format("Unknown remote opaque type ~w\n", [Name]), - throw({error, Msg}); error -> Msg = io_lib:format("Unable to find remote type ~w:~w()\n", [RemMod, Name]), @@ -1458,21 +1450,6 @@ t_is_tuple(_) -> false. t_bitstrlist() -> t_iolist(1, t_bitstr()). --spec t_charlist() -> erl_type(). - -t_charlist() -> - t_charlist(1). - --spec t_charlist(non_neg_integer()) -> erl_type(). - -t_charlist(N) when N > 0 -> - t_maybe_improper_list(t_sup([t_unicode_char(), - t_unicode_binary(), - t_charlist(N-1)]), - t_sup(t_unicode_binary(), t_nil())); -t_charlist(0) -> - t_maybe_improper_list(t_any(), t_sup(t_unicode_binary(), t_nil())). - -spec t_constant() -> erl_type(). t_constant() -> @@ -1568,21 +1545,6 @@ t_parameterized_module() -> t_timeout() -> t_sup(t_non_neg_integer(), t_atom('infinity')). --spec t_unicode_binary() -> erl_type(). - -t_unicode_binary() -> - t_binary(). % with characters encoded in UTF-8 coding standard - --spec t_unicode_char() -> erl_type(). - -t_unicode_char() -> - t_integer(). % representing a valid unicode codepoint - --spec t_unicode_string() -> erl_type(). - -t_unicode_string() -> - t_list(t_unicode_char()). - %%----------------------------------------------------------------------------- %% Some built-in opaque types %% @@ -3273,6 +3235,8 @@ t_to_string(?bitstr(0, 0), _RecDict) -> "<<>>"; t_to_string(?bitstr(8, 0), _RecDict) -> "binary()"; +t_to_string(?bitstr(1, 0), _RecDict) -> + "bitstring()"; t_to_string(?bitstr(0, B), _RecDict) -> lists:flatten(io_lib:format("<<_:~w>>", [B])); t_to_string(?bitstr(U, 0), _RecDict) -> @@ -3432,7 +3396,7 @@ record_field_diffs_to_string(?tuple([_|Fs], Arity, Tag), RecDict) -> field_diffs([F|Fs], [{FName, DefType}|FDefs], RecDict, Acc) -> NewAcc = - case t_is_subtype(F, DefType) of + case not t_is_none(t_inf(F, DefType)) of true -> Acc; false -> Str = atom_to_string(FName) ++ "::" ++ t_to_string(DefType, RecDict), @@ -3566,7 +3530,7 @@ t_from_form({type, _L, function, []}, _TypeNames, _InOpaque, _RecDict, t_from_form({type, _L, 'fun', []}, _TypeNames, _InOpaque, _RecDict, _VarDict) -> {t_fun(), []}; -t_from_form({type, _L, 'fun', [{type, _, any, []}, Range]}, TypeNames, +t_from_form({type, _L, 'fun', [{type, _, any}, Range]}, TypeNames, InOpaque, RecDict, VarDict) -> {T, R} = t_from_form(Range, TypeNames, InOpaque, RecDict, VarDict), {t_fun(T), R}; @@ -3712,8 +3676,9 @@ t_from_form({type, _L, union, Args}, TypeNames, InOpaque, RecDict, VarDict) -> {L, R} = list_from_form(Args, TypeNames, InOpaque, RecDict, VarDict), {t_sup(L), R}; t_from_form({type, _L, Name, Args}, TypeNames, InOpaque, RecDict, VarDict) -> - case lookup_type(Name, RecDict) of - {type, {_Module, Type, ArgNames}} when length(Args) =:= length(ArgNames) -> + ArgsLen = length(Args), + case lookup_type(Name, ArgsLen, RecDict) of + {type, {_Module, Type, ArgNames}} -> case can_unfold_more({type, Name}, TypeNames) of true -> List = lists:zipwith( @@ -3733,7 +3698,7 @@ t_from_form({type, _L, Name, Args}, TypeNames, InOpaque, RecDict, VarDict) -> end; false -> {t_any(), [{type, Name}]} end; - {opaque, {Module, Type, ArgNames}} when length(Args) =:= length(ArgNames) -> + {opaque, {Module, Type, ArgNames}} -> {Rep, Rret} = case can_unfold_more({opaque, Name}, TypeNames) of true -> @@ -3762,12 +3727,9 @@ t_from_form({type, _L, Name, Args}, TypeNames, InOpaque, RecDict, VarDict) -> RecDict, VarDict) end, {Tret, Rret}; - {type, _} -> - throw({error, io_lib:format("Unknown type ~w\n", [Name])}); - {opaque, _} -> - throw({error, io_lib:format("Unknown opaque type ~w\n", [Name])}); error -> - throw({error, io_lib:format("Unable to find type ~w\n", [Name])}) + Msg = io_lib:format("Unable to find type ~w/~w\n", [Name, ArgsLen]), + throw({error, Msg}) end; t_from_form({opaque, _L, Name, {Mod, Args, Rep}}, _TypeNames, _InOpaque, _RecDict, _VarDict) -> @@ -3902,14 +3864,16 @@ t_form_to_string({type, _L, binary, [Base, Unit]} = Type) -> case {U, B} of {0, 0} -> "<<>>"; {8, 0} -> "binary()"; + {1, 0} -> "bitstring()"; {0, B} -> lists:flatten(io_lib:format("<<_:~w>>", [B])); {U, 0} -> lists:flatten(io_lib:format("<<_:_*~w>>", [U])); {U, B} -> lists:flatten(io_lib:format("<<_:~w,_:_*~w>>", [B, U])) end; _ -> io_lib:format("Badly formed bitstr type ~w", [Type]) end; +t_form_to_string({type, _L, bitstring, []}) -> "bitstring()"; t_form_to_string({type, _L, 'fun', []}) -> "fun()"; -t_form_to_string({type, _L, 'fun', [{type, _, any, []}, Range]}) -> +t_form_to_string({type, _L, 'fun', [{type, _, any}, Range]}) -> "fun(...) -> " ++ t_form_to_string(Range); t_form_to_string({type, _L, 'fun', [{type, _, product, Domain}, Range]}) -> "fun((" ++ string:join(t_form_to_string_list(Domain), ",") ++ ") -> " @@ -3930,7 +3894,7 @@ t_form_to_string({type, _L, range, [From, To]} = Type) -> case {erl_eval:partial_eval(From), erl_eval:partial_eval(To)} of {{integer, _, FromVal}, {integer, _, ToVal}} -> io_lib:format("~w..~w", [FromVal, ToVal]); - _ -> io_lib:format("Bad formed type ~w",[Type]) + _ -> io_lib:format("Badly formed type ~w",[Type]) end; t_form_to_string({type, _L, record, [{atom, _, Name}]}) -> io_lib:format("#~w{}", [Name]); @@ -4018,20 +3982,20 @@ lookup_record(Tag, Arity, RecDict) when is_atom(Tag) -> error -> error end. -lookup_type(Name, RecDict) -> - case dict:find({type, Name}, RecDict) of +lookup_type(Name, Arity, RecDict) -> + case dict:find({type, Name, Arity}, RecDict) of error -> - case dict:find({opaque, Name}, RecDict) of + case dict:find({opaque, Name, Arity}, RecDict) of error -> error; {ok, Found} -> {opaque, Found} end; {ok, Found} -> {type, Found} end. --spec type_is_defined('type' | 'opaque', atom(), dict()) -> boolean(). +-spec type_is_defined('type' | 'opaque', atom(), arity(), dict()) -> boolean(). -type_is_defined(TypeOrOpaque, Name, RecDict) -> - dict:is_key({TypeOrOpaque, Name}, RecDict). +type_is_defined(TypeOrOpaque, Name, Arity, RecDict) -> + dict:is_key({TypeOrOpaque, Name, Arity}, RecDict). can_unfold_more(TypeName, TypeNames) -> Fun = fun(E, Acc) -> case E of TypeName -> Acc + 1; _ -> Acc end end, diff --git a/lib/hipe/doc/src/notes.xml b/lib/hipe/doc/src/notes.xml index cfd22a9d8d..73ab1dbfda 100644 --- a/lib/hipe/doc/src/notes.xml +++ b/lib/hipe/doc/src/notes.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2006</year><year>2012</year> + <year>2006</year><year>2013</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -30,6 +30,76 @@ </header> <p>This document describes the changes made to HiPE.</p> +<section><title>Hipe 3.10.1</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + Bug fixed in hipe to where it did not allow unicode code + points 16#FFFE and 16#FFFF in bit syntax in natively + compiled modules.</p> + <p> + Own Id: OTP-10867</p> + </item> + <item> + <p> + Fix bug in hipe compiled code related to the handling of + <c>is_number/1</c>. (Thanks to Sebastian Egner and + Johannes Wei�l for minimal test code and Kostis for quick + patch)</p> + <p> + Own Id: OTP-10897</p> + </item> + </list> + </section> + +</section> + +<section><title>Hipe 3.10</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> The type <c>ascii_string()</c> in the <c>base64</c> + module has been corrected. The type + <c>file:file_info()</c> has been cleaned up. The type + <c>file:fd()</c> has been made opaque in the + documentation. </p> + <p> + Own Id: OTP-10624 Aux Id: kunagi-352 [263] </p> + </item> + </list> + </section> + + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> Support for Unicode has been implemented. </p> + <p> + Own Id: OTP-10302</p> + </item> + <item> + <p>Where necessary a comment stating encoding has been + added to Erlang files. The comment is meant to be removed + in Erlang/OTP R17B when UTF-8 becomes the default + encoding. </p> + <p> + Own Id: OTP-10630</p> + </item> + <item> + <p> + Update .gitignore (lib/hipe/boot_ebin). Thanks to Tuncer + Ayaz.</p> + <p> + Own Id: OTP-10705</p> + </item> + </list> + </section> + +</section> + <section><title>Hipe 3.9.3</title> <section><title>Fixed Bugs and Malfunctions</title> diff --git a/lib/hipe/flow/hipe_dominators.erl b/lib/hipe/flow/hipe_dominators.erl index 17357461a5..1f2c830eaf 100644 --- a/lib/hipe/flow/hipe_dominators.erl +++ b/lib/hipe/flow/hipe_dominators.erl @@ -1,8 +1,8 @@ -%% -*- erlang-indent-level: 2 -*- +%% -*- coding: utf-8; erlang-indent-level: 2 -*- %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2010. All Rights Reserved. +%% Copyright Ericsson AB 2004-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -19,7 +19,7 @@ %% %%------------------------------------------------------------------------ %% File : hipe_dominators.erl -%% Author : Christoffer Vikstr�m <[email protected]> +%% Author : Christoffer Vikström <[email protected]> %% Daniel Deogun <[email protected]> %% Jesper Bengtsson <[email protected]> %% Created : 18 Mar 2002 diff --git a/lib/hipe/icode/hipe_beam_to_icode.erl b/lib/hipe/icode/hipe_beam_to_icode.erl index ecf1c77abc..81249c958e 100644 --- a/lib/hipe/icode/hipe_beam_to_icode.erl +++ b/lib/hipe/icode/hipe_beam_to_icode.erl @@ -41,6 +41,9 @@ %% %%-ifndef(DEBUG). %%-define(DEBUG,6). +%% Choose one of two tracing methods +%%-define(DEBUG_BIF_CALL_TRACE,true). +%%-define(IO_FORMAT_CALL_TRACE,true). %%-endif. -include("../main/hipe.hrl"). @@ -51,8 +54,27 @@ -define(no_debug_msg(Str,Xs),ok). %%-define(no_debug_msg(Str,Xs),msg(Str,Xs)). --define(mk_debugcode(MFA, Env, Code), - case MFA of +-ifdef(DEBUG_BIF_CALL_TRACE). + +%% Use BIF hipe_bifs_debug_native_called_2 to trace function calls +mk_debug_calltrace({_M,_F,A}=MFA, Env, Code) -> + MFAVar = mk_var(new), + Ignore = mk_var(new), + MkMfa = hipe_icode:mk_move(MFAVar,hipe_icode:mk_const(MFA)), + Args = [mk_var({x,I-1}) || I <- lists:seq(1,A)], + ArgTup = mk_var(new), + MkArgTup = hipe_icode:mk_primop([ArgTup], mktuple, Args), + Call = hipe_icode:mk_primop([Ignore], debug_native_called, + [MFAVar,ArgTup]), + {[MkMfa,MkArgTup,Call | Code], Env}. + +-endif. + +-ifdef(IO_FORMAT_CALL_TRACE). + +%% Use io:format to trace function calls +mk_debug_calltrace(MFA, Env, Code) -> + case MFA of {io,_,_} -> %% We do not want to loop infinitely if we are compiling %% the module io. @@ -69,7 +91,9 @@ Call = hipe_icode:mk_call([Ignore],io,format,[StringVar,MFAVar],remote), {[MkMfa,MkString,Call | Code], Env} - end). + end. +-endif. + %%----------------------------------------------------------------------- %% Types @@ -126,7 +150,7 @@ trans_mfa_code(M,F,A, FunBeamCode, ClosureInfo) -> MFA = {M,F,A}, %% Debug code ?IF_DEBUG_LEVEL(5, - {Code3,_Env3} = ?mk_debugcode(MFA, Env2, Code2), + {Code3,_Env3} = mk_debug_calltrace(MFA, Env1, Code2), {Code3,_Env3} = {Code2,Env1}), %% For stack optimization Leafness = leafness(Code3), diff --git a/lib/hipe/icode/hipe_icode_mulret.erl b/lib/hipe/icode/hipe_icode_mulret.erl index a3cae621ab..0bf9f89994 100644 --- a/lib/hipe/icode/hipe_icode_mulret.erl +++ b/lib/hipe/icode/hipe_icode_mulret.erl @@ -1,8 +1,8 @@ -%% -*- erlang-indent-level: 2 -*- +%% -*- coding: utf-8; erlang-indent-level: 2 -*- %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2005-2011. All Rights Reserved. +%% Copyright Ericsson AB 2005-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -19,9 +19,9 @@ %% %%---------------------------------------------------------------------- %% File : hipe_icode_mulret.erl -%% Author : Christoffer Vikstr�m <[email protected]> +%% Author : Christoffer Vikström <[email protected]> %% Purpose : -%% Created : 23 Jun 2004 by Christoffer Vikstr�m <[email protected]> +%% Created : 23 Jun 2004 by Christoffer Vikström <[email protected]> %%---------------------------------------------------------------------- -module(hipe_icode_mulret). @@ -890,7 +890,7 @@ removeUnElems([I|Code], [OldVar] = OldVars, DstLst, Res, Def, Lab) -> %% [I|Res], Def, Lab) %% end; false -> - io:format("Borde aldrig kunna hamna h�r!", []), + io:format("Borde aldrig kunna hamna här!", []), removeUnElems(Code, OldVars, DstLst, [I|Res], Def, Lab) end end; @@ -1159,8 +1159,8 @@ printCallList([]) -> io:format("~n"). %% % Purpose : %% % Arguments : %% % Return : -%% % Notes : Fixa s� att funktionen anv�nder defines(I) ist�llet och -%% % selektorer ist�llet f�r att matcha p� #call{}. L�tt gjort. +%% % Notes : Fixa så att funktionen använder defines(I) istället och +%% % selektorer istället för att matcha på #call{}. Lätt gjort. %% %%>----------------------------------------------------------------------< %% removeUnElems(List, Var) -> removeUnElems(List, Var, []). %% removeUnElems([#icode_call{'fun'={unsafe_element,_}, args=Var}|List], Var, Res) -> diff --git a/lib/hipe/icode/hipe_icode_primops.erl b/lib/hipe/icode/hipe_icode_primops.erl index a413531c07..b0113fc556 100644 --- a/lib/hipe/icode/hipe_icode_primops.erl +++ b/lib/hipe/icode/hipe_icode_primops.erl @@ -137,7 +137,8 @@ is_safe({hipe_bs_primop, {bs_private_append, _, _}}) -> false; is_safe({hipe_bs_primop, bs_init_writable}) -> true; is_safe(#mkfun{}) -> true; is_safe(#unsafe_element{}) -> true; -is_safe(#unsafe_update_element{}) -> true. +is_safe(#unsafe_update_element{}) -> true; +is_safe(debug_native_called) -> false. -spec fails(icode_funcall()) -> boolean(). @@ -237,6 +238,7 @@ fails({hipe_bs_primop, bs_init_writable}) -> true; fails(#mkfun{}) -> false; fails(#unsafe_element{}) -> false; fails(#unsafe_update_element{}) -> false; +fails(debug_native_called) -> false; %% Apparently, we are calling fails/1 for all MFAs which are compiled. %% This is weird and we should restructure the compiler to avoid %% calling fails/1 for things that are not primops. @@ -721,6 +723,8 @@ type(Primop, Args) -> erl_types:t_any(); redtest -> erl_types:t_any(); + debug_native_called -> + erl_types:t_any(); {M, F, A} -> erl_bif_types:type(M, F, A, Args) end. @@ -893,6 +897,8 @@ type(Primop) -> erl_types:t_any(); redtest -> erl_types:t_any(); + debug_native_called -> + erl_types:t_any(); {M, F, A} -> erl_bif_types:type(M, F, A) end. diff --git a/lib/hipe/icode/hipe_icode_range.erl b/lib/hipe/icode/hipe_icode_range.erl index c222e8a5d5..46c5a39f2c 100644 --- a/lib/hipe/icode/hipe_icode_range.erl +++ b/lib/hipe/icode/hipe_icode_range.erl @@ -784,6 +784,8 @@ analyse_type(Type, Info, Rewrite) -> integer -> TrueRange = inf(any_range(), OldVarRange), FalseRange = inf(none_range(), OldVarRange); + number -> + TrueRange = FalseRange = OldVarRange; _ -> TrueRange = inf(none_range(), OldVarRange), FalseRange = OldVarRange diff --git a/lib/hipe/main/Makefile b/lib/hipe/main/Makefile index 673431a175..66e4c3e39a 100644 --- a/lib/hipe/main/Makefile +++ b/lib/hipe/main/Makefile @@ -76,7 +76,7 @@ ERL_COMPILE_FLAGS += +nowarn_shadow_vars +warn_missing_spec +warn_untyped_record # ---------------------------------------------------- hipe.hrl: ../vsn.mk hipe.hrl.src - sed -e "s;%VSN%;$(HIPE_VSN);" ../../hipe/main/hipe.hrl.src > ../../hipe/main/hipe.hrl + $(vsn_verbose)sed -e "s;%VSN%;$(HIPE_VSN);" ../../hipe/main/hipe.hrl.src > ../../hipe/main/hipe.hrl $(EBIN)/hipe.beam: hipe.hrl ../../compiler/src/beam_disasm.hrl $(EBIN)/hipe_main.beam: hipe.hrl ../icode/hipe_icode.hrl #../rtl/hipe_rtl.hrl @@ -97,17 +97,17 @@ distclean: clean realclean: clean $(DOCS)/%.html:%.erl - erl -noshell -run edoc_run file '"$<"' '[{dir, "$(DOCS)"}]' -s init stop + $(gen_verbose)erl -noshell -run edoc_run file '"$<"' '[{dir, "$(DOCS)"}]' -s init stop # ---------------------------------------------------- # Special Build Targets # ---------------------------------------------------- $(APP_TARGET): $(APP_SRC) ../vsn.mk - sed -e 's;%VSN%;$(VSN);' $< > $@ + $(vsn_verbose)sed -e 's;%VSN%;$(VSN);' $< > $@ $(APPUP_TARGET): $(APPUP_SRC) ../vsn.mk - sed -e 's;%VSN%;$(VSN);' $< > $@ + $(vsn_verbose)sed -e 's;%VSN%;$(VSN);' $< > $@ # ---------------------------------------------------- # Release Target diff --git a/lib/hipe/main/hipe.erl b/lib/hipe/main/hipe.erl index b2789978a4..6e00b13292 100644 --- a/lib/hipe/main/hipe.erl +++ b/lib/hipe/main/hipe.erl @@ -1135,7 +1135,7 @@ option_text(debug) -> option_text(icode_range) -> "Performs integer range analysis on the Icode level"; option_text(icode_ssa_check) -> - "Checks whether Icode is on SSA form or not\n"; + "Checks whether Icode is on SSA form or not"; option_text(icode_ssa_copy_prop) -> "Performs copy propagation on Icode SSA"; option_text(icode_ssa_const_prop) -> @@ -1143,14 +1143,14 @@ option_text(icode_ssa_const_prop) -> option_text(icode_ssa_struct_reuse) -> "Factors out common tuple and list constructions on Icode SSA"; option_text(icode_type) -> - "Performs type analysis on the Icode level" ++ + "Performs type analysis on the Icode level\n" ++ "and then simplifies the code based on the results of this analysis"; option_text(load) -> "Automatically load the produced native code into memory"; option_text(peephole) -> "Enables peephole optimizations"; option_text(pmatch) -> - "Enables pattern matching compilation when compiling from Core; " ++ + "Enables pattern matching compilation when compiling from Core;\n" ++ "has no effect when compiling from BEAM bytecode"; option_text(pp_asm) -> "Displays assembly listing with addresses and bytecode\n" ++ @@ -1197,11 +1197,11 @@ option_text(timeout) -> " The limit must be a non-negative integer or the atom 'infinity'.\n" ++ " The current default limit is 15 minutes (900000 ms)."; option_text(use_indexing) -> - "Use indexing for multiple-choice branch selection."; + "Use indexing for multiple-choice branch selection"; option_text(use_callgraph) -> - "Compile the functions in a module according to a reversed topological " ++ - "sorted order to gain more information when using a persistent lookup " ++ - "table for storing intra-modular type information."; + "Compile the functions in a module according to a reversed topological\n" ++ + "sorted order to gain more information when using a persistent lookup\n" ++ + "table for storing intra-modular type information"; option_text(verbose) -> "Output information about what is being done"; option_text(Opt) when is_atom(Opt) -> diff --git a/lib/hipe/regalloc/hipe_coalescing_regalloc.erl b/lib/hipe/regalloc/hipe_coalescing_regalloc.erl index 5a4b017c71..7169dd18f3 100644 --- a/lib/hipe/regalloc/hipe_coalescing_regalloc.erl +++ b/lib/hipe/regalloc/hipe_coalescing_regalloc.erl @@ -1,8 +1,8 @@ -%% -*- erlang-indent-level: 2 -*- +%% -*- coding: utf-8; erlang-indent-level: 2 -*- %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% Copyright Ericsson AB 2001-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -20,8 +20,8 @@ %%----------------------------------------------------------------------- %% File : hipe_coalescing_regalloc.erl %% Authors : Andreas Wallin <[email protected]> -%% Thorild Sel�n <[email protected]> -%% Ingemar �berg <[email protected]> +%% Thorild Selén <[email protected]> +%% Ingemar Åberg <[email protected]> %% Purpose : Play paintball with registers on a target machine. We win %% if they are all colored. This is an iterated coalescing %% register allocator. diff --git a/lib/hipe/regalloc/hipe_optimistic_regalloc.erl b/lib/hipe/regalloc/hipe_optimistic_regalloc.erl index 183ec1994c..fc3718cbc0 100644 --- a/lib/hipe/regalloc/hipe_optimistic_regalloc.erl +++ b/lib/hipe/regalloc/hipe_optimistic_regalloc.erl @@ -1,8 +1,8 @@ -%% -*- erlang-indent-level: 2 -*- +%% -*- coding: utf-8; erlang-indent-level: 2 -*- %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% Copyright Ericsson AB 2005-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -1657,9 +1657,9 @@ findPrimitiveNodes(Node, N, Alias, PrimitiveNodes) -> % %?debug_msg("Node ~p~n", [Node]), % NextNode = Node - 1, % Coalesced_to = hipe_reg_worklists:member_coalesced_to(NextNode, Worklists), -% ?debug_msg("��-- member coalesced: ~p~n", [Coalesced_to]), +% ?debug_msg("³³-- member coalesced: ~p~n", [Coalesced_to]), % {Primitives, Alias1} = undoCoalescing(NextNode, No_temporaries, Alias), -% ?debug_msg("��-- primitivenodes ~w\n", [Primitives]), +% ?debug_msg("½½-- primitivenodes ~w\n", [Primitives]), % case (Coalesced_to) of % true -> printAlias(Alias1); % _ -> true @@ -1683,9 +1683,9 @@ findPrimitiveNodes(Node, N, Alias, PrimitiveNodes) -> fixAdj(N, SavedAdj, IG, Target) -> %Saved = hipe_vectors:get(SavedAdj, N), Saved = hipe_adj_list:edges(N, SavedAdj), - ?debug_msg("��--adj to ~p: ~p~n", [N, Saved]), + ?debug_msg("§§--adj to ~p: ~p~n", [N, Saved]), Adj = hipe_ig:node_adj_list(N, IG), - ?debug_msg("��--adj to ~p: ~p~n", [N, Adj]), + ?debug_msg("««--adj to ~p: ~p~n", [N, Adj]), New = findNew(Adj, Saved), ?debug_msg("++--new adj to ~p: ~p~n", [N, New]), removeAdj(New, N, IG, Target), diff --git a/lib/hipe/regalloc/hipe_reg_worklists.erl b/lib/hipe/regalloc/hipe_reg_worklists.erl index 67a5788c7c..e22cc8dc07 100644 --- a/lib/hipe/regalloc/hipe_reg_worklists.erl +++ b/lib/hipe/regalloc/hipe_reg_worklists.erl @@ -1,8 +1,8 @@ -%%% -*- erlang-indent-level: 2 -*- +%%% -*- coding: utf-8; erlang-indent-level: 2 -*- %%% %%% %CopyrightBegin% %%% -%%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%%% Copyright Ericsson AB 2001-2012. All Rights Reserved. %%% %%% The contents of this file are subject to the Erlang Public License, %%% Version 1.1, (the "License"); you may not use this file except in @@ -28,7 +28,7 @@ %%%---------------------------------------------------------------------- -module(hipe_reg_worklists). --author(['Andreas Wallin', 'Thorild Sel�n']). +-author(['Andreas Wallin', 'Thorild Selén']). -export([new/5, % only used by optimistic allocator new/6, simplify/1, diff --git a/lib/hipe/rtl/Makefile b/lib/hipe/rtl/Makefile index 426d1bd3ee..7852a2172b 100644 --- a/lib/hipe/rtl/Makefile +++ b/lib/hipe/rtl/Makefile @@ -134,13 +134,13 @@ HIPE_MKLITERALS=$(ERL_TOP)/bin/$(TARGET)/hipe_mkliterals$(TYPE_STR)$(FLAVOR_STR) hipe_literals.hrl: $(HIPE_MKLITERALS) - $(HIPE_MKLITERALS) $(MKLIT_FLAGS) -e > hipe_literals.hrl + $(gen_verbose)$(HIPE_MKLITERALS) $(MKLIT_FLAGS) -e > hipe_literals.hrl # Need to generate hipe.hrl from one and only one target in one and only # one makefile; otherwise, clearmake will force rebuilds of hipe over and # over again. ../main/hipe.hrl: ../vsn.mk ../main/hipe.hrl.src - (cd ../main && $(MAKE) hipe.hrl) + $(V_at)(cd ../main && $(MAKE) hipe.hrl) # 2012-02-24. Please keep these dependencies up to date. They tend to rot. # grep ^-include *.erl says a lot, but you need to dig further, e.g: diff --git a/lib/hipe/rtl/hipe_rtl_arith.inc b/lib/hipe/rtl/hipe_rtl_arith.inc index e608506234..7b587e882d 100644 --- a/lib/hipe/rtl/hipe_rtl_arith.inc +++ b/lib/hipe/rtl/hipe_rtl_arith.inc @@ -1,9 +1,9 @@ %% -*- Erlang -*- -%% -*- erlang-indent-level: 2 -*- +%% -*- coding: utf-8; erlang-indent-level: 2 -*- %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2011. All Rights Reserved. +%% Copyright Ericsson AB 2004-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -114,7 +114,7 @@ eval_alu(Op, Arg1, Arg2) eval_alu(Op, Arg1, Arg2) -> ?EXIT({argument_overflow,Op,Arg1,Arg2}). -%% Bj�rn & Bjarni: +%% Björn & Bjarni: %% We need to be able to do evaluations based only on the bits, since %% there are cases where we can evaluate a subset of the bits, but can %% not do a full eval-alub call (eg. a + 0 gives no carry) diff --git a/lib/hipe/rtl/hipe_rtl_mk_switch.erl b/lib/hipe/rtl/hipe_rtl_mk_switch.erl index e5175217d6..d859c50b7d 100644 --- a/lib/hipe/rtl/hipe_rtl_mk_switch.erl +++ b/lib/hipe/rtl/hipe_rtl_mk_switch.erl @@ -1,8 +1,8 @@ -%% -*- erlang-indent-level: 2 -*- +%% -*- coding: utf-8; erlang-indent-level: 2 -*- %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% Copyright Ericsson AB 2001-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -31,7 +31,7 @@ %% History : * 2001-02-28 Erik Johansson ([email protected]): %% Created. %% * 2001-04-01 Erik Trulsson ([email protected]): -%% Stefan Lindstr�m ([email protected]): +%% Stefan Lindström ([email protected]): %% Added clustering and inlined binary search trees. %% * 2001-07-30 EJ ([email protected]): %% Fixed some bugs and started cleanup. diff --git a/lib/hipe/rtl/hipe_rtl_primops.erl b/lib/hipe/rtl/hipe_rtl_primops.erl index 5f273d8251..d9d08356ce 100644 --- a/lib/hipe/rtl/hipe_rtl_primops.erl +++ b/lib/hipe/rtl/hipe_rtl_primops.erl @@ -2,7 +2,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2001-2011. All Rights Reserved. +%% Copyright Ericsson AB 2001-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -396,6 +396,8 @@ gen_primop({Op,Dst,Args,Cont,Fail}, IsGuard, ConstTab) -> [Dst1]-> hipe_tagscheme:unsafe_tag_float(Dst1, Arg) end; + debug_native_called -> + [hipe_rtl:mk_call(Dst, Op, Args, Cont, Fail, not_remote)]; %% Only names listed above are accepted! MFA:s are not primops! _ -> @@ -736,7 +738,7 @@ gen_mkfun([Dst], {_Mod, _FunId, _Arity} = MFidA, MagicNr, Index, FreeVars) -> %% Tag the thing and increase the heap_pointer. %% make_fun(funp); - WordSize�= hipe_rtl_arch:word_size(), + WordSize = hipe_rtl_arch:word_size(), HeapNeed = (?ERL_FUN_SIZE + NumFree) * WordSize, TagCode = [hipe_tagscheme:tag_fun(Dst, HP), %% AdjustHPCode @@ -827,7 +829,7 @@ load_struct_field(Dest, StructP, Offset, int32) -> gen_free_vars(Vars, HPReg) -> HPVar = hipe_rtl:mk_new_var(), - WordSize�= hipe_rtl_arch:word_size(), + WordSize = hipe_rtl_arch:word_size(), [hipe_rtl:mk_alu(HPVar, HPReg, add, hipe_rtl:mk_imm(?EFT_ENV)) | gen_free_vars(Vars, HPVar, 0, WordSize, [])]. diff --git a/lib/hipe/rtl/hipe_rtl_ssa_const_prop.erl b/lib/hipe/rtl/hipe_rtl_ssa_const_prop.erl index 194cf29b64..1c900d767e 100644 --- a/lib/hipe/rtl/hipe_rtl_ssa_const_prop.erl +++ b/lib/hipe/rtl/hipe_rtl_ssa_const_prop.erl @@ -1,8 +1,8 @@ -%% -*- erlang-indent-level: 2 -*- +%% -*- coding: utf-8; erlang-indent-level: 2 -*- %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2011. All Rights Reserved. +%% Copyright Ericsson AB 2004-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -190,7 +190,7 @@ set_to(Dst, Val, Env) -> %% Returns : { FlowWorkList, SSAWorkList, NewEnvironment} %%----------------------------------------------------------------------------- -visit_branch(Inst, Env) -> %% Titta ocks� p� exekverbarflagga +visit_branch(Inst, Env) -> %% Titta också på exekverbarflagga Val1 = lookup_lattice_value(hipe_rtl:branch_src1(Inst), Env), Val2 = lookup_lattice_value(hipe_rtl:branch_src2(Inst), Env), CFGWL = case evaluate_relop(Val1, hipe_rtl:branch_cond(Inst), Val2) of diff --git a/lib/hipe/rtl/hipe_rtl_ssapre.erl b/lib/hipe/rtl/hipe_rtl_ssapre.erl index a9e92e5688..34897ba4b7 100644 --- a/lib/hipe/rtl/hipe_rtl_ssapre.erl +++ b/lib/hipe/rtl/hipe_rtl_ssapre.erl @@ -1,8 +1,8 @@ -%% -*- erlang-indent-level: 2 -*- +%% -*- coding: utf-8; erlang-indent-level: 2 -*- %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2005-2009. All Rights Reserved. +%% Copyright Ericsson AB 2005-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -19,7 +19,7 @@ %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% File : hipe_rtl_ssapre.erl -%% Author : He Bingwen and Fr�d�ric Haziza +%% Author : He Bingwen and Frédéric Haziza %% Description : Performs Partial Redundancy Elimination on SSA form. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% @doc @@ -552,7 +552,7 @@ emend_with_processed_xsis(E, [I|Rest], Pred, XsiGraph) -> true -> %% It's a computation of E! case xsi_arg(Xsi,Pred) of undetermined_operand -> - exit({?MODULE,check_operand_sharing,"######## �h Dear, we trusted Kostis !!!!!!!!! #############"}); + exit({?MODULE,check_operand_sharing,"######## Ôh Dear, we trusted Kostis !!!!!!!!! #############"}); XsiOp -> {sharing_operand,XsiOp} %% They share operands end; @@ -571,7 +571,7 @@ emend_with_processed_xsis(E, [I|Rest], Pred, XsiGraph) -> NewE = emend(E,Def,A#eop.var), emend_with_processed_xsis(NewE,Rest,Pred,XsiGraph); undetermined_operand -> - exit({?MODULE,emend_with_processed_xsis,"######## �h Dear, we trusted Kostis, again !!!!!!!!! #############"}); + exit({?MODULE,emend_with_processed_xsis,"######## Ôh Dear, we trusted Kostis, again !!!!!!!!! #############"}); XsiOp -> NewE = emend(E,Def,XsiOp), emend_with_processed_xsis(NewE,Rest,Pred,XsiGraph) diff --git a/lib/hipe/ssa/hipe_ssa.inc b/lib/hipe/ssa/hipe_ssa.inc index d15b5ddd56..e766a83c41 100644 --- a/lib/hipe/ssa/hipe_ssa.inc +++ b/lib/hipe/ssa/hipe_ssa.inc @@ -1,8 +1,8 @@ -%% -*- erlang-indent-level: 2 -*- +%% -*- coding: utf-8; erlang-indent-level: 2 -*- %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2002-2009. All Rights Reserved. +%% Copyright Ericsson AB 2002-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -19,7 +19,7 @@ %% %%---------------------------------------------------------------------- %% File : hipe_ssa.inc -%% Authors : Christoffer Vikstr�m, Daniel Deogun, and Jesper Bengtsson +%% Authors : Christoffer Vikström, Daniel Deogun, and Jesper Bengtsson %% Created : March 2002 %% Purpose : Provides code which converts the code of a CFG into SSA %% (Static Single Assignment) form and back. diff --git a/lib/hipe/vsn.mk b/lib/hipe/vsn.mk index f3e2e695b5..6cd87708ef 100644 --- a/lib/hipe/vsn.mk +++ b/lib/hipe/vsn.mk @@ -1 +1 @@ -HIPE_VSN = 3.9.3 +HIPE_VSN = 3.10.1 diff --git a/lib/hipe/x86/hipe_x86_assemble.erl b/lib/hipe/x86/hipe_x86_assemble.erl index 4e65736db3..7878c7219d 100644 --- a/lib/hipe/x86/hipe_x86_assemble.erl +++ b/lib/hipe/x86/hipe_x86_assemble.erl @@ -2,7 +2,7 @@ %%% %%% %CopyrightBegin% %%% -%%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%%% Copyright Ericsson AB 2001-2012. All Rights Reserved. %%% %%% The contents of this file are subject to the Erlang Public License, %%% Version 1.1, (the "License"); you may not use this file except in @@ -698,7 +698,7 @@ mem_to_ea_common(#x86_mem{base=#x86_temp{reg=Base}, off=#x86_imm{value=Off}}) -> %% jmp_switch -ifdef(HIPE_AMD64). -resolve_jmp_switch_arg(I,�_Context) -> +resolve_jmp_switch_arg(I, _Context) -> Base = hipe_x86:temp_reg(hipe_x86:jmp_switch_jtab(I)), Index = hipe_x86:temp_reg(hipe_x86:jmp_switch_temp(I)), SINDEX = hipe_amd64_encode:sindex(3, Index), diff --git a/lib/hipe/x86/hipe_x86_postpass.erl b/lib/hipe/x86/hipe_x86_postpass.erl index 34e3d7a11b..c0918c4f89 100644 --- a/lib/hipe/x86/hipe_x86_postpass.erl +++ b/lib/hipe/x86/hipe_x86_postpass.erl @@ -1,8 +1,8 @@ -%%% -*- erlang-indent-level: 2 -*- +%%% -*- coding: utf-8; erlang-indent-level: 2 -*- %%% %%% %CopyrightBegin% %%% -%%% Copyright Ericsson AB 2003-2009. All Rights Reserved. +%%% Copyright Ericsson AB 2003-2012. All Rights Reserved. %%% %%% The contents of this file are subject to the Erlang Public License, %%% Version 1.1, (the "License"); you may not use this file except in @@ -19,9 +19,9 @@ %%% %%%---------------------------------------------------------------------- %%% File : hipe_x86_postpass.erl -%%% Author : Christoffer Vikstr�m <[email protected]> +%%% Author : Christoffer Vikström <[email protected]> %%% Purpose : Contain postpass optimisations for x86-assembler code. -%%% Created : 5 Aug 2003 by Christoffer Vikstr�m <[email protected]> +%%% Created : 5 Aug 2003 by Christoffer Vikström <[email protected]> %%%---------------------------------------------------------------------- -ifndef(HIPE_X86_POSTPASS). diff --git a/lib/hipe/x86/hipe_x86_ra_postconditions.erl b/lib/hipe/x86/hipe_x86_ra_postconditions.erl index 0b70764daf..6d7e90df43 100644 --- a/lib/hipe/x86/hipe_x86_ra_postconditions.erl +++ b/lib/hipe/x86/hipe_x86_ra_postconditions.erl @@ -2,7 +2,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2001-2009. All Rights Reserved. +%% Copyright Ericsson AB 2001-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -224,7 +224,7 @@ do_byte_move(Src0, Dst0, TempMap, Strategy) -> do_move64(I, TempMap, Strategy) -> #move64{dst=Dst} = I, - case�is_spilled(Dst, TempMap) of + case is_spilled(Dst, TempMap) of false -> {[I], false}; true -> |