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-2/src/compiler/ElabData/types/typesutil.sml
ViewVC logotype

Diff of /sml/branches/primop-branch-2/src/compiler/ElabData/types/typesutil.sml

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

revision 1951, Wed Jul 5 21:31:22 2006 UTC revision 1952, Thu Jul 6 03:07:18 2006 UTC
# Line 506  Line 506 
506                    | _ => equalType(spec,actual))                    | _ => equalType(spec,actual))
507      end handle CompareTypes => false      end handle CompareTypes => false
508    
509    (* matchTypes -- one-way matching of actual to spec type; yields
510                     list of instantiation metavariables
511       Parameters:
512            spec -- specification type
513            actual -- actual type
514       Returns:
515            (specGenericTvs, -- spec metavariables that are generalized
516                                in the match
517             actParamTvs) -- metavariables in actual type that are instantiations
518                            of spec metavariables in match
519       Invariant: specGenericTvs are always instantiated but
520                  actInstTvs are never generalized (because they are only
521                  meaningful in this function and are immediately generalized
522                  away.
523       Comments: compareTypes does pruning so there is no need to prune in
524                 this function or anywhere else that uses compareTypes or
525                 matchTypes.
526     *)
527    fun matchTypes (specTy, actualTy) =
528        (* If specTy is not an instance of actualTy, then give up. *)
529        if compareTypes(specTy, actualTy) then
530            let
531                val (actinst, actParamTvs) =
532                    instantiatePoly actual
533                val (specinst, specGenericTvs) =
534                    instantiatePoly spec
535            in
536                (specGenericTvs, actParamTvs)
537            end
538        else ([], [])
539    
540  (* given a single-type-variable type, extract out the tyvar *)  (* given a single-type-variable type, extract out the tyvar *)
541  fun tyvarType (VARty (tv as ref(OPEN _))) = tv  fun tyvarType (VARty (tv as ref(OPEN _))) = tv
542    | tyvarType (VARty (tv as ref(INSTANTIATED t))) = tyvarType t    | tyvarType (VARty (tv as ref(INSTANTIATED t))) = tyvarType t

Legend:
Removed from v.1951  
changed lines
  Added in v.1952

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