Skip to content

Commit

Permalink
Remove resolved TODO's
Browse files Browse the repository at this point in the history
  • Loading branch information
filipeom committed Jul 23, 2024
1 parent 541da1f commit 735ff5c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
15 changes: 7 additions & 8 deletions lib/eval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,15 @@ module Real = struct
let relop (op : relop) (v1 : Value.t) (v2 : Value.t) : bool =
let f =
match op with
| Lt -> ( < )
| Le -> ( <= )
| Gt -> ( > )
| Ge -> ( >= )
| Eq -> ( = )
| Ne -> ( <> )
| Lt -> Float.( < )
| Le -> Float.( <= )
| Gt -> Float.( > )
| Ge -> Float.( >= )
| Eq -> Float.( = )
| Ne -> Float.( <> )
| _ ->
Fmt.failwith {|relop: Unsupported real operator "%a"|} Ty.pp_relop op
in
(* TODO: check that this is doing what we want with NaN *)
let f x y = f (Float.compare x y) 0 in
f (of_value 1 (`Relop op) v1) (of_value 2 (`Relop op) v2)

let cvtop (op : cvtop) (v : Value.t) : Value.t =
Expand Down Expand Up @@ -931,6 +929,7 @@ end

module F64CvtOp = struct
Float.is_nan

let promote_f32 x =
let xf = F32.to_float x in
if Float.(xf = xf) then F64.of_float xf
Expand Down
5 changes: 1 addition & 4 deletions lib/num.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ let compare n1 n2 =
| I32 i1, I32 i2 -> Int32.compare i1 i2
| I64 i1, I64 i2 -> Int64.compare i1 i2
| F32 i1, F32 i2 ->
(* TODO: is this really what we want on `nan` ? *)
Float.compare (Int32.float_of_bits i1) (Int32.float_of_bits i2)
| F64 i1, F64 i2 ->
Float.compare (Int64.float_of_bits i1) (Int64.float_of_bits i2)
Expand All @@ -42,9 +41,7 @@ let compare n1 n2 =
| F32 _, F64 _ -> -1
| F64 _, _ -> 1

let equal (n1 : t) (n2 : t) : bool =
(* TODO: is this what we want on `nan` ? *)
compare n1 n2 = 0
let equal (n1 : t) (n2 : t) : bool = compare n1 n2 = 0

let num_of_bool (b : bool) : t = I32 (if b then 1l else 0l)

Expand Down
4 changes: 1 addition & 3 deletions lib/value.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ let rec equal (v1 : t) (v2 : t) : bool =
match (v1, v2) with
| True, True | False, False | Unit, Unit -> true
| Int x1, Int x2 -> Int.equal x1 x2
| Real x1, Real x2 ->
(* TODO: is this what we want regarding `nan` ? *)
Float.equal x1 x2
| Real x1, Real x2 -> Float.equal x1 x2
| Str x1, Str x2 -> String.equal x1 x2
| Num x1, Num x2 -> Num.equal x1 x2
| List l1, List l2 -> List.equal equal l1 l2
Expand Down

0 comments on commit 735ff5c

Please sign in to comment.