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

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


    }
    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.getDeclaredField(((SymbolTerm) a2).name());
      field.setAccessible(true);
View Full Code Here


    Object stream = null;

    // Char
    a2 = a2.dereference();
    if (a2.isVariable()) {
      throw new PInstantiationException(this, 2);
    }
    if (!a2.isSymbol()) {
      throw new IllegalTypeException(this, 2, "character", a2);
    }
    // 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

    // close options
    a2 = a2.dereference();
    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_FORCE_1)) {
          Term bool = args[0].dereference();
          if (bool.equals(SYM_TRUE)) {
            forceFlag = true;
          } else if (bool.equals(SYM_FALSE)) {
            forceFlag = false;
          } else {
            throw new IllegalDomainException(this, 2,
                "close_option", car);
          }
        } else {
          throw new IllegalDomainException(this, 2, "close_option",
              car);
        }
      } else {
        throw new IllegalDomainException(this, 2, "close_option", car);
      }
      tmp = ((ListTerm) tmp).cdr().dereference();
    }
    // stream
    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 stream = null;

    // Byte
    a2 = a2.dereference();
    if (a2.isVariable()) {
      throw new PInstantiationException(this, 2);
    }
    if (!a2.isInteger()) {
      throw new IllegalTypeException(this, 2, "byte", a2);
    }
    c = ((IntegerTerm) a2).intValue();
    if (c < 0 || c > 255) {
      throw new IllegalTypeException(this, 2, "byte", a2);
    }
    // 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

    Object stream = null;

    // 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

    }
    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.getMethod(((SymbolTerm) a2).name());
        // m.setAccessible(true);
        value = m.invoke(instance);
      } else if (a2.isStructure()) { // Parameterized method
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

    }
    // 1st. argument (atom or callable term)
    try {
      a1 = a1.dereference();
      if (a1.isVariable()) {
        throw new PInstantiationException(this, 1);
      }
      if (!a1.isSymbol() && !a1.isStructure()) {
        throw new IllegalTypeException(this, 1, "callable", a1);
      }
      if (a1.isSymbol()) { // No argument constructor
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 stream = null;

    // Char
    a2 = a2.dereference();
    if (a2.isVariable()) {
      throw new PInstantiationException(this, 2);
    }
    if (!a2.isInteger()) {
      try {
        a2 = Arithmetic.evaluate(a2);
      } catch (BuiltinException e) {
        e.goal = this;
        e.argNo = 2;
        throw e;
      }
    }
    n = ((NumberTerm) a2).intValue();
    // 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.