public static AtomicGoalCache createAtomicGoalCache(ControlFrame frame, AtomicGoalCache cache, boolean successP) {
    { boolean collisionP = cache != null;
      Proposition proposition = frame.proposition;

      if (!collisionP) {
        cache = AtomicGoalCache.newAtomicGoalCache();
      }
      if (successP) {
        if (collisionP) {
          if (cache.next != null) {
            cache.next.previous = cache.previous;
          }
          if (cache.previous == null) {
            Proposition.setGoalCacheList(cache.proposition, cache.next);
          }
          else {
            cache.previous.next = cache.next;
          }
          cache.previous = null;
          cache.next = null;
        }
        { AtomicGoalCache previousstart = Proposition.getGoalCacheList(proposition);

          if (!(cache == previousstart)) {
            if (previousstart != null) {
              previousstart.previous = cache;
              cache.next = previousstart;
            }
          }
        }
        Proposition.setGoalCacheList(proposition, cache);
      }
      cache.goalContext = ((Context)(Stella.$CONTEXT$.get()));
      cache.timestamp = Logic.getNowTimestamp();
      cache.reversePolarityP = frame.reversePolarityP;
      cache.proposition = proposition;
      cache.bindings = Proposition.yieldGoalBindings(proposition);
      cache.justification = (successP ? ((Justification)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, Logic.SYM_LOGIC_JUSTIFICATION, null))) : null);
      cache.truthValue = frame.truthValue;
      if ((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
          (((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy != null)) {
        frame.setCachePartialTruth(cache);
      }
      frame.cachedGoalResultP = true;
      return (cache);
    }
  }