Package org.eclipse.cdt.core.dom.ast

Examples of org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration


    return convertFragments(wrapper, declSpecifier);
  }

  private IASTSimpleDeclaration convertFragments(final VariableDeclarationWrapper wrapper, final IASTDeclSpecifier declSpecifier) {
    final IASTSimpleDeclaration simpleDeclaration = f.newSimpleDeclaration(declSpecifier);
    for (final Object fragmentObject : wrapper.fragments()) {
      final VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragmentObject;
      final VariableDeclarationFragmentInfo fragmentInfo = new VariableDeclarationFragmentInfo(fragment, wrapper.getType(), compilationUnitInfo);
      simpleDeclaration.addDeclarator(fragmentInfo.getDeclarator());

    }
    return simpleDeclaration;
  }
View Full Code Here


    // If the type is nested, simulate Java inner class access visibility by creating a
    // reference to the outer type on the constructor and store it in the object
    if (enclosingType != null) {
      final ICPPASTDeclSpecifier parentReferenceDeclSpecifier = f.newTypedefNameSpecifier(new NameInfo(enclosingType.getName()).getName());
      final IASTSimpleDeclaration parentReference = f.newSimpleDeclaration(parentReferenceDeclSpecifier);
      final ICPPASTDeclarator parentReferenceDeclarator = f.newDeclarator(f.newName("__parent".toCharArray()));
      parentReference.addDeclarator(parentReferenceDeclarator);
      parentReferenceDeclarator.addPointerOperator(f.newPointer());
      final ModifiersInfo modifiersInfo = new ModifiersInfo(false, false, true, false, false, false, false);
      fields.add(new FieldDeclarationInfo(parentReference, modifiersInfo));
    }
  }
View Full Code Here

  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());
View Full Code Here

      declSpecifier.setStorageClass(IASTDeclSpecifier.sc_static);
    }
  }

  private IASTSimpleDeclaration convertFragments(final IASTDeclSpecifier declSpecifier) {
    final IASTSimpleDeclaration simpleDeclaration = f.newSimpleDeclaration(declSpecifier);
    for (final Object fragmentObject : fieldDeclaration.fragments()) {
      final VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragmentObject;
      final VariableDeclarationFragmentInfo fragmentInfo = new VariableDeclarationFragmentInfo(fragment, fieldDeclaration.getType(), compilationUnitInfo);
      fragments.put(new NameInfo(fragment.getName()).getName(), fragmentInfo.initializer);
      final ITypeBinding typeBinding = fieldDeclaration.getType().resolveBinding();
      if ((fragmentInfo.getDeclarator().getInitializer() == null) && !new TypeInfo(fieldDeclaration.getType(), compilationUnitInfo).isStl() && !typeBinding.isEnum()) {
        fragmentInfo.getDeclarator().setInitializer(f.newEqualsInitializer(typeInfo.getJavaDefaultValue()));
      }
      simpleDeclaration.addDeclarator(fragmentInfo.getDeclarator());
    }
    return simpleDeclaration;
  }
View Full Code Here

      ExprVisitor initExpr = new ExprVisitor();
      ExprVisitor finalExpr = new ExprVisitor();

      if (initializer instanceof IASTDeclarationStatement) {
        IASTDeclarationStatement declaration = (IASTDeclarationStatement) initializer;
        IASTSimpleDeclaration simple = (IASTSimpleDeclaration) (declaration.getDeclaration());
     
        IASTDeclarator[] declarators = simple.getDeclarators();
        initVar = declarators[0].getName().getRawSignature();
        ((IASTEqualsInitializer) (declarators[0].getInitializer())).getInitializerClause().accept(initExpr);
      } else {     
       initVar = ((IASTBinaryExpression) (((IASTExpressionStatement) initializer)
          .getExpression())).getOperand1().getRawSignature();
View Full Code Here

TOP

Related Classes of org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration

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.