Beispiel #1
0
 private StructuredGraph parseAndProcess(String snippet) {
   StructuredGraph graph = parse(snippet);
   LocalNode local = graph.getNodes(LocalNode.class).first();
   ConstantNode constant = ConstantNode.forInt(0, graph);
   for (Node n : local.usages().filter(isNotA(FrameState.class)).snapshot()) {
     n.replaceFirstInput(local, constant);
   }
   Map<Invoke, Double> hints = new HashMap<>();
   for (Invoke invoke : graph.getInvokes()) {
     hints.put(invoke, 1000d);
   }
   Assumptions assumptions = new Assumptions(false);
   new InliningPhase(
           runtime(),
           hints,
           replacements,
           assumptions,
           null,
           getDefaultPhasePlan(),
           OptimisticOptimizations.ALL)
       .apply(graph);
   new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(graph);
   new DeadCodeEliminationPhase().apply(graph);
   return graph;
 }
  /**
   * Initializer for a SQLBooleanConstantNode.
   *
   * @param newValue A String containing the value of the constant: true, false, unknown
   * @exception StandardException
   */
  public void init(Object newValue) throws StandardException {
    String strVal = (String) newValue;
    Boolean val = null;

    if ("true".equalsIgnoreCase(strVal)) val = Boolean.TRUE;
    else if ("false".equalsIgnoreCase(strVal)) val = Boolean.FALSE;

    /*
     ** RESOLVE: The length is fixed at 1, even for nulls.
     ** Is that OK?
     */

    /* Fill in the type information in the parent ValueNode */
    super.init(TypeId.BOOLEAN_ID, Boolean.TRUE, 1);

    setValue(val);
  }