aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_ssa_type.erl
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-05-29 16:11:46 +0200
committerJohn Högberg <[email protected]>2019-06-12 15:03:46 +0200
commit48f83e165a2dae8ed04a74ba3c6308250168f790 (patch)
tree95c292f7c74aedad0c0bd75b64eec38698dd7dba /lib/compiler/src/beam_ssa_type.erl
parent4411b1953bfb862aad433c2269acb82a35b0cc72 (diff)
downloadotp-48f83e165a2dae8ed04a74ba3c6308250168f790.tar.gz
otp-48f83e165a2dae8ed04a74ba3c6308250168f790.tar.bz2
otp-48f83e165a2dae8ed04a74ba3c6308250168f790.zip
beam_validator: Replace old type representation with beam_types
Diffstat (limited to 'lib/compiler/src/beam_ssa_type.erl')
-rw-r--r--lib/compiler/src/beam_ssa_type.erl59
1 files changed, 9 insertions, 50 deletions
diff --git a/lib/compiler/src/beam_ssa_type.erl b/lib/compiler/src/beam_ssa_type.erl
index 99dec0d84f..79ed0d7885 100644
--- a/lib/compiler/src/beam_ssa_type.erl
+++ b/lib/compiler/src/beam_ssa_type.erl
@@ -144,50 +144,15 @@ opt_finish_1([Arg | Args], [TypeMap | TypeMaps], ParamInfo)
map_size(TypeMap) =:= 0 ->
opt_finish_1(Args, TypeMaps, ParamInfo);
opt_finish_1([Arg | Args], [TypeMap | TypeMaps], ParamInfo0) ->
- JoinedType0 = beam_types:join(maps:values(TypeMap)),
- case validator_anno(JoinedType0) of
- any ->
- opt_finish_1(Args, TypeMaps, ParamInfo0);
- JoinedType ->
- ParamInfo = ParamInfo0#{ Arg => JoinedType },
- opt_finish_1(Args, TypeMaps, ParamInfo)
- end;
+ JoinedType = beam_types:join(maps:values(TypeMap)),
+ ParamInfo = case JoinedType of
+ any -> ParamInfo0;
+ _ -> ParamInfo0#{ Arg => JoinedType }
+ end,
+ opt_finish_1(Args, TypeMaps, ParamInfo);
opt_finish_1([], [], ParamInfo) ->
ParamInfo.
-validator_anno(any) ->
- any;
-validator_anno(#t_fun{}) ->
- %% There is no need make funs visible to beam_validator.
- any;
-validator_anno(#t_tuple{size=Size,exact=Exact,elements=Elements0}) ->
- Elements = maps:fold(fun(Index, Type0, Acc) ->
- case validator_anno(Type0) of
- any -> Acc;
- Type -> Acc#{ Index => Type }
- end
- end, #{}, Elements0),
- beam_validator:type_anno(tuple, Size, Exact, Elements);
-validator_anno(#t_integer{elements={Same,Same}}) ->
- beam_validator:type_anno(integer, Same);
-validator_anno(#t_integer{}) ->
- beam_validator:type_anno(integer);
-validator_anno(#t_bitstring{unit=U}) ->
- beam_validator:type_anno({binary,U});
-validator_anno(float) ->
- beam_validator:type_anno(float);
-validator_anno(#t_map{}) ->
- beam_validator:type_anno(map);
-validator_anno(#t_atom{elements=[Val]}) ->
- beam_validator:type_anno(atom, Val);
-validator_anno(#t_atom{}=A) ->
- case beam_types:is_boolean_type(A) of
- true -> beam_validator:type_anno(bool);
- false -> beam_validator:type_anno(atom)
- end;
-validator_anno(T) ->
- beam_validator:type_anno(T).
-
get_func_id(Anno) ->
#{func_info:={_Mod, Name, Arity}} = Anno,
#b_local{name=#b_literal{val=Name}, arity=Arity}.
@@ -443,15 +408,9 @@ opt_local_call(#b_set{dst=Dst,args=[Id|_]}=I0, Ts0, Ds0, Fdb) ->
#{} -> any
end,
I = case Type of
- none ->
- I0;
- _ ->
- case validator_anno(Type) of
- any ->
- I0;
- ValidatorType ->
- beam_ssa:add_anno(result_type, ValidatorType, I0)
- end
+ any -> I0;
+ none -> I0;
+ _ -> beam_ssa:add_anno(result_type, Type, I0)
end,
Ts = Ts0#{ Dst => Type },
Ds = Ds0#{ Dst => I },