|
|
1.1 root 1: (* Copyright 1989 by AT&T Bell Laboratories *)
2: (* conrep.sml *)
3:
4: structure ConRep = struct
5:
6: local open Basics BasicTypes in
7:
8: fun count predicate l
9: = let fun test (a::rest,acc) = test (rest,if predicate a then 1+acc else acc)
10: | test (nil,acc) = acc
11: in test (l,0)
12: end
13:
14: fun boxed ([(_,false,_)]: (Symbol.symbol*bool*ty) list): conrep list = [TRANSPARENT]
15: | boxed predcons =
16: let val multiple = (count (fn (_,const,_) => not const) predcons) > 1
17: fun decide (i,j,(_,true,_)::rest) = CONSTANT i :: decide(i+1,j,rest)
18: | decide (i,j,(_,_,CONty(_,[argty,_]))::rest) =
19: (case (multiple,argty)
20: of (false,CONty(ref(TYCON{kind=RECORDtyc(_::_::_), ...}),_)) =>
21: TRANSPARENT :: decide(i,j,rest)
22: | _ => TAGGED j :: decide(i,j+1,rest))
23: | decide (_,_,nil) = []
24: | decide _ = ErrorMsg.impossible "ConRep.boxed"
25: in decide(0,0,predcons)
26: end
27:
28: end (* local *)
29:
30: end (* structure ConRep *)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.