Skip to content

Commit 2116da4

Browse files
committed
Getting rid of obsolete boolean operators & and or
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3359 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1 parent 447c79e commit 2116da4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+281
-277
lines changed

asmcomp/closure.ml

+13-13
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,27 @@ let occurs_var var u =
4242
Uvar v -> v = var
4343
| Uconst cst -> false
4444
| Udirect_apply(lbl, args) -> List.exists occurs args
45-
| Ugeneric_apply(funct, args) -> occurs funct or List.exists occurs args
45+
| Ugeneric_apply(funct, args) -> occurs funct || List.exists occurs args
4646
| Uclosure(fundecls, clos) -> List.exists occurs clos
4747
| Uoffset(u, ofs) -> occurs u
48-
| Ulet(id, def, body) -> occurs def or occurs body
48+
| Ulet(id, def, body) -> occurs def || occurs body
4949
| Uletrec(decls, body) ->
50-
List.exists (fun (id, u) -> occurs u) decls or occurs body
50+
List.exists (fun (id, u) -> occurs u) decls || occurs body
5151
| Uprim(p, args) -> List.exists occurs args
5252
| Uswitch(arg, s) ->
53-
occurs arg or occurs_array s.us_cases_consts
54-
or occurs_array s.us_cases_blocks
53+
occurs arg || occurs_array s.us_cases_consts
54+
|| occurs_array s.us_cases_blocks
5555
| Ustaticfail (_, args) -> List.exists occurs args
56-
| Ucatch(_, _, body, hdlr) -> occurs body or occurs hdlr
57-
| Utrywith(body, exn, hdlr) -> occurs body or occurs hdlr
56+
| Ucatch(_, _, body, hdlr) -> occurs body || occurs hdlr
57+
| Utrywith(body, exn, hdlr) -> occurs body || occurs hdlr
5858
| Uifthenelse(cond, ifso, ifnot) ->
59-
occurs cond or occurs ifso or occurs ifnot
60-
| Usequence(u1, u2) -> occurs u1 or occurs u2
61-
| Uwhile(cond, body) -> occurs cond or occurs body
62-
| Ufor(id, lo, hi, dir, body) -> occurs lo or occurs hi or occurs body
63-
| Uassign(id, u) -> id = var or occurs u
59+
occurs cond || occurs ifso || occurs ifnot
60+
| Usequence(u1, u2) -> occurs u1 || occurs u2
61+
| Uwhile(cond, body) -> occurs cond || occurs body
62+
| Ufor(id, lo, hi, dir, body) -> occurs lo || occurs hi || occurs body
63+
| Uassign(id, u) -> id = var || occurs u
6464
| Usend(met, obj, args) ->
65-
occurs met or occurs obj or List.exists occurs args
65+
occurs met || occurs obj || List.exists occurs args
6666
and occurs_array a =
6767
try
6868
for i = 0 to Array.length a - 1 do

asmcomp/cmmgen.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ let rec transl = function
772772
let unboxed_id = Ident.create (Ident.name id) in
773773
let (tr_body, need_boxed, is_assigned) =
774774
subst_boxed_float id unboxed_id (transl body) in
775-
if need_boxed & is_assigned then
775+
if need_boxed && is_assigned then
776776
Clet(id, transl exp, transl body)
777777
else
778778
Clet(unboxed_id, transl_unbox_float exp,

asmcomp/coloring.ml

+8-8
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ let allocate_spilled reg =
3131
| _ -> ())
3232
reg.interf;
3333
let slot = ref 0 in
34-
while !slot < nslots & conflict.(!slot) do incr slot done;
34+
while !slot < nslots && conflict.(!slot) do incr slot done;
3535
reg.loc <- Stack(Local !slot);
3636
if !slot >= nslots then Proc.num_stack_slots.(cl) <- !slot + 1
3737
end
@@ -56,7 +56,7 @@ let find_degree reg =
5656
else begin
5757
let deg = ref 0 in
5858
List.iter
59-
(fun r -> if not r.spill & Proc.register_class r = cl then incr deg)
59+
(fun r -> if not r.spill && Proc.register_class r = cl then incr deg)
6060
reg.interf;
6161
reg.degree <- !deg;
6262
if !deg >= avail_regs
@@ -72,7 +72,7 @@ let remove_reg reg =
7272
let cl = Proc.register_class reg in
7373
List.iter
7474
(fun r ->
75-
if Proc.register_class r = cl & r.degree > 0 then begin
75+
if Proc.register_class r = cl && r.degree > 0 then begin
7676
let olddeg = r.degree in
7777
r.degree <- olddeg - 1;
7878
if olddeg = Proc.num_available_registers.(cl) then begin
@@ -154,13 +154,13 @@ let assign_location reg =
154154
iter_preferred
155155
(fun r w ->
156156
match r.loc with
157-
Reg n -> if n >= first_reg & n < last_reg then
157+
Reg n -> if n >= first_reg && n < last_reg then
158158
score.(n - first_reg) <- score.(n - first_reg) + w
159159
| Unknown ->
160160
List.iter
161161
(fun neighbour ->
162162
match neighbour.loc with
163-
Reg n -> if n >= first_reg & n < last_reg then
163+
Reg n -> if n >= first_reg && n < last_reg then
164164
score.(n - first_reg) <- score.(n - first_reg) - w
165165
| _ -> ())
166166
r.interf
@@ -171,7 +171,7 @@ let assign_location reg =
171171
(* Prohibit the registers that have been assigned
172172
to our neighbours *)
173173
begin match neighbour.loc with
174-
Reg n -> if n >= first_reg & n < last_reg then
174+
Reg n -> if n >= first_reg && n < last_reg then
175175
score.(n - first_reg) <- (-1000000)
176176
| _ -> ()
177177
end;
@@ -180,7 +180,7 @@ let assign_location reg =
180180
iter_preferred
181181
(fun r w ->
182182
match r.loc with
183-
Reg n -> if n >= first_reg & n < last_reg then
183+
Reg n -> if n >= first_reg && n < last_reg then
184184
score.(n - first_reg) <- score.(n - first_reg) - (w - 1)
185185
(* w-1 to break the symmetry when two conflicting regs
186186
have the same preference for a third reg. *)
@@ -216,7 +216,7 @@ let assign_location reg =
216216
match r.loc with
217217
Stack(Incoming n) ->
218218
if w > !best_score
219-
& List.for_all (fun neighbour -> neighbour.loc <> r.loc)
219+
&& List.for_all (fun neighbour -> neighbour.loc <> r.loc)
220220
reg.interf
221221
then begin
222222
best_score := w;

asmcomp/power/selection.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class selector = object (self)
5151

5252
inherit Selectgen.selector_generic as super
5353

54-
method is_immediate n = (n <= 32767) & (n >= -32768)
54+
method is_immediate n = (n <= 32767) && (n >= -32768)
5555

5656
method select_addressing exp =
5757
match select_addr exp with
@@ -95,9 +95,9 @@ method select_operation op args =
9595
super#select_operation op args
9696

9797
method select_logical op = function
98-
[arg; Cconst_int n] when n >= 0 & n <= 0xFFFF ->
98+
[arg; Cconst_int n] when n >= 0 && n <= 0xFFFF ->
9999
(Iintop_imm(op, n), [arg])
100-
| [Cconst_int n; arg] when n >= 0 & n <= 0xFFFF ->
100+
| [Cconst_int n; arg] when n >= 0 && n <= 0xFFFF ->
101101
(Iintop_imm(op, n), [arg])
102102
| args ->
103103
(Iintop op, args)

asmcomp/schedgen.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ let rec longest_path critical_outputs node =
8787
[] ->
8888
node.length <-
8989
if is_critical critical_outputs node.instr.res
90-
or node.instr.desc = Lreloadretaddr (* alway critical *)
90+
|| node.instr.desc = Lreloadretaddr (* alway critical *)
9191
then node.delay
9292
else 0
9393
| sons ->

asmcomp/selectgen.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ method private select_arith op = function
275275
(Iintop op, args)
276276

277277
method private select_shift op = function
278-
[arg; Cconst_int n] when n >= 0 & n < Arch.size_int * 8 ->
278+
[arg; Cconst_int n] when n >= 0 && n < Arch.size_int * 8 ->
279279
(Iintop_imm(op, n), [arg])
280280
| args ->
281281
(Iintop op, args)

asmcomp/sparc/selection.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ method select_operation op args =
4949
| (Cmuli, _) ->
5050
(Iextcall(".umul", false), args)
5151
| (Cdivi, [arg; Cconst_int n])
52-
when self#is_immediate n & n = 1 lsl (Misc.log2 n) ->
52+
when self#is_immediate n && n = 1 lsl (Misc.log2 n) ->
5353
(Iintop_imm(Idiv, n), [arg])
5454
| (Cdivi, _) ->
5555
(Iextcall(".div", false), args)
5656
| (Cmodi, [arg; Cconst_int n])
57-
when self#is_immediate n & n = 1 lsl (Misc.log2 n) ->
57+
when self#is_immediate n && n = 1 lsl (Misc.log2 n) ->
5858
(Iintop_imm(Imod, n), [arg])
5959
| (Cmodi, _) ->
6060
(Iextcall(".rem", false), args)

bytecomp/emitcode.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,13 @@ let emit_instr = function
228228
| Kconst sc ->
229229
begin match sc with
230230
Const_base(Const_int i) when is_immed i ->
231-
if i >= 0 & i <= 3
231+
if i >= 0 && i <= 3
232232
then out (opCONST0 + i)
233233
else (out opCONSTINT; out_int i)
234234
| Const_base(Const_char c) ->
235235
out opCONSTINT; out_int (Char.code c)
236236
| Const_pointer i ->
237-
if i >= 0 & i <= 3
237+
if i >= 0 && i <= 3
238238
then out (opCONST0 + i)
239239
else (out opCONSTINT; out_int i)
240240
| Const_block(t, []) ->
@@ -347,13 +347,13 @@ let rec emit = function
347347
| Kpush :: Kconst sc :: c ->
348348
begin match sc with
349349
Const_base(Const_int i) when is_immed i ->
350-
if i >= 0 & i <= 3
350+
if i >= 0 && i <= 3
351351
then out (opPUSHCONST0 + i)
352352
else (out opPUSHCONSTINT; out_int i)
353353
| Const_base(Const_char c) ->
354354
out opPUSHCONSTINT; out_int(Char.code c)
355355
| Const_pointer i ->
356-
if i >= 0 & i <= 3
356+
if i >= 0 && i <= 3
357357
then out (opPUSHCONST0 + i)
358358
else (out opPUSHCONSTINT; out_int i)
359359
| Const_block(t, []) ->

bytecomp/matching.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ let rec cut n l =
586586

587587
let make_test_sequence nofail check tst lt_tst arg const_lambda_list =
588588
let rec make_test_sequence const_lambda_list =
589-
if List.length const_lambda_list >= 4 & lt_tst <> Praise then
589+
if List.length const_lambda_list >= 4 && lt_tst <> Praise then
590590
split_sequence const_lambda_list
591591
else
592592
List.fold_right

bytecomp/simplif.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ let simplify_lambda lam =
136136
| Llet(str, v, l1, l2) ->
137137
count l2;
138138
(* If v is unused, l1 will be removed, so don't count its variables *)
139-
if str = Strict or count_var v > 0 then count l1
139+
if str = Strict || count_var v > 0 then count l1
140140
| Lletrec(bindings, body) ->
141141
List.iter (fun (v, l) -> count l) bindings;
142142
count body

bytecomp/translcore.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ let transl_prim prim args =
239239
| [{exp_desc = Texp_construct({cstr_tag = Cstr_constant _}, _)}; arg2] ->
240240
intcomp
241241
| [arg1; arg2] when has_base_type arg1 Predef.path_int
242-
or has_base_type arg1 Predef.path_char ->
242+
|| has_base_type arg1 Predef.path_char ->
243243
intcomp
244244
| [arg1; arg2] when has_base_type arg1 Predef.path_float ->
245245
floatcomp

debugger/pattern_matching.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let error_matching () =
6060
let same_name {qualid = name1} =
6161
function
6262
GRname name2 ->
63-
(name2 = "") or (name1.id = name2)
63+
(name2 = "") || (name1.id = name2)
6464
| GRmodname name2 ->
6565
name1 = name2
6666

driver/main.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ let process_implementation_file ppf name =
2424

2525
let process_file ppf name =
2626
if Filename.check_suffix name ".ml"
27-
or Filename.check_suffix name ".mlt" then begin
27+
|| Filename.check_suffix name ".mlt" then begin
2828
Compile.implementation ppf name;
2929
objfiles := (Filename.chop_extension name ^ ".cmo") :: !objfiles
3030
end
3131
else if Filename.check_suffix name !Config.interface_suffix then
3232
Compile.interface ppf name
3333
else if Filename.check_suffix name ".cmo"
34-
or Filename.check_suffix name ".cma" then
34+
|| Filename.check_suffix name ".cma" then
3535
objfiles := name :: !objfiles
3636
else if Filename.check_suffix name ext_obj
37-
or Filename.check_suffix name ext_lib then
37+
|| Filename.check_suffix name ext_lib then
3838
ccobjs := name :: !ccobjs
3939
else if Filename.check_suffix name ".c" then begin
4040
Compile.c_file name;

driver/optmain.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ let process_implementation_file ppf name =
2424

2525
let process_file ppf name =
2626
if Filename.check_suffix name ".ml"
27-
or Filename.check_suffix name ".mlt" then begin
27+
|| Filename.check_suffix name ".mlt" then begin
2828
Optcompile.implementation ppf name;
2929
objfiles := (Filename.chop_extension name ^ ".cmx") :: !objfiles
3030
end
3131
else if Filename.check_suffix name !Config.interface_suffix then
3232
Optcompile.interface ppf name
3333
else if Filename.check_suffix name ".cmx"
34-
or Filename.check_suffix name ".cmxa" then
34+
|| Filename.check_suffix name ".cmxa" then
3535
objfiles := name :: !objfiles
3636
else if Filename.check_suffix name ext_obj
37-
or Filename.check_suffix name ext_lib then
37+
|| Filename.check_suffix name ext_lib then
3838
ccobjs := name :: !ccobjs
3939
else if Filename.check_suffix name ".c" then begin
4040
Optcompile.c_file name;

lex/lexgen.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ let rec nullable = function
113113
Empty -> true
114114
| Chars _ -> false
115115
| Action _ -> false
116-
| Seq(r1,r2) -> nullable r1 & nullable r2
117-
| Alt(r1,r2) -> nullable r1 or nullable r2
116+
| Seq(r1,r2) -> nullable r1 && nullable r2
117+
| Alt(r1,r2) -> nullable r1 || nullable r2
118118
| Star r -> true
119119

120120
let rec firstpos = function

otherlibs/dynlink/dynlink.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ let allow_unsafe_modules b =
106106
unsafe_allowed := b
107107

108108
let check_unsafe_module cu =
109-
if (not !unsafe_allowed) & cu.cu_primitives <> []
109+
if (not !unsafe_allowed) && cu.cu_primitives <> []
110110
then raise(Error(Unsafe_file))
111111

112112
(* Check that all globals referenced in the object file have been

otherlibs/labltk/browser/editor.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ let send_phrase txt =
200200
sh#send ";;\n"
201201

202202
let search_pos_window txt ~x ~y =
203-
if txt.structure = [] & txt.psignature = [] then () else
203+
if txt.structure = [] && txt.psignature = [] then () else
204204
let `Linechar (l, c) = Text.index txt.tw ~index:(`Atxy(x,y), []) in
205205
let text = Jg_text.get_all txt.tw in
206206
let pos = Searchpos.lines_to_chars l ~text + c in
@@ -217,7 +217,7 @@ let search_pos_window txt ~x ~y =
217217
with Not_found -> ()
218218

219219
let search_pos_menu txt ~x ~y =
220-
if txt.structure = [] & txt.psignature = [] then () else
220+
if txt.structure = [] && txt.psignature = [] then () else
221221
let `Linechar (l, c) = Text.index txt.tw ~index:(`Atxy(x,y), []) in
222222
let text = Jg_text.get_all txt.tw in
223223
let pos = Searchpos.lines_to_chars l ~text + c in
@@ -326,8 +326,8 @@ class editor ~top ~menus = object (self)
326326
bind tw ~events:[`Modified([`Alt], `KeyPress)] ~action:ignore;
327327
bind tw ~events:[`KeyPress] ~fields:[`Char]
328328
~action:(fun ev ->
329-
if ev.ev_Char <> "" &
330-
(ev.ev_Char.[0] >= ' ' or
329+
if ev.ev_Char <> "" &&
330+
(ev.ev_Char.[0] >= ' ' ||
331331
List.mem ev.ev_Char.[0]
332332
(List.map ~f:control ['d'; 'h'; 'i'; 'k'; 'o'; 't'; 'w'; 'y']))
333333
then Textvariable.set txt.modified "modified");
@@ -440,7 +440,7 @@ class editor ~top ~menus = object (self)
440440
close_in file;
441441
Text.mark_set tw ~mark:"insert" ~index;
442442
Text.see tw ~index;
443-
if Filename.check_suffix name ".ml" or
443+
if Filename.check_suffix name ".ml" ||
444444
Filename.check_suffix name ".mli"
445445
then begin
446446
if !lex_on_load then self#lex ();

0 commit comments

Comments
 (0)