Package com.google.dart.engine.ast

Examples of com.google.dart.engine.ast.Expression


  }

  @Override
  public Void visitVariableDeclaration(VariableDeclaration node) {
    SimpleIdentifier nameNode = node.getName();
    Expression initializerNode = node.getInitializer();
    // do checks
    checkForInvalidAssignment(nameNode, initializerNode);
    // visit name
    nameNode.accept(this);
    // visit initializer
    String name = nameNode.getName();
    namesForReferenceToDeclaredVariableInInitializer.add(name);
    isInInstanceVariableInitializer = isInInstanceVariableDeclaration;
    try {
      if (initializerNode != null) {
        initializerNode.accept(this);
      }
    } finally {
      isInInstanceVariableInitializer = false;
      namesForReferenceToDeclaredVariableInInitializer.remove(name);
    }
View Full Code Here


   */
  private boolean checkForAllReturnStatementErrorCodes(ReturnStatement node) {
    FunctionType functionType = enclosingFunction == null ? null : enclosingFunction.getType();
    Type expectedReturnType = functionType == null ? DynamicTypeImpl.getInstance()
        : functionType.getReturnType();
    Expression returnExpression = node.getExpression();
    // RETURN_IN_GENERATIVE_CONSTRUCTOR
    boolean isGenerativeConstructor = enclosingFunction instanceof ConstructorElement
        && !((ConstructorElement) enclosingFunction).isFactory();
    if (isGenerativeConstructor) {
      if (returnExpression == null) {
View Full Code Here

          || statement instanceof ReturnStatement) {
        return false;
      }
      // terminated with 'throw' expression
      if (statement instanceof ExpressionStatement) {
        Expression expression = ((ExpressionStatement) statement).getExpression();
        if (expression instanceof ThrowExpression) {
          return false;
        }
      }
    }
View Full Code Here

    }
    FieldElement fieldElement = (FieldElement) staticElement;
    // prepare field type
    Type fieldType = fieldElement.getType();
    // prepare expression type
    Expression expression = node.getExpression();
    if (expression == null) {
      return false;
    }
    // test the static type of the expression
    Type staticType = getStaticType(expression);
View Full Code Here

    }
    // Check every map entry.
    boolean hasProblems = false;
    NodeList<MapLiteralEntry> entries = node.getEntries();
    for (MapLiteralEntry entry : entries) {
      Expression key = entry.getKey();
      Expression value = entry.getValue();
      hasProblems |= checkForArgumentTypeNotAssignableWithExpectedTypes(key, keyType, keyErrorCode);
      hasProblems |= checkForArgumentTypeNotAssignableWithExpectedTypes(
          value,
          valueType,
          valueErrorCode);
View Full Code Here

   * @param statement the switch statement to check
   * @return {@code true} if and only if an error code is generated on the passed node
   */
  private boolean checkForMissingEnumConstantInSwitch(SwitchStatement statement) {
    // TODO(brianwilkerson) This needs to be checked after constant values have been computed.
    Expression expression = statement.getExpression();
    Type expressionType = getStaticType(expression);
    if (expressionType == null) {
      return false;
    }
    Element expressionElement = expressionType.getElement();
View Full Code Here

   * @param node the assert statement to evaluate
   * @return {@code true} if and only if an error code is generated on the passed node
   * @see StaticTypeWarningCode#NON_BOOL_EXPRESSION
   */
  private boolean checkForNonBoolExpression(AssertStatement node) {
    Expression expression = node.getCondition();
    Type type = getStaticType(expression);
    if (type instanceof InterfaceType) {
      if (!type.isAssignableTo(boolType)) {
        errorReporter.reportErrorForNode(StaticTypeWarningCode.NON_BOOL_EXPRESSION, expression);
        return true;
View Full Code Here

   * @return {@code true} if and only if an error code is generated on the passed node
   * @see StaticWarningCode#SWITCH_EXPRESSION_NOT_ASSIGNABLE
   */
  private boolean checkForSwitchExpressionNotAssignable(SwitchStatement node) {
    // prepare 'switch' expression type
    Expression expression = node.getExpression();
    Type expressionType = getStaticType(expression);
    if (expressionType == null) {
      return false;
    }
    // compare with type of the first 'case'
    NodeList<SwitchMember> members = node.getMembers();
    for (SwitchMember switchMember : members) {
      if (!(switchMember instanceof SwitchCase)) {
        continue;
      }
      SwitchCase switchCase = (SwitchCase) switchMember;
      // prepare 'case' type
      Expression caseExpression = switchCase.getExpression();
      Type caseType = getStaticType(caseExpression);
      // check types
      if (expressionType.isAssignableTo(caseType)) {
        return false;
      }
View Full Code Here

  }

  @Override
  public Void visitBinaryExpression(BinaryExpression node) {
    TokenType operatorType = node.getOperator().getType();
    Expression leftOperand = node.getLeftOperand();
    Expression rightOperand = node.getRightOperand();
    if (operatorType == TokenType.AMPERSAND_AMPERSAND) {
      safelyVisit(leftOperand);
      if (rightOperand != null) {
        overrideManager.enterScope();
        try {
          promoteManager.enterScope();
          try {
            propagateTrueState(leftOperand);
            // Type promotion.
            promoteTypes(leftOperand);
            clearTypePromotionsIfPotentiallyMutatedIn(leftOperand);
            clearTypePromotionsIfPotentiallyMutatedIn(rightOperand);
            clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(rightOperand);
            // Visit right operand.
            rightOperand.accept(this);
          } finally {
            promoteManager.exitScope();
          }
        } finally {
          overrideManager.exitScope();
        }
      }
    } else if (operatorType == TokenType.BAR_BAR) {
      safelyVisit(leftOperand);
      if (rightOperand != null) {
        overrideManager.enterScope();
        try {
          propagateFalseState(leftOperand);
          rightOperand.accept(this);
        } finally {
          overrideManager.exitScope();
        }
      }
    } else {
View Full Code Here

    return null;
  }

  @Override
  public Void visitConditionalExpression(ConditionalExpression node) {
    Expression condition = node.getCondition();
    safelyVisit(condition);
    Expression thenExpression = node.getThenExpression();
    if (thenExpression != null) {
      overrideManager.enterScope();
      try {
        promoteManager.enterScope();
        try {
          propagateTrueState(condition);
          // Type promotion.
          promoteTypes(condition);
          clearTypePromotionsIfPotentiallyMutatedIn(thenExpression);
          clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenExpression);
          // Visit "then" expression.
          thenExpression.accept(this);
        } finally {
          promoteManager.exitScope();
        }
      } finally {
        overrideManager.exitScope();
      }
    }
    Expression elseExpression = node.getElseExpression();
    if (elseExpression != null) {
      overrideManager.enterScope();
      try {
        propagateFalseState(condition);
        elseExpression.accept(this);
      } finally {
        overrideManager.exitScope();
      }
    }
    node.accept(elementResolver);
View Full Code Here

TOP

Related Classes of com.google.dart.engine.ast.Expression

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.