Package com.google.dart.engine.internal.constant

Examples of com.google.dart.engine.internal.constant.ValidResult


  @Override
  public Void visitConditionalExpression(ConditionalExpression node) {
    Expression conditionExpression = node.getCondition();
    safelyVisit(conditionExpression);
    if (!isDebugConstant(conditionExpression)) {
      ValidResult result = getConstantBooleanValue(conditionExpression);
      if (result != null) {
        if (result.isTrue()) {
          // report error on else block: true ? 1 : !2!
          errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.getElseExpression());
          safelyVisit(node.getThenExpression());
          return null;
        } else {
View Full Code Here


  @Override
  public Void visitIfStatement(IfStatement node) {
    Expression conditionExpression = node.getCondition();
    safelyVisit(conditionExpression);
    if (!isDebugConstant(conditionExpression)) {
      ValidResult result = getConstantBooleanValue(conditionExpression);
      if (result != null) {
        if (result.isTrue()) {
          // report error on else block: if(true) {} else {!}
          Statement elseStatement = node.getElseStatement();
          if (elseStatement != null) {
            errorReporter.reportErrorForNode(HintCode.DEAD_CODE, elseStatement);
            safelyVisit(node.getThenStatement());
View Full Code Here

  @Override
  public Void visitWhileStatement(WhileStatement node) {
    Expression conditionExpression = node.getCondition();
    safelyVisit(conditionExpression);
    if (!isDebugConstant(conditionExpression)) {
      ValidResult result = getConstantBooleanValue(conditionExpression);
      if (result != null) {
        if (result.isFalse()) {
          // report error on if block: while (false) {!}
          errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.getBody());
          return null;
        }
      }
View Full Code Here

   *         value
   */
  private ValidResult getConstantBooleanValue(Expression expression) {
    if (expression instanceof BooleanLiteral) {
      if (((BooleanLiteral) expression).getValue()) {
        return new ValidResult(new DartObjectImpl(null, BoolState.from(true)));
      } else {
        return new ValidResult(new DartObjectImpl(null, BoolState.from(false)));
      }
    }
    // Don't consider situations where we could evaluate to a constant boolean expression with the
    // ConstantVisitor
//    else {
View Full Code Here

    boolean isAmpAmp = operator.getType() == TokenType.AMPERSAND_AMPERSAND;
    boolean isBarBar = operator.getType() == TokenType.BAR_BAR;
    if (isAmpAmp || isBarBar) {
      Expression lhsCondition = node.getLeftOperand();
      if (!isDebugConstant(lhsCondition)) {
        ValidResult lhsResult = getConstantBooleanValue(lhsCondition);
        if (lhsResult != null) {
          if (lhsResult.isTrue() && isBarBar) {
            // report error on else block: true || !e!
            errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.getRightOperand());
            // only visit the LHS:
            safelyVisit(lhsCondition);
            return null;
          } else if (lhsResult.isFalse() && isAmpAmp) {
            // report error on if block: false && !e!
            errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.getRightOperand());
            // only visit the LHS:
            safelyVisit(lhsCondition);
            return null;
View Full Code Here

      // Create a value for the constant.
      //
      HashMap<String, DartObjectImpl> fieldMap = new HashMap<String, DartObjectImpl>();
      fieldMap.put(indexFieldName, new DartObjectImpl(intType, new IntState(BigInteger.valueOf(i))));
      DartObjectImpl value = new DartObjectImpl(enumType, new GenericState(fieldMap));
      constantField.setEvaluationResult(new ValidResult(value));
      fields.add(constantField);
      getters.add(createGetter(constantField));
      constantName.setStaticElement(constantField);
    }
    //
View Full Code Here

      }
    }
  }

  private ValidResult valid(InterfaceType type, InstanceState state) {
    return new ValidResult(new DartObjectImpl(type, state));
  }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.internal.constant.ValidResult

Copyright © 2018 www.massapicom. 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.