diff options
author | Kostis Sagonas <[email protected]> | 2014-03-19 10:54:21 +0100 |
---|---|---|
committer | Kostis Sagonas <[email protected]> | 2014-03-19 10:54:21 +0100 |
commit | 8b23a059c7c0e23c08b76871ba502f8e9db08c84 (patch) | |
tree | 317854ac418babbfb20ab26c0497aca6e9d6cdd2 /lib/compiler/src/cerl.erl | |
parent | aab1afa8a63081f2c30f83ebe8b6caaac979795c (diff) | |
download | otp-8b23a059c7c0e23c08b76871ba502f8e9db08c84.tar.gz otp-8b23a059c7c0e23c08b76871ba502f8e9db08c84.tar.bz2 otp-8b23a059c7c0e23c08b76871ba502f8e9db08c84.zip |
Clean up the types of cerl
The introduction of c_map and c_map_pair was not done properly. In
particular, the definition of ctype() and an important Edoc comment
were not up-to-date.
While at it,
- some more types were cleaned up and exported so as to be used
in core_parse.hrl and
- some obviously dead code was removed (the type/1 function does
not return 'nil', which in turn simplified a clause in the code
of meta_1/2).
Diffstat (limited to 'lib/compiler/src/cerl.erl')
-rw-r--r-- | lib/compiler/src/cerl.erl | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/lib/compiler/src/cerl.erl b/lib/compiler/src/cerl.erl index ecc4b2c9b1..e400e4f185 100644 --- a/lib/compiler/src/cerl.erl +++ b/lib/compiler/src/cerl.erl @@ -132,16 +132,13 @@ ann_c_map_pair/4 ]). --export_type([c_binary/0, c_call/0, c_clause/0, c_cons/0, c_fun/0, c_literal/0, - c_module/0, c_tuple/0, c_values/0, c_var/0, cerl/0, var_name/0]). +-export_type([c_binary/0, c_bitstr/0, c_call/0, c_clause/0, c_cons/0, c_fun/0, + c_literal/0, c_map_pair/0, c_module/0, c_tuple/0, + c_values/0, c_var/0, cerl/0, var_name/0]). %% HiPE does not understand Maps %% (guard functions is_map/1 and map_size/1 in ann_c_map/3) -compile(no_native). -%% -%% needed by the include file below -- do not move -%% --type var_name() :: integer() | atom() | {atom(), integer()}. -include("core_parse.hrl"). @@ -176,6 +173,8 @@ | c_module() | c_primop() | c_receive() | c_seq() | c_try() | c_tuple() | c_values() | c_var(). +-type var_name() :: integer() | atom() | {atom(), integer()}. + %% ===================================================================== %% Representation (general) %% @@ -207,13 +206,15 @@ %% <td>call</td> %% <td>case</td> %% <td>catch</td> -%% </tr><tr> %% <td>clause</td> +%% </tr><tr> %% <td>cons</td> %% <td>fun</td> %% <td>let</td> %% <td>letrec</td> %% <td>literal</td> +%% <td>map</td> +%% <td>map_pair</td> %% <td>module</td> %% </tr><tr> %% <td>primop</td> @@ -264,10 +265,10 @@ %% @see subtrees/1 %% @see meta/1 --type ctype() :: 'alias' | 'apply' | 'binary' | 'bitrst' | 'call' | 'case' - | 'catch' | 'clause' | 'cons' | 'fun' | 'let' | 'letrec' - | 'literal' | 'map' | 'module' | 'primop' | 'receive' | 'seq' - | 'try' | 'tuple' | 'values' | 'var'. +-type ctype() :: 'alias' | 'apply' | 'binary' | 'bitrst' | 'call' | 'case' + | 'catch' | 'clause' | 'cons' | 'fun' | 'let' | 'letrec' + | 'literal' | 'map' | 'map_pair' | 'module' | 'primop' + | 'receive' | 'seq' | 'try' | 'tuple' | 'values' | 'var'. -spec type(cerl()) -> ctype(). @@ -4377,12 +4378,8 @@ meta_1(cons, Node) -> %% we get exactly one element, we generate a 'c_cons' call %% instead of 'make_list' to reconstruct the node. case split_list(Node) of - {[H], none} -> - meta_call(c_cons, [meta(H), meta(c_nil())]); {[H], Node1} -> meta_call(c_cons, [meta(H), meta(Node1)]); - {L, none} -> - meta_call(make_list, [make_list(meta_list(L))]); {L, Node1} -> meta_call(make_list, [make_list(meta_list(L)), meta(Node1)]) @@ -4469,8 +4466,6 @@ split_list(Node, L) -> case type(Node) of cons when A =:= [] -> split_list(cons_tl(Node), [cons_hd(Node) | L]); - nil when A =:= [] -> - {lists:reverse(L), none}; _ -> {lists:reverse(L), Node} end. |