Skip to content

Commit

Permalink
TOP
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Apr 18, 2024
1 parent 104b0f5 commit e3864b7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions compiler/lib/flow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ let rec the_shape_of info x =
info
(fun x ->
if Var.ISet.mem info.info_possibly_mutable x
then Shape.Bot "possibly_mutable"
then Shape.Top "possibly_mutable"
else
match Shape.get x with
| Some shape -> shape
Expand All @@ -411,16 +411,16 @@ let rec the_shape_of info x =
| Expr (Block (_, a, _, Immutable)) ->
Shape.Block (List.map ~f:(the_shape_of info) (Array.to_list a))
| Expr (Closure (l, _)) ->
Shape.Function { arity = List.length l; pure = false; res = Bot "unk" }
Shape.Function { arity = List.length l; pure = false; res = Top "unk" }
| Expr (Special (Alias_prim name)) -> (
try
let arity = Primitive.arity name in
let pure = Primitive.is_pure name in
Shape.Function { arity; pure; res = Bot "unk" }
with _ -> Bot "other")
| _ -> Shape.Bot "other"))
(Bot "init")
(fun _u _v -> Shape.Bot "merge")
Shape.Function { arity; pure; res = Top "unk" }
with _ -> Top "other")
| _ -> Shape.Top "other"))
(Top "init")
(fun _u _v -> Shape.Top "merge")
x

let build_subst (info : Info.t) vars =
Expand Down
6 changes: 3 additions & 3 deletions compiler/lib/shape.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
open! Stdlib

type t =
| Bot of string
| Top of string
| Block of t list
| Function of
{ arity : int
Expand All @@ -30,7 +30,7 @@ type t =

let rec to_string (shape : t) =
match shape with
| Bot s -> if true then "N" else Printf.sprintf "N(%s)" s
| Top s -> if true then "N" else Printf.sprintf "N(%s)" s
| Block l -> "[" ^ String.concat ~sep:"," (List.map ~f:to_string l) ^ "]"
| Function { arity; _ } -> Printf.sprintf "F(%d)" arity

Expand Down Expand Up @@ -59,7 +59,7 @@ let assign x shape = Hashtbl.add state (Var x) shape
let propagate x offset target =
match Hashtbl.find_opt state (Var x) with
| None -> ()
| Some (Bot _ | Function _) -> ()
| Some (Top _ | Function _) -> ()
| Some (Block l) -> Hashtbl.replace state (Var target) (List.nth l offset)

let get x = Hashtbl.find_opt state (Var x)
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/shape.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*)

type t =
| Bot of string
| Top of string
| Block of t list
| Function of
{ arity : int
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/specialize.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let function_arity info x =
| Some shape -> (
match shape with
| Function { arity; _ } -> Some arity
| Block _ | Bot _ -> None)
| Block _ | Top _ -> None)
| None ->
get_approx
info
Expand Down

0 comments on commit e3864b7

Please sign in to comment.