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/Elaborator/types/unify.sml
ViewVC logotype

Diff of /sml/branches/primop-branch-3/compiler/Elaborator/types/unify.sml

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

revision 2560, Wed May 16 22:24:49 2007 UTC revision 2561, Thu May 17 03:41:11 2007 UTC
# Line 389  Line 389 
389              | _ => raise Unify (TYP(VARty(var), ty))              | _ => raise Unify (TYP(VARty(var), ty))
390        end        end
391    
392      (* special handling of SCHEME tyvar instantiation:
393       * ty must reduce to either a tyvar, var', in which case we unify
394       * var and var' (in that order!), or
395       * ty must reduce to a (basic) constant type, in which case ty
396       * does not contain any type variables, and the occurrence check
397       * (i.e. adjustType) is not necessary *)
398    | instTyvar (var as ref(i as SCHEME eq),ty) =    | instTyvar (var as ref(i as SCHEME eq),ty) =
399        let val ty' = TU.headReduceType ty        (case ty
        in case ty'  
400              of VARty var1 => unifyTyvars(var, var1)              of VARty var1 => unifyTyvars(var, var1)
401               | CONty(tyc,nil) => var := INSTANTIATED ty'                (* because of asymmetric handling of SCHEME tyvars in
402                   (* valid potential resolution type. Could check                 * unifyTyvars -- here SCHEME must be first arg *)
403                    * for membership in allowed basic types (e.g. int, real, ...) *)            | CONty(tyc,nil) => var := INSTANTIATED ty
404               | _ => raise Unify(OVLD ty')            | CONty(tyc,_) => (* nonnull arguments *)
405        end               (case TU.nullReduceType ty
406                    of VARty var1 => unifyTyvars(var, var1)
407                     | ty' as CONty(tyc,nil) => var := INSTANTIATED ty'
408                     (* valid potential resolution type. Could check more precisely
409                      * for membership in the allowed basic types
410                      * (e.g. int, real, ...) *)
411                     | WILDCARDty => ()
412                     | _ => raise Unify(OVLD ty))
413              | WILDCARDty => ()
414              | _ => bug "instTyvar: SCHEME")
415    
416    | instTyvar (var as ref(i as LITERAL{kind,...}),ty) =    | instTyvar (var as ref(i as LITERAL{kind,...}),ty) =
417        (case TU.headReduceType ty        (case TU.headReduceType ty
418           of WILDCARDty => ()           of WILDCARDty => ()
419            | ty' =>            | ty' =>
420               if OLL.isLiteralTy(kind,ty')               if OLL.isLiteralTy(kind,ty')
421               then var := INSTANTIATED ty               then var := INSTANTIATED (TU.nullReduceType ty)
422               else raise Unify (LIT i))   (* could return the ty for error msg*)               else raise Unify (LIT i))   (* could return the ty for error msg*)
423    
424    | instTyvar (ref(i as UBOUND _),ty) =    | instTyvar (ref(i as UBOUND _),ty) =

Legend:
Removed from v.2560  
changed lines
  Added in v.2561

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