예제 #1
0
파일: TypeScheme.cs 프로젝트: minib00m/JNP2
        public override Type Instantiate()
        {
            var subst = new Substitution();

            foreach (var arg in Arguments.Where(arg => arg.RigidName == null))
            {
                subst.Bind(arg, new TypeVariable());
            }
            return(Inner.Perform(subst));
        }
예제 #2
0
 public void Unify(Type that, Substitution substitution)
 {
     try
     {
         Perform(substitution).SubstUnify(that.Perform(substitution), substitution);
     }
     catch (StackedException ex)
     {
         var sb = new StringBuilder("While trying to unify ");
         PrettyPrint(ex.PrettyPrinter, sb, 0);
         sb.Append(" with ");
         that.PrettyPrint(ex.PrettyPrinter, sb, 0);
         ex.Push(sb.ToString());
         throw;
     }
 }
예제 #3
0
        public override void DoUnify(Type var, Substitution substitution)
        {
            if (this == var)
            {
                return;
            }

            if (RigidName != null)
            {
                var.UnifyWithRigid(this, substitution);
            }
            else
            {
                if (var.FreeVariables().Contains(this))
                {
                    throw OccursCheckException.Create(var.Perform(substitution), this.Perform(substitution));
                }
                substitution.Bind(this, var);
            }
        }
예제 #4
0
 public override Type Perform(Substitution substitution)
 {
     return(new FunctionType(Argument.Perform(substitution), Result.Perform(substitution)));
 }
예제 #5
0
 public virtual void DoUnify(Type that, Substitution substitution)
 {
     throw TypeException.Create(Perform(substitution), that.Perform(substitution));
 }