Пример #1
0
  protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
    int mark = src.position();

    if (needsMark) {
      if (dst.remaining() < 2) return CoderResult.OVERFLOW;
      put(BYTE_ORDER_MARK, dst);
      needsMark = false;
    }

    try {
      while (src.hasRemaining()) {
        char c = src.get();
        if (!Surrogate.is(c)) {
          if (dst.remaining() < 2) return CoderResult.OVERFLOW;
          mark++;
          put(c, dst);
          continue;
        }
        int d = sgp.parse(c, src);
        if (d < 0) return sgp.error();
        if (dst.remaining() < 4) return CoderResult.OVERFLOW;
        mark += 2;
        put(Surrogate.high(d), dst);
        put(Surrogate.low(d), dst);
      }
      return CoderResult.UNDERFLOW;
    } finally {
      src.position(mark);
    }
  }
Пример #2
0
  /**
   * Return TRUE if <code>x</code> and <code>y</code> represent the same set of key/value pairs.
   *
   * @param y
   * @return boolean
   */
  public boolean objectEqualP(Stella_Object y) {
    {
      StellaHashTable x = this;

      if (Surrogate.subtypeOfP(
          Stella_Object.safePrimaryType(y), Stella.SGT_STELLA_STELLA_HASH_TABLE)) {
        {
          StellaHashTable y000 = ((StellaHashTable) (y));

          if (x.length() == y000.length()) {
            {
              Stella_Object key = null;
              Stella_Object value = null;
              StellaHashTableIterator iter000 = ((StellaHashTableIterator) (x.allocateIterator()));

              while (iter000.nextP()) {
                key = iter000.key;
                value = iter000.value;
                if (!Stella_Object.equalP(value, y000.lookup(key))) {
                  return (false);
                }
              }
            }
            return (true);
          }
        }
      } else {
      }
      return (false);
    }
  }
Пример #3
0
  public boolean lessP(Stella_Object t2) {
    {
      CalendarDate t1 = this;

      if (Surrogate.subtypeOfP(
          Stella_Object.safePrimaryType(t2), Stella.SGT_STELLA_CALENDAR_DATE)) {
        {
          CalendarDate t2000 = ((CalendarDate) (t2));

          if (t1.modifiedJulianDay == t2000.modifiedJulianDay) {
            return (t1.timeMillis < t2000.timeMillis);
          } else {
            return (t1.modifiedJulianDay < t2000.modifiedJulianDay);
          }
        }
      } else {
        {
          OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

          stream000.nativeStream.print(
              "Can't compare calendar date `" + t1 + "' with object `" + t2 + "'");
          throw ((IncompatibleQuantityException)
              (IncompatibleQuantityException.newIncompatibleQuantityException(
                      stream000.theStringReader())
                  .fillInStackTrace()));
        }
      }
    }
  }
Пример #4
0
  public void propagateFramePartialTruth(ControlFrame target) {
    {
      PartialMatchFrame source = this;

      {
        PartialMatchFrame targetpmf = target.partialMatchFrame;
        boolean flippolarityP = !(source.controlFrame.reversePolarityP == target.reversePolarityP);

        if (targetpmf == null) {
          if (flippolarityP) {
            targetpmf =
                ((PartialMatchFrame)
                    (Surrogate.createObject(
                        source.primaryType(),
                        Stella_Object.cons(
                            Logic.KWD_CONTROL_FRAME,
                            Stella_Object.cons(
                                target,
                                Stella_Object.cons(
                                    Logic.KWD_KIND,
                                    Stella_Object.cons(target.state, Stella.NIL)))))));
            targetpmf.parent = source.parent;
            targetpmf.child = source;
          } else {
            targetpmf = source;
          }
          target.partialMatchFrame = targetpmf;
        }
        if (flippolarityP) {
          targetpmf.positiveScore = 0 - source.positiveScore;
          targetpmf.negativeScore = source.positiveScore;
        } else {
          targetpmf.positiveScore = source.positiveScore;
          targetpmf.negativeScore = source.negativeScore;
        }
        KeyValueList.setDynamicSlotValue(
            ((QueryIterator) (Logic.$QUERYITERATOR$.get())).dynamicSlots,
            Logic.SYM_LOGIC_LATEST_POSITIVE_SCORE,
            FloatWrapper.wrapFloat(targetpmf.positiveScore),
            Stella.NULL_FLOAT_WRAPPER);
      }
    }
  }
Пример #5
0
  public boolean objectEqlP(Stella_Object t2) {
    {
      CalendarDate t1 = this;

      if (Surrogate.subtypeOfP(
          Stella_Object.safePrimaryType(t2), Stella.SGT_STELLA_CALENDAR_DATE)) {
        {
          CalendarDate t2000 = ((CalendarDate) (t2));

          if (t1.modifiedJulianDay == t2000.modifiedJulianDay) {
            return (t1.timeMillis == t2000.timeMillis);
          } else {
            return (t1.modifiedJulianDay == t2000.modifiedJulianDay);
          }
        }
      } else {
        return (false);
      }
    }
  }
Пример #6
0
  public void vizExportConcepts(Module module) {
    {
      VizInfo self = this;

      {
        Stella_Object concept = null;
        edu.isi.powerloom.PlIterator iter000 =
            edu.isi.powerloom.PLI.getConceptInstances(
                ((LogicObject) (Logic.getInstance(OntosaurusUtil.SGT_PL_KERNEL_KB_CONCEPT))),
                module,
                null);

        while (iter000.nextP()) {
          concept = iter000.value;
          if (Surrogate.subtypeOfP(
              Stella_Object.safePrimaryType(concept), OntosaurusUtil.SGT_LOGIC_LOGIC_OBJECT)) {
            {
              LogicObject concept000 = ((LogicObject) (concept));

              if ((concept000.homeModule() == module) && self.vizAllowedObjectP(concept000)) {
                self.vizExportConcept(concept000, module);
              }
            }
          } else {
            {
              OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

              stream000.nativeStream.print(
                  "viz-export-concepts: concept not handled: `" + concept + "'");
              throw ((StellaException)
                  (StellaException.newStellaException(stream000.theStringReader())
                      .fillInStackTrace()));
            }
          }
        }
      }
    }
  }
Пример #7
0
  public Quantity coerceTo(Stella_Object y) {
    {
      CalendarDate x = this;

      if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(y), Stella.SGT_STELLA_CALENDAR_DATE)) {
        {
          CalendarDate y000 = ((CalendarDate) (y));

          return (y000);
        }
      } else {
        {
          OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

          stream000.nativeStream.print("Can't coerce `" + y + "' to a CALENDAR-DATE");
          throw ((IncompatibleQuantityException)
              (IncompatibleQuantityException.newIncompatibleQuantityException(
                      stream000.theStringReader())
                  .fillInStackTrace()));
        }
      }
    }
  }
Пример #8
0
 public boolean canEncode(char c) {
   return !Surrogate.is(c);
 }
Пример #9
0
  public Cons vizGetBinaryRelationsOf(LogicObject concept) {
    {
      VizInfo self = this;

      {
        MemoizationTable memoTable000 = null;
        Cons memoizedEntry000 = null;
        Stella_Object memoizedValue000 = null;

        if (Stella.$MEMOIZATION_ENABLEDp$) {
          memoTable000 =
              ((MemoizationTable)
                  (OntosaurusUtil
                      .SGT_ONTOSAURUS_M_VIZ_INFOdVIZ_GET_BINARY_RELATIONS_OF_MEMO_TABLE_000
                      .surrogateValue));
          if (memoTable000 == null) {
            Surrogate.initializeMemoizationTable(
                OntosaurusUtil.SGT_ONTOSAURUS_M_VIZ_INFOdVIZ_GET_BINARY_RELATIONS_OF_MEMO_TABLE_000,
                "(:MAX-VALUES 1000 :TIMESTAMPS (:META-KB-UPDATE))");
            memoTable000 =
                ((MemoizationTable)
                    (OntosaurusUtil
                        .SGT_ONTOSAURUS_M_VIZ_INFOdVIZ_GET_BINARY_RELATIONS_OF_MEMO_TABLE_000
                        .surrogateValue));
          }
          memoizedEntry000 =
              MruMemoizationTable.lookupMruMemoizedValue(
                  ((MruMemoizationTable) (memoTable000)),
                  concept,
                  ((Context) (Stella.$CONTEXT$.get())),
                  Stella.MEMOIZED_NULL_VALUE,
                  null,
                  -1);
          memoizedValue000 = memoizedEntry000.value;
        }
        if (memoizedValue000 != null) {
          if (memoizedValue000 == Stella.MEMOIZED_NULL_VALUE) {
            memoizedValue000 = null;
          }
        } else {
          memoizedValue000 =
              Logic.applyCachedRetrieve(
                  Cons.list$(
                      Cons.cons(
                          OntosaurusUtil.SYM_LOGIC_pRELATION,
                          Cons.cons(
                              OntosaurusUtil.SYM_ONTOSAURUS_pDOMAIN,
                              Cons.cons(Stella.NIL, Stella.NIL)))),
                  Cons.list$(
                      Cons.cons(
                          OntosaurusUtil.SYM_STELLA_AND,
                          Cons.cons(
                              Cons.list$(
                                  Cons.cons(
                                      OntosaurusUtil.SYM_PL_KERNEL_KB_NTH_DOMAIN,
                                      Cons.cons(
                                          OntosaurusUtil.SYM_LOGIC_pRELATION,
                                          Cons.cons(
                                              IntegerWrapper.wrapInteger(0),
                                              Cons.cons(
                                                  OntosaurusUtil.SYM_ONTOSAURUS_pDOMAIN,
                                                  Cons.cons(Stella.NIL, Stella.NIL)))))),
                              Cons.cons(
                                  Cons.list$(
                                      Cons.cons(
                                          OntosaurusUtil.SYM_ONTOSAURUS_BINARY_RELATION,
                                          Cons.cons(
                                              OntosaurusUtil.SYM_LOGIC_pRELATION,
                                              Cons.cons(Stella.NIL, Stella.NIL)))),
                                  Cons.cons(Stella.NIL, Stella.NIL))))),
                  Cons.consList(Cons.cons(null, Cons.cons(concept, Stella.NIL))),
                  Cons.consList(
                      Cons.cons(
                          OntosaurusUtil.KWD_SINGLETONSp,
                          Cons.cons(
                              Stella.TRUE_WRAPPER,
                              Cons.cons(
                                  OntosaurusUtil.KWD_INFERENCE_LEVEL,
                                  Cons.cons(OntosaurusUtil.KWD_SHALLOW, Stella.NIL))))),
                  OntosaurusUtil.SYM_ONTOSAURUS_M_VIZ_INFOdVIZ_GET_BINARY_RELATIONS_OF_QUERY_001,
                  new Object[2]);
          if (Stella.$MEMOIZATION_ENABLEDp$) {
            memoizedEntry000.value =
                ((memoizedValue000 == null) ? Stella.MEMOIZED_NULL_VALUE : memoizedValue000);
          }
        }
        {
          Cons value000 = ((Cons) (memoizedValue000));

          return (value000);
        }
      }
    }
  }
Пример #10
0
  public void vizConceptLinksToDotEdges(LogicObject concept, Module module) {
    {
      VizInfo self = this;

      {
        OutputStream stream = self.stream;
        int count = 0;

        {
          LogicObject renamed_Super = null;
          edu.isi.powerloom.PlIterator iter000 =
              edu.isi.powerloom.PLI.getDirectSuperrelations(concept, module, null);

          while (iter000.nextP()) {
            renamed_Super = ((LogicObject) (iter000.value));
            if (Surrogate.subtypeOfP(
                Stella_Object.safePrimaryType(renamed_Super),
                OntosaurusUtil.SGT_LOGIC_NAMED_DESCRIPTION)) {
              {
                NamedDescription super000 = ((NamedDescription) (renamed_Super));

                if (self.vizAllowedObjectP(super000)) {
                  stream.nativeStream.println(
                      "  \""
                          + OntosaurusUtil.vizDotObjectName(super000)
                          + "\" -> \""
                          + OntosaurusUtil.vizDotObjectName(concept)
                          + "\" [dir=back]");
                  count = count + 1;
                } else {
                  stream.nativeStream.print(
                      "  \""
                          + OntosaurusUtil.vizDotObjectName(super000)
                          + "\" [shape=box, style=filled, fillcolor=grey,URL=\""
                          + self.vizGenerateOntosaurusHandle(super000)
                          + "\"]");
                  stream.nativeStream.println(
                      "  \""
                          + OntosaurusUtil.vizDotObjectName(super000)
                          + "\" -> \""
                          + OntosaurusUtil.vizDotObjectName(concept)
                          + "\" [dir=back]");
                  count = count + 1;
                }
              }
            } else {
              {
                OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

                stream000.nativeStream.print(
                    "viz-concept-links-to-dot-edges: unhandled super concept: `"
                        + renamed_Super
                        + "'");
                throw ((StellaException)
                    (StellaException.newStellaException(stream000.theStringReader())
                        .fillInStackTrace()));
              }
            }
          }
        }
        if ((count == 0) && self.addTopP) {
          stream.nativeStream.println(
              "  \""
                  + OntosaurusUtil.VIZ_TOP
                  + "\" -> \""
                  + OntosaurusUtil.vizDotObjectName(concept)
                  + "\" [dir=back]");
        }
        if (self.showRelationsP) {
          {
            LogicObject range = null;
            String relcolor = self.relationColor;
            String relstyle = self.relationStyle;

            {
              Object old$Module$000 = Stella.$MODULE$.get();
              Object old$Context$000 = Stella.$CONTEXT$.get();

              try {
                Native.setSpecial(Stella.$MODULE$, module);
                Native.setSpecial(Stella.$CONTEXT$, ((Module) (Stella.$MODULE$.get())));
                {
                  LogicObject relation = null;
                  Cons iter001 = self.vizGetBinaryRelationsOf(concept);

                  for (; !(iter001 == Stella.NIL); iter001 = iter001.rest) {
                    relation = ((LogicObject) (iter001.value));
                    range = edu.isi.powerloom.PLI.getRange(relation);
                    if (self.vizAllowedObjectP(relation)) {
                      stream.nativeStream.println(
                          "  \""
                              + OntosaurusUtil.vizDotObjectName(concept)
                              + "\" -> \""
                              + OntosaurusUtil.vizDotObjectName(range)
                              + "\" [label=\""
                              + OntosaurusUtil.vizDotObjectName(relation)
                              + "\", color="
                              + relcolor
                              + ", style="
                              + relstyle
                              + "]");
                    }
                  }
                }

              } finally {
                Stella.$CONTEXT$.set(old$Context$000);
                Stella.$MODULE$.set(old$Module$000);
              }
            }
          }
        }
      }
    }
  }
Пример #11
0
  public void vizExportConceptTree(LogicObject concept, Module module) {
    {
      VizInfo self = this;

      self.nodeColor = "palegreen";
      self.vizExportConcept(concept, module);
      self.nodeColor = "yellow";
      self.vizAllowObject(concept);
      {
        LogicObject renamed_Super = null;
        edu.isi.powerloom.PlIterator iter000 =
            edu.isi.powerloom.PLI.getProperSuperrelations(concept, module, null);

        while (iter000.nextP()) {
          renamed_Super = ((LogicObject) (iter000.value));
          self.vizAllowObject(renamed_Super);
        }
      }
      {
        LogicObject sub = null;
        edu.isi.powerloom.PlIterator iter001 =
            edu.isi.powerloom.PLI.getProperSubrelations(concept, module, null);

        while (iter001.nextP()) {
          sub = ((LogicObject) (iter001.value));
          self.vizAllowObject(sub);
        }
      }
      {
        LogicObject renamed_Super = null;
        edu.isi.powerloom.PlIterator iter002 =
            edu.isi.powerloom.PLI.getProperSuperrelations(concept, module, null);

        while (iter002.nextP()) {
          renamed_Super = ((LogicObject) (iter002.value));
          if (Surrogate.subtypeOfP(
              Stella_Object.safePrimaryType(renamed_Super),
              OntosaurusUtil.SGT_LOGIC_LOGIC_OBJECT)) {
            {
              LogicObject super000 = ((LogicObject) (renamed_Super));

              self.vizExportConcept(super000, module);
            }
          } else {
            {
              OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

              stream000.nativeStream.print(
                  "viz-export-concept-tree: concept not handled: `" + renamed_Super + "'");
              throw ((StellaException)
                  (StellaException.newStellaException(stream000.theStringReader())
                      .fillInStackTrace()));
            }
          }
        }
      }
      {
        LogicObject sub = null;
        edu.isi.powerloom.PlIterator iter003 =
            edu.isi.powerloom.PLI.getProperSubrelations(concept, module, null);

        while (iter003.nextP()) {
          sub = ((LogicObject) (iter003.value));
          if (Surrogate.subtypeOfP(
              Stella_Object.safePrimaryType(sub), OntosaurusUtil.SGT_LOGIC_LOGIC_OBJECT)) {
            {
              LogicObject sub000 = ((LogicObject) (sub));

              self.vizExportConcept(sub000, module);
            }
          } else {
            {
              OutputStringStream stream001 = OutputStringStream.newOutputStringStream();

              stream001.nativeStream.print(
                  "viz-export-concept-tree: concept not handled: `" + sub + "'");
              throw ((StellaException)
                  (StellaException.newStellaException(stream001.theStringReader())
                      .fillInStackTrace()));
            }
          }
        }
      }
    }
  }