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

SCM Repository

[smlnj] Diff of /sml/branches/primop-branch-3/compiler/FLINT/trans/modtype.sml
ViewVC logotype

Diff of /sml/branches/primop-branch-3/compiler/FLINT/trans/modtype.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3507, Fri Feb 26 15:55:08 2010 UTC revision 3508, Fri Feb 26 23:23:08 2010 UTC
# Line 184  Line 184 
184    
185  (* function that types a functor body entDecl, producing an ltycEnv *)  (* function that types a functor body entDecl, producing an ltycEnv *)
186    
187  fun typeEntDecl (entDec, ltenv, penv) : ltycEnv =  datatype ltycTree
188      let fun tycDec (TYCdec(ev,tycExp), ltycenv) : ltycEnv =    = TYCleaf of ltyc
189              let val ltyc =    | FCTleaf of ltyc
190      | STRnode of ltycEnv  (* don't need ltycs for structures *)
191    
192    withtype ltycEnv = (entvar * ltyctree) list
193    
194    fun typeBodyDecl (entDec, sign, ltenv, penv) : ltycEnv =
195        (* should entDec return a cumulative or incremental ltycEnv? *)
196        let fun entDec (TYCdec(ev,tycExp), ltycenv) : ltycEnv =
197                let val ltyc =  (* tycon leaf *)
198                      case tycExp                      case tycExp
199                       of VARtyc entpath => lookPathLtyc(ltenv, entpath)                       of VARtyc entpath => lookPathLtyc(ltycenv, entpath)
200                        | CONSTtyc tycon => TT.tyconToTyc(tycon, penv, penvDepth(penv))                        | CONSTtyc tycon => TT.tyconToTyc(tycon, emptyPenv, 0)
201                              (* nonvolatile tycon *)
202                        | FORMtyc tycon => (* lookup in penv? same as CONSTtyc? *)                        | FORMtyc tycon => (* lookup in penv? same as CONSTtyc? *)
203                 in bindLtyc(ev, TYCleaf ltyc, ltycenv)
204                end
205              | entDec (STRdec(ev,strExp,_), ltycenv) =  (* structure node *)
206                (* we don't need an ltyc for the structure elements, just a nested
207                 * ltycEnv *)
208                let val strltycenv =
209                        case strExp
210                         of VARstr entpath => lookPathLtyc(ltycenv, entpath)
211                          | CONSTstr strEnt =>
212                            (* nonvolatile constant? or can it be volatile?
213                             * or would a volatile str always be represented by
214                             * a VARstr?
215                             * Can we ignore this because none of its elements
216                             * can be primaries? No. *)
217                            ... getStrTycs(..., strEnt, ...) ...
218                            (* getStrTycs needs to be replaced by something
219                             * like getStrLtycEnv? *)
220                          | STRUCTURE {entDec,...} => entDec(entDec, ltycenv)
221                            (* is it ok to return the cumulative ltycEnv here? *)
222                          | APPLY (fctExp, strExp) =>
223                          | LETstr (localDec,strExp) =>
224                          | ABSstr (sign, strExp) =>
225                          | FORMstr fctsig =>  bug "FORMstr"
226                             (* can't happen? Shouldn't find FORMstr embedded
227                              * within a regular function body.  It can only
228                              * occur as the whole functor body, instead of
229                              * a STRUCTURE *)
230                          | CONSTRAINstr {boundvar, raw, coercion } =>
231                            (* is this what we always have for a body where
232                             * the functor has a result signature? *)
233                 in bindLtyc(ev, STRnode strltycenv, ltycenv)
234                end
235              | entDec (FCTdec(ev,fctExp), ltycenv) =  (* functor leaf *)
236                let val ltyc =
237                        case fctExp
238                         of VARfct entpath => lookPathLtyc(ltycenv, entpath)
239                          | CONSTfct fctEnt => getFctTyc( ... fctEnt ... )
240                          | LAMBDA {param, body} =>
241                          | LETfct (entDec, fctExp) =>
242               in bindLtyc(ev, ltyc, ltycenv)               in bindLtyc(ev, ltyc, ltycenv)
243              end              end
244              | entDec (SEQdec entDecs, ltycenv) =
245                 foldl (fn (entDec, ltycenv') => entDec(entDec, ltycenv')) ltycenv entDecs
246              | entDec (LOCALdec (locDecs, bodyDecs), ltycenv) =
247                 entDec(bodyDecs, entDec(locDecs, ltycenv))
248                 (* we don't bother to hide the local bindings *)
249              | entDec (EMPTYdec ltycenv) = ltycenv
250              | entDec (ERRORdec, _) = bug "typeEntDecl ERRORdec"
251       in       in
252    
253      end      end
# Line 214  Line 269 
269    
270          val M.LAMBDA{param,body} = exp          val M.LAMBDA{param,body} = exp
271              (* need param field to define bodyEnv below *)              (* need param field to define bodyEnv below *)
272            val bodyPrimaries = (* get primaries for bodysig *)
273    
274       in case body       in case body
275            of M.STRUCTURE{entDec,...} =>  (* regular functor *)            of M.STRUCTURE{entDec,...} =>  (* regular functor *)
# Line 228  Line 284 
284                     (* how do we use parameter primaries? Presumably these                     (* how do we use parameter primaries? Presumably these
285                      * should translate to tcc_var tycs in paramLtyEnv? Or does this                      * should translate to tcc_var tycs in paramLtyEnv? Or does this
286                      * get taken care of when translating tycons against penv? *)                      * get taken care of when translating tycons against penv? *)
287                   val bodyLtyc = LT.STR(getPrimaries(bodyPrimaries, ltenvBody))                   val bodyLtyc = LT.tcc_str(getPrimaries(bodyPrimaries, ltenvBody))
288                     (* extract body primaries from ltenvBody *)                     (* extract body primaries from ltenvBody *)
289                   val paramTkinds = getTkind map paramPrimaries                   val paramTkinds = getTkind map paramPrimaries
290                in LT.tcc_fun(paramTkinds, bodyLtyc)                in LT.tcc_fun(paramTkinds, bodyLtyc)
# Line 241  Line 297 
297                 * is external to the formal functor and so can't be computed                 * is external to the formal functor and so can't be computed
298                 * here. *)                 * here. *)
299    
300  (* old stuff -----------------------------  (* old stuff, before typing body entDecl -----------------------------
301          val resultEnt = evalEnt(APP(fctEntity,paramRlzn), ...) ???          val resultEnt = evalEnt(APP(fctEntity,paramRlzn), ...) ???
302              (* apply the functor to the parameter instantiation, i.e.              (* apply the functor to the parameter instantiation, i.e.
303               * the one that was saved in the fctEntity (= functor realization) *)               * the one that was saved in the fctEntity (= functor realization) *)

Legend:
Removed from v.3507  
changed lines
  Added in v.3508

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