Package jp.ac.kobe_u.cs.prolog.lang

Examples of jp.ac.kobe_u.cs.prolog.lang.PInstantiationException


    }
    // a2 is list
    Term tmp = a2;
    while (!tmp.isNil()) {
      if (tmp.isVariable()) {
        throw new PInstantiationException(this, 2);
      }
      if (!tmp.isList()) {
        throw new IllegalTypeException(this, 2, "list", a2);
      }
      Term car = ((ListTerm) tmp).car().dereference();
      if (car.isVariable()) {
        throw new PInstantiationException(this, 2);
      }
      if (car.isStructure()) {
        SymbolTerm functor = ((StructureTerm) car).functor();
        Term[] args = ((StructureTerm) car).args();
        if (functor.equals(SYM_ALIAS_1)) {
View Full Code Here


    Term tmp, tmp2;
    Term[] list;

    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.equals(Nil)) {
      if (!a2.unify(Nil, engine.trail)) {
        return engine.fail();
      }
      return cont;
    } else if (!a1.isList()) {
      throw new IllegalTypeException(this, 1, "list", a1);
    }
    len = ((ListTerm) a1).length();
    list = new Term[len];
    tmp = a1;
    for (int i = 0; i < len; i++) {
      if (!tmp.isList()) {
        throw new IllegalTypeException(this, 1, "list", a1);
      }
      list[i] = ((ListTerm) tmp).car().dereference();
      tmp = ((ListTerm) tmp).cdr().dereference();
    }
    if (!tmp.equals(Nil)) {
      throw new PInstantiationException(this, 1);
    }
    try {
      Arrays.sort(list);
    } catch (ClassCastException e) {
      throw new JavaException(this, 1, e);
View Full Code Here

    a2 = arg2;

    Object hash = null;
    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getHashManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "hash", a1, "");
      }
      hash = ((JavaObjectTerm) engine.getHashManager().get(a1)).object();
View Full Code Here

    Term t;

    // S_or_a
    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getStreamManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "stream", a1, "");
      }
      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
View Full Code Here

      }
    }
    // S_or_a
    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getStreamManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "stream", a1, "");
      }
      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
View Full Code Here

      if (!tmp.isList()) {
        throw new IllegalTypeException(this, 1, "list", a1);
      }
      Term car = ((ListTerm) tmp).car().dereference();
      if (car.isVariable()) {
        throw new PInstantiationException(this, 1);
      }
      if (!car.isInteger()) {
        throw new RepresentationException(this, 1, "integer");
      }
      // car is an integer
View Full Code Here

    }
    try {
      // 1st. argument (atom or java term)
      a1 = a1.dereference();
      if (a1.isVariable()) {
        throw new PInstantiationException(this, 1);
      } else if (a1.isSymbol()) { // class
        clazz = Class.forName(((SymbolTerm) a1).name());
      } else if (a1.isJavaObject()) { // instance
        instance = ((JavaObjectTerm) a1).object();
        clazz = ((JavaObjectTerm) a1).getClazz();
      } else {
        throw new IllegalTypeException(this, 1, "atom_or_java", a1);
      }
      // 2nd. argument (atom or callable term)
      a2 = a2.dereference();
      if (a2.isVariable()) {
        throw new PInstantiationException(this, 2);
      } else if (a2.isSymbol()) { // No argument method
        m = clazz.getDeclaredMethod(((SymbolTerm) a2).name());
        m.setAccessible(true);
        value = m.invoke(instance);
      } else if (a2.isStructure()) { // Parameterized method
View Full Code Here

    if (a1.isVariable()) { // atom_codes(-Atom, +CharCodeList)
      StringBuffer sb = new StringBuffer();
      Term x = a2;
      while (!x.isNil()) {
        if (x.isVariable()) {
          throw new PInstantiationException(this, 2);
        }
        if (!x.isList()) {
          throw new IllegalTypeException(this, 2, "list", a2);
        }
        Term car = ((ListTerm) x).car().dereference();
        if (car.isVariable()) {
          throw new PInstantiationException(this, 2);
        }
        if (!car.isInteger()) {
          throw new RepresentationException(this, 2, "character_code");
        }
        // car is an integer
View Full Code Here

      }
    }
    // S_or_a
    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getStreamManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "stream", a1, "");
      }
      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
View Full Code Here

      }
    }
    // S_or_a
    a1 = a1.dereference();
    if (a1.isVariable()) {
      throw new PInstantiationException(this, 1);
    } else if (a1.isSymbol()) {
      if (!engine.getStreamManager().containsKey(a1)) {
        throw new ExistenceException(this, 1, "stream", a1, "");
      }
      stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))
View Full Code Here

TOP

Related Classes of jp.ac.kobe_u.cs.prolog.lang.PInstantiationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.