K addSideCondition(K requires) {
   Optional<KApply> sideCondition = state.stream().reduce(BooleanUtils::and);
   if (!sideCondition.isPresent()) {
     return requires;
   } else if (requires.equals(BooleanUtils.TRUE) && sideCondition.isPresent()) {
     return sideCondition.get();
   } else {
     return BooleanUtils.and(requires, sideCondition.get());
   }
 }
Ejemplo n.º 2
0
 /**
  * Adds lookups to the side condition in sorted order in which they must be performed. Lookups are
  * sorted based on dependencies between each other, but non-lookup operations appear in no
  * particular order with respect to the lookups.
  *
  * @param requires Previous side condition, if any.
  * @return Side condition generated by this compiler pass + previous side condition.
  */
 K addSideCondition(K requires) {
   Optional<KApply> sideCondition = getSortedLookups().reduce(BooleanUtils::and);
   if (!sideCondition.isPresent()) {
     return requires;
   } else if (requires.equals(BooleanUtils.TRUE) && sideCondition.isPresent()) {
     return sideCondition.get();
   } else {
     // we order lookups before the requires clause so that the fresh constant
     // matching side condition remains last. This is necessary in order to
     // ensure that fresh constants in rule RHSs are consecutive
     return BooleanUtils.and(sideCondition.get(), requires);
   }
 }