コード例 #1
0
ファイル: CyclicTerm.cs プロジェクト: nasa03/Jasonity
        public override ITerm CApply(Unifier u)
        {
            ITerm v = u.Get(cyclicVar);

            u.Remove(cyclicVar);
            ITerm r = new CyclicTerm(this, cyclicVar.Clone() as VarTerm, u);

            if (v != null)
            {
                u.Bind(cyclicVar, v);
            }
            return(r);
        }
コード例 #2
0
ファイル: CyclicTerm.cs プロジェクト: nasa03/Jasonity
        public override bool Equals(object o)
        {
            if (o == null)
            {
                return(false);
            }
            if (o == this)
            {
                return(true);
            }

            if (o.GetType() == typeof(CyclicTerm))
            {
                CyclicTerm l = o as CyclicTerm;
                return(base.Equals(l));
            }
            return(false);
        }
コード例 #3
0
ファイル: VarTerm.cs プロジェクト: nasa03/Jasonity
        public override ITerm CApply(Unifier u)
        {
            if (u != null)
            {
                ITerm vl = u.Get(this);
                if (vl != null)
                {
                    if (!vl.IsCyclicTerm() && vl.HasVar(this, u))
                    {
                        u.Remove(this);
                        ITerm tempVl = vl.CApply(u);
                        u.Bind(this, vl);

                        CyclicTerm ct          = new CyclicTerm(tempVl as Literal, this);
                        Unifier    renamedVars = new Unifier();
                        ct.MakeVarsAnnon(renamedVars);
                        renamedVars.Remove(this);
                        u.Compose(renamedVars);
                        vl = ct;
                    }

                    vl = vl.CApply(u);

                    if (vl.IsLiteral())
                    {
                        if (GetNS() != Literal.DefaultNS)
                        {
                            vl = (vl.CloneNS(GetNS().CApply(u) as Atom) as Literal);
                        }
                        if (Negated())
                        {
                            ((Literal)vl).SetNegated(Literal.LNeg);
                        }
                    }

                    if (vl.IsLiteral() && this.HasAnnot())
                    {
                        vl = ((Literal)vl).ForceFullLiteralImpl().AddAnnots((IListTerm)this.GetAnnots().CApply(u));
                    }
                    return(vl);
                }
            }
            return((ITerm)Clone()); // Como uso el Clone de C# lo que clono son object que luego hay que castear...
        }