4
%% Copyright Ericsson AB 2008-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
64
64
%% InEncoding =:= latin1, OutEncoding =:= unicode;
65
65
%% InEncoding =:= latin1, OutEncoding =:= utf8 ->
69
%% is_ne_exact Fail Reg Literal1
70
%% is_ne_exact Fail Reg Literal2
71
%% is_ne_exact Fail Reg Literal3
72
%% is_eq_exact UltimateFail Reg Literal4
75
%% can be rewritten to
77
%% select_val Reg UltimateFail [ Literal1 Fail
82
%% (3) A select_val/4 instruction that only verifies that
67
%% (2) A select_val/4 instruction that only verifies that
83
68
%% its argument is either 'true' or 'false' can be
84
69
%% be replaced with an is_boolean/2 instruction. That is:
133
118
%% Remember that we have seen this test.
134
119
SeenTests = gb_sets:insert(Test, SeenTests0),
135
make_select_val(I, Is, SeenTests, Acc)
120
peep(Is, SeenTests, [I|Acc])
138
123
peep([{select_val,Src,Fail,
151
136
peep(Is, gb_sets:empty(), [I|Acc]);
152
137
peep([], _, Acc) -> reverse(Acc).
154
make_select_val({test,is_ne_exact,{f,Fail},[Val,Lit]}=I0,
155
Is0, SeenTests, Acc) ->
159
{integer,_} -> integer;
160
_ -> throw(impossible)
162
{I,Is} = make_select_val_1(Is0, Fail, Val, Type, [Lit,{f,Fail}]),
163
peep([I|Is], SeenTests, Acc)
166
peep(Is0, SeenTests, [I0|Acc])
168
make_select_val(I, Is, SeenTests, Acc) ->
169
peep(Is, SeenTests, [I|Acc]).
171
make_select_val_1([{test,is_ne_exact,{f,Fail},[Val,{Type,_}=Lit]}|Is],
172
Fail, Val, Type, Acc) ->
173
make_select_val_1(Is, Fail, Val, Type, [Lit,{f,Fail}|Acc]);
174
make_select_val_1([{test,is_eq_exact,{f,UltimateFail},[Val,{Type,_}=Lit]} |
175
[{label,Fail}|_]=Is], Fail, Val, Type, Acc) ->
176
Choices = [Lit,{f,Fail}|Acc],
177
I = {select_val,Val,{f,UltimateFail},{list,Choices}},
179
make_select_val_1(_Is, _Fail, _Val, _Type, _Acc) -> throw(impossible).
181
139
kill_seen(Dst, Seen0) ->
182
140
gb_sets:from_ordset(kill_seen_1(gb_sets:to_list(Seen0), Dst)).