Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/compiler/Semant/types/types.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/Semant/types/types.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16 - (view) (download)

1 : monnier 16 (* Copyright 1997 by Bell Laboratories *)
2 :     (* types.sml *)
3 :    
4 :     structure Types : TYPES =
5 :     struct
6 :    
7 :     local structure A = Access
8 :     structure DI = DebIndex
9 :     structure EP = EntPath
10 :     structure IP = InvPath
11 :     structure LT = PLambdaType
12 :     structure PT = PrimTyc
13 :     structure S = Symbol
14 :     structure ST = Stamps
15 :     in
16 :    
17 :     type label = S.symbol
18 :     type polysign = bool list (* equality property indicator *)
19 :    
20 :     datatype eqprop = YES | NO | IND | OBJ | DATA | ABS | UNDEF
21 :    
22 :     datatype litKind = INT | WORD | REAL | CHAR | STRING
23 :    
24 :     datatype openTvKind
25 :     = META (* metavariables:
26 :     depth = infinity for meta-args
27 :     depth < infinity for lambda bound *)
28 :     | FLEX of (label * ty) list (* flex record variables *)
29 :    
30 :     and tvKind
31 :     = INSTANTIATED of ty (* instantiation of an OPEN *)
32 :     | OPEN of
33 :     {depth: int, eq: bool, kind: openTvKind}
34 :     | UBOUND of (* explicit type variables *)
35 :     {depth: int, eq: bool, name: Symbol.symbol}
36 :     | LITERAL of (* type of a literal *)
37 :     {kind: litKind, region: SourceMap.region}
38 :     | SCHEME of bool (* overloaded operator type scheme variable
39 :     * arg is true if must be instantiated to equality type *)
40 :     | LBOUND of {depth: DI.depth, num: int}
41 :    
42 :     and tycpath
43 :     = TP_VAR of {depth: DI.depth, num: int, kind: LT.tkind}
44 :     | TP_TYC of tycon
45 :     | TP_FCT of tycpath list * tycpath list
46 :     | TP_APP of tycpath * tycpath list
47 :     | TP_SEL of tycpath * int
48 :    
49 :     and tyckind
50 :     = PRIMITIVE of PT.primtyc
51 :     | DATATYPE of
52 :     {index: int,
53 :     stamps: ST.stamp vector,
54 :     root : EP.entVar option, (* the root field used by type spec only *)
55 :     freetycs: tycon list,
56 :     family : dtypeFamily}
57 :     | ABSTRACT of tycon
58 :     | FLEXTYC of tycpath (* instantiated formal type constructor *)
59 :     | FORMAL (* used only inside signatures *)
60 :     | TEMP (* used only during datatype elaborations *)
61 :    
62 :     and tycon
63 :     = GENtyc of
64 :     {stamp : ST.stamp,
65 :     arity : int,
66 :     eq : eqprop ref,
67 :     kind : tyckind,
68 :     path : IP.path}
69 :     | DEFtyc of
70 :     {stamp : ST.stamp,
71 :     tyfun : tyfun,
72 :     strict: bool list,
73 :     path : IP.path}
74 :     | PATHtyc of (* used only inside signatures *)
75 :     {arity : int,
76 :     entPath : EP.entPath,
77 :     path : IP.path}
78 :     | RECORDtyc of label list
79 :     | RECtyc of int (* used only in domain type of dconDesc *)
80 :     | FREEtyc of int (* used only in domain type of dconDesc *)
81 :     | ERRORtyc
82 :    
83 :     and ty
84 :     = VARty of tyvar
85 :     | IBOUND of int
86 :     | CONty of tycon * ty list
87 :     | POLYty of {sign: polysign, tyfun: tyfun}
88 :     | WILDCARDty
89 :     | UNDEFty
90 :    
91 :     and tyfun
92 :     = TYFUN of {arity: int, body: ty}
93 :    
94 :     withtype tyvar = tvKind ref
95 :    
96 :     (* datacon description used in dtmember *)
97 :     and dconDesc =
98 :     {name: S.symbol,
99 :     rep: A.conrep,
100 :     domain: ty option}
101 :    
102 :     (* member of a family of (potentially) mutually recursive datatypes *)
103 :     and dtmember =
104 :     {tycname: S.symbol,
105 :     arity: int,
106 :     eq: eqprop ref,
107 :     dcons: dconDesc list,
108 :     sign: A.consig}
109 :    
110 :     and dtypeFamily =
111 :     {mkey: ST.stamp,
112 :     members: dtmember vector,
113 :     lambdatyc: (LT.tyc * DI.depth) option ref}
114 :    
115 :     fun mkTyvar(kind: tvKind) : tyvar = ref kind
116 :    
117 :     fun copyTyvar(tv: tyvar) = ref(!tv)
118 :    
119 :     val infinity = 10000000
120 :    
121 :     datatype datacon (* data constructors *)
122 :     = DATACON of
123 :     {name : S.symbol,
124 :     typ : ty,
125 :     rep : A.conrep,
126 :     const : bool, (* redundant, could be determined from typ *)
127 :     sign : A.consig} (* redundant, ditto *)
128 :    
129 :     end (* local *)
130 :     end (* structure Types *)
131 :    

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0