コード例 #1
0
 /**
  * @param oldParams
  * @return
  */
 private FormalParamNode[] generateNewParams(FormalParamNode[] oldParams) {
   FormalParamNode[] newParams = new FormalParamNode[oldParams.length];
   for (int i = 0; i < oldParams.length; i++) {
     FormalParamNode oldParam = oldParams[i];
     FormalParamNode newParam =
         new FormalParamNode(
             oldParam.getName(), oldParam.getArity(), oldParam.getTreeNode(), null, null);
     // set reference to the old param to the new
     oldParam.setToolObject(substitutionId, newParam);
     newParams[i] = newParam;
   }
   return newParams;
 }
コード例 #2
0
  /**
   * @param n
   * @param prefix
   * @return
   * @throws AbortException
   */
  private ExprNode generateNewBuiltInNode(OpApplNode n, String prefix) throws AbortException {
    switch (getOpCode(n.getOperator().getName())) {
      case OPCODE_exc:
        { // Except
          OpApplNode newNode =
              new OpApplNode(n.getOperator().getName(), null, n.getTreeNode(), null);
          n.setToolObject(substitutionId, newNode); // needed for @ node
          ExprOrOpArgNode[] newArgs = new ExprOrOpArgNode[n.getArgs().length];
          newArgs[0] = generateNewExprOrOpArgNode(n.getArgs()[0], prefix);

          for (int i = 1; i < n.getArgs().length; i++) {
            OpApplNode pair = (OpApplNode) n.getArgs()[i];
            OpApplNode newPair =
                new OpApplNode(pair.getOperator().getName(), null, pair.getTreeNode(), null);
            // needed for @ node: we have to set a reference from the old
            // pair to the new pair
            // before evaluation the arguments which may be contains a @
            // node
            pair.setToolObject(substitutionId, newPair);
            newPair.setArgs(generateNewArgs(pair.getArgs(), prefix));
            newArgs[i] = newPair;
          }
          newNode.setArgs(newArgs);
          return newNode;
        }
      case OPCODE_uc:
        { // CHOOSE x : P
          FormalParamNode[] oldSymbols = n.getUnbdedQuantSymbols();
          FormalParamNode[] newSymbols = new FormalParamNode[oldSymbols.length];
          for (int i = 0; i < n.getUnbdedQuantSymbols().length; i++) {
            FormalParamNode f = oldSymbols[i];
            newSymbols[i] =
                new FormalParamNode(f.getName(), f.getArity(), f.getTreeNode(), null, null);
            f.setToolObject(substitutionId, newSymbols[i]);
          }
          OpApplNode newNode =
              new OpApplNode(
                  n.getOperator().getName(),
                  newSymbols,
                  generateNewArgs(n.getArgs(), prefix),
                  null,
                  null,
                  null,
                  n.getTreeNode(),
                  null);
          return newNode;
        }

      case OPCODE_rfs:
      case OPCODE_nrfs:
      case OPCODE_fc: // Represents [x \in S |-> e]
      case OPCODE_be: // \E x \in S : P
      case OPCODE_bf: // \A x \in S : P
      case OPCODE_bc: // CHOOSE x \in S: P
      case OPCODE_sso: // $SubsetOf Represents {x \in S : P}
      case OPCODE_soa: // $SetOfAll Represents {e : p1 \in S, p2,p3 \in S2}
        {
          // new formalparamnodes
          FormalParamNode[][] oldParams = n.getBdedQuantSymbolLists();
          FormalParamNode[][] newParams = new FormalParamNode[oldParams.length][0];
          for (int i = 0; i < oldParams.length; i++) {
            FormalParamNode[] temp = new FormalParamNode[oldParams[i].length];
            for (int j = 0; j < oldParams[i].length; j++) {
              FormalParamNode f = oldParams[i][j];
              temp[j] = new FormalParamNode(f.getName(), f.getArity(), f.getTreeNode(), null, null);
              // set reference the old param to the new
              f.setToolObject(substitutionId, temp[j]);
            }
            newParams[i] = temp;
          }

          // new ranges
          ExprNode[] ranges = new ExprNode[n.getBdedQuantBounds().length];
          for (int i = 0; i < n.getBdedQuantBounds().length; i++) {
            ranges[i] = generateNewExprNode(n.getBdedQuantBounds()[i], prefix);
          }
          OpApplNode newNode =
              new OpApplNode(
                  n.getOperator().getName(),
                  null,
                  generateNewArgs(n.getArgs(), prefix),
                  newParams,
                  n.isBdedQuantATuple(),
                  ranges,
                  n.getTreeNode(),
                  null);
          return newNode;
        }

      default:
        { // =
          OpApplNode newNode =
              new OpApplNode(
                  n.getOperator(), generateNewArgs(n.getArgs(), prefix), n.getTreeNode(), null);
          return newNode;
        }
    }
  }