Examples of toBoolean()


Examples of com.google.javascript.rhino.jstype.TernaryValue.toBoolean()

      branchToKeep.addChildToFront(IR.exprResult(cond).srcref(cond));
      reportCodeChange();
      cond = newCond;
    }

    boolean condTrue = condValue.toBoolean(true);
    if (n.getChildCount() == 2) {
      Preconditions.checkState(type == Token.IF);

      if (condTrue) {
        // Replace "if (true) { X }" with "X".
View Full Code Here

Examples of com.google.javascript.rhino.jstype.TernaryValue.toBoolean()

        return n;  // We can't remove branches otherwise!
      }
    }

    // Transform "(a = 2) ? x =2 : y" into "a=2,x=2"
    Node branchToKeep = condValue.toBoolean(true) ? thenBody : elseBody;
    Node replacement;
    boolean condHasSideEffects = mayHaveSideEffects(cond);
    // Must detach after checking for side effects, to ensure that the parents
    // of nodes are set correctly.
    n.detachChildren();
View Full Code Here

Examples of com.google.javascript.rhino.jstype.TernaryValue.toBoolean()

        return "undefined";

      case Token.NOT:
        TernaryValue child = getPureBooleanValue(n.getFirstChild());
        if (child != TernaryValue.UNKNOWN) {
          return child.toBoolean(true) ? "false" : "true"; // reversed.
        }
        break;

      case Token.ARRAYLIT:
        return arrayToString(n);
View Full Code Here

Examples of com.google.javascript.rhino.jstype.TernaryValue.toBoolean()

        return null;

      case Token.NOT:
        TernaryValue child = getPureBooleanValue(n.getFirstChild());
        if (child != TernaryValue.UNKNOWN) {
          return child.toBoolean(true) ? 0.0 : 1.0; // reversed.
        }
        break;

      case Token.STRING:
        return getStringNumberValue(n.getString());
View Full Code Here

Examples of com.google.javascript.rhino.jstype.TernaryValue.toBoolean()

        // the new AST is easier for other passes to handle.
        TernaryValue rightVal = NodeUtil.getPureBooleanValue(right);
        if (NodeUtil.getPureBooleanValue(right) != TernaryValue.UNKNOWN) {
          int type = n.getType();
          Node replacement = null;
          boolean rval = rightVal.toBoolean(true);

          // (x || FALSE) => x
          // (x && TRUE) => x
          if (type == Token.OR && !rval ||
              type == Token.AND && rval) {
View Full Code Here

Examples of com.google.javascript.rhino.jstype.TernaryValue.toBoolean()

      default:
        // while(true) --> while(1)
        TernaryValue nVal = NodeUtil.getPureBooleanValue(n);
        if (nVal != TernaryValue.UNKNOWN) {
          boolean result = nVal.toBoolean(true);
          int equivalentResult = result ? 1 : 0;
          return maybeReplaceChildWithNumber(n, parent, equivalentResult);
        }
        // We can't do anything else currently.
        return n;
View Full Code Here

Examples of com.google.javascript.rhino.jstype.TernaryValue.toBoolean()

      // TODO(user): Handle more complicated expression like true == true,
      // etc....
      if (condition != null) {
        TernaryValue val = NodeUtil.getImpureBooleanValue(condition);
        if (val != TernaryValue.UNKNOWN) {
          return val.toBoolean(true) == (branch == Branch.ON_TRUE);
        }
      }
      return true;
    }
  }
View Full Code Here

Examples of com.google.template.soy.data.SoyData.toBoolean()


  @Override protected SoyData visitNotOpNode(NotOpNode node) {

    SoyData operand = visit(node.getChild(0));
    return convertResult( ! operand.toBoolean() );
  }


  @Override protected SoyData visitTimesOpNode(TimesOpNode node) {
View Full Code Here

Examples of com.google.template.soy.data.SoyData.toBoolean()

      return// cannot simplify
    }

    ExprNode replacementNode;
    if (operand0 != null && operand1 != null) {
      replacementNode = new BooleanNode(operand0.toBoolean() && operand1.toBoolean());
    } else if (operand0 != null) {
      replacementNode = operand0.toBoolean() ? node.getChild(1) : new BooleanNode(false);
    } else /*(operand1 != null)*/ {
      replacementNode = operand1.toBoolean() ? node.getChild(0) : new BooleanNode(false);
    }
View Full Code Here

Examples of com.google.template.soy.data.SoyData.toBoolean()

    if (operand0 != null && operand1 != null) {
      replacementNode = new BooleanNode(operand0.toBoolean() && operand1.toBoolean());
    } else if (operand0 != null) {
      replacementNode = operand0.toBoolean() ? node.getChild(1) : new BooleanNode(false);
    } else /*(operand1 != null)*/ {
      replacementNode = operand1.toBoolean() ? node.getChild(0) : new BooleanNode(false);
    }

    node.getParent().replaceChild(node, replacementNode);
  }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.