Examples of ICPPASTRangeBasedForStatement


Examples of org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement

    }
    return f.newExpressionStatement(f.newFunctionCallExpression(call, initializerClauses.toArray(new IASTInitializerClause[initializerClauses.size()])));
  }

  private IASTStatement convertEnhancedForStatement(final EnhancedForStatement enhancedForStatement) {
    final ICPPASTRangeBasedForStatement rangeBased = f.newRangeBasedForStatement();

    final ICPPASTSimpleDeclSpecifier declSpecifier = f.newSimpleDeclSpecifier();
    declSpecifier.setStorageClass(IASTDeclSpecifier.sc_auto);
    final IASTSimpleDeclaration declaration = f.newSimpleDeclaration(declSpecifier);

    final SingleVariableDeclarationInfo parameter = new SingleVariableDeclarationInfo(enhancedForStatement.getParameter(), compilationUnitInfo);
    final ICPPASTDeclarator declarator = parameter.getDeclarator();
    for (int i = 0; i < declarator.getPointerOperators().length; i++) {
      declarator.getPointerOperators()[i] = null;
    }
    declaration.addDeclarator(declarator);

    rangeBased.setDeclaration(declaration);

    final ExpressionInfo expressionInfo = new ExpressionInfo(enhancedForStatement.getExpression(), typeDeclaration, compilationUnitInfo);
    rangeBased.setInitializerClause(expressionInfo.getExpression());

    final StatementInfo body = new StatementInfo(enhancedForStatement.getBody(), typeDeclaration, compilationUnitInfo);
    rangeBased.setBody(body.getStatement());
    return rangeBased;
  }
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.