예제 #1
0
 public virtual void SubstUnify(Type that, Substitution substitution)
 {
     if (this != that)
     {
         that.DoUnify(this, substitution);
     }
 }
예제 #2
0
 public override void SubstUnify(Type that, Substitution substitution)
 {
     if (that != this)
     {
         that.DoUnify(this, substitution);
     }
 }
예제 #3
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));
        }
예제 #4
0
파일: TypeScheme.cs 프로젝트: minib00m/JNP2
        public override Type Perform(Substitution substitution)
        {
            var local = substitution.Local();

            foreach (var arg in Arguments)
            {
                local.Map = local.Map.Remove(arg);
            }
            return(new TypeScheme(Arguments, Inner.Perform(local)));
        }
예제 #5
0
파일: TupleType.cs 프로젝트: minib00m/JNP2
        public override void DoUnify(TupleType var, Substitution substitution)
        {
            if (Arguments.Count != var.Arguments.Count)
            {
                throw TypeException.Create(this.Perform(substitution), var.Perform(substitution));
            }

            for (var i = 0; i < Arguments.Count; ++i)
            {
                Arguments[i].Perform(substitution).Unify(var.Arguments[i].Perform(substitution), substitution);
            }
        }
예제 #6
0
        public override void UnifyWithRigid(TypeVariable var, Substitution substitution)
        {
            if (var == this)
            {
                return;
            }

            if (RigidName != null)
            {
                throw RigidTypeException.Create(RigidName, var);
            }

            substitution.Bind(this, var);
        }
예제 #7
0
        public override Type Perform(Substitution substitution)
        {
            if (!substitution.Map.ContainsKey(this))
            {
                return(this);
            }

            if (RigidName != null)
            {
                throw RigidTypeException.Create(RigidName, substitution.Map[this]);
            }

            return(substitution.Map[this].Perform(substitution));
        }
예제 #8
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;
     }
 }
예제 #9
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);
            }
        }
예제 #10
0
 public override void DoUnify(FunctionType var, Substitution substitution)
 {
     Argument.Perform(substitution).Unify(var.Argument.Perform(substitution), substitution);
     Result.Perform(substitution).Unify(var.Result.Perform(substitution), substitution);
 }
예제 #11
0
 public override Type Perform(Substitution substitution)
 {
     return(new FunctionType(Argument.Perform(substitution), Result.Perform(substitution)));
 }
예제 #12
0
 public override void DoUnify(FloatingType var, Substitution substitution)
 {
 }
예제 #13
0
 public override void DoUnify(CharacterType var, Substitution substitution)
 {
 }
예제 #14
0
 public virtual void DoUnify(TupleType var, Substitution substitution)
 {
     DoUnify((Type)var, substitution);
 }
예제 #15
0
 public virtual void DoUnify(TypeVariable var, Substitution substitution)
 {
     var.DoUnify(this, substitution);
 }
예제 #16
0
파일: TupleType.cs 프로젝트: minib00m/JNP2
 public override Type Perform(Substitution substitution)
 {
     return(new TupleType(Arguments.Select(x => x.Perform(substitution)).ToList()));
 }
예제 #17
0
 public virtual void DoUnify(FunctionType var, Substitution substitution)
 {
     DoUnify((Type)var, substitution);
 }
예제 #18
0
 public virtual void DoUnify(FloatingType var, Substitution substitution)
 {
     DoUnify((Type)var, substitution);
 }
예제 #19
0
 public virtual void DoUnify(CharacterType var, Substitution substitution)
 {
     DoUnify((Type)var, substitution);
 }
예제 #20
0
 public virtual void DoUnify(IntegralType var, Substitution substitution)
 {
     DoUnify((Type)var, substitution);
 }
예제 #21
0
 public override Type Perform(Substitution substitution)
 {
     return(this);
 }
예제 #22
0
 public override void DoUnify(IntegralType var, Substitution substitution)
 {
 }
예제 #23
0
 public virtual void DoUnify(Type that, Substitution substitution)
 {
     throw TypeException.Create(Perform(substitution), that.Perform(substitution));
 }
예제 #24
0
 public abstract Type Perform(Substitution substitution);
예제 #25
0
 public virtual void UnifyWithRigid(TypeVariable var, Substitution subst)
 {
     throw RigidTypeException.Create(var.RigidName, this);
 }