當前位置: 首頁>>代碼示例>>Java>>正文


Java MinimizationStyle類代碼示例

本文整理匯總了Java中com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle的典型用法代碼示例。如果您正苦於以下問題:Java MinimizationStyle類的具體用法?Java MinimizationStyle怎麽用?Java MinimizationStyle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MinimizationStyle類屬於com.google.javascript.jscomp.MinimizedCondition包,在下文中一共展示了MinimizationStyle類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: tryMinimizeHook

import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //導入依賴的package包/類
/**
 * Try flipping HOOKs that have negated conditions.
 *
 * Returns the replacement for n or the original if no replacement was
 * necessary.
 */
private Node tryMinimizeHook(Node n) {
  Node originalCond = n.getFirstChild();
  MinimizedCondition minCond = MinimizedCondition.fromConditionNode(originalCond);
  MeasuredNode mNode =
      minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT);
  if (mNode.isNot()) {
    // Swap the HOOK
    Node thenBranch = n.getSecondChild();
    replaceNode(originalCond, mNode.withoutNot());
    n.removeChild(thenBranch);
    n.addChildToBack(thenBranch);
    compiler.reportChangeToEnclosingScope(n);
  } else {
    replaceNode(originalCond, mNode);
  }
  return n;
}
 
開發者ID:google,項目名稱:closure-compiler,代碼行數:24,代碼來源:PeepholeMinimizeConditions.java

示例2: tryMinimizeExprResult

import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //導入依賴的package包/類
/**
 * Try to remove leading NOTs from EXPR_RESULTS.
 *
 * Returns the replacement for n or the original if no replacement was
 * necessary.
 */
private Node tryMinimizeExprResult(Node n) {
  MinimizedCondition minCond =
      MinimizedCondition.fromConditionNode(n.getFirstChild());
  MinimizedCondition.MeasuredNode mNode =
      minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT);
  Node placeholder = minCond.getPlaceholder();
  if (mNode.getNode().isNot()) {
    // Remove the leading NOT in the EXPR_RESULT.
    n.replaceChild(placeholder, mNode.getNode().removeFirstChild());
    reportCodeChange();
  } else {
    replaceNode(placeholder, mNode);
  }
  return n;
}
 
開發者ID:nicks,項目名稱:closure-compiler-old,代碼行數:22,代碼來源:PeepholeMinimizeConditions.java

示例3: tryMinimizeHook

import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //導入依賴的package包/類
/**
 * Try flipping HOOKs that have negated conditions.
 *
 * Returns the replacement for n or the original if no replacement was
 * necessary.
 */
private Node tryMinimizeHook(Node n) {
  MinimizedCondition minCond =
    MinimizedCondition.fromConditionNode(n.getFirstChild());
  MinimizedCondition.MeasuredNode mNode =
      minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT);
  Node placeholder = minCond.getPlaceholder();
  if (mNode.getNode().isNot()) {
    // Swap the HOOK
    Node thenBranch = n.getFirstChild().getNext();
    n.replaceChild(placeholder, mNode.getNode().removeFirstChild());
    n.removeChild(thenBranch);
    n.addChildToBack(thenBranch);
    reportCodeChange();
  } else {
    replaceNode(placeholder, mNode);
  }
  return n;
}
 
開發者ID:nicks,項目名稱:closure-compiler-old,代碼行數:25,代碼來源:PeepholeMinimizeConditions.java

示例4: minCond

import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //導入依賴的package包/類
private static void minCond(String input, String positive, String negative) {
  Node inputNode = parseExpr(input);
  MinimizedCondition result = MinimizedCondition.fromConditionNode(inputNode);
  Node positiveNode = parseExpr(positive);
  Node negativeNode = parseExpr(negative);
  // With counting the leading NOT node:
  Node positiveResult =
      result.getMinimized(MinimizationStyle.PREFER_UNNEGATED).getNode();
  // Without counting the leading NOT node:
  Node negativeResult =
      result.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT).getNode();
  if (!positiveResult.isEquivalentTo(positiveNode)) {
    fail("Not equal:" +
        "\nExpected: " + positive +
        "\nBut was : " + (new Compiler()).toSource(positiveResult) +
        "\nExpected tree:\n" + positiveNode.toStringTree() +
        "\nActual tree:\n" + positiveResult.toStringTree());
  }
  if (!negativeResult.isEquivalentTo(negativeNode)) {
    fail("Not equal:" +
        "\nExpected: " + negative +
        "\nBut was : " + (new Compiler()).toSource(negativeResult) +
        "\nExpected tree:\n" + negativeNode.toStringTree() +
        "\nActual tree:\n" + negativeResult.toStringTree());
  }
}
 
開發者ID:nicks,項目名稱:closure-compiler-old,代碼行數:27,代碼來源:MinimizedConditionTest.java

示例5: minCond

import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //導入依賴的package包/類
private static void minCond(String input, String positive, String negative) {
  Node inputNode = parseExpr(input);
  MinimizedCondition result = MinimizedCondition.fromConditionNode(inputNode);
  Node positiveNode = parseExpr(positive);
  Node negativeNode = parseExpr(negative);
  // With counting the leading NOT node:
  Node positiveResult =
      result.getMinimized(MinimizationStyle.PREFER_UNNEGATED).getNode();
  // Without counting the leading NOT node:
  Node negativeResult =
      result.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT).getNode();
  if (!positiveResult.isEquivalentTo(positiveNode)) {
    fail("Not equal:\n" + positiveResult.toStringTree()
        + "and:\n" + positiveNode.toStringTree());
  }
  if (!negativeResult.isEquivalentTo(negativeNode)) {
    fail("Not equal:\n" + negativeResult.toStringTree()
        + "and:\n" + negativeNode.toStringTree());
  }
}
 
開發者ID:Robbert,項目名稱:closure-compiler-copy,代碼行數:21,代碼來源:MinimizedConditionTest.java

示例6: tryMinimizeExprResult

import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //導入依賴的package包/類
/**
 * Try to remove leading NOTs from EXPR_RESULTS.
 *
 * Returns the replacement for n or the original if no replacement was
 * necessary.
 */
private Node tryMinimizeExprResult(Node n) {
  Node originalExpr = n.getFirstChild();
  MinimizedCondition minCond = MinimizedCondition.fromConditionNode(originalExpr);
  MeasuredNode mNode =
      minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT);
  if (mNode.isNot()) {
    // Remove the leading NOT in the EXPR_RESULT.
    replaceNode(originalExpr, mNode.withoutNot());
  } else {
    replaceNode(originalExpr, mNode);
  }
  return n;
}
 
開發者ID:google,項目名稱:closure-compiler,代碼行數:20,代碼來源:PeepholeMinimizeConditions.java

示例7: tryMinimizeCondition

import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //導入依賴的package包/類
/**
 * Try to minimize condition expression, as there are additional
 * assumptions that can be made when it is known that the final result
 * is a boolean.
 *
 * @return The replacement for n, or the original if no change was made.
 */
private Node tryMinimizeCondition(Node n) {
  n = performConditionSubstitutions(n);
  MinimizedCondition minCond = MinimizedCondition.fromConditionNode(n);
  return replaceNode(
      n,
      minCond.getMinimized(MinimizationStyle.PREFER_UNNEGATED));
}
 
開發者ID:google,項目名稱:closure-compiler,代碼行數:15,代碼來源:PeepholeMinimizeConditions.java

示例8: minCond

import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //導入依賴的package包/類
private static void minCond(String input, String positive, String negative) {
  Node inputNode = parseExpr(input);
  MinimizedCondition result1 = MinimizedCondition.fromConditionNode(cloneAttachedTree(inputNode));
  MinimizedCondition result2 = MinimizedCondition.fromConditionNode(cloneAttachedTree(inputNode));
  Node positiveNode = parseExpr(positive);
  Node negativeNode = parseExpr(negative);
  // With counting the leading NOT node:
  Node positiveResult =
      result1.getMinimized(MinimizationStyle.PREFER_UNNEGATED).buildReplacement();
  // Without counting the leading NOT node:
  Node negativeResult =
      result2.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT).buildReplacement();
  if (!positiveResult.isEquivalentTo(positiveNode)) {
    fail("Not equal:" +
        "\nExpected: " + positive +
        "\nBut was : " + (new Compiler()).toSource(positiveResult) +
        "\nExpected tree:\n" + positiveNode.toStringTree() +
        "\nActual tree:\n" + positiveResult.toStringTree());
  }
  if (!negativeResult.isEquivalentTo(negativeNode)) {
    fail("Not equal:" +
        "\nExpected: " + negative +
        "\nBut was : " + (new Compiler()).toSource(negativeResult) +
        "\nExpected tree:\n" + negativeNode.toStringTree() +
        "\nActual tree:\n" + negativeResult.toStringTree());
  }
}
 
開發者ID:google,項目名稱:closure-compiler,代碼行數:28,代碼來源:MinimizedConditionTest.java

示例9: tryMinimizeCondition

import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //導入依賴的package包/類
/**
 * Try to minimize condition expression, as there are additional
 * assumptions that can be made when it is known that the final result
 * is a boolean.
 *
 * @return The replacement for n, or the original if no change was made.
 */
private Node tryMinimizeCondition(Node n) {
  n = performConditionSubstitutions(n);
  MinimizedCondition minCond = MinimizedCondition.fromConditionNode(n);
  return replaceNode(
      minCond.getPlaceholder(),
      minCond.getMinimized(MinimizationStyle.PREFER_UNNEGATED));
}
 
開發者ID:nicks,項目名稱:closure-compiler-old,代碼行數:15,代碼來源:PeepholeMinimizeConditions.java


注:本文中的com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。