From d7cbeba731716f176f4c116cfe92f3ec246e1396 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 21 Dec 2010 15:58:17 -0800 Subject: [PATCH] rustboot: Only bottom out at opaque IL types after finding two cycles. DON'T ASK ME WHY THIS WORKS. --- src/boot/me/semant.ml | 2 +- src/boot/util/common.ml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/boot/me/semant.ml b/src/boot/me/semant.ml index cea0b479b13..019cd13ea12 100644 --- a/src/boot/me/semant.ml +++ b/src/boot/me/semant.ml @@ -2425,7 +2425,7 @@ and referent_type Some parent_tags when boxed && parent_tags <> [] - && List.mem ttag parent_tags + && (list_count ttag parent_tags) > 1 && is_back_edge ttag (List.hd parent_tags) -> Il.StructTy [| word; Il.OpaqueTy |] | _ -> tag ttag diff --git a/src/boot/util/common.ml b/src/boot/util/common.ml index 7a95573cd4e..f9b18246c79 100644 --- a/src/boot/util/common.ml +++ b/src/boot/util/common.ml @@ -380,6 +380,13 @@ let rec list_drop n ls = else list_drop (n-1) (List.tl ls) ;; +let rec list_count elem lst = + match lst with + [] -> 0 + | h::t when h = elem -> 1 + (list_count elem t) + | _::t -> list_count elem t +;; + (* * Auxiliary pair functions.