예제 #1
0
        internal static Term ToJPL(PlTerm o)
        {
            switch (o.PlType)
            {
            case PlType.PlAtom:
            {
                return(new Atom((string)o));
            }
            break;

            case PlType.PlInteger:
            {
                return(new jpl.Integer((long)o));
            }
            break;

            case PlType.PlFloat:
            {
                return(new jpl.Float((double)o));
            }
            break;

            case PlType.PlString:
            {
                return(new jpl.Atom((string)o));
            }
            break;

            case PlType.PlTerm:
            {
                var a = o.Arity;
                var c = new jpl.Compound(o.Name, a);
                for (int i = 1; i <= a; i++)
                {
                    c.setArg(i, ToJPL(o[i]));
                }
                return(c);
            }
            break;

            case PlType.PlVariable:
            {
                var v = new jpl.Variable();
                SetField(v, "term_", o.TermRef);
                return(v);
            }
            break;

            case PlType.PlUnknown:
            {
                return(jpl.Util.textToTerm((string)o));
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #2
0
 internal static Term ToJPL(PlTerm o)
 {
     switch (o.PlType)
     {
         case PlType.PlAtom:
             {
                 return new Atom((string)o);
             }
             break;
         case PlType.PlInteger:
             {
                 return new jpl.Integer((long)o);
             }
             break;
         case PlType.PlFloat:
             {
                 return new jpl.Float((double)o);
             }
             break;
         case PlType.PlString:
             {
                 return new jpl.Atom((string)o);
             }
             break;
         case PlType.PlTerm:
             {
                 var a = o.Arity;
                 var c = new jpl.Compound(o.Name, a);
                 for (int i = 1; i <= a; i++)
                 {
                     c.setArg(i, ToJPL(o[i]));
                 }
                 return c;
             }
             break;
         case PlType.PlVariable:
             {
                 var v = new jpl.Variable();
                 SetField(v, "term_", o.TermRef);
                 return v;
             }
             break;
         case PlType.PlUnknown:
             {
                 return jpl.Util.textToTerm((string)o);
             }
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }