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

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


    a1 = arg1;
    Object stream = null;

    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


    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

    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

    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

    if (a1.isVariable()) { // number_codes(-Number, +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

    if (a2.isNil()) {
      throw new SyntaxException(this, 2, "character_code_list", a2, "");
    }
    if (a1.isVariable()) { // number_chars(-Number, +CharList)
      if (a2.isVariable()) {
        throw new PInstantiationException(this, 2);
      } else if (!a2.isList()) {
        throw new IllegalTypeException(this, 2, "list", a2);
      }
      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.isSymbol() || ((SymbolTerm) car).name().length() != 1) {
          throw new IllegalTypeException(this, 2, "character", a2);
        }
        sb.append(((SymbolTerm) car).name());
View Full Code Here

    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

    }
    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)
      a2 = a2.dereference();
      if (a2.isVariable()) {
        throw new PInstantiationException(this, 2);
      } else if (!a2.isSymbol()) {
        throw new IllegalTypeException(this, 2, "atom", a2);
      }
      field = clazz.getField(((SymbolTerm) a2).name());
      value = field.get(instance);
View Full Code Here

    Term tmp;
    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();
      if (list[i].isVariable()) {
        throw new PInstantiationException(this, 1);
      }
      if (!list[i].isStructure()) {
        throw new IllegalTypeException(this, 1, "key_value_pair", a1);
      }
      if (!((StructureTerm) list[i]).functor().equals(SYM_HYPHEN_2)) {
        throw new IllegalTypeException(this, 1, "key_value_pair", a1);
      }
      tmp = ((ListTerm) tmp).cdr().dereference();
    }
    if (!tmp.equals(Nil)) {
      throw new PInstantiationException(this, 1);
    }
    try {
      Arrays.sort(list, new KeySortComparator());
    } catch (BuiltinException e) {
      e.goal = this;
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.