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/FLINT/flint/flint.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/FLINT/flint/flint.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24 - (view) (download)
Original Path: sml/branches/SMLNJ/src/compiler/FLINT/flint/flint.sml

1 : monnier 16 (* COPYRIGHT (c) 1997 YALE FLINT PROJECT *)
2 :     (* flint.sml *)
3 :    
4 :     structure FLINT : FLINT =
5 :     struct
6 :    
7 :     local structure A = Access (* should go away soon *)
8 :     structure LD = LtyDef
9 :     structure LV = LambdaVar
10 :     structure PO = PrimOp
11 :     structure S = Symbol
12 :     in
13 :    
14 :     type tkind = LD.tkind
15 :     type tyc = LD.tyc
16 :     type lty = LD.lty
17 : monnier 24 type tvar = LV.lvar
18 : monnier 16 type lvar = LV.lvar
19 :    
20 :     (** classifying various kinds of functions *)
21 : monnier 24 type fkind =
22 :     {isrec : lty list option,
23 :     raw : LD.rawflag,
24 :     isfct : bool}
25 : monnier 16
26 :     (** classifying various kinds of records *)
27 :     datatype rkind
28 : monnier 24 = RK_VECTOR of tyc (* vector: all elements have same type *)
29 :     | RK_RECORD (* tuple: all elements are monomorphic *)
30 :     | RK_STRUCT (* module: elements may be polymorphic *)
31 : monnier 16
32 :     (*
33 :     * dcon records the name of the constructor (for debugging), the
34 : monnier 24 * corresponding conrep, and the lambda type lty; the value carrying
35 :     * data constructors must have the arrow type.
36 : monnier 16 *)
37 :     type dcon = S.symbol * A.conrep * lty
38 :    
39 :     (*
40 :     * con: used to specify all possible switching statements. Efficient switch
41 :     * generation can be applied to DATAcon and INTcon. Otherwise, the switch is
42 :     * just a short-hand of the binary branch trees. Some of these instances
43 : monnier 24 * such as REALcon probably should go away.
44 : monnier 16 *)
45 :     datatype con
46 : monnier 24 = DATAcon of dcon * tyc list * lvar list
47 : monnier 16 | INTcon of int (* should use InfInf.int *)
48 :     | INT32con of Int32.int
49 :     | WORDcon of word
50 :     | WORD32con of Word32.word
51 :     | REALcon of string
52 :     | STRINGcon of string
53 :     | VLENcon of int
54 :    
55 :     (** simple values, including variables and static constants. *)
56 :     datatype value
57 :     = VAR of lvar
58 :     | INT of int (* should use InfInf.int *)
59 :     | INT32 of Int32.int
60 :     | WORD of word
61 :     | WORD32 of Word32.word
62 :     | REAL of string
63 :     | STRING of string
64 :    
65 :     (** the definitions of the lambda expressions *)
66 :     datatype lexp
67 :     = RET of value list
68 :     | LET of lvar list * lexp * lexp
69 :    
70 :     | FIX of fundec list * lexp
71 : monnier 24 | APP of value * value list
72 : monnier 16
73 : monnier 24 | TFN of tfundec * lexp
74 : monnier 16 | TAPP of value * tyc list
75 :    
76 :     | SWITCH of value * A.consig * (con * lexp) list * lexp option
77 : monnier 24 | CON of dcon * tyc list * value list * lvar * lexp
78 : monnier 16
79 :     | RECORD of rkind * value list * lvar * lexp
80 :     | SELECT of value * int * lvar * lexp (* add rkind ? *)
81 :    
82 :     | RAISE of value * lty list
83 :     | HANDLE of lexp * value
84 : monnier 24 | ETAG of tyc * value * lvar * lexp
85 : monnier 16
86 :     | PRIMOP of primop * value list * lvar * lexp
87 : monnier 24 | GENOP of dict * primop * value list * lvar * lexp
88 : monnier 16
89 : monnier 24 | WRAP of tyc * value * lvar * lexp
90 :     | UNWRAP of tyc * value * lvar * lexp
91 :     (*
92 :     * | PACK of lty * tyc list * tyc list * value * lvar * lexp
93 :     * | BRANCH of primop * value list * lexp * lexp (* comparison *)
94 :     * | ARITH of primop * value list * lvar * lexp (* arithmetic *)
95 :     * | SETTER of primop * value list * lexp (* mutator *)
96 :     * | LOOKER of primop * value list * lvar * lexp (* selector *)
97 :     * | PURE of primop * value list * lvar * lexp (* constructor? *)
98 :     *)
99 :    
100 : monnier 16 withtype fundec = fkind * lvar * (lvar * lty) list * lexp
101 : monnier 24 and tfundec = lvar * (tvar * tkind) list * lexp
102 :     and primop = PO.primop * lty * tyc list
103 : monnier 16 and dict = {default: lvar, table: (tyc list * lvar) list}
104 :    
105 : monnier 24 type prog = fundec (* was "lvar * lty * lexp" *)
106 : monnier 16
107 : monnier 24 (*
108 :     * TODO: 0. what can we expect from the use of "tvar" ?
109 :     * 1. organize the set of valid primops and primtycs
110 :     * 2. organize the set of standard constants and constructors
111 :     * 3. what is the std way of adding pre-defined GENOP ?
112 :     * 4. how to clean up pack, wrap, and unwrap ?
113 :     * 5. how to standardize the fkind and rkind ?
114 :     * 6. how to handle the wrappers in CON and DECON (SWITCH) ?
115 :     * 7. how to avoid the use of conrep ? what about exceptions ?
116 :     *)
117 :    
118 : monnier 16 end (* local *)
119 :     end (* structure FLINT *)

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