Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
4362-dialyzer_typesig-Simplify-find_constraint_...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 4362-dialyzer_typesig-Simplify-find_constraint_deps-and-f.patch of Package erlang
From 4010463e87f7193d027a2ea98c0cdebd7e8a0f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org> Date: Thu, 16 Sep 2021 18:48:41 +0200 Subject: [PATCH 2/7] dialyzer_typesig: Simplify find_constraint_deps and friends --- lib/dialyzer/src/dialyzer_typesig.erl | 22 ++++++------ lib/dialyzer/src/erl_types.erl | 50 +++++++++++++-------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/lib/dialyzer/src/dialyzer_typesig.erl b/lib/dialyzer/src/dialyzer_typesig.erl index c47f751bfc..9fc0cda089 100644 --- a/lib/dialyzer/src/dialyzer_typesig.erl +++ b/lib/dialyzer/src/dialyzer_typesig.erl @@ -34,7 +34,7 @@ -import(erl_types, [t_any/0, t_atom/0, t_atom_vals/1, t_binary/0, t_bitstr/0, t_bitstr/2, t_bitstr_concat/1, t_boolean/0, - t_collect_vars/1, t_cons/2, t_cons_hd/1, t_cons_tl/1, + t_collect_var_names/1, t_cons/2, t_cons_hd/1, t_cons_tl/1, t_float/0, t_from_range/2, t_from_term/1, t_fun/0, t_fun/2, t_fun_args/1, t_fun_range/1, t_integer/0, @@ -2671,8 +2671,8 @@ constraint_opnd_is_any(Type) -> t_is_any(Type). [erl_types:erl_type()]) -> #fun_var{}. mk_fun_var(Line, Fun, Types) -> - Deps = [t_var_name(Var) || Var <- t_collect_vars(t_product(Types))], - #fun_var{'fun' = Fun, deps = ordsets:from_list(Deps), origin = Line}. + Deps = t_collect_var_names(t_product(Types)), + #fun_var{'fun' = Fun, deps = Deps, origin = Line}. pp_map(S, Map) -> ?debug("\t~s: ~p\n", @@ -2684,8 +2684,8 @@ pp_map(S, Map) -> -spec mk_fun_var(fun((_) -> erl_types:erl_type()), [erl_types:erl_type()]) -> #fun_var{}. mk_fun_var(Fun, Types) -> - Deps = [t_var_name(Var) || Var <- t_collect_vars(t_product(Types))], - #fun_var{'fun' = Fun, deps = ordsets:from_list(Deps)}. + Deps = t_collect_var_names(t_product(Types)), + #fun_var{'fun' = Fun, deps = Deps}. -endif. @@ -2698,15 +2698,15 @@ get_deps(#constraint_ref{deps = D}) -> D. -spec find_constraint_deps([fvar_or_type()]) -> deps(). find_constraint_deps(List) -> - ordsets:from_list(find_constraint_deps(List, [])). + find_constraint_deps(List, []). find_constraint_deps([#fun_var{deps = Deps}|Tail], Acc) -> - find_constraint_deps(Tail, [Deps|Acc]); -find_constraint_deps([Type|Tail], Acc) -> - NewAcc = [[t_var_name(D) || D <- t_collect_vars(Type)]|Acc], - find_constraint_deps(Tail, NewAcc); + find_constraint_deps(Tail, ordsets:union(Deps, Acc)); +find_constraint_deps([Type | Tail], Acc0) -> + Acc = ordsets:union(t_collect_var_names(Type), Acc0), + find_constraint_deps(Tail, Acc); find_constraint_deps([], Acc) -> - lists:append(Acc). + Acc. mk_constraint_1(Lhs, eq, Rhs, Deps) when Lhs < Rhs -> #constraint{lhs = Lhs, op = eq, rhs = Rhs, deps = Deps}; diff --git a/lib/hipe/cerl/erl_types.erl b/lib/hipe/cerl/erl_types.erl index fe918027d8..37b7793d56 100644 --- a/lib/hipe/cerl/erl_types.erl +++ b/lib/hipe/cerl/erl_types.erl @@ -55,7 +55,7 @@ t_boolean/0, t_byte/0, t_char/0, - t_collect_vars/1, + t_collect_var_names/1, t_cons/0, t_cons/2, t_cons_hd/1, t_cons_hd/2, @@ -2339,45 +2339,43 @@ t_has_var_list([T|Ts]) -> t_has_var(T) orelse t_has_var_list(Ts); t_has_var_list([]) -> false. --spec t_collect_vars(erl_type()) -> [erl_type()]. +-spec t_collect_var_names(erl_type()) -> any(). -t_collect_vars(T) -> - Vs = t_collect_vars(T, maps:new()), - [V || {V, _} <- maps:to_list(Vs)]. +t_collect_var_names(T) -> + t_collect_var_names(T, []). --type ctab() :: #{erl_type() => 'any'}. +-spec t_collect_var_names(erl_type(), ordsets:ordset(term())) -> + ordsets:ordset(term()). --spec t_collect_vars(erl_type(), ctab()) -> ctab(). - -t_collect_vars(?var(_) = Var, Acc) -> - maps:put(Var, any, Acc); -t_collect_vars(?function(Domain, Range), Acc) -> - Acc1 = t_collect_vars(Domain, Acc), - t_collect_vars(Range, Acc1); -t_collect_vars(?list(Contents, Termination, _), Acc) -> - Acc1 = t_collect_vars(Contents, Acc), - t_collect_vars(Termination, Acc1); -t_collect_vars(?product(Types), Acc) -> +t_collect_var_names(?var(Id), Acc) -> + ordsets:add_element(Id, Acc); +t_collect_var_names(?function(Domain, Range), Acc) -> + Acc1 = t_collect_var_names(Domain, Acc), + t_collect_var_names(Range, Acc1); +t_collect_var_names(?list(Contents, Termination, _), Acc) -> + Acc1 = t_collect_var_names(Contents, Acc), + t_collect_var_names(Termination, Acc1); +t_collect_var_names(?product(Types), Acc) -> t_collect_vars_list(Types, Acc); -t_collect_vars(?tuple(?any, ?any, ?any), Acc) -> +t_collect_var_names(?tuple(?any, ?any, ?any), Acc) -> Acc; -t_collect_vars(?tuple(Types, _, _), Acc) -> +t_collect_var_names(?tuple(Types, _, _), Acc) -> t_collect_vars_list(Types, Acc); -t_collect_vars(?tuple_set(_) = TS, Acc) -> +t_collect_var_names(?tuple_set(_) = TS, Acc) -> t_collect_vars_list(t_tuple_subtypes(TS), Acc); -t_collect_vars(?map(_, DefK, _) = Map, Acc0) -> +t_collect_var_names(?map(_, DefK, _) = Map, Acc0) -> Acc = t_collect_vars_list(map_all_values(Map), Acc0), - t_collect_vars(DefK, Acc); -t_collect_vars(?opaque(Set), Acc) -> + t_collect_var_names(DefK, Acc); +t_collect_var_names(?opaque(Set), Acc) -> %% Assume variables in 'args' are also present i 'struct' t_collect_vars_list([O#opaque.struct || O <- set_to_list(Set)], Acc); -t_collect_vars(?union(List), Acc) -> +t_collect_var_names(?union(List), Acc) -> t_collect_vars_list(List, Acc); -t_collect_vars(_, Acc) -> +t_collect_var_names(_, Acc) -> Acc. t_collect_vars_list([T|Ts], Acc0) -> - Acc = t_collect_vars(T, Acc0), + Acc = t_collect_var_names(T, Acc0), t_collect_vars_list(Ts, Acc); t_collect_vars_list([], Acc) -> Acc. -- 2.31.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor