Example #1
0
  @Override
  public LinearContext join(LinearContext other, ASTNode node, JoiningChoices jc) {
    this.freeze();
    if (other == this) return this;
    other.freeze();

    return this;
  }
Example #2
0
  @Override
  public boolean atLeastAsPrecise(LinearContext other, final ASTNode node) {
    this.freeze();
    if (this == other) return true;
    other.freeze();

    return true;
  }
Example #3
0
  @Override
  public boolean atLeastAsPrecise(LinearContext other, final ASTNode node) {
    // Copied from ContextChoiceLE.asLeastAsPrecise(DisjunctiveLE, ASTNode)
    this.freeze();
    if (this == other) return true;
    other.freeze();

    // This implements proving other with the given choices
    // For completeness, first break down other until atoms (tuples)
    // are found.  Then, break down the receiver using the helper
    // atLeastAsPrecise method.
    final DisjunctiveVisitor<Boolean> compVisitor =
        new DisjunctiveVisitor<Boolean>() {

          @Override
          public Boolean choice(ContextChoiceLE other) {
            for (LinearContext otherElem : other.getElements()) {
              if (!otherElem.dispatch(this)) return false;
            }
            return true;
          }

          @Override
          public Boolean trueContext(TrueContext trueContext) {
            return true;
          }

          @Override
          public Boolean context(TensorContext other) {
            return TrueContext.this.atLeastAsPrecise(other.getTuple(), node);
          }

          @Override
          public Boolean falseContext(FalseContext falseContext) {
            return false;
          }
        };
    return other.dispatch(compVisitor);
  }