Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/.settings/.api_filters45
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java46
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java112
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java43
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEqualsInitializer.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerExpression.java)25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java62
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitName.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitNameOwner.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerClause.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializer.java)16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java38
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java28
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java191
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java58
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java40
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArraySubscriptExpression.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java63
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java50
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExpressionList.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java127
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java129
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java259
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IInactiveCodeToken.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java87
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java107
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java40
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousSimpleDeclaration.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java70
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java34
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java123
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerExpression.java69
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerList.java81
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTReturnStatement.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java294
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java41
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java35
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java33
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java91
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java119
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEqualsInitializer.java34
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java149
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java81
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java119
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java266
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java35
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java44
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java188
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java127
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java493
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java34
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java699
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java110
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java93
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java52
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java27
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java55
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOParser64.java1
72 files changed, 3097 insertions, 2260 deletions
diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters
new file mode 100644
index 00000000000..2aae30a0706
--- /dev/null
+++ b/core/org.eclipse.cdt.core/.settings/.api_filters
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.cdt.core" version="2">
+ <resource path="parser/org/eclipse/cdt/core/dom/ast/IASTImplicitName.java" type="org.eclipse.cdt.core.dom.ast.IASTImplicitName">
+ <filter id="403853384">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.dom.ast.IASTImplicitName"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="parser/org/eclipse/cdt/core/dom/ast/IASTImplicitNameOwner.java" type="org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner">
+ <filter id="403853384">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArraySubscriptExpression.java" type="org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArraySubscriptExpression">
+ <filter id="403853384">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArraySubscriptExpression"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExpressionList.java" type="org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList">
+ <filter id="403853384">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java" type="org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression">
+ <filter id="403853384">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="parser/org/eclipse/cdt/core/parser/IInactiveCodeToken.java" type="org.eclipse.cdt.core.parser.IInactiveCodeToken">
+ <filter id="403853384">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.parser.IInactiveCodeToken"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java
index 48d6f7a138e..89b0f7b28dd 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java
@@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
@@ -26,7 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -51,12 +52,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.parser.Keywords;
@@ -324,20 +325,20 @@ public class ASTStringUtil {
}
private static StringBuilder appendInitializerString(StringBuilder buffer, IASTInitializer initializer) {
- if (initializer instanceof IASTInitializerExpression) {
- final IASTInitializerExpression initializerExpression= (IASTInitializerExpression)initializer;
+ if (initializer instanceof IASTEqualsInitializer) {
+ final IASTEqualsInitializer initializerExpression= (IASTEqualsInitializer)initializer;
buffer.append(Keywords.cpASSIGN);
- appendExpressionString(buffer, initializerExpression.getExpression());
+ appendInitClauseString(buffer, initializerExpression.getInitializerClause());
} else if (initializer instanceof IASTInitializerList) {
final IASTInitializerList initializerList= (IASTInitializerList)initializer;
- final IASTInitializer[] initializers= initializerList.getInitializers();
+ final IASTInitializerClause[] initializers= initializerList.getClauses();
buffer.append(Keywords.cpASSIGN);
buffer.append(Keywords.cpLBRACE);
for (int i= 0; i < initializers.length; i++) {
if (i > 0) {
buffer.append(COMMA_SPACE);
}
- appendInitializerString(buffer, initializers[i]);
+ appendInitClauseString(buffer, initializers[i]);
}
trimRight(buffer);
buffer.append(Keywords.cpRBRACE);
@@ -347,9 +348,14 @@ public class ASTStringUtil {
// final ICASTDesignator[] designator= designatedInitializer.getDesignators();
} else if (initializer instanceof ICPPASTConstructorInitializer) {
final ICPPASTConstructorInitializer constructorInitializer= (ICPPASTConstructorInitializer)initializer;
- final IASTExpression expression= constructorInitializer.getExpression();
+ final IASTInitializerClause[] clauses= constructorInitializer.getArguments();
buffer.append(Keywords.cpLPAREN);
- appendExpressionString(buffer, expression);
+ for (int i= 0; i < clauses.length; i++) {
+ if (i > 0) {
+ buffer.append(COMMA_SPACE);
+ }
+ appendInitClauseString(buffer, clauses[i]);
+ }
trimRight(buffer);
buffer.append(Keywords.cpRPAREN);
} else if (initializer != null) {
@@ -358,6 +364,14 @@ public class ASTStringUtil {
return buffer;
}
+ private static void appendInitClauseString(StringBuilder buffer, IASTInitializerClause initializerClause) {
+ if (initializerClause instanceof IASTExpression) {
+ appendExpressionString(buffer, (IASTExpression) initializerClause);
+ } else if (initializerClause instanceof IASTInitializer) {
+ appendInitializerString(buffer, (IASTInitializer) initializerClause);
+ }
+ }
+
private static StringBuilder appendTypeIdString(StringBuilder buffer, IASTTypeId typeId) {
appendDeclSpecifierString(buffer, typeId.getDeclSpecifier());
appendDeclaratorString(buffer, typeId.getAbstractDeclarator(), false, null);
@@ -681,14 +695,12 @@ public class ASTStringUtil {
}
appendExpressionString(buffer, expressions[i]);
}
- } else if (expression instanceof ICPPASTTypenameExpression) {
- final ICPPASTTypenameExpression typenameExpression= (ICPPASTTypenameExpression)expression;
- buffer.append(Keywords.TYPENAME).append(' ');
- appendQualifiedNameString(buffer, typenameExpression.getName());
- final IASTExpression initialValue= typenameExpression.getInitialValue();
- if (initialValue != null) {
- buffer.append(Keywords.cpASSIGN);
- appendExpressionString(buffer, initialValue);
+ } else if (expression instanceof ICPPASTSimpleTypeConstructorExpression) {
+ final ICPPASTSimpleTypeConstructorExpression typeCast= (ICPPASTSimpleTypeConstructorExpression)expression;
+ appendDeclSpecifierString(buffer, typeCast.getDeclSpecifier());
+ final IASTInitializer init= typeCast.getInitializer();
+ if (init != null) {
+ appendInitializerString(buffer, init);
}
} else if (expression instanceof IASTLiteralExpression) {
buffer.append(ASTSignatureUtil.getExpressionString(expression));
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
index 1ac28708624..fca79f0bb96 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
@@ -28,7 +28,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
@@ -324,16 +323,12 @@ public class ASTSignatureUtil {
public static String getInitializerString(IASTInitializer init) {
StringBuffer result = new StringBuffer();
- if (init instanceof IASTInitializerExpression) {
- result.append(getExpressionString(((IASTInitializerExpression) init).getExpression()));
+ if (init instanceof IASTEqualsInitializer) {
+ result.append(Keywords.cpASSIGN);
+ result.append(getInitializerClauseString(((IASTEqualsInitializer) init).getInitializerClause()));
} else if (init instanceof IASTInitializerList) {
result.append(Keywords.cpLBRACE);
- IASTInitializer[] inits = ((IASTInitializerList) init).getInitializers();
- for (int i = 0; i < inits.length; i++) {
- result.append(getInitializerString(inits[i]));
- if (i < inits.length - 1)
- result.append(COMMA_SPACE);
- }
+ appendExpressionList(result, ((IASTInitializerList) init).getClauses());
result.append(Keywords.cpRBRACE);
} else if (init instanceof ICASTDesignatedInitializer) {
ICASTDesignator[] designators = ((ICASTDesignatedInitializer) init).getDesignators();
@@ -343,16 +338,34 @@ public class ASTSignatureUtil {
result.append(COMMA_SPACE);
}
result.append(Keywords.cpASSIGN);
- result.append(getInitializerString(((ICASTDesignatedInitializer) init).getOperandInitializer()));
+ result.append(getInitializerClauseString(((ICASTDesignatedInitializer) init).getOperand()));
} else if (init instanceof ICPPASTConstructorInitializer) {
result.append("("); //$NON-NLS-1$
- result.append(getExpressionString(((ICPPASTConstructorInitializer) init).getExpression()));
+ appendExpressionList(result, ((ICPPASTConstructorInitializer) init).getArguments());
result.append(")"); //$NON-NLS-1$
}
return result.toString();
}
+ private static void appendExpressionList(StringBuffer result, IASTInitializerClause[] inits) {
+ for (int i = 0; i < inits.length; i++) {
+ result.append(getInitializerClauseString(inits[i]));
+ if (i < inits.length - 1)
+ result.append(COMMA_SPACE);
+ }
+ }
+
+ private static String getInitializerClauseString(IASTInitializerClause initializerClause) {
+ if (initializerClause instanceof IASTExpression) {
+ return getExpressionString((IASTExpression) initializerClause);
+ }
+ if (initializerClause instanceof IASTInitializer) {
+ return getInitializerString((IASTInitializer) initializerClause);
+ }
+ return ""; //$NON-NLS-1$
+ }
+
private static String getDesignatorSignature(ICASTDesignator designator) {
StringBuffer result = new StringBuffer();
@@ -796,8 +809,6 @@ public class ASTSignatureUtil {
return getNewExpression((ICPPASTNewExpression)expression);
else if (expression instanceof ICPPASTSimpleTypeConstructorExpression)
return getSimpleTypeConstructorExpression((ICPPASTSimpleTypeConstructorExpression)expression);
- else if (expression instanceof ICPPASTTypenameExpression)
- return getTypenameExpression((ICPPASTTypenameExpression)expression);
else if (expression instanceof IGNUASTCompoundStatementExpression)
return getCompoundStatementExpression((IGNUASTCompoundStatementExpression)expression);
else if (expression instanceof ICPPASTPackExpansionExpression)
@@ -856,7 +867,13 @@ public class ASTSignatureUtil {
StringBuffer result = new StringBuffer();
result.append(getExpressionString(expression.getFunctionNameExpression()));
result.append(Keywords.cpLPAREN);
- result.append(getExpressionString(expression.getParameterExpression()));
+ IASTInitializerClause[] clauses = expression.getArguments();
+ for (int i= 0; i < clauses.length; i++) {
+ if (i > 0) {
+ result.append(COMMA_SPACE);
+ }
+ result.append(getInitializerClauseString(clauses[i]));
+ }
result.append(Keywords.cpRPAREN);
return result.toString();
}
@@ -881,58 +898,8 @@ public class ASTSignatureUtil {
private static String getSimpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression expression) {
StringBuffer result = new StringBuffer();
- switch (expression.getSimpleType()) {
- case ICPPASTSimpleTypeConstructorExpression.t_bool:
- result.append(Keywords.BOOL);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_char:
- result.append(Keywords.CHAR);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_double:
- result.append(Keywords.DOUBLE);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_float:
- result.append(Keywords.FLOAT);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_int:
- result.append(Keywords.INT);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_long:
- result.append(Keywords.LONG);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_short:
- result.append(Keywords.SHORT);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_signed:
- result.append(Keywords.SIGNED);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_unsigned:
- result.append(Keywords.UNSIGNED);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_void:
- result.append(Keywords.VOID);
- break;
- case ICPPASTSimpleTypeConstructorExpression.t_wchar_t:
- result.append(Keywords.WCHAR_T);
- break;
- }
- result.append(Keywords.cpLPAREN);
- result.append(expression.getInitialValue());
- result.append(Keywords.cpRPAREN);
- return result.toString();
- }
-
- private static String getTypenameExpression(ICPPASTTypenameExpression expression) {
- StringBuffer result = new StringBuffer();
- result.append(Keywords.TYPENAME);
- result.append(SPACE);
- result.append(expression.getName().toString());
- IASTExpression initValue = expression.getInitialValue();
- result.append(Keywords.cpLPAREN);
- if (initValue != null) {
- result.append(getExpressionString(initValue));
- }
- result.append(Keywords.cpRPAREN);
+ result.append(getSignature(expression.getDeclSpecifier()));
+ result.append(getInitializerString(expression.getInitializer()));
return result.toString();
}
@@ -1004,13 +971,16 @@ public class ASTSignatureUtil {
StringBuffer result = new StringBuffer();
result.append(Keywords.NEW);
result.append(SPACE);
- if (expression.getNewPlacement() != null) {
- result.append(getExpressionString(expression.getNewPlacement()));
+ final IASTInitializerClause[] args = expression.getPlacementArguments();
+ if (args != null) {
+ result.append("("); //$NON-NLS-1$
+ appendExpressionList(result, args);
+ result.append(")"); //$NON-NLS-1$
}
result.append(getSignature(expression.getTypeId()));
- result.append(Keywords.cpLPAREN);
- result.append(getExpressionString(expression.getNewInitializer()));
- result.append(Keywords.cpRPAREN);
+ final IASTInitializer initializer = expression.getInitializer();
+ if (initializer != null)
+ result.append(getInitializerString(initializer));
return result.toString();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java
index f3efe3a618f..3e9580a921e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTArraySubscriptExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,15 +19,18 @@ package org.eclipse.cdt.core.dom.ast;
*/
public interface IASTArraySubscriptExpression extends IASTExpression {
+ public static final ASTNodeProperty ARRAY = new ASTNodeProperty(
+ "IASTArraySubscriptExpression.ARRAY [IASTExpression]"); //$NON-NLS-1$
+ public static final ASTNodeProperty SUBSCRIPT = new ASTNodeProperty(
+ "IASTArraySubscriptExpression.SUBSCRIPT - [IASTFunctionArgument]"); //$NON-NLS-1$
+
/**
- * Node property that describes the relationship between an
- * <code>IASTArraySubscriptExpression</code> and an
- * <code>IASTExpression</code> representing the subscript.
+ * @since 5.1
*/
- public static final ASTNodeProperty ARRAY = new ASTNodeProperty("IASTArraySubscriptExpression.ARRAY - IASTExpression representing the Array"); //$NON-NLS-1$
-
+ IASTArraySubscriptExpression copy();
+
/**
- * Get the expression that represents the array.
+ * Get the expression that represents the array
*
* @return <code>IASTExpression</code> that represents the array.
*/
@@ -42,30 +45,24 @@ public interface IASTArraySubscriptExpression extends IASTExpression {
public void setArrayExpression(IASTExpression expression);
/**
- * Node property that describes the relationship between an
- * <code>IASTArraySubscriptExpression</code> and an
- * <code>IASTExpression</code> representing the array.
+ * Returns the operand of this expression. In c++ the operand can be a braced initializer list.
+ * @since 5.2
*/
- public static final ASTNodeProperty SUBSCRIPT = new ASTNodeProperty(
- "IASTArraySubscriptExpression.SUBSCRIPT - IASTExpression representing the Subscript"); //$NON-NLS-1$
+ public IASTInitializerClause getArgument();
/**
- * Get the subscript expression.
- *
- * @return <code>IASTExpression</code> that represents the subscript.
+ * Not allowed on frozen ast.
+ * @since 5.2
*/
- public IASTExpression getSubscriptExpression();
+ public void setArgument(IASTInitializerClause expression);
/**
- * Set the subscript expression.
- *
- * @param expression
- * <code>IASTExpression</code> to be set.
+ * Returns the subscript expression, or <code>null</code>. Consider using {@link #getArgument()}.
*/
- public void setSubscriptExpression(IASTExpression expression);
+ public IASTExpression getSubscriptExpression();
/**
- * @since 5.1
+ * Not allowed on frozen ast.
*/
- public IASTArraySubscriptExpression copy();
+ public void setSubscriptExpression(IASTExpression expression);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java
index 671c35c2e4c..8e30888c24a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@@ -255,6 +256,13 @@ public interface IASTBinaryExpression extends IASTExpression {
public IASTExpression getOperand2();
/**
+ * Returns the second operand of the expression. For c++ assignment expressions this can be
+ * a braced list initializer.
+ * @since 5.2
+ */
+ public IASTInitializerClause getInitOperand2();
+
+ /**
* @param expression
* <code>IASTExpression</code> value
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEqualsInitializer.java
index 835cecee6eb..67cca433a4b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTEqualsInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,17 +8,28 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.core.dom.ast.cpp;
+package org.eclipse.cdt.core.dom.ast;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
/**
- * Initializer expression for c++.
- *
+ * Initializer with equals sign (copy initialization) as in <code>int x= 0;</code>.
+ * @since 5.2
+ *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
- * @since 5.2
*/
-public interface ICPPASTInitializerExpression extends IASTInitializerExpression, ICPPASTInitializer {
+public interface IASTEqualsInitializer extends IASTInitializer {
+ ASTNodeProperty INITIALIZER = new ASTNodeProperty(
+ "IASTEqualsInitializer - INITIALIZER [IASTInitializerClause]"); //$NON-NLS-1$
+
+ /**
+ * Returns the expression or braced initializer list of this initializer.
+ */
+ IASTInitializerClause getInitializerClause();
+
+ /**
+ * Not allowed on frozen ast.
+ */
+ void setInitializerClause(IASTInitializerClause clause);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java
index 973e23d65ef..ce7f1d0a09f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,7 +17,7 @@ package org.eclipse.cdt.core.dom.ast;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface IASTExpression extends IASTNode {
+public interface IASTExpression extends IASTInitializerClause {
/**
* Empty expression array.
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java
index 62443d31847..46a07d33f85 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionCallExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@@ -19,55 +20,54 @@ package org.eclipse.cdt.core.dom.ast;
*/
public interface IASTFunctionCallExpression extends IASTExpression {
- /**
- * <code>FUNCTION_NAME</code> represents the relationship between a
- * <code>IASTFunctionCallExpression</code> and its
- * <code>IASTExpression</code> (function name).
- */
public static final ASTNodeProperty FUNCTION_NAME = new ASTNodeProperty(
- "IASTFunctionCallExpression.FUNCTION_Name - IASTExpression (name) for IASTFunctionCallExpression"); //$NON-NLS-1$
+ "IASTFunctionCallExpression.FUNCTION_NAME [IASTExpression]"); //$NON-NLS-1$
/**
- * Set the function name expression.
- *
- * @param expression
- * <code>IASTExpression</code> representing the function name
+ * @since 5.2
*/
- public void setFunctionNameExpression(IASTExpression expression);
+ public static final ASTNodeProperty ARGUMENT = new ASTNodeProperty(
+ "IASTFunctionCallExpression.ARGUMENT [IASTInitializerClause]"); //$NON-NLS-1$
/**
* Get the function name expression.
- *
- * @return <code>IASTExpression</code> representing the function name
*/
public IASTExpression getFunctionNameExpression();
/**
- * <code>PARAMETERS</code> represents the relationship between a
- * <code>IASTFunctionCallExpression</code> and its
- * <code>IASTExpression</code> (parameters).
+ * Returns the arguments for this function call, never <code>null</code>.
+ * @since 5.2
*/
- public static final ASTNodeProperty PARAMETERS = new ASTNodeProperty(
- "IASTFunctionCallExpression.PARAMETERS - IASTExpression (parameters) for IASTFunctionCallExpression"); //$NON-NLS-1$
+ public IASTInitializerClause[] getArguments();
/**
- * Set the parameters expression.
- *
- * @param expression
- * <code>IASTExpression</code> representing the parameters
+ * @since 5.1
*/
- public void setParameterExpression(IASTExpression expression);
+ public IASTFunctionCallExpression copy();
/**
- * Get the parameter expression.
- *
- * @return <code>IASTExpression</code> representing the parameters
+ * Not allowed on frozen ast.
*/
- public IASTExpression getParameterExpression();
-
+ public void setFunctionNameExpression(IASTExpression expression);
+
/**
- * @since 5.1
+ * Not allowed on frozen ast.
+ * @since 5.2
*/
- public IASTFunctionCallExpression copy();
+ public void setArguments(IASTInitializerClause[] args);
+
+ @Deprecated
+ public static final ASTNodeProperty PARAMETERS = ARGUMENT;
+ /**
+ * @deprecated Replaced by {@link #setArguments(IASTInitializerClause[])}.
+ */
+ @Deprecated
+ public void setParameterExpression(IASTExpression expression);
+
+ /**
+ * @deprecated Replaced by {@link #getArguments()}.
+ */
+ @Deprecated
+ public IASTExpression getParameterExpression();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitName.java
index 6751396d423..00e45778a40 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitName.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitName.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,6 +18,8 @@ package org.eclipse.cdt.core.dom.ast;
*
* @see ASTVisitor#shouldVisitImplicitNames
* @since 5.1
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTImplicitName extends IASTName {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitNameOwner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitNameOwner.java
index 21b3c3b9179..a7afbffea22 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitNameOwner.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTImplicitNameOwner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,8 @@ package org.eclipse.cdt.core.dom.ast;
/**
* An implicit name generated on demand.
* @since 5.1
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTImplicitNameOwner extends IASTNode {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerClause.java
index 46a11628cb8..37448482778 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerClause.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,15 +8,15 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.core.dom.ast.cpp;
-
-import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+package org.eclipse.cdt.core.dom.ast;
/**
- * Initializer for c++
- *
+ * Interface for ast nodes that can nest in initializer lists.
+ * @since 5.2
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
- * @since 5.2
*/
-public interface ICPPASTInitializer extends IASTInitializer, ICPPASTPackExpandable {}
+public interface IASTInitializerClause extends IASTNode {
+
+ IASTInitializerClause copy();
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java
index 4d972dc1895..8e49f3a0071 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,15 +15,16 @@ package org.eclipse.cdt.core.dom.ast;
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
+ * @deprecated Replaced by {@link IASTEqualsInitializer}.
*/
-public interface IASTInitializerExpression extends IASTInitializer {
+@Deprecated
+public interface IASTInitializerExpression extends IASTEqualsInitializer {
/**
* <code>INITIALIZER_EXPRESSION</code> represents the relationship between
* an <code>IASTInitializerExpression</code>. and its <code></code>IASTExpression</code>.
*/
- public static final ASTNodeProperty INITIALIZER_EXPRESSION = new ASTNodeProperty(
- "IASTInitializerExpression.INITIALIZER_EXPRESSION - IASTExpression for IASTInitializerExpression"); //$NON-NLS-1$
+ public static final ASTNodeProperty INITIALIZER_EXPRESSION = INITIALIZER;
/**
* Get the expression for the initializer.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java
index 937ab4c8aab..b3a094e441b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTInitializerList.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,25 +7,21 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
/**
- * This is an an initializer that is a list of initializers.
- * For example as in:
+ * Braced initializer list, for example as in:
* <pre> int a[]= {1,2,3}; </pre>
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface IASTInitializerList extends IASTInitializer {
+public interface IASTInitializerList extends IASTInitializer, IASTInitializerClause {
- /**
- * <code>NESTED_INITIALIZER</code> describes the relationship between an
- * <code>IASTInitializerList</code> and its sub-<code>IASTInitializer</code>s.
- */
public static final ASTNodeProperty NESTED_INITIALIZER = new ASTNodeProperty(
- "IASTInitializerList.NESTED_INITIALIZER - sub-IASTInitializer for IASTInitializerList"); //$NON-NLS-1$
+ "IASTInitializerList.NESTED_INITIALIZER [IASTInitializerClause]"); //$NON-NLS-1$
/**
* Returns the size of the initializer list, including trivial initializers. This size may
@@ -37,18 +33,34 @@ public interface IASTInitializerList extends IASTInitializer {
/**
* Returns the list of initializers. Depending on how the ast was created, this may omit
* trivial initializers in order to save memory.
+ * @since 5.2
*/
- public IASTInitializer[] getInitializers();
-
+ public IASTInitializerClause[] getClauses();
+
+
/**
- * Add an initializer to the initializer list. Depending on how the AST is created the
+ * Add an initializer clause to the initializer list. Depending on how the AST is created the
* initializer may be <code>null</code>. A <code>null</code> initializer will not be returned
* by {@link #getInitializers()}, however it contributes to the actual element count (#getSize()).
+ * @since 5.2
*/
- public void addInitializer(IASTInitializer initializer);
+ public void addClause(IASTInitializerClause clause);
/**
* @since 5.1
*/
public IASTInitializerList copy();
+
+ /**
+ * @deprecated Replaced by {@link #getClauses()}.
+ */
+ @Deprecated
+ public IASTInitializer[] getInitializers();
+
+ /**
+ * @deprecated Replaced by {@link #addClause(IASTInitializerClause)}.
+ */
+ @Deprecated
+ public void addInitializer(IASTInitializer initializer);
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java
index 7c341d9f50e..c84bc91ede2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@@ -16,13 +17,8 @@ package org.eclipse.cdt.core.dom.ast;
*/
public interface IASTReturnStatement extends IASTStatement {
- /**
- * <code>RETURNVALUE</code> represents the relationship between an
- * <code>IASTReturnStatement</code> and it's nested
- * <code>IASTExpression</code>.
- */
public static final ASTNodeProperty RETURNVALUE = new ASTNodeProperty(
- "IASTReturnValue.RETURNVALUE - IASTExpression (returnValue) for IASTReturnStatement"); //$NON-NLS-1$
+ "IASTReturnValue.RETURNVALUE - [IASTInitializerClause]"); //$NON-NLS-1$
/**
* This is the optional return value for this function.
@@ -32,10 +28,20 @@ public interface IASTReturnStatement extends IASTStatement {
public IASTExpression getReturnValue();
/**
- * Set the return value.
- *
- * @param returnValue
- * <code>IASTExpression</code>
+ * Returns the return value as {@link IASTInitializerClause}, or <code>null</code>.
+ * In c++ this can be an braced initializer list.
+ * @since 5.2
+ */
+ public IASTInitializerClause getReturnArgument();
+
+ /**
+ * Not allowed on frozen ast.
+ * @since 5.2
+ */
+ public void setReturnArgument(IASTInitializerClause returnValue);
+
+ /**
+ * Not allowed on frozen ast.
*/
public void setReturnValue(IASTExpression returnValue);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java
index 1d4de605026..50a4371c653 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Corporation - initial API and implementation
+ * Mike Kucera (IBM Corporation) - initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@@ -15,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IToken;
-
/**
* Factory for creating AST nodes. This interface contains factory methods
* for nodes that are available for both C and C++.
@@ -33,153 +33,165 @@ import org.eclipse.cdt.core.parser.IToken;
*
* None of the factory methods should return null.
*
- * @author Mike Kucera
* @since 5.1
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface INodeFactory {
- /**
- * Creates a "dummy" name using an empty char array.
- */
- public IASTName newName();
+ public IASTArrayDeclarator newArrayDeclarator(IASTName name);
- public IASTName newName(char[] name);
+ public IASTArrayModifier newArrayModifier(IASTExpression expr);
- /**
- * @deprecated use {@link #newTranslationUnit(IScanner)}, instead.
- */
- @Deprecated
- public IASTTranslationUnit newTranslationUnit();
-
- /**
- * Creates a new translation unit that cooperates with the given scanner in order
- * to track macro-expansions and location information.
- * @param scanner the preprocessor the translation unit interacts with.
- * @since 5.2
- */
- public IASTTranslationUnit newTranslationUnit(IScanner scanner);
+ public IASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript);
- public IASTLiteralExpression newLiteralExpression(int kind, String rep);
+ public IASTASMDeclaration newASMDeclaration(String assembly);
- public IASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand);
+ public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2);
- public IASTIdExpression newIdExpression(IASTName name);
+ public IASTBreakStatement newBreakStatement();
- public IASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript);
+ public IASTCaseStatement newCaseStatement(IASTExpression expr);
- public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList);
+ public IASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand);
- public IASTExpressionList newExpressionList();
+ public IASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name);
- public IASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand);
+ public IASTCompoundStatement newCompoundStatement();
- public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2);
-
public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3);
- public IASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer);
+ public IASTContinueStatement newContinueStatement();
- public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement);
+ public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration);
- public IASTCaseStatement newCaseStatement(IASTExpression expr);
+ public IASTDeclarator newDeclarator(IASTName name);
public IASTDefaultStatement newDefaultStatement();
+
+ public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition);
- public IASTExpressionStatement newExpressionStatement(IASTExpression expression);
+ public IASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
- public IASTNullStatement newNullStatement();
+ public IASTEnumerationSpecifier newEnumerationSpecifier(IASTName name);
- public IASTCompoundStatement newCompoundStatement();
+ public IASTEnumerator newEnumerator(IASTName name, IASTExpression value);
- public IASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body);
+ /**
+ * @since 5.2
+ */
+ public IASTEqualsInitializer newEqualsInitializer(IASTInitializerClause initClause);
+
+ public IASTExpressionList newExpressionList();
- public IASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause);
+ public IASTExpressionStatement newExpressionStatement(IASTExpression expression);
- public IASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body);
+ public IASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize);
- public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition);
+ public IASTFieldReference newFieldReference(IASTName name, IASTExpression owner);
public IASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
IASTExpression iterationExpression, IASTStatement body);
- public IASTGotoStatement newGotoStatement(IASTName name);
+ /**
+ * @deprecated Replaced by {@link #newFunctionCallExpression(IASTExpression, IASTInitializerClause[])}
+ */
+ @Deprecated
+ public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList);
- public IASTContinueStatement newContinueStatement();
+ /**
+ * @since 5.2
+ */
+ public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTInitializerClause[] arguments);
- public IASTBreakStatement newBreakStatement();
+ public IASTStandardFunctionDeclarator newFunctionDeclarator(IASTName name);
- public IASTReturnStatement newReturnStatement(IASTExpression retValue);
+ public IASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
+ IASTFunctionDeclarator declarator, IASTStatement bodyStatement);
- public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration);
+ public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement);
- public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId);
+ public IASTGotoStatement newGotoStatement(IASTName name);
- public IASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator);
+ public IASTIdExpression newIdExpression(IASTName name);
- public IASTDeclarator newDeclarator(IASTName name);
-
- public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier);
+ public IASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause);
+ /**
+ * @deprecated Replaced by {@link #newEqualsInitializer(IASTInitializerClause)}.
+ */
+ @Deprecated
public IASTInitializerExpression newInitializerExpression(IASTExpression expression);
-
+
public IASTInitializerList newInitializerList();
- public IASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
- IASTFunctionDeclarator declarator, IASTStatement bodyStatement);
+ public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement);
- public IASTStandardFunctionDeclarator newFunctionDeclarator(IASTName name);
+ public IASTLiteralExpression newLiteralExpression(int kind, String rep);
- public IASTASMDeclaration newASMDeclaration(String assembly);
+ /**
+ * Creates a "dummy" name using an empty char array.
+ */
+ public IASTName newName();
- public IASTProblemDeclaration newProblemDeclaration(IASTProblem problem);
+ public IASTName newName(char[] name);
+
+ public IASTNullStatement newNullStatement();
- public IASTProblemStatement newProblemStatement(IASTProblem problem);
+ public IASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator);
- public IASTProblemExpression newProblemExpression(IASTProblem problem);
+ public IASTPointer newPointer();
public IASTProblem newProblem(int id, char[] arg, boolean error);
- public IASTEnumerationSpecifier newEnumerationSpecifier(IASTName name);
+ public IASTProblemDeclaration newProblemDeclaration(IASTProblem problem);
- public IASTEnumerator newEnumerator(IASTName name, IASTExpression value);
+ public IASTProblemExpression newProblemExpression(IASTProblem problem);
- public IASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
+ public IASTProblemStatement newProblemStatement(IASTProblem problem);
- public IASTArrayModifier newArrayModifier(IASTExpression expr);
+ public IASTReturnStatement newReturnStatement(IASTExpression retValue);
- public IASTArrayDeclarator newArrayDeclarator(IASTName name);
+ public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier);
- public IASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator);
+ public IASTSimpleDeclSpecifier newSimpleDeclSpecifier();
- public IASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize);
+ public IASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body);
- public IASTSimpleDeclSpecifier newSimpleDeclSpecifier();
+ /**
+ * @deprecated Replaced by {@link #newTranslationUnit(IScanner)}.
+ */
+ @Deprecated
+ public IASTTranslationUnit newTranslationUnit();
- public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement);
+ /**
+ * Creates a new translation unit that cooperates with the given scanner in order
+ * to track macro-expansions and location information.
+ * @param scanner the preprocessor the translation unit interacts with.
+ * @since 5.2
+ */
+ public IASTTranslationUnit newTranslationUnit(IScanner scanner);
- public IASTPointer newPointer();
+ public IASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name);
- public IASTFieldReference newFieldReference(IASTName name, IASTExpression owner);
+ public IASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator);
- public IASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name);
+ public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId);
- public IASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name);
+ public IASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer);
+
+ public IASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand);
+ public IASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body);
+
/**
- * Provides the offsets for a node. The offsets are artificial numbers that identify the
- * position of a node in the translation unit. They are not file-offsets. You can obtain
- * valid offsets via {@link IToken#getOffset()} or {@link IToken#getEndOffset()} from tokens
- * provided by the scanner for this translation unit.
- * <par> May throw an exception when the node provided was not created by this factory.
+ * Adjusts the end-offset of a node to be the same as the end-offset of a given node.
+ * <par> May throw an exception when either one of the nodes provided was not created by this factory.
* @param node a node created by this factory
- * @param offset the offset (inclusive) for the node
- * @param endOffset the end offset (exclusive) for the node
- * @see #newTranslationUnit(IScanner)
+ * @param endNode a node created by this factory defining the end for the other node.
* @since 5.2
*/
- public void setOffsets(IASTNode node, int offset, int endOffset);
+ void setEndOffset(IASTNode node, IASTNode endNode);
/**
* Provides the end offset for a node. The offset is an artificial numbers that identifies the
@@ -192,14 +204,19 @@ public interface INodeFactory {
* @see #newTranslationUnit(IScanner)
* @since 5.2
*/
- void setEndOffset(IASTNode node, int endOffset);
-
+ void setEndOffset(IASTNode node, int endOffset);
+
/**
- * Adjusts the end-offset of a node to be the same as the end-offset of a given node.
- * <par> May throw an exception when either one of the nodes provided was not created by this factory.
+ * Provides the offsets for a node. The offsets are artificial numbers that identify the
+ * position of a node in the translation unit. They are not file-offsets. You can obtain
+ * valid offsets via {@link IToken#getOffset()} or {@link IToken#getEndOffset()} from tokens
+ * provided by the scanner for this translation unit.
+ * <par> May throw an exception when the node provided was not created by this factory.
* @param node a node created by this factory
- * @param endNode a node created by this factory defining the end for the other node.
+ * @param offset the offset (inclusive) for the node
+ * @param endOffset the end offset (exclusive) for the node
+ * @see #newTranslationUnit(IScanner)
* @since 5.2
*/
- void setEndOffset(IASTNode node, IASTNode endNode);
+ public void setOffsets(IASTNode node, int offset, int endOffset);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java
index cae27e5e523..cbdb4256f24 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTDesignatedInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,11 +7,13 @@
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.c;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
/**
* This interface represents a designated initializer. e.g. struct x y = { .z=4,
@@ -20,61 +22,53 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializer;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICASTDesignatedInitializer extends IASTInitializer {
+public interface ICASTDesignatedInitializer extends IASTInitializer, IASTInitializerClause {
- /**
- * Constant.
- */
public static final ICASTDesignator[] EMPTY_DESIGNATOR_ARRAY = new ICASTDesignator[0];
- /**
- * <code>DESIGNATOR</code> represents the relationship between an
- * <code>ICASTDesignatedInitializer</code> and
- * <code>ICASTDesignator</code>.
- */
public static final ASTNodeProperty DESIGNATOR = new ASTNodeProperty(
- "ICASTDesignatedInitializer.DESIGNATOR - relationship between ICASTDesignatedInitializer and ICASTDesignator"); //$NON-NLS-1$
+ "ICASTDesignatedInitializer.DESIGNATOR [ICASTDesignator]"); //$NON-NLS-1$
+
+ public static final ASTNodeProperty OPERAND = new ASTNodeProperty(
+ "ICASTDesignatedInitializer.OPERAND - [IASTInitializerClause]"); //$NON-NLS-1$
/**
* Add a designator to this initializer.
- *
- * @param designator
- * <code>ICASTDesignator</code>
*/
public void addDesignator(ICASTDesignator designator);
/**
* Get all of the designators.
- *
- * @return <code>ICASTDesignator []</code>
*/
public ICASTDesignator[] getDesignators();
/**
- * <code>OPERAND</code> represents the relationship between
- * <code>ICASTDesignatedInitializer</code> and its
- * <code>IASTInitializer</code>.
+ * Returns the operand initializer.
+ * @since 5.2
*/
- public static final ASTNodeProperty OPERAND = new ASTNodeProperty(
- "ICASTDesignatedInitializer.OPERAND - RHS IASTInitializer for ICASTDesignatedInitializer"); //$NON-NLS-1$
+ public IASTInitializerClause getOperand();
/**
- * Get the nested initializer.
- *
- * @return <code>IASTInitializer</code>
+ * Not allowed on frozen ast
+ * @since 5.2
*/
+ void setOperand(IASTInitializerClause operand);
+
+ /**
+ * @since 5.1
+ */
+ public ICASTDesignatedInitializer copy();
+
+ /**
+ * @deprecated Replaced by {@link #getOperand()};
+ */
+ @Deprecated
public IASTInitializer getOperandInitializer();
/**
- * Set the nested initializer.
- *
- * @param rhs
- * <code>IASTInitializer</code>
+ * @deprecated Replaced by setOperand();
*/
+ @Deprecated
public void setOperandInitializer(IASTInitializer rhs);
- /**
- * @since 5.1
- */
- public ICASTDesignatedInitializer copy();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java
index 7886253a5a1..da6e5c4ce89 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICNodeFactory.java
@@ -14,6 +14,7 @@ package org.eclipse.cdt.core.dom.ast.c;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.INodeFactory;
@@ -30,35 +31,44 @@ import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
*/
public interface ICNodeFactory extends INodeFactory {
- public ICASTEnumerationSpecifier newEnumerationSpecifier(IASTName name);
+ public ICASTArrayDesignator newArrayDesignator(IASTExpression exp);
- public ICASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
+ public ICASTArrayModifier newArrayModifier(IASTExpression expr);
- public ICASTSimpleDeclSpecifier newSimpleDeclSpecifier();
+ public IGCCASTArrayRangeDesignator newArrayRangeDesignatorGCC(IASTExpression floor, IASTExpression ceiling);
- public ICASTPointer newPointer();
+ public ICASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name);
- public ICASTTypedefNameSpecifier newTypedefNameSpecifier(IASTName name);
+ /**
+ * @deprecated Replaced by {@link #newDesignatedInitializer(IASTInitializerClause)}.
+ */
+ @Deprecated
+ public ICASTDesignatedInitializer newDesignatedInitializer(IASTInitializer rhs);
- public ICASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name);
+ /**
+ * @since 5.2
+ */
+ public ICASTDesignatedInitializer newDesignatedInitializer(IASTInitializerClause initializer);
- public ICASTArrayModifier newArrayModifier(IASTExpression expr);
+ public ICASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
- public ICASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer);
-
- public ICASTKnRFunctionDeclarator newKnRFunctionDeclarator(IASTName[] parameterNames, IASTDeclaration[] parameterDeclarations);
+ public ICASTEnumerationSpecifier newEnumerationSpecifier(IASTName name);
- public ICASTDesignatedInitializer newDesignatedInitializer(IASTInitializer rhs);
+ public ICASTFieldDesignator newFieldDesignator(IASTName name);
- public ICASTArrayDesignator newArrayDesignator(IASTExpression exp);
+ public ICASTKnRFunctionDeclarator newKnRFunctionDeclarator(IASTName[] parameterNames, IASTDeclaration[] parameterDeclarations);
- public ICASTFieldDesignator newFieldDesignator(IASTName name);
+ public ICASTPointer newPointer();
- public IGCCASTArrayRangeDesignator newArrayRangeDesignatorGCC(IASTExpression floor, IASTExpression ceiling);
+ public ICASTSimpleDeclSpecifier newSimpleDeclSpecifier();
/**
* @deprecated Replaced by {@link #newSimpleDeclSpecifier()}
*/
@Deprecated
- public org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression);
+ public org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression);
+
+ public ICASTTypedefNameSpecifier newTypedefNameSpecifier(IASTName name);
+
+ public ICASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer);
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArraySubscriptExpression.java
index cfeb6342564..8111a899a9a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArraySubscriptExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTArraySubscriptExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,9 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
/**
* @since 5.1
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTArraySubscriptExpression extends IASTArraySubscriptExpression, IASTImplicitNameOwner {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java
index 1ee336218c3..9928c292003 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorChainInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,70 +13,67 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
/**
+ * Represents a member initializer:
* <pre> class X {
* int a;
* X();
* };
- * X::X : a(0) {} // a(0) is a constructor chain initializer.
+ * X::X : a(0) {} // a(0) is a member initializer.
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICPPASTConstructorChainInitializer extends ICPPASTInitializer, IASTNameOwner {
- /**
- * Constant.
- */
+public interface ICPPASTConstructorChainInitializer extends IASTInitializer, ICPPASTPackExpandable,
+ IASTNameOwner {
public static final ICPPASTConstructorChainInitializer[] EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY = new ICPPASTConstructorChainInitializer[0];
- /**
- * <code>MEMBER_ID</code> represents the class field name being
- * initialized.
- */
public static final ASTNodeProperty MEMBER_ID = new ASTNodeProperty(
- "ICPPASTConstructorChainInitializer.MEMBER_ID - Class field name initialized"); //$NON-NLS-1$
+ "ICPPASTConstructorChainInitializer.MEMBER_ID [IASTName]"); //$NON-NLS-1$
+
+ public static final ASTNodeProperty INITIALIZER = new ASTNodeProperty(
+ "ICPPASTConstructorChainInitializer.INITIALIZER [IASTInitializer]"); //$NON-NLS-1$
/**
- * Get the field name.
- *
- * @return <code>IASTName</code>
+ * Returns the name of the member.
*/
public IASTName getMemberInitializerId();
/**
- * Set the field name.
- *
- * @param name
- * <code>IASTName</code>
+ * Returns the initializer for the member
+ * @since 5.2
*/
- public void setMemberInitializerId(IASTName name);
+ public IASTInitializer getInitializer();
/**
- * <code>Expression field is being initialized to.</code>
+ * @since 5.1
*/
- public static final ASTNodeProperty INITIALIZER = new ASTNodeProperty(
- "ICPPASTConstructorChainInitializer.INITIALIZER - Expression Field Initializer"); //$NON-NLS-1$
+ public ICPPASTConstructorChainInitializer copy();
/**
- * Get the initializer value.
- *
- * @return <code>IASTExpression</code>
+ * Not allowed on frozen ast.
*/
- public IASTExpression getInitializerValue();
+ public void setMemberInitializerId(IASTName name);
/**
- * Set the initializer value.
- *
- * @param expression
- * <code>IASTExpression</code>
+ * Not allowed on frozen ast.
+ * @since 5.2
*/
- public void setInitializerValue(IASTExpression expression);
+ public void setInitializer(IASTInitializer initializer);
+
+ /**
+ * @deprecated Replaced by {@link #getInitializer()}.
+ */
+ @Deprecated
+ public IASTExpression getInitializerValue();
/**
- * @since 5.1
+ * @deprecated Replaced by {@link #setInitializer(IASTInitializer)}.
*/
- public ICPPASTConstructorChainInitializer copy();
+ @Deprecated
+ public void setInitializerValue(IASTExpression expression);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java
index eab636f08e2..7b63a37fc2b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTConstructorInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,38 +13,56 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
/**
- * This is an initializer that is a call to the constructor for the declarator.
+ * Represents a potentially empty list of initializers in parenthesis: ( initializer-list? )
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICPPASTConstructorInitializer extends ICPPASTInitializer {
+public interface ICPPASTConstructorInitializer extends IASTInitializer {
/**
- * <code>EXPRESSION</code> represents the expression being conusmed in a
- * constructor.
+ * @since 5.2
*/
- public static final ASTNodeProperty EXPRESSION = new ASTNodeProperty(
- "ICPPASTConstructorInitializer.EXPRESSION - Expression consumed in constructor"); //$NON-NLS-1$
+ public static final ASTNodeProperty ARGUMENT = new ASTNodeProperty(
+ "ICPPASTConstructorInitializer.ARGUMENT - [IASTInitializerClause]"); //$NON-NLS-1$
/**
- * Get the arguments to the constructor.
+ * Returns the arguments of this initializer, never <code>null</code>.
+ * An argument can be of type {@link IASTInitializerList}.
*
- * @return IASTExpression
+ * @since 5.2
*/
- public IASTExpression getExpression();
+ public IASTInitializerClause[] getArguments();
+
+ /**
+ * @since 5.1
+ */
+ public ICPPASTConstructorInitializer copy();
+
/**
- * Set the arguments to the constructor.
- *
- * @param expression
+ * Not allowed on frozen ast.
+ * @since 5.2
*/
- public void setExpression(IASTExpression expression);
+ public void setArguments(IASTInitializerClause[] args);
/**
- * @since 5.1
+ * @deprecated Replaced by {@link #getArguments()}.
*/
- public ICPPASTConstructorInitializer copy();
+ @Deprecated
+ public IASTExpression getExpression();
+
+ /**
+ * @deprecated Replaced by {@link #setArguments(IASTInitializerClause[])}.
+ */
+ @Deprecated
+ public void setExpression(IASTExpression expression);
+
+ @Deprecated
+ public static final ASTNodeProperty EXPRESSION = ARGUMENT;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExpressionList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExpressionList.java
index 15e900eaf23..7e40a64f1f1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExpressionList.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTExpressionList.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,9 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
/**
* @since 5.1
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTExpressionList extends IASTExpressionList, IASTImplicitNameOwner {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java
index 8c8e91facea..065b5661927 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,9 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
/**
* @since 5.1
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTFunctionCallExpression extends IASTFunctionCallExpression, IASTImplicitNameOwner {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java
index 594659eeb94..487cffbc224 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerList.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,12 +13,13 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
/**
- * Initializer expression for c++.
+ * Braced initializer list.
*
+ * @since 5.2
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
- * @since 5.2
*/
-public interface ICPPASTInitializerList extends IASTInitializerList, ICPPASTInitializer {
+public interface ICPPASTInitializerList extends IASTInitializerList, ICPPASTPackExpandable {
+ ICPPASTInitializerList copy();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java
index 85780652f53..ff165ab158b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNewExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,8 +14,10 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
/**
* This interface represents a new expression.
@@ -25,104 +27,88 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
*/
public interface ICPPASTNewExpression extends IASTExpression, IASTImplicitNameOwner {
+ public static final ASTNodeProperty NEW_PLACEMENT = new ASTNodeProperty(
+ "ICPPASTNewExpression.NEW_PLACEMENT [IASTExpression]"); //$NON-NLS-1$
+
+ public static final ASTNodeProperty TYPE_ID = new ASTNodeProperty(
+ "ICPPASTNewExpression.TYPE_ID - [IASTTypeId]"); //$NON-NLS-1$
+
+ public static final ASTNodeProperty NEW_INITIALIZER = new ASTNodeProperty(
+ "ICPPASTNewExpression.NEW_INITIALIZER - [IASTInitializer]"); //$NON-NLS-1$
+
/**
* Is this a ::new expression?
- *
- * @return boolean
*/
public boolean isGlobal();
/**
- * Set this expression to bea global ::new expression (or not).
- *
- * @param value
- * boolean
- */
- public void setIsGlobal(boolean value);
-
- /**
- * NEW_PLACEMENT is a role for an expression to represent the location of
- * where the memory should be allocated.
+ * Returns true if this expression is allocating an array.
+ * @since 5.1
*/
- public static final ASTNodeProperty NEW_PLACEMENT = new ASTNodeProperty(
- "ICPPASTNewExpression.NEW_PLACEMENT - Location where memory should be allocated"); //$NON-NLS-1$
+ public boolean isArrayAllocation();
/**
- * Get the new placement (optional).
- *
- * @return <code>IASTExpression</code>
+ * Returns the additional arguments for the new placement, or <code>null</code>.
+ * A placement argument can be of type {@link ICPPASTInitializerList}.
+ * @since 5.2
*/
- public IASTExpression getNewPlacement();
-
+ public IASTInitializerClause[] getPlacementArguments();
+
/**
- * Set the new placement expression.
- *
- * @param expression
- * <code>IASTExpression</code>
+ * Get the type Id. The type-id includes the optional array modifications.
*/
- public void setNewPlacement(IASTExpression expression);
+ public IASTTypeId getTypeId();
/**
- * <code>NEW_INITIALIZER</code>
+ * Returns whether the the typeID a new type ID, which is the case when
+ * the type-id is provided without parenthesis.
*/
- public static final ASTNodeProperty NEW_INITIALIZER = new ASTNodeProperty(
- "ICPPASTNewExpression.NEW_INITIALIZER - New Initializer"); //$NON-NLS-1$
+ public boolean isNewTypeId();
/**
- * @return <code>IASTExpression</code>
+ * Returns the initializer or <code>null</code>.
+ * @since 5.2
*/
- public IASTExpression getNewInitializer();
+ public IASTInitializer getInitializer();
/**
- * @param expression
- * <code>IASTExpression</code>
+ * @since 5.1
*/
- public void setNewInitializer(IASTExpression expression);
+ public ICPPASTNewExpression copy();
+
/**
- * TYPE_ID is the type being 'newed'.
+ * Not allowed on frozen ast.
*/
- public static final ASTNodeProperty TYPE_ID = new ASTNodeProperty("ICPPASTNewExpression.TYPE_ID - The type being 'newed'"); //$NON-NLS-1$
+ public void setIsGlobal(boolean value);
/**
- * Get the type Id. The type-id includes the optional array modifications.
- * @return <code>IASTTypeId</code>
+ * Not allowed on frozen ast.
+ * @since 5.2
*/
- public IASTTypeId getTypeId();
+ public void setPlacementArguments(IASTInitializerClause[] expression);
/**
- * Set the type Id.
- *
- * @param typeId
- * <code>IASTTypeId</code>
+ * Not allowed on frozen ast.
*/
public void setTypeId(IASTTypeId typeId);
/**
- * Returns whether the the typeID a new type ID, which is the case when
- * the type-id is provided without parenthesis.
- */
- public boolean isNewTypeId();
-
- /**
- * Set the type ID to be a new type ID.
- *
- * @param value
- * boolean
+ * Not allowed on frozen ast.
*/
public void setIsNewTypeId(boolean value);
-
/**
- * Returns true if this expression is allocating an array.
- * @since 5.1
+ * Not allowed on frozen ast.
+ * @since 5.2
*/
- public boolean isArrayAllocation();
-
-
+ public void setInitializer(IASTInitializer init);
+
+
/**
- * Expressions that go inside array brackets.
+ * @deprecated the id-expressions are part of the type-id.
*/
+ @Deprecated
public static final ASTNodeProperty NEW_TYPEID_ARRAY_EXPRESSION = new ASTNodeProperty(
"ICPPASTNewExpression.NEW_TYPEID_ARRAY_EXPRESSION - Expressions inside array brackets"); //$NON-NLS-1$
@@ -138,10 +124,27 @@ public interface ICPPASTNewExpression extends IASTExpression, IASTImplicitNameOw
@Deprecated
public void addNewTypeIdArrayExpression(IASTExpression expression);
+ /**
+ * @deprecated Replaced by {@link #getPlacementArguments()}
+ */
+ @Deprecated
+ public IASTExpression getNewPlacement();
/**
- * @since 5.1
+ * @deprecated Replaced by {@link #setPlacementArguments(IASTInitializerClause[])}
*/
- public ICPPASTNewExpression copy();
+ @Deprecated
+ public void setNewPlacement(IASTExpression expression);
+
+ /**
+ * @deprecated Replaced by {@link #getInitializer()}
+ */
+ @Deprecated
+ public IASTExpression getNewInitializer();
+ /**
+ * @deprecated Replaced by {@link #setInitializer(IASTInitializer)}
+ */
+ @Deprecated
+ public void setNewInitializer(IASTExpression expression);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java
index 889fb3b5a3b..9d1c2cdc59a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeConstructorExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,123 +7,108 @@
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
/**
- * Simple type constructor postfix expression.
- *
+ * Functional cast expressions:
+ * simple-type-specifier (expression-list?)
+ * simple-type-specifier braced-init-list
+ * typename-specifier (expression-list?)
+ * typename-specifier braced-init-list
+ *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTSimpleTypeConstructorExpression extends IASTExpression {
-
- /**
- * t_unspecified (error)
- */
- public static final int t_unspecified = 0;
-
- /**
- * t_void == void
- */
- public static final int t_void = 1;
-
- /**
- * t_char == char
- */
- public static final int t_char = 2;
-
- /**
- * t_int == int
- */
- public static final int t_int = 3;
-
- /**
- * t_float == float
- */
- public static final int t_float = 4;
-
/**
- * t_double == double
+ * @since 5.2
*/
- public static final int t_double = 5;
-
+ public static final ASTNodeProperty TYPE_SPECIFIER = new ASTNodeProperty(
+ "ICPPASTSimpleTypeConstructorExpression.TYPE_SPECIFIER [ICPPASTSimpleDeclSpecifier]"); //$NON-NLS-1$
/**
- * t_bool = bool
+ * @since 5.2
*/
- public static final int t_bool = 6;
+ public static final ASTNodeProperty INITIALIZER = new ASTNodeProperty(
+ "ICPPASTSimpleTypeConstructorExpression.INITIALIZER [IASTInitializer]"); //$NON-NLS-1$
/**
- * t_wchar_t = wchar_t
+ * Returns the declaration specifier that specifies the type.
+ * @since 5.2
*/
- public static final int t_wchar_t = 7;
+ public ICPPASTDeclSpecifier getDeclSpecifier();
/**
- * t_short = short
+ * Returns the argument for initialization. Can be {@link ICPPASTConstructorInitializer} or
+ * {@link ICPPASTInitializerList}
+ * @since 5.2
*/
- public static final int t_short = 8;
-
- /**
- * t_long = long
- */
- public static final int t_long = 9;
-
+ public IASTInitializer getInitializer();
+
/**
- * t_signed = signed
+ * @since 5.1
*/
- public static final int t_signed = 10;
+ public ICPPASTSimpleTypeConstructorExpression copy();
/**
- * t_unsigned = unsigned
+ * Not allowed on frozen ast.
+ * @since 5.2
*/
- public static final int t_unsigned = 11;
+ public void setDeclSpecifier(ICPPASTDeclSpecifier declSpec);
/**
- * t_last is provided for subinterfaces.
+ * Not allowed on frozen ast.
+ * @since 5.2
*/
- public static final int t_last = t_unsigned;
+ public void setInitializer(IASTInitializer initializer);
+
+
+ @Deprecated public static final int t_unspecified = 0;
+ @Deprecated public static final int t_void = 1;
+ @Deprecated public static final int t_char = 2;
+ @Deprecated public static final int t_int = 3;
+ @Deprecated public static final int t_float = 4;
+ @Deprecated public static final int t_double = 5;
+ @Deprecated public static final int t_bool = 6;
+ @Deprecated public static final int t_wchar_t = 7;
+ @Deprecated public static final int t_short = 8;
+ @Deprecated public static final int t_long = 9;
+ @Deprecated public static final int t_signed = 10;
+ @Deprecated public static final int t_unsigned = 11;
+ @Deprecated public static final int t_last = t_unsigned;
/**
- * Get the simple type.
- *
- * @return int
+ * @deprecated Replaced by {@link #getDeclSpecifier()}.
*/
+ @Deprecated
public int getSimpleType();
/**
- * Set the simple type.
- *
- * @param value
- * int
+ * @deprecated Replaced by {@link #setDeclSpecifier(ICPPASTDeclSpecifier)}
*/
+ @Deprecated
public void setSimpleType(int value);
/**
- * INITIALIZER_VALUE is the value passed into the constructor.
+ * @deprecated Replaced by {@link #INITIALIZER}.
*/
- public static final ASTNodeProperty INITIALIZER_VALUE = new ASTNodeProperty(
- "ICPPASTSimpleTypeConstructorExpression.INITIALIZER_VALUE - Value passed into constructor"); //$NON-NLS-1$
+ @Deprecated
+ public static final ASTNodeProperty INITIALIZER_VALUE = INITIALIZER;
/**
- * Get the initial value.
- *
- * @return <code>IASTExpression</code>
+ * @deprecated Replaced by {@link #getInitializer()}
*/
+ @Deprecated
public IASTExpression getInitialValue();
/**
- * Set the initial value.
- *
- * @param expression
- * <code>IASTExpression</code>
+ * @deprecated Replaced by {@link #setInitializer(IASTInitializer)}
*/
+ @Deprecated
public void setInitialValue(IASTExpression expression);
-
- /**
- * @since 5.1
- */
- public ICPPASTSimpleTypeConstructorExpression copy();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java
index 2beb51c289e..2123f9ab9be 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTypenameExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@@ -18,8 +19,10 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
/**
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
+ * @deprecated Unified with {@link ICPPASTSimpleTypeConstructorExpression}.
*/
-public interface ICPPASTTypenameExpression extends IASTExpression, IASTNameOwner {
+@Deprecated
+public interface ICPPASTTypenameExpression extends ICPPASTSimpleTypeConstructorExpression, IASTNameOwner {
/**
* Was template token consumed?
@@ -60,8 +63,7 @@ public interface ICPPASTTypenameExpression extends IASTExpression, IASTNameOwner
/**
* <code>INITIAL_VALUE</code> is an expression.
*/
- public static final ASTNodeProperty INITIAL_VALUE = new ASTNodeProperty(
- "ICPPASTTypenameExpression.INITIAL_VALUE - Initial Value is an expression"); //$NON-NLS-1$
+ public static final ASTNodeProperty INITIAL_VALUE = INITIALIZER;
/**
* Set initial value.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
index e8408356aba..a69eb686ad7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
@@ -16,9 +16,12 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTProblem;
import org.eclipse.cdt.core.dom.ast.IASTProblemTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.INodeFactory;
@@ -37,199 +40,259 @@ import org.eclipse.cdt.core.parser.IScanner;
public interface ICPPNodeFactory extends INodeFactory {
/**
- * Creates a new translation unit that cooperates with the given scanner in order
- * to track macro-expansions and location information.
- * @scanner the preprocessor the translation unit interacts with.
* @since 5.2
*/
- public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner);
+ public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name);
- public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep);
+ public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript);
- public ICPPASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand);
+ /**
+ * @since 5.2
+ */
+ public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTInitializerClause subscript);
- public ICPPASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand);
+ public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual);
public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2);
- public ICPPASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId);
-
- public ICPPASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
- IASTFunctionDeclarator declarator, IASTStatement bodyStatement);
-
/**
* @since 5.2
*/
- public ICPPASTDeclarator newDeclarator(IASTName name);
+ public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTInitializerClause expr2);
- public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name);
+ public ICPPASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand);
+
+ public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body);
+
+ public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name);
+
+ /**
+ * @deprecated Replaced by {@link #newConstructorChainInitializer(IASTName, IASTInitializer)}
+ */
+ @Deprecated
+ public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName memberInitializerId, IASTExpression initializerValue);
/**
* @since 5.2
*/
- public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name);
+ public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName id, IASTInitializer initializer);
/**
- * @since 5.2
+ * @deprecated Replaced by {@link #newConstructorInitializer(IASTInitializerClause[])}.
*/
- public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize);
+ @Deprecated
+ public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp);
- public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
+ /**
+ * @since 5.2
+ */
+ public ICPPASTConstructorInitializer newConstructorInitializer(IASTInitializerClause[] args);
- public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator);
+ public ICPPASTConversionName newConversionName(IASTTypeId typeId);
- public ICPPASTSimpleDeclSpecifier newSimpleDeclSpecifier();
-
- public ICPPASTOperatorName newOperatorName(char[] name);
+ /**
+ * @since 5.2
+ */
+ public ICPPASTDeclarator newDeclarator(IASTName name);
- public ICPPASTNewExpression newNewExpression(IASTExpression placement, IASTExpression initializer, IASTTypeId typeId);
+ public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
- public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner);
+ public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
+
+ public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration);
- public ICPPASTTemplateId newTemplateId(IASTName templateName);
+ /**
+ * @deprecated Replaced by {@link #newExplicitTemplateInstantiation(IASTDeclaration)}.
+ */
+ @Deprecated
+ public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration);
- public ICPPASTConversionName newConversionName(IASTTypeId typeId);
+ public ICPPASTExpressionList newExpressionList();
- public ICPPASTQualifiedName newQualifiedName();
+ /**
+ * @since 5.2
+ */
+ public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize);
- public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controlloer, IASTStatement body);
+ public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner);
- public ICPPASTSwitchStatement newSwitchStatement(IASTDeclaration controller, IASTStatement body);
+ public ICPPASTForStatement newForStatement();
- public ICPPASTSwitchStatement newSwitchStatement();
+ public ICPPASTForStatement newForStatement(IASTStatement init, IASTDeclaration condition,
+ IASTExpression iterationExpression, IASTStatement body);
- public ICPPASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause);
+ public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
+ IASTExpression iterationExpression, IASTStatement body);
- public ICPPASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause);
+ /**
+ * @deprecated Replaced by {@link #newFunctionCallExpression(IASTExpression, IASTInitializerClause[])}.
+ */
+ @Deprecated
+ public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList);
- public ICPPASTIfStatement newIfStatement();
+ /**
+ * @since 5.2
+ */
+ public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTInitializerClause[] arguments);
- public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
- IASTExpression iterationExpression, IASTStatement body);
+ public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name);
- public ICPPASTForStatement newForStatement(IASTStatement init, IASTDeclaration condition,
- IASTExpression iterationExpression, IASTStatement body);
+ public ICPPASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
+ IASTFunctionDeclarator declarator, IASTStatement bodyStatement);
- public ICPPASTForStatement newForStatement();
+ public ICPPASTFunctionWithTryBlock newFunctionTryBlock(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator,
+ IASTStatement bodyStatement);
- public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body);
+ public ICPPASTIfStatement newIfStatement();
- public ICPPASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body);
+ public ICPPASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause);
- public ICPPASTWhileStatement newWhileStatement();
+ public ICPPASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause);
/**
* @since 5.2
*/
- public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator);
+ public ICPPASTInitializerList newInitializerList();
- public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
+ public ICPPASTLinkageSpecification newLinkageSpecification(String literal);
- public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression);
-
- public ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate);
+ public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep);
public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName);
+
+ public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name);
- public ICPPASTUsingDeclaration newUsingDeclaration(IASTName name);
+ /**
+ * @deprecated Replaced by {@link #newNewExpression(IASTInitializerClause[], IASTInitializer, IASTTypeId)}
+ */
+ @Deprecated
+ public ICPPASTNewExpression newNewExpression(IASTExpression placement, IASTExpression initializer, IASTTypeId typeId);
- public ICPPASTUsingDirective newUsingDirective(IASTName name);
+ /**
+ * @since 5.2
+ */
+ public ICPPASTNewExpression newNewExpression(IASTInitializerClause[] placement, IASTInitializer initializer, IASTTypeId typeId);
- public ICPPASTLinkageSpecification newLinkageSpecification(String literal);
+ public ICPPASTOperatorName newOperatorName(char[] name);
- public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name);
+ /**
+ * Creates a new pack expansion expression for the given pattern.
+ * @since 5.2
+ */
+ public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern);
- public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration);
+ public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator);
- public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration);
+ public IGPPASTPointer newPointerGPP();
- public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration);
+ public ICPPASTPointerToMember newPointerToMember(IASTName name);
- public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body);
+ public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name);
- public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body);
-
- public ICPPASTVisibilityLabel newVisibilityLabel(int visibility);
-
- public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual);
-
- public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name);
+ public IASTProblemTypeId newProblemTypeId(IASTProblem problem);
- public ICPPASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name);
+ public ICPPASTQualifiedName newQualifiedName();
- public IGPPASTPointer newPointerGPP();
+ /**
+ * @deprecated Replaced by {@link #newReferenceOperator(boolean)}.
+ */
+ @Deprecated public ICPPASTReferenceOperator newReferenceOperator();
/**
* Creates an lvalue or rvalue reference operator.
* @since 5.2
*/
public ICPPASTReferenceOperator newReferenceOperator(boolean isRValueReference);
-
- public ICPPASTPointerToMember newPointerToMember(IASTName name);
- public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name);
+ /**
+ * @since 5.2
+ */
+ public IASTReturnStatement newReturnStatement(IASTInitializerClause retValue);
+
+ public ICPPASTSimpleDeclSpecifier newSimpleDeclSpecifier();
+
+ /**
+ * @deprecated Replaced by {@link #newSimpleDeclSpecifier()}
+ */
+ @Deprecated
+ public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
+
+ /**
+ * @deprecated Replaced by {@link #newSimpleTypeConstructorExpression(ICPPASTDeclSpecifier, IASTInitializer)}
+ */
+ @Deprecated
+ public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression);
/**
* @since 5.2
*/
- public ICPPASTInitializerExpression newInitializerExpression(IASTExpression expression);
+ public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(ICPPASTDeclSpecifier declSpec, IASTInitializer initializer);
+
+ public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId);
/**
+ * Creates a new static assertion declaration with the given condition and message.
* @since 5.2
*/
- public ICPPASTInitializerList newInitializerList();
+ public ICPPASTStaticAssertDeclaration newStaticAssertion(IASTExpression condition, ICPPASTLiteralExpression message);
- public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp);
+ public ICPPASTSwitchStatement newSwitchStatement();
- public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName memberInitializerId, IASTExpression initializerValue);
+ public ICPPASTSwitchStatement newSwitchStatement(IASTDeclaration controller, IASTStatement body);
- public ICPPASTFunctionWithTryBlock newFunctionTryBlock(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator,
- IASTStatement bodyStatement);
+ public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controlloer, IASTStatement body);
- public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId);
+ public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration);
public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression defaultValue);
- public IASTProblemTypeId newProblemTypeId(IASTProblem problem);
-
- public ICPPASTExpressionList newExpressionList();
+ public ICPPASTTemplateId newTemplateId(IASTName templateName);
- public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript);
+ public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration);
- public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList);
+ /**
+ * @deprecated Replaced by {@link #newTranslationUnit(IScanner)}.
+ */
+ @Deprecated
+ public ICPPASTTranslationUnit newTranslationUnit();
/**
- * Creates a new static assertion declaration with the given condition and message.
+ * Creates a new translation unit that cooperates with the given scanner in order
+ * to track macro-expansions and location information.
+ * @scanner the preprocessor the translation unit interacts with.
* @since 5.2
*/
- public ICPPASTStaticAssertDeclaration newStaticAssertion(IASTExpression condition, ICPPASTLiteralExpression message);
+ public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner);
+
+ public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body);
+
+ public ICPPASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name);
/**
- * Creates a new pack expansion expression for the given pattern.
* @since 5.2
*/
- public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern);
+ public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator);
- /**
- * @deprecated Replaced by {@link #newReferenceOperator(boolean)}.
- */
- @Deprecated public ICPPASTReferenceOperator newReferenceOperator();
- /**
- * @deprecated Replaced by {@link #newTranslationUnit(IScanner)}.
- */
- @Deprecated
- public ICPPASTTranslationUnit newTranslationUnit();
- /**
- * @deprecated Replaced by {@link #newSimpleDeclSpecifier()}
- */
- @Deprecated
- public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
+ public ICPPASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId);
/**
- * @deprecated Replaced by {@link #newExplicitTemplateInstantiation(IASTDeclaration)}.
+ * @deprecated Replaced by {@link #newSimpleTypeConstructorExpression(ICPPASTDeclSpecifier, IASTInitializer)}
*/
@Deprecated
- public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration);
+ public ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate);
+
+ public ICPPASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand);
+
+ public ICPPASTUsingDeclaration newUsingDeclaration(IASTName name);
+
+ public ICPPASTUsingDirective newUsingDirective(IASTName name);
+ public ICPPASTVisibilityLabel newVisibilityLabel(int visibility);
+
+ public ICPPASTWhileStatement newWhileStatement();
+
+ public ICPPASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body);
+
+ public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java
index 9e372d78c99..86be3b62afe 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java
@@ -14,6 +14,9 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
/**
* @deprecated Replaced by {@link IASTUnaryExpression}.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
@Deprecated
public interface IGNUASTUnaryExpression extends IASTUnaryExpression {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IInactiveCodeToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IInactiveCodeToken.java
index b756aca39eb..34ae2bf74c5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IInactiveCodeToken.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IInactiveCodeToken.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,8 @@ package org.eclipse.cdt.core.parser;
* Interface for tokens of kind {@link IToken#tINACTIVE_CODE_START}, {@link IToken#tINACTIVE_CODE_SEPARATOR} and
* {@link IToken#tINACTIVE_CODE_END}.
* @since 5.1
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface IInactiveCodeToken extends IToken {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java
index 0a5044376a4..41b01aa6ef4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,8 +14,10 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
@@ -104,7 +106,15 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbigu
if (!hasIssue)
return nodeToReplace;
- fFunctionCallExpression.setParameterExpression(primaryWithParenthesis.getOperand());
+ final IASTExpression operand = primaryWithParenthesis.getOperand();
+ if (operand instanceof IASTExpressionList) {
+ final IASTExpressionList list= (IASTExpressionList) operand;
+ fFunctionCallExpression.setArguments(list.getExpressions());
+ } else if (operand != null) {
+ fFunctionCallExpression.setArguments(new IASTInitializerClause[] {operand});
+ } else {
+ fFunctionCallExpression.setArguments(IASTExpression.EMPTY_EXPRESSION_ARRAY);
+ }
setRange(fFunctionCallExpression, fCastExpression, primaryWithParenthesis);
IASTExpression result= fFunctionCallExpression;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java
new file mode 100644
index 00000000000..1311303fadc
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+
+/**
+ * Initializer with equals sign (copy initialization)
+ */
+public abstract class ASTEqualsInitializer extends ASTNode implements IASTEqualsInitializer,
+ IASTAmbiguityParent {
+
+ private IASTInitializerClause fArgument;
+
+ public ASTEqualsInitializer() {
+ }
+
+ public ASTEqualsInitializer(IASTInitializerClause arg) {
+ setInitializerClause(arg);
+ }
+
+ public IASTInitializerClause getInitializerClause() {
+ return fArgument;
+ }
+
+ public void setInitializerClause(IASTInitializerClause clause) {
+ assertNotFrozen();
+ fArgument = clause;
+ if (clause != null) {
+ clause.setParent(this);
+ clause.setPropertyInParent(INITIALIZER);
+ }
+ }
+
+ @Override
+ public boolean accept( ASTVisitor action ){
+ if( action.shouldVisitInitializers ){
+ switch( action.visit( this ) ){
+ case ASTVisitor.PROCESS_ABORT : return false;
+ case ASTVisitor.PROCESS_SKIP : return true;
+ default : break;
+ }
+ }
+
+ if (fArgument != null && !fArgument.accept(action))
+ return false;
+
+ if (action.shouldVisitInitializers && action.leave(this) == ASTVisitor.PROCESS_ABORT)
+ return false;
+
+ return true;
+ }
+
+ public void replace(IASTNode child, IASTNode other) {
+ if (child == fArgument) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ fArgument = (IASTInitializerClause) other;
+ }
+ }
+
+ @Deprecated
+ public IASTExpression getExpression() {
+ if (fArgument instanceof IASTExpression)
+ return (IASTExpression) fArgument;
+
+ return null;
+ }
+
+ @Deprecated
+ public void setExpression(IASTExpression expression) {
+ setInitializerClause(expression);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
index 70b0d5b8fe0..8c523178d8d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
@@ -43,8 +43,8 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
-import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -55,7 +55,6 @@ import org.eclipse.cdt.core.dom.ast.IASTProblem;
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
-import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
@@ -67,7 +66,6 @@ import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
import org.eclipse.cdt.core.dom.ast.INodeFactory;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
@@ -633,6 +631,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
throw backtrack;
}
+ protected final void throwBacktrack(IASTNode node) throws BacktrackException {
+ final ASTNode n= (ASTNode) node;
+ throwBacktrack(n.getOffset(), n.getLength());
+ }
+
public IASTTranslationUnit parse() {
long startTime = System.currentTimeMillis();
translationUnit();
@@ -900,16 +903,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
- protected IASTExpression possiblyEmptyExpressionList(int endToken) throws BacktrackException, EndOfFileException {
- IToken la1= LA(1);
- if (la1.getType() == endToken) {
- IASTExpressionList expressionList = nodeFactory.newExpressionList();
- ((ASTNode) expressionList).setOffsetAndLength(la1.getOffset(), 0);
- return expressionList;
- }
- return expression();
- }
-
/**
* Models a cast expression followed by an operator. Can be linked into a chain.
* This is done right to left, such that a tree of variants can be built.
@@ -919,10 +912,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
final int fLeftPrecedence;
final int fRightPrecedence;
BinaryOperator fNext;
- IASTExpression fExpression;
+ IASTInitializerClause fExpression;
final CastAmbiguityMarker fAmbiguityMarker;
- public BinaryOperator(BinaryOperator nextOp, IASTExpression expression, int operatorToken, int leftPrecedence, int rightPrecedence) {
+ public BinaryOperator(BinaryOperator nextOp, IASTInitializerClause expression, int operatorToken, int leftPrecedence, int rightPrecedence) {
fNext= nextOp;
fOperatorToken= operatorToken;
fLeftPrecedence= leftPrecedence;
@@ -937,24 +930,24 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
}
- public IASTExpression exchange(IASTExpression expr) {
- IASTExpression e= fExpression;
+ public IASTInitializerClause exchange(IASTInitializerClause expr) {
+ IASTInitializerClause e= fExpression;
fExpression= expr;
return e;
}
}
- protected final IASTExpression buildExpression(BinaryOperator leftChain, IASTExpression expr) throws BacktrackException {
+ protected final IASTExpression buildExpression(BinaryOperator leftChain, IASTInitializerClause expr) throws BacktrackException {
BinaryOperator rightChain= null;
for (;;) {
if (leftChain == null) {
if (rightChain == null)
- return expr;
+ return (IASTExpression) expr;
- expr= buildExpression(expr, rightChain);
+ expr= buildExpression((IASTExpression) expr, rightChain);
rightChain= rightChain.fNext;
} else if (rightChain != null && leftChain.fRightPrecedence < rightChain.fLeftPrecedence) {
- expr= buildExpression(expr, rightChain);
+ expr= buildExpression((IASTExpression) expr, rightChain);
rightChain= rightChain.fNext;
} else {
BinaryOperator op= leftChain;
@@ -968,7 +961,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
private IASTExpression buildExpression(IASTExpression left, BinaryOperator operator) throws BacktrackException {
int op, unaryOp= 0;
- final IASTExpression right= operator.fExpression;
+ final IASTInitializerClause right= operator.fExpression;
switch(operator.fOperatorToken) {
case IToken.tQUESTION:
if (operator.fNext == null || operator.fNext.fOperatorToken != IToken.tCOLON) {
@@ -977,26 +970,15 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
throwBacktrack(node.getOffset(), node.getLength());
return null; // Will never be reached.
}
- IASTExpression negative= operator.fNext.fExpression;
+ IASTInitializerClause negative= operator.fNext.fExpression;
operator.fNext= operator.fNext.fNext;
- IASTConditionalExpression conditionalEx = nodeFactory.newConditionalExpession(left, right, negative);
+ IASTConditionalExpression conditionalEx = nodeFactory.newConditionalExpession(left, (IASTExpression) right, (IASTExpression) negative);
setRange(conditionalEx, left);
if (negative != null) {
adjustLength(conditionalEx, negative);
}
return conditionalEx;
- case IToken.tELLIPSIS:
- if (right instanceof ICPPASTPackExpansionExpression) {
- ((ICPPASTPackExpansionExpression) right).setPattern(left);
- int endOffset= ((ASTNode) right).getLength();
- setRange(right, left);
- adjustEndOffset(right, endOffset);
- return right;
- }
- assert false;
- return left;
-
case IToken.tCOMMA:
IASTExpressionList list;
if (left instanceof IASTExpressionList) {
@@ -1006,7 +988,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
list.addExpression(left);
setRange(list, left);
}
- list.addExpression(right);
+ list.addExpression((IASTExpression) right);
adjustLength(list, right);
return list;
@@ -1220,7 +1202,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
backup(mark);
try {
IASTExpression expr= primaryExpression(ctx);
- IASTFunctionCallExpression fcall = nodeFactory.newFunctionCallExpression(expr, null);
+ IASTFunctionCallExpression fcall = nodeFactory.newFunctionCallExpression(expr, (IASTExpression[]) null);
IASTAmbiguousExpression ambiguity = createAmbiguousCastVsFunctionCallExpression(result, fcall);
((ASTNode) ambiguity).setOffsetAndLength((ASTNode) result);
return ca == null ? ambiguity : ca.updateExpression(ambiguity);
@@ -1346,12 +1328,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
parent.addDeclaration(declaration);
}
- protected IASTExpression buildBinaryExpression(int operator, IASTExpression expr1, IASTExpression expr2, int lastOffset) {
- IASTBinaryExpression result = nodeFactory.newBinaryExpression(operator, expr1, expr2);
- int o = ((ASTNode) expr1).getOffset();
- ((ASTNode) result).setOffsetAndLength(o, lastOffset - o);
- return result;
- }
+ abstract protected IASTExpression buildBinaryExpression(int operator, IASTExpression expr1, IASTInitializerClause expr2, int lastOffset);
private IASTExpression createCastVsBinaryExpressionAmbiguity(IASTBinaryExpression expr, final IASTTypeId typeid, int unaryOperator, int unaryOpOffset) {
IASTUnaryExpression unary= nodeFactory.newUnaryExpression(unaryOperator, null);
@@ -1829,6 +1806,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
((ASTNode) ds).setOffsetAndLength(((ASTNode) d).getOffset(), ((ASTNode) d).getLength());
} catch (BacktrackException b) {
if (expressionStatement == null) {
+ backup(mark);
throw b;
}
}
@@ -1974,40 +1952,17 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
protected IASTStatement parseReturnStatement() throws EndOfFileException, BacktrackException {
- int startOffset;
- startOffset = consume().getOffset(); // t_return
- IASTExpression result = null;
-
- // See if there is a return expression
- switch (LT(1)) {
- case IToken.tEOC:
- // We're trying to start one
- IASTName name = identifier();
- IASTIdExpression idExpr = nodeFactory.newIdExpression(name);
- result = idExpr;
- break;
- case IToken.tSEMI:
- // None
- break;
- default:
- // Yes
- result = expression();
- break;
- }
+ final int offset= consume(IToken.t_return).getOffset();
- int lastOffset = 0;
- switch (LT(1)) {
- case IToken.tSEMI:
- case IToken.tEOC:
- lastOffset = consume().getEndOffset();
- break;
- default:
- throwBacktrack(LA(1));
+ // Optional expression
+ IASTExpression expr = null;
+ if (LT(1) != IToken.tSEMI) {
+ expr = expression();
}
+ // Semicolon
+ final int endOffset= consumeOrEOC(IToken.tSEMI).getEndOffset();
- IASTReturnStatement return_statement = nodeFactory.newReturnStatement(result);
- ((ASTNode) return_statement).setOffsetAndLength(startOffset, lastOffset - startOffset);
- return return_statement;
+ return setRange(nodeFactory.newReturnStatement(expr), offset, endOffset);
}
protected IASTStatement parseDoStatement() throws EndOfFileException, BacktrackException {
@@ -2316,7 +2271,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
// Allow empty attribute
if (lt1 != IToken.tCOMMA) {
- singelAttribute();
+ singleAttribute();
}
// Require comma
@@ -2330,7 +2285,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
}
- private void singelAttribute() throws EndOfFileException, BacktrackException {
+ private void singleAttribute() throws EndOfFileException, BacktrackException {
// Check if we have an identifier including keywords
if (!isIdentifier(LA(1)))
throw backtrack;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
index 13122ad584a..ac5294f63e8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java
@@ -12,33 +12,33 @@ package org.eclipse.cdt.internal.core.dom.parser;
/**
* Configures the parsing of a declaration in various contexts.
- * @since 5.0
*/
public class DeclarationOptions {
- final public static int ALLOW_EMPTY_SPECIFIER= 0x01;
- final public static int ALLOW_ABSTRACT= 0x02;
- final public static int REQUIRE_ABSTRACT= 0x04;
- final public static int ALLOW_BITFIELD= 0x08;
- final public static int NO_INITIALIZER= 0x10;
- final public static int ALLOW_CONSTRUCTOR_INITIALIZER= 0x20;
- final public static int NO_FUNCTIONS= 0x40;
- final public static int NO_ARRAYS= 0x80;
- final public static int NO_NESTED= 0x100;
- final public static int ALLOW_PARAMETER_PACKS= 0x200;
- final public static int REQUIRE_SIMPLE_NAME= 0x400;
+ final public static int ALLOW_EMPTY_SPECIFIER= 0x01;
+ final public static int ALLOW_ABSTRACT= 0x02;
+ final public static int REQUIRE_ABSTRACT= 0x04;
+ final public static int ALLOW_BITFIELD= 0x08;
+ final public static int NO_INITIALIZER= 0x10;
+ final public static int NO_CTOR_STYLE_INITIALIZER= 0x20;
+ final public static int NO_BRACED_INITIALIZER= 0x40;
+ final public static int NO_FUNCTIONS= 0x80;
+ final public static int NO_ARRAYS= 0x100;
+ final public static int NO_NESTED= 0x200;
+ final public static int ALLOW_PARAMETER_PACKS= 0x400;
+ final public static int REQUIRE_SIMPLE_NAME= 0x800;
public static final DeclarationOptions
- GLOBAL= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_CONSTRUCTOR_INITIALIZER),
+ GLOBAL= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER),
FUNCTION_STYLE_ASM= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | NO_INITIALIZER | ALLOW_ABSTRACT),
C_MEMBER= new DeclarationOptions(ALLOW_BITFIELD | ALLOW_ABSTRACT),
- CPP_MEMBER= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD),
- LOCAL= new DeclarationOptions(ALLOW_CONSTRUCTOR_INITIALIZER),
- PARAMETER= new DeclarationOptions(ALLOW_ABSTRACT | ALLOW_PARAMETER_PACKS | REQUIRE_SIMPLE_NAME),
+ CPP_MEMBER= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD | NO_CTOR_STYLE_INITIALIZER),
+ LOCAL= new DeclarationOptions(0),
+ PARAMETER= new DeclarationOptions(ALLOW_ABSTRACT | ALLOW_PARAMETER_PACKS | REQUIRE_SIMPLE_NAME | NO_BRACED_INITIALIZER | NO_CTOR_STYLE_INITIALIZER),
TYPEID= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER),
TYPEID_NEW= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | NO_FUNCTIONS | NO_NESTED),
TYPEID_CONVERSION= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | NO_FUNCTIONS | NO_NESTED),
EXCEPTION= new DeclarationOptions(ALLOW_ABSTRACT | NO_INITIALIZER),
- CONDITION= new DeclarationOptions(ALLOW_CONSTRUCTOR_INITIALIZER),
+ CONDITION= new DeclarationOptions(NO_CTOR_STYLE_INITIALIZER),
C_PARAMETER_NON_ABSTRACT= new DeclarationOptions(ALLOW_ABSTRACT | ALLOW_EMPTY_SPECIFIER);
final public boolean fAllowEmptySpecifier;
@@ -46,7 +46,8 @@ public class DeclarationOptions {
final public boolean fRequireAbstract;
final public boolean fAllowBitField;
final public boolean fAllowInitializer;
- final public boolean fAllowConstructorInitializer;
+ final public boolean fAllowBracedInitializer;
+ final public boolean fAllowCtorStyleInitializer;
final public boolean fAllowFunctions;
final public boolean fAllowNested;
final public boolean fAllowParameterPacks;
@@ -58,7 +59,8 @@ public class DeclarationOptions {
fAllowAbstract= fRequireAbstract || (options & ALLOW_ABSTRACT) != 0;
fAllowBitField= (options & ALLOW_BITFIELD) != 0;
fAllowInitializer= (options & NO_INITIALIZER) == 0;
- fAllowConstructorInitializer= fAllowInitializer && (options & ALLOW_CONSTRUCTOR_INITIALIZER) != 0;
+ fAllowBracedInitializer= fAllowInitializer && (options & NO_BRACED_INITIALIZER) == 0;
+ fAllowCtorStyleInitializer= fAllowInitializer && (options & NO_CTOR_STYLE_INITIALIZER) == 0;
fAllowFunctions= (options & NO_FUNCTIONS) == 0;
fAllowNested= (options & NO_NESTED) == 0;
fAllowParameterPacks= (options & ALLOW_PARAMETER_PACKS) != 0;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousSimpleDeclaration.java
index 14c61f38e4b..4b59b50b0f3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousSimpleDeclaration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousSimpleDeclaration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,7 +14,6 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
/**
* Needed to handle the ambiguity for simple declarations in plain C
- * @since 5.1
*/
public interface IASTAmbiguousSimpleDeclaration extends IASTSimpleDeclaration {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java
index 7bc08231750..5024bdd2094 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,7 +14,6 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
/**
* Internal interface for c- or c++ enumeration specifiers.
- * @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTInternalEnumerationSpecifier extends IASTEnumerationSpecifier {
/**
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
index 88ac199cb3e..84a4b24f34e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/VariableReadWriteFlags.java
@@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
@@ -28,7 +29,6 @@ import org.eclipse.cdt.core.dom.ast.IASTForStatement;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
@@ -65,7 +65,7 @@ public abstract class VariableReadWriteFlags {
else if (parent instanceof IASTStatement) {
return rwInStatement(node, (IASTStatement) parent, indirection);
}
- else if (parent instanceof IASTInitializerExpression) {
+ else if (parent instanceof IASTEqualsInitializer) {
return rwInInitializerExpression(indirection, parent);
}
else if (parent instanceof IASTArrayModifier) {
@@ -113,7 +113,7 @@ public abstract class VariableReadWriteFlags {
if (expr instanceof IASTExpressionList) {
final IASTExpressionList exprList = (IASTExpressionList)expr;
final IASTNode grand= expr.getParent();
- if (grand instanceof IASTFunctionCallExpression && expr.getPropertyInParent() == IASTFunctionCallExpression.PARAMETERS) {
+ if (grand instanceof IASTFunctionCallExpression && expr.getPropertyInParent() == IASTFunctionCallExpression.ARGUMENT) {
final IASTFunctionCallExpression funcCall = (IASTFunctionCallExpression) grand;
return rwArgumentForFunctionCall(node, exprList, funcCall, indirection);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java
index 420e0188cb8..65090f6183d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArraySubscriptExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IPointerType;
@@ -73,7 +74,20 @@ public class CASTArraySubscriptExpression extends ASTNode implements
}
}
- @Override
+
+ public IASTInitializerClause getArgument() {
+ return getSubscriptExpression();
+ }
+
+ public void setArgument(IASTInitializerClause expression) {
+ if (expression instanceof IASTExpression) {
+ setSubscriptExpression((IASTExpression) expression);
+ } else {
+ setSubscriptExpression(null);
+ }
+ }
+
+ @Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitExpressions ){
switch( action.visit( this ) ){
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java
index 9216dada5fd..6de2baaa096 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java
@@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IType;
@@ -62,7 +63,11 @@ public class CASTBinaryExpression extends ASTNode implements
return operand2;
}
- /**
+ public IASTInitializerClause getInitOperand2() {
+ return operand2;
+ }
+
+ /**
* @param op An op_X field from {@link IASTBinaryExpression}
*/
public void setOperator(int op) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java
index 0b746a82d3e..14a62cfdb37 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDesignatedInitializer.java
@@ -1,36 +1,43 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM - Initial API and implementation
- * Yuan Zhang / Beth Tibbitts (IBM Research)
+ * John Camelon (IBM) - Initial API and implementation
+ * Yuan Zhang / Beth Tibbitts (IBM Research)
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
+import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
- * @author jcamelon
+ * Implementation for designated initializers
*/
-public class CASTDesignatedInitializer extends ASTNode implements ICASTDesignatedInitializer {
+public class CASTDesignatedInitializer extends ASTNode implements ICASTDesignatedInitializer, IASTAmbiguityParent {
- private IASTInitializer rhs;
-
-
+ private IASTInitializerClause rhs;
+ private ICASTDesignator [] designators = null;
+ private int designatorsPos=-1;
+
public CASTDesignatedInitializer() {
}
- public CASTDesignatedInitializer(IASTInitializer operandInitializer) {
- setOperandInitializer(operandInitializer);
+ public CASTDesignatedInitializer(IASTInitializerClause init) {
+ setOperand(init);
}
public CASTDesignatedInitializer copy() {
@@ -57,22 +64,44 @@ public class CASTDesignatedInitializer extends ASTNode implements ICASTDesignate
return designators;
}
- private ICASTDesignator [] designators = null;
- int designatorsPos=-1;
- public IASTInitializer getOperandInitializer() {
+ public IASTInitializerClause getOperand() {
return rhs;
- }
+ }
-
- public void setOperandInitializer(IASTInitializer rhs) {
+ public void setOperand(IASTInitializerClause operand) {
assertNotFrozen();
- this.rhs = rhs;
+ this.rhs = operand;
if (rhs != null) {
rhs.setParent(this);
rhs.setPropertyInParent(OPERAND);
}
+ }
+
+ @Deprecated
+ public IASTInitializer getOperandInitializer() {
+ if (rhs instanceof IASTInitializer) {
+ return (IASTInitializer) rhs;
+ }
+ if (rhs instanceof IASTExpression) {
+ CASTEqualsInitializer init = new CASTEqualsInitializer(((IASTExpression)rhs).copy());
+ init.setParent(this);
+ init.setPropertyInParent(OPERAND);
+ return init;
+ }
+ return null;
+ }
+
+ @Deprecated
+ public void setOperandInitializer(IASTInitializer rhs) {
+ if (rhs instanceof IASTEqualsInitializer) {
+ setOperand(((IASTEqualsInitializer) rhs).getInitializerClause());
+ } else if (rhs instanceof IASTInitializerClause) {
+ setOperand((IASTInitializerClause) rhs);
+ } else {
+ setOperand(null);
+ }
}
@Override
@@ -100,4 +129,11 @@ public class CASTDesignatedInitializer extends ASTNode implements ICASTDesignate
return true;
}
+ public void replace(IASTNode child, IASTNode other) {
+ if (child == rhs) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ rhs = (IASTInitializerClause) other;
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java
new file mode 100644
index 00000000000..41ec7663860
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTEqualsInitializer.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser.c;
+
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.internal.core.dom.parser.ASTEqualsInitializer;
+
+/**
+ * Initializer with equals sign (copy initialization)
+ */
+public class CASTEqualsInitializer extends ASTEqualsInitializer {
+ public CASTEqualsInitializer() {
+ }
+
+ public CASTEqualsInitializer(IASTInitializerClause arg) {
+ super(arg);
+ }
+
+ public CASTEqualsInitializer copy() {
+ IASTInitializerClause arg = getInitializerClause();
+ CASTEqualsInitializer copy = new CASTEqualsInitializer(arg == null ? null : arg.copy());
+ copy.setOffsetAndLength(this);
+ return copy;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java
index dc94acc2313..6f08ca8d85e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFunctionCallExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,8 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
@@ -29,21 +31,29 @@ public class CASTFunctionCallExpression extends ASTNode implements
IASTFunctionCallExpression, IASTAmbiguityParent {
private IASTExpression functionName;
- private IASTExpression parameter;
+ private IASTInitializerClause[] fArguments;
public CASTFunctionCallExpression() {
+ setArguments(null);
}
- public CASTFunctionCallExpression(IASTExpression functionName, IASTExpression parameter) {
+ public CASTFunctionCallExpression(IASTExpression functionName, IASTInitializerClause[] args) {
setFunctionNameExpression(functionName);
- setParameterExpression(parameter);
+ setArguments(args);
}
public CASTFunctionCallExpression copy() {
- CASTFunctionCallExpression copy = new CASTFunctionCallExpression();
+ IASTInitializerClause[] args = null;
+ if (fArguments.length > 0) {
+ args= new IASTInitializerClause[fArguments.length];
+ for (int i=0; i<fArguments.length; i++) {
+ args[i]= fArguments[i].copy();
+ }
+ }
+
+ CASTFunctionCallExpression copy = new CASTFunctionCallExpression(null, args);
copy.setFunctionNameExpression(functionName == null ? null : functionName.copy());
- copy.setParameterExpression(parameter == null ? null : parameter.copy());
copy.setOffsetAndLength(this);
return copy;
}
@@ -61,17 +71,21 @@ public class CASTFunctionCallExpression extends ASTNode implements
return functionName;
}
- public void setParameterExpression(IASTExpression expression) {
- assertNotFrozen();
- this.parameter = expression;
- if (expression != null) {
- expression.setParent(this);
- expression.setPropertyInParent(PARAMETERS);
- }
+ public IASTInitializerClause[] getArguments() {
+ return fArguments;
}
- public IASTExpression getParameterExpression() {
- return parameter;
+ public void setArguments(IASTInitializerClause[] arguments) {
+ assertNotFrozen();
+ if (arguments == null) {
+ fArguments= IASTExpression.EMPTY_EXPRESSION_ARRAY;
+ } else {
+ fArguments= arguments;
+ for (IASTInitializerClause arg : arguments) {
+ arg.setParent(this);
+ arg.setPropertyInParent(ARGUMENT);
+ }
+ }
}
@Override
@@ -84,33 +98,34 @@ public class CASTFunctionCallExpression extends ASTNode implements
}
}
- if( functionName != null ) if( !functionName.accept( action ) ) return false;
- if( parameter != null ) if( !parameter.accept( action ) ) return false;
+ if (functionName != null && !functionName.accept(action))
+ return false;
- if( action.shouldVisitExpressions ){
- switch( action.leave( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
- }
+ for (IASTInitializerClause arg : fArguments) {
+ if (!arg.accept(action))
+ return false;
}
- return true;
+
+ if (action.shouldVisitExpressions && action.leave(this) == ASTVisitor.PROCESS_ABORT)
+ return false;
+
+ return true;
}
public void replace(IASTNode child, IASTNode other) {
- if( child == functionName )
- {
- other.setPropertyInParent( child.getPropertyInParent() );
- other.setParent( child.getParent() );
- functionName = (IASTExpression) other;
- }
- if( child == parameter)
- {
- other.setPropertyInParent( child.getPropertyInParent() );
- other.setParent( child.getParent() );
- parameter = (IASTExpression) other;
- }
- }
+ if (child == functionName) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ functionName = (IASTExpression) other;
+ }
+ for (int i = 0; i < fArguments.length; ++i) {
+ if (child == fArguments[i]) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ fArguments[i] = (IASTInitializerClause) other;
+ }
+ }
+ }
public IType getExpressionType() {
IType type = getFunctionNameExpression().getExpressionType();
@@ -124,4 +139,38 @@ public class CASTFunctionCallExpression extends ASTNode implements
public boolean isLValue() {
return false;
}
+
+ @Deprecated
+ public IASTExpression getParameterExpression() {
+ if (fArguments.length == 0)
+ return null;
+ if (fArguments.length == 1) {
+ IASTInitializerClause arg = fArguments[0];
+ if (arg instanceof IASTExpression)
+ return (IASTExpression) arg;
+ return null;
+ }
+
+ CASTExpressionList result= new CASTExpressionList();
+ for (IASTInitializerClause arg : fArguments) {
+ if (arg instanceof IASTExpression) {
+ result.addExpression(((IASTExpression) arg).copy());
+ }
+ }
+ result.setParent(this);
+ result.setPropertyInParent(ARGUMENT);
+ return result;
+ }
+
+ @Deprecated
+ public void setParameterExpression(IASTExpression expression) {
+ assertNotFrozen();
+ if (expression == null) {
+ setArguments(null);
+ } else if (expression instanceof IASTExpressionList) {
+ setArguments(((IASTExpressionList) expression).getExpressions());
+ } else {
+ setArguments(new IASTExpression[] {expression});
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerExpression.java
index 34abea73a86..5828125664c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,77 +11,26 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
-import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
-/**
- * @author jcamelon
- */
-public class CASTInitializerExpression extends ASTNode implements
- IASTInitializerExpression, IASTAmbiguityParent {
+@Deprecated
+public class CASTInitializerExpression extends CASTEqualsInitializer implements IASTInitializerExpression {
- private IASTExpression expression;
-
-
public CASTInitializerExpression() {
}
public CASTInitializerExpression(IASTExpression expression) {
setExpression(expression);
}
-
+
+ @Override
public CASTInitializerExpression copy() {
- CASTInitializerExpression copy = new CASTInitializerExpression();
- copy.setExpression(expression == null ? null : expression.copy());
+ CASTInitializerExpression copy= new CASTInitializerExpression();
+ IASTInitializerClause init= getInitializerClause();
+ copy.setInitializerClause(init == null ? null : init.copy());
copy.setOffsetAndLength(this);
return copy;
}
-
- public IASTExpression getExpression() {
- return expression;
- }
-
- public void setExpression(IASTExpression expression) {
- assertNotFrozen();
- this.expression = expression;
- if (expression != null) {
- expression.setParent(this);
- expression.setPropertyInParent(INITIALIZER_EXPRESSION);
- }
- }
-
- @Override
- public boolean accept( ASTVisitor action ){
- if( action.shouldVisitInitializers ){
- switch( action.visit( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
- }
- }
- if( expression != null ) if( !expression.accept( action ) ) return false;
-
- if( action.shouldVisitInitializers ){
- switch( action.leave( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
- }
- }
- return true;
- }
-
- public void replace(IASTNode child, IASTNode other) {
- if( child == expression )
- {
- other.setPropertyInParent( child.getPropertyInParent() );
- other.setParent( child.getParent() );
- expression = (IASTExpression) other;
- }
- }
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerList.java
index 86c7a0a839e..4acd1b729cb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerList.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTInitializerList.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,24 +13,29 @@
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
+import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* e.g.: int a[]= {1,2,3};
*/
-public class CASTInitializerList extends ASTNode implements IASTInitializerList {
+public class CASTInitializerList extends ASTNode implements IASTInitializerList, IASTAmbiguityParent {
- private IASTInitializer [] initializers = null;
+ private IASTInitializerClause[] initializers = null;
private int initializersPos=-1;
private int actualSize;
public CASTInitializerList copy() {
CASTInitializerList copy = new CASTInitializerList();
- for(IASTInitializer initializer : getInitializers())
- copy.addInitializer(initializer == null ? null : initializer.copy());
+ for(IASTInitializerClause initializer : getClauses())
+ copy.addClause(initializer == null ? null : initializer.copy());
copy.setOffsetAndLength(this);
copy.actualSize= getSize();
return copy;
@@ -41,24 +46,56 @@ public class CASTInitializerList extends ASTNode implements IASTInitializerList
return actualSize;
}
- public IASTInitializer[] getInitializers() {
+ public IASTInitializerClause[] getClauses() {
if (initializers == null)
- return IASTInitializer.EMPTY_INITIALIZER_ARRAY;
- initializers = ArrayUtil.trimAt(IASTInitializer.class, initializers, initializersPos);
+ return IASTExpression.EMPTY_EXPRESSION_ARRAY;
+ initializers = ArrayUtil.trimAt(IASTInitializerClause.class, initializers, initializersPos);
return initializers;
}
-
- public void addInitializer( IASTInitializer d ) {
+
+ @Deprecated
+ public IASTInitializer[] getInitializers() {
+ IASTInitializerClause[] clauses= getClauses();
+ if (clauses.length == 0)
+ return IASTInitializer.EMPTY_INITIALIZER_ARRAY;
+
+ IASTInitializer[] inits= new IASTInitializer[clauses.length];
+ for (int i = 0; i < inits.length; i++) {
+ IASTInitializerClause clause= clauses[i];
+ if (clause instanceof IASTInitializer) {
+ inits[i]= (IASTInitializer) clause;
+ } else if (clause instanceof IASTExpression) {
+ final CASTEqualsInitializer initExpr = new CASTEqualsInitializer(((IASTExpression) clause).copy());
+ initExpr.setParent(this);
+ initExpr.setPropertyInParent(NESTED_INITIALIZER);
+ inits[i]= initExpr;
+ }
+ }
+ return inits;
+ }
+
+ public void addClause(IASTInitializerClause d) {
assertNotFrozen();
if (d != null) {
- initializers = (IASTInitializer[]) ArrayUtil.append( IASTInitializer.class, initializers, ++initializersPos, d );
+ initializers = (IASTInitializerClause[]) ArrayUtil.append( IASTInitializerClause.class, initializers, ++initializersPos, d );
d.setParent(this);
d.setPropertyInParent(NESTED_INITIALIZER);
}
actualSize++;
}
-
+ @Deprecated
+ public void addInitializer(IASTInitializer d) {
+ assertNotFrozen();
+ if (d instanceof IASTInitializerClause) {
+ addClause((IASTInitializerClause) d);
+ } else if (d instanceof IASTEqualsInitializer) {
+ addClause(((IASTEqualsInitializer) d).getInitializerClause());
+ } else {
+ addClause(null);
+ }
+ }
+
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitInitializers ){
@@ -68,10 +105,11 @@ public class CASTInitializerList extends ASTNode implements IASTInitializerList
default : break;
}
}
- IASTInitializer [] list = getInitializers();
- for ( int i = 0; i < list.length; i++ ) {
- if( !list[i].accept( action ) ) return false;
- }
+ IASTInitializerClause[] list = getClauses();
+ for (IASTInitializerClause clause : list) {
+ if (!clause.accept(action))
+ return false;
+ }
if( action.shouldVisitInitializers ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
@@ -82,4 +120,15 @@ public class CASTInitializerList extends ASTNode implements IASTInitializerList
return true;
}
+ public void replace(IASTNode child, IASTNode other) {
+ if (initializers != null) {
+ for (int i = 0; i < initializers.length; ++i) {
+ if (child == initializers[i]) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ initializers[i] = (IASTInitializerClause) other;
+ }
+ }
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTReturnStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTReturnStatement.java
index e2cb41ae187..7e8520d217d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTReturnStatement.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTReturnStatement.java
@@ -1,26 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Rational Software - Initial API and implementation
- * Yuan Zhang / Beth Tibbitts (IBM Research)
+ * John Camelon (IBM Rational Software) - Initial API and implementation
+ * Yuan Zhang / Beth Tibbitts (IBM Research)
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
-/**
- * @author jcamelon
- */
public class CASTReturnStatement extends ASTNode implements
IASTReturnStatement, IASTAmbiguityParent {
@@ -43,7 +42,6 @@ public class CASTReturnStatement extends ASTNode implements
return retValue;
}
-
public void setReturnValue(IASTExpression returnValue) {
assertNotFrozen();
retValue = returnValue;
@@ -53,7 +51,19 @@ public class CASTReturnStatement extends ASTNode implements
}
}
- @Override
+ public IASTInitializerClause getReturnArgument() {
+ return getReturnValue();
+ }
+
+ public void setReturnArgument(IASTInitializerClause returnValue) {
+ if (returnValue instanceof IASTExpression) {
+ setReturnValue((IASTExpression) returnValue);
+ } else {
+ setReturnValue(null);
+ }
+ }
+
+ @Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitStatements ){
switch( action.visit( this ) ){
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java
index 6a952ec16cc..ee633799221 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java
@@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
@@ -40,7 +41,7 @@ import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
@@ -93,157 +94,126 @@ public class CNodeFactory extends NodeFactory implements ICNodeFactory {
return DEFAULT_INSTANCE;
}
- public IASTTranslationUnit newTranslationUnit() {
- return newTranslationUnit(null);
- }
-
- public IASTTranslationUnit newTranslationUnit(IScanner scanner) {
- CASTTranslationUnit tu = new CASTTranslationUnit();
-
- if (scanner != null) {
- tu.setLocationResolver(scanner.getLocationResolver());
- }
- tu.setASTNodeFactory(this);
- return tu;
- }
-
- public IASTName newName(char[] name) {
- return new CASTName(name);
- }
-
- public IASTName newName() {
- return new CASTName();
- }
-
- public IASTLiteralExpression newLiteralExpression(int kind, String rep) {
- return new CASTLiteralExpression(kind, rep.toCharArray());
+ public IASTArrayDeclarator newArrayDeclarator(IASTName name) {
+ return new CASTArrayDeclarator(name);
}
- public IASTIdExpression newIdExpression(IASTName name) {
- return new CASTIdExpression(name);
+ public ICASTArrayDesignator newArrayDesignator(IASTExpression exp) {
+ return new CASTArrayDesignator(exp);
}
- public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2) {
- return new CASTBinaryExpression(op, expr1, expr2);
+ public ICASTArrayModifier newArrayModifier(IASTExpression expr) {
+ return new CASTArrayModifier(expr);
}
- public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3) {
- return new CASTConditionalExpression(expr1, expr2, expr3);
+ public IGCCASTArrayRangeDesignator newArrayRangeDesignatorGCC(IASTExpression floor, IASTExpression ceiling) {
+ return new CASTArrayRangeDesignator(floor, ceiling);
}
public IASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript) {
return new CASTArraySubscriptExpression(arrayExpr, subscript);
}
- public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList) {
- return new CASTFunctionCallExpression(idExpr, argList);
- }
-
- public IASTExpressionList newExpressionList() {
- return new CASTExpressionList();
- }
-
- public IASTFieldReference newFieldReference(IASTName name, IASTExpression owner) {
- return new CASTFieldReference(name, owner);
+ public IASTASMDeclaration newASMDeclaration(String assembly) {
+ return new CASTASMDeclaration(assembly);
}
- public IASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand) {
- return new CASTUnaryExpression(operator, operand);
+ public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2) {
+ return new CASTBinaryExpression(op, expr1, expr2);
}
- public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) {
- return new CASTTypeIdExpression(operator, typeId);
+ public IASTBreakStatement newBreakStatement() {
+ return new CASTBreakStatement();
}
- public ICASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer) {
- return new CASTTypeIdInitializerExpression(typeId, initializer);
+ public IASTCaseStatement newCaseStatement(IASTExpression expression) {
+ return new CASTCaseStatement(expression);
}
-
+
/**
* @param operator
*/
public IASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand) {
return new CASTCastExpression(typeId, operand);
}
-
- public IASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
- return new CASTTypeId(declSpecifier, declarator);
+
+ public ICASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name) {
+ return new CASTCompositeTypeSpecifier(key, name);
}
- public IASTDeclarator newDeclarator(IASTName name) {
- return new CASTDeclarator(name);
+ public IASTCompoundStatement newCompoundStatement() {
+ return new CASTCompoundStatement();
}
- public IASTArrayDeclarator newArrayDeclarator(IASTName name) {
- return new CASTArrayDeclarator(name);
+ public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3) {
+ return new CASTConditionalExpression(expr1, expr2, expr3);
}
- public ICASTArrayModifier newArrayModifier(IASTExpression expr) {
- return new CASTArrayModifier(expr);
+ public IASTContinueStatement newContinueStatement() {
+ return new CASTContinueStatement();
}
- public IASTStandardFunctionDeclarator newFunctionDeclarator(IASTName name) {
- return new CASTFunctionDeclarator(name);
+ public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration) {
+ return new CASTDeclarationStatement(declaration);
}
- public ICASTKnRFunctionDeclarator newKnRFunctionDeclarator(IASTName[] parameterNames, IASTDeclaration[] parameterDeclarations) {
- return new CASTKnRFunctionDeclarator(parameterNames, parameterDeclarations);
+ public IASTDeclarator newDeclarator(IASTName name) {
+ return new CASTDeclarator(name);
}
- public ICASTPointer newPointer() {
- return new CASTPointer();
+ public IASTDefaultStatement newDefaultStatement() {
+ return new CASTDefaultStatement();
}
- public IASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
- return new CASTParameterDeclaration(declSpec, declarator);
+ @Deprecated
+ public ICASTDesignatedInitializer newDesignatedInitializer(IASTInitializer operandInitializer) {
+ CASTDesignatedInitializer result = new CASTDesignatedInitializer();
+ result.setOperandInitializer(operandInitializer);
+ return result;
}
- public IASTInitializerExpression newInitializerExpression(IASTExpression expression) {
- return new CASTInitializerExpression(expression);
+ public ICASTDesignatedInitializer newDesignatedInitializer(IASTInitializerClause clause) {
+ return new CASTDesignatedInitializer(clause);
}
- public IASTInitializerList newInitializerList() {
- return new CASTInitializerList();
+ public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition) {
+ return new CASTDoStatement(body, condition);
}
- public ICASTDesignatedInitializer newDesignatedInitializer(IASTInitializer operandInitializer) {
- return new CASTDesignatedInitializer(operandInitializer);
+ public ICASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name) {
+ return new CASTElaboratedTypeSpecifier(kind, name);
}
- public ICASTArrayDesignator newArrayDesignator(IASTExpression exp) {
- return new CASTArrayDesignator(exp);
+ public ICASTEnumerationSpecifier newEnumerationSpecifier(IASTName name) {
+ return new CASTEnumerationSpecifier(name);
}
- public ICASTFieldDesignator newFieldDesignator(IASTName name) {
- return new CASTFieldDesignator(name);
+ public IASTEnumerator newEnumerator(IASTName name, IASTExpression value) {
+ return new CASTEnumerator(name, value);
}
- public ICASTTypedefNameSpecifier newTypedefNameSpecifier(IASTName name) {
- return new CASTTypedefNameSpecifier(name);
+ public IASTEqualsInitializer newEqualsInitializer(IASTInitializerClause initClause) {
+ return new CASTEqualsInitializer(initClause);
}
- public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) {
- return new CASTSimpleDeclaration(declSpecifier);
+ public IASTExpressionList newExpressionList() {
+ return new CASTExpressionList();
}
+ public IASTExpressionStatement newExpressionStatement(IASTExpression expr) {
+ return new CASTExpressionStatement(expr);
+ }
+
public IASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize) {
return new CASTFieldDeclarator(name, bitFieldSize);
}
-
- public ICASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name) {
- return new CASTCompositeTypeSpecifier(key, name);
- }
-
- public ICASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name) {
- return new CASTElaboratedTypeSpecifier(kind, name);
- }
-
- public IASTEnumerator newEnumerator(IASTName name, IASTExpression value) {
- return new CASTEnumerator(name, value);
+
+ public ICASTFieldDesignator newFieldDesignator(IASTName name) {
+ return new CASTFieldDesignator(name);
}
-
- public IASTCompoundStatement newCompoundStatement() {
- return new CASTCompoundStatement();
+
+ public IASTFieldReference newFieldReference(IASTName name, IASTExpression owner) {
+ return new CASTFieldReference(name, owner);
}
public IASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
@@ -251,106 +221,156 @@ public class CNodeFactory extends NodeFactory implements ICNodeFactory {
return new CASTForStatement(init, condition, iterationExpression, body);
}
- public IASTExpressionStatement newExpressionStatement(IASTExpression expr) {
- return new CASTExpressionStatement(expr);
+ @Deprecated
+ public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList) {
+ CASTFunctionCallExpression result = new CASTFunctionCallExpression(idExpr, null);
+ result.setParameterExpression(argList);
+ return result;
}
- public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration) {
- return new CASTDeclarationStatement(declaration);
+ public IASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTInitializerClause[] arguments) {
+ return new CASTFunctionCallExpression(idExpr, arguments);
}
- public IASTNullStatement newNullStatement() {
- return new CASTNullStatement();
+ public IASTStandardFunctionDeclarator newFunctionDeclarator(IASTName name) {
+ return new CASTFunctionDeclarator(name);
}
- public IASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) {
- return new CASTWhileStatement(condition, body);
+ public IASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
+ IASTFunctionDeclarator declarator, IASTStatement bodyStatement) {
+ return new CASTFunctionDefinition(declSpecifier, declarator, bodyStatement);
}
- public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition) {
- return new CASTDoStatement(body, condition);
+ public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement) {
+ return new CASTCompoundStatementExpression(compoundStatement);
}
public IASTGotoStatement newGotoStatement(IASTName name) {
return new CASTGotoStatement(name);
}
- public IASTContinueStatement newContinueStatement() {
- return new CASTContinueStatement();
+ public IASTIdExpression newIdExpression(IASTName name) {
+ return new CASTIdExpression(name);
}
- public IASTBreakStatement newBreakStatement() {
- return new CASTBreakStatement();
+ public IASTIfStatement newIfStatement(IASTExpression expr, IASTStatement thenStat, IASTStatement elseClause) {
+ return new CASTIfStatement(expr, thenStat, elseClause);
}
- public IASTReturnStatement newReturnStatement(IASTExpression retValue) {
- return new CASTReturnStatement(retValue);
+ @Deprecated
+ public org.eclipse.cdt.core.dom.ast.IASTInitializerExpression newInitializerExpression(IASTExpression expression) {
+ return new CASTInitializerExpression(expression);
+ }
+
+ public IASTInitializerList newInitializerList() {
+ return new CASTInitializerList();
+ }
+
+ public ICASTKnRFunctionDeclarator newKnRFunctionDeclarator(IASTName[] parameterNames, IASTDeclaration[] parameterDeclarations) {
+ return new CASTKnRFunctionDeclarator(parameterNames, parameterDeclarations);
}
public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement) {
return new CASTLabelStatement(name, nestedStatement);
}
- public IASTCaseStatement newCaseStatement(IASTExpression expression) {
- return new CASTCaseStatement(expression);
+ public IASTLiteralExpression newLiteralExpression(int kind, String rep) {
+ return new CASTLiteralExpression(kind, rep.toCharArray());
}
- public IASTDefaultStatement newDefaultStatement() {
- return new CASTDefaultStatement();
+ public IASTName newName() {
+ return new CASTName();
}
- public IASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body) {
- return new CASTSwitchStatement(controller, body);
+ public IASTName newName(char[] name) {
+ return new CASTName(name);
}
- public IASTIfStatement newIfStatement(IASTExpression expr, IASTStatement thenStat, IASTStatement elseClause) {
- return new CASTIfStatement(expr, thenStat, elseClause);
+ public IASTNullStatement newNullStatement() {
+ return new CASTNullStatement();
}
- public IASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier,
- IASTFunctionDeclarator declarator, IASTStatement bodyStatement) {
- return new CASTFunctionDefinition(declSpecifier, declarator, bodyStatement);
+ public IASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
+ return new CASTParameterDeclaration(declSpec, declarator);
+ }
+
+ public ICASTPointer newPointer() {
+ return new CASTPointer();
+ }
+
+ public IASTProblem newProblem(int id, char[] arg, boolean error) {
+ return new CASTProblem(id, arg, error);
}
public IASTProblemDeclaration newProblemDeclaration(IASTProblem problem) {
return new CASTProblemDeclaration(problem);
}
+ public IASTProblemExpression newProblemExpression(IASTProblem problem) {
+ return new CASTProblemExpression(problem);
+ }
+
public IASTProblemStatement newProblemStatement(IASTProblem problem) {
return new CASTProblemStatement(problem);
}
- public IASTProblemExpression newProblemExpression(IASTProblem problem) {
- return new CASTProblemExpression(problem);
+ public IASTReturnStatement newReturnStatement(IASTExpression retValue) {
+ return new CASTReturnStatement(retValue);
}
- public IASTProblem newProblem(int id, char[] arg, boolean error) {
- return new CASTProblem(id, arg, error);
+ public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) {
+ return new CASTSimpleDeclaration(declSpecifier);
+ }
+
+ public ICASTSimpleDeclSpecifier newSimpleDeclSpecifier() {
+ return new CASTSimpleDeclSpecifier();
+ }
+
+ @Deprecated
+ public org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression) {
+ return new GCCASTSimpleDeclSpecifier(typeofExpression);
+ }
+
+ public IASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body) {
+ return new CASTSwitchStatement(controller, body);
+ }
+
+ public IASTTranslationUnit newTranslationUnit() {
+ return newTranslationUnit(null);
}
- public IASTASMDeclaration newASMDeclaration(String assembly) {
- return new CASTASMDeclaration(assembly);
+ public IASTTranslationUnit newTranslationUnit(IScanner scanner) {
+ CASTTranslationUnit tu = new CASTTranslationUnit();
+
+ if (scanner != null) {
+ tu.setLocationResolver(scanner.getLocationResolver());
+ }
+ tu.setASTNodeFactory(this);
+ return tu;
}
- public ICASTEnumerationSpecifier newEnumerationSpecifier(IASTName name) {
- return new CASTEnumerationSpecifier(name);
+ public ICASTTypedefNameSpecifier newTypedefNameSpecifier(IASTName name) {
+ return new CASTTypedefNameSpecifier(name);
}
- public ICASTSimpleDeclSpecifier newSimpleDeclSpecifier() {
- return new CASTSimpleDeclSpecifier();
+ public IASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
+ return new CASTTypeId(declSpecifier, declarator);
}
- public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement) {
- return new CASTCompoundStatementExpression(compoundStatement);
+ public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) {
+ return new CASTTypeIdExpression(operator, typeId);
}
- public IGCCASTArrayRangeDesignator newArrayRangeDesignatorGCC(IASTExpression floor, IASTExpression ceiling) {
- return new CASTArrayRangeDesignator(floor, ceiling);
+ public ICASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer) {
+ return new CASTTypeIdInitializerExpression(typeId, initializer);
}
- @Deprecated
- public org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier newSimpleDeclSpecifierGCC(IASTExpression typeofExpression) {
- return new GCCASTSimpleDeclSpecifier(typeofExpression);
+ public IASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand) {
+ return new CASTUnaryExpression(operator, operand);
+ }
+
+ public IASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) {
+ return new CASTWhileStatement(condition, body);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java
index d428d66048c..5eb21782fbc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVariable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,9 +16,10 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
@@ -186,10 +187,11 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn
IASTDeclarator dtor= findDeclarator(name);
if (dtor != null) {
IASTInitializer init= dtor.getInitializer();
- if (init instanceof IASTInitializerExpression) {
- IASTExpression expr= ((IASTInitializerExpression) init).getExpression();
- if (expr != null)
- return Value.create(expr, maxDepth);
+ if (init instanceof IASTEqualsInitializer) {
+ final IASTInitializerClause initClause = ((IASTEqualsInitializer) init).getInitializerClause();
+ if (initClause instanceof IASTExpression) {
+ return Value.create((IASTExpression) initClause, maxDepth);
+ }
}
if (init != null)
return Value.UNKNOWN;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
index 8d19058bba6..97b5ca46b61 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
@@ -30,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
@@ -40,7 +41,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -135,13 +136,15 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
protected IASTInitializer optionalCInitializer() throws EndOfFileException, BacktrackException {
if (LTcatchEOF(1) == IToken.tASSIGN) {
- consume();
- return cInitializerClause(false);
+ final int offset= consume().getOffset();
+ IASTInitializerClause initClause = initClause(false);
+ IASTEqualsInitializer result= nodeFactory.newEqualsInitializer(initClause);
+ return setRange(result, offset, calculateEndOffset(initClause));
}
return null;
}
- protected IASTInitializer cInitializerClause(boolean inAggregate) throws EndOfFileException, BacktrackException {
+ private IASTInitializerClause initClause(boolean inAggregate) throws EndOfFileException, BacktrackException {
final int offset = LA(1).getOffset();
if (LT(1) != IToken.tLBRACE) {
IASTExpression assignmentExpression= expression(ExprKind.eAssignment);
@@ -149,9 +152,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
if (!ASTQueries.canContainName(assignmentExpression))
return null;
}
- IASTInitializerExpression result= nodeFactory.newInitializerExpression(assignmentExpression);
- setRange(result, assignmentExpression);
- return result;
+ return assignmentExpression;
}
// it's an aggregate initializer
@@ -171,22 +172,24 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
// get designator list
List<? extends ICASTDesignator> designator= designatorList();
if (designator == null) {
- IASTInitializer initializer= cInitializerClause(true);
+ IASTInitializerClause clause= initClause(true);
// depending on value of skipTrivialItemsInCompoundInitializers initializer may be null
// in any way add the initializer such that the actual size can be tracked.
- result.addInitializer(initializer);
+ result.addClause(clause);
} else {
+ // Gnu extension: the assign operator is optional
if (LT(1) == IToken.tASSIGN)
- consume();
- IASTInitializer initializer= cInitializerClause(false);
- ICASTDesignatedInitializer desigInitializer = nodeFactory.newDesignatedInitializer(initializer);
+ consume(IToken.tASSIGN);
+
+ IASTInitializerClause clause= initClause(false);
+ ICASTDesignatedInitializer desigInitializer = nodeFactory.newDesignatedInitializer(clause);
setRange(desigInitializer, designator.get(0));
- adjustLength(desigInitializer, initializer);
+ adjustLength(desigInitializer, clause);
for (ICASTDesignator d : designator) {
desigInitializer.addDesignator(d);
}
- result.addInitializer(desigInitializer);
+ result.addClause(desigInitializer);
}
// can end with ", }" or "}"
@@ -567,6 +570,14 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
}
@Override
+ protected IASTExpression buildBinaryExpression(int operator, IASTExpression expr1, IASTInitializerClause expr2, int lastOffset) {
+ IASTBinaryExpression result = nodeFactory.newBinaryExpression(operator, expr1, (IASTExpression) expr2);
+ int o = ((ASTNode) expr1).getOffset();
+ ((ASTNode) result).setOffsetAndLength(o, lastOffset - o);
+ return result;
+ }
+
+ @Override
protected IASTExpression unaryExpression(CastExprCtx ctx) throws EndOfFileException, BacktrackException {
switch (LT(1)) {
case IToken.tSTAR:
@@ -609,7 +620,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
if (t != null) {
consume(IToken.tRPAREN);
if (LT(1) == IToken.tLBRACE) {
- IASTInitializer i = cInitializerClause(false);
+ IASTInitializer i = (IASTInitializerList) initClause(false);
firstExpression= nodeFactory.newTypeIdInitializerExpression(t, i);
setRange(firstExpression, offset, calculateEndOffset(i));
break;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java
index 3ba0cd9bc45..377639ab364 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTArraySubscriptExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IPointerType;
@@ -31,8 +32,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
public class CPPASTArraySubscriptExpression extends ASTNode implements ICPPASTArraySubscriptExpression, IASTAmbiguityParent {
- private IASTExpression subscriptExp;
private IASTExpression arrayExpression;
+ private IASTInitializerClause subscriptExp;
private ICPPFunction overload= UNINITIALIZED_FUNCTION;
private IASTImplicitName[] implicitNames = null;
@@ -40,15 +41,15 @@ public class CPPASTArraySubscriptExpression extends ASTNode implements ICPPASTAr
public CPPASTArraySubscriptExpression() {
}
- public CPPASTArraySubscriptExpression(IASTExpression arrayExpression, IASTExpression subscriptExp) {
+ public CPPASTArraySubscriptExpression(IASTExpression arrayExpression, IASTInitializerClause operand) {
setArrayExpression(arrayExpression);
- setSubscriptExpression(subscriptExp);
+ setArgument(operand);
}
public CPPASTArraySubscriptExpression copy() {
CPPASTArraySubscriptExpression copy = new CPPASTArraySubscriptExpression();
copy.setArrayExpression(arrayExpression == null ? null : arrayExpression.copy());
- copy.setSubscriptExpression(subscriptExp == null ? null : subscriptExp.copy());
+ copy.setArgument(subscriptExp == null ? null : subscriptExp.copy());
copy.setOffsetAndLength(this);
return copy;
}
@@ -67,18 +68,30 @@ public class CPPASTArraySubscriptExpression extends ASTNode implements ICPPASTAr
}
}
- public IASTExpression getSubscriptExpression() {
+ public IASTInitializerClause getArgument() {
return subscriptExp;
}
- public void setSubscriptExpression(IASTExpression expression) {
+ public void setArgument(IASTInitializerClause arg) {
assertNotFrozen();
- subscriptExp = expression;
- if (expression != null) {
- expression.setParent(this);
- expression.setPropertyInParent(SUBSCRIPT);
+ subscriptExp = arg;
+ if (arg != null) {
+ arg.setParent(this);
+ arg.setPropertyInParent(SUBSCRIPT);
}
}
+
+ @Deprecated
+ public IASTExpression getSubscriptExpression() {
+ if (subscriptExp instanceof IASTExpression)
+ return (IASTExpression) subscriptExp;
+ return null;
+ }
+
+ @Deprecated
+ public void setSubscriptExpression(IASTExpression expression) {
+ setArgument(expression);
+ }
public IASTImplicitName[] getImplicitNames() {
if(implicitNames == null) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java
index dee8ac63cc1..2131a4a4ce6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java
@@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
@@ -37,7 +38,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpression, IASTAmbiguityParent {
private int op;
private IASTExpression operand1;
- private IASTExpression operand2;
+ private IASTInitializerClause operand2;
private IType type;
private ICPPFunction overload= UNINITIALIZED_FUNCTION;
private IASTImplicitName[] implicitNames = null;
@@ -46,17 +47,17 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
public CPPASTBinaryExpression() {
}
- public CPPASTBinaryExpression(int op, IASTExpression operand1, IASTExpression operand2) {
+ public CPPASTBinaryExpression(int op, IASTExpression operand1, IASTInitializerClause operand2) {
this.op = op;
setOperand1(operand1);
- setOperand2(operand2);
+ setInitOperand2(operand2);
}
public CPPASTBinaryExpression copy() {
CPPASTBinaryExpression copy = new CPPASTBinaryExpression();
copy.op = op;
copy.setOperand1(operand1 == null ? null : operand1.copy());
- copy.setOperand2(operand2 == null ? null : operand2.copy());
+ copy.setInitOperand2(operand2 == null ? null : operand2.copy());
copy.setOffsetAndLength(this);
return copy;
}
@@ -69,8 +70,14 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
return operand1;
}
+ public IASTInitializerClause getInitOperand2() {
+ return operand2;
+ }
+
public IASTExpression getOperand2() {
- return operand2;
+ if (operand2 instanceof IASTExpression)
+ return (IASTExpression) operand2;
+ return null;
}
public void setOperator(int op) {
@@ -87,15 +94,19 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
}
}
- public void setOperand2(IASTExpression expression) {
+ public void setInitOperand2(IASTInitializerClause operand) {
assertNotFrozen();
- operand2 = expression;
- if (expression != null) {
- expression.setParent(this);
- expression.setPropertyInParent(OPERAND_TWO);
+ operand2 = operand;
+ if (operand != null) {
+ operand.setParent(this);
+ operand.setPropertyInParent(OPERAND_TWO);
}
}
+ public void setOperand2(IASTExpression expression) {
+ setInitOperand2(expression);
+ }
+
public IASTImplicitName[] getImplicitNames() {
if(implicitNames == null) {
ICPPFunction overload = getOverload();
@@ -219,7 +230,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
if (child == operand2) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
- operand2 = (IASTExpression) other;
+ operand2 = (IASTInitializerClause) other;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
index f595db5c936..62c9d27605c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,18 +16,19 @@ import java.util.Arrays;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompletionContext;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
-import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
/**
@@ -39,25 +40,25 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
* {@code Base()} and {@code field()} are the constructor chain initializers.<br>
*/
public class CPPASTConstructorChainInitializer extends ASTNode implements
- ICPPASTConstructorChainInitializer, IASTAmbiguityParent, IASTCompletionContext {
+ ICPPASTConstructorChainInitializer, IASTCompletionContext {
private IASTName name;
- private IASTExpression value;
+ private IASTInitializer initializer;
private boolean fIsPackExpansion;
public CPPASTConstructorChainInitializer() {
}
- public CPPASTConstructorChainInitializer(IASTName memberInitializerid, IASTExpression initializerValue) {
- setMemberInitializerId(memberInitializerid);
- setInitializerValue(initializerValue);
+ public CPPASTConstructorChainInitializer(IASTName id, IASTInitializer initializer) {
+ setMemberInitializerId(id);
+ setInitializer(initializer);
}
public CPPASTConstructorChainInitializer copy() {
CPPASTConstructorChainInitializer copy = new CPPASTConstructorChainInitializer();
copy.setMemberInitializerId(name == null ? null : name.copy());
- copy.setInitializerValue(value == null ? null : value.copy());
+ copy.setInitializer(initializer == null ? null : initializer.copy());
copy.setOffsetAndLength(this);
copy.fIsPackExpansion= fIsPackExpansion;
return copy;
@@ -76,17 +77,16 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements
}
}
- public IASTExpression getInitializerValue() {
- return value;
+ public IASTInitializer getInitializer() {
+ return initializer;
}
-
- public void setInitializerValue(IASTExpression expression) {
+ public void setInitializer(IASTInitializer init) {
assertNotFrozen();
- value = expression;
- if(expression != null) {
- expression.setParent(this);
- expression.setPropertyInParent(INITIALIZER);
+ initializer = init;
+ if(init != null) {
+ init.setParent(this);
+ init.setPropertyInParent(INITIALIZER);
}
}
@@ -100,17 +100,15 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements
return true;
}
}
- if (name != null)
- if (!name.accept(action))
- return false;
- if (value != null)
- if (!value.accept(action))
- return false;
+ if (name != null && !name.accept(action))
+ return false;
- if (action.shouldVisitInitializers) {
- if (action.leave(this) == ASTVisitor.PROCESS_ABORT)
- return false;
- }
+ if (initializer != null && !initializer.accept(action))
+ return false;
+
+ if (action.shouldVisitInitializers && action.leave(this) == ASTVisitor.PROCESS_ABORT)
+ return false;
+
return true;
}
@@ -120,21 +118,12 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements
return r_unclear;
}
- public void replace(IASTNode child, IASTNode other) {
- if (child == value) {
- other.setPropertyInParent(child.getPropertyInParent());
- other.setParent(child.getParent());
- value = (IASTExpression) other;
- }
- }
-
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix);
ICPPASTBaseSpecifier[] baseClasses = null;
for (int i = 0; i < bindings.length; i++) {
-
if ((bindings[i] instanceof ICPPField) || (bindings[i] instanceof ICPPNamespace)) {
continue;
} else if (bindings[i] instanceof ICPPConstructor) {
@@ -184,4 +173,36 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements
assertNotFrozen();
fIsPackExpansion= val;
}
+
+ @Deprecated
+ public IASTExpression getInitializerValue() {
+ if (initializer == null || initializer instanceof IASTExpression) {
+ return (IASTExpression) initializer;
+ }
+ if (initializer instanceof ICPPASTConstructorInitializer) {
+ IASTExpression expr= ((ICPPASTConstructorInitializer) initializer).getExpression();
+ if (expr != null) {
+ expr= expr.copy();
+ expr.setParent(this);
+ expr.setPropertyInParent(INITIALIZER);
+ }
+ return expr;
+ }
+ return null;
+ }
+
+ @Deprecated
+ public void setInitializerValue(IASTExpression expression) {
+ assertNotFrozen();
+ if (expression == null) {
+ setInitializer(null);
+ } else if (expression instanceof IASTInitializer) {
+ setInitializer((IASTInitializer) expression);
+ } else {
+ CPPASTConstructorInitializer ctorInit= new CPPASTConstructorInitializer();
+ ctorInit.setExpression(expression);
+ ctorInit.setOffsetAndLength((ASTNode) expression);
+ setInitializer(ctorInit);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java
index acc4f311e31..46730475857 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,45 +13,56 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
- * Initializer in parenthesis.
+ * Initializer list in parenthesis.
*/
-public class CPPASTConstructorInitializer extends ASTNode implements
- ICPPASTConstructorInitializer, IASTAmbiguityParent {
-
- private IASTExpression exp;
- private boolean fIsPackExpansion;
+public class CPPASTConstructorInitializer extends ASTNode implements ICPPASTConstructorInitializer,
+ IASTAmbiguityParent {
+ private IASTInitializerClause[] fArguments;
public CPPASTConstructorInitializer() {
+ setArguments(null);
}
- public CPPASTConstructorInitializer(IASTExpression exp) {
- setExpression(exp);
+ public CPPASTConstructorInitializer(IASTInitializerClause[] args) {
+ setArguments(args);
}
public CPPASTConstructorInitializer copy() {
- CPPASTConstructorInitializer copy = new CPPASTConstructorInitializer(exp == null ? null : exp.copy());
+ IASTInitializerClause[] args = null;
+ if (fArguments != null) {
+ args= new IASTExpression[fArguments.length];
+ for (int i=0; i<fArguments.length; i++) {
+ args[i]= fArguments[i].copy();
+ }
+ }
+ CPPASTConstructorInitializer copy = new CPPASTConstructorInitializer(args);
copy.setOffsetAndLength(this);
- copy.fIsPackExpansion= fIsPackExpansion;
return copy;
}
- public IASTExpression getExpression() {
- return exp;
+ public IASTInitializerClause[] getArguments() {
+ return fArguments;
}
- public void setExpression(IASTExpression expression) {
+ public void setArguments(IASTInitializerClause[] arguments) {
assertNotFrozen();
- this.exp = expression;
- if (expression != null) {
- expression.setParent(this);
- expression.setPropertyInParent(EXPRESSION);
+ if (arguments == null) {
+ fArguments= IASTExpression.EMPTY_EXPRESSION_ARRAY;
+ } else {
+ fArguments= arguments;
+ for (IASTInitializerClause arg : arguments) {
+ arg.setParent(this);
+ arg.setPropertyInParent(ARGUMENT);
+ }
}
}
@@ -64,31 +75,59 @@ public class CPPASTConstructorInitializer extends ASTNode implements
default : break;
}
}
- if( exp != null ) if( !exp.accept( action ) ) return false;
- if( action.shouldVisitInitializers ){
- switch( action.leave( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
- }
+
+ for (IASTInitializerClause arg : fArguments) {
+ if (!arg.accept(action))
+ return false;
+ }
+
+ if (action.shouldVisitInitializers && action.leave(this) == ASTVisitor.PROCESS_ABORT)
+ return false;
+
+ return true;
+ }
+
+ public void replace(IASTNode child, IASTNode other) {
+ for (int i = 0; i < fArguments.length; ++i) {
+ if (child == fArguments[i]) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ fArguments[i] = (IASTExpression) other;
+ }
}
- return true;
+ }
+
+ @Deprecated
+ public IASTExpression getExpression() {
+ if (fArguments.length == 0)
+ return null;
+ if (fArguments.length == 1) {
+ IASTInitializerClause arg = fArguments[0];
+ if (arg instanceof IASTExpression)
+ return (IASTExpression) arg;
+ return null;
+ }
+
+ CPPASTExpressionList result= new CPPASTExpressionList();
+ for (IASTInitializerClause arg : fArguments) {
+ if (arg instanceof IASTExpression) {
+ result.addExpression(((IASTExpression) arg).copy());
+ }
+ }
+ result.setParent(this);
+ result.setPropertyInParent(EXPRESSION);
+ return result;
}
- public void replace(IASTNode child, IASTNode other) {
- if (child == exp) {
- other.setPropertyInParent(child.getPropertyInParent());
- other.setParent(child.getParent());
- exp = (IASTExpression) other;
+ @Deprecated
+ public void setExpression(IASTExpression expression) {
+ assertNotFrozen();
+ if (expression == null) {
+ setArguments(null);
+ } else if (expression instanceof ICPPASTExpressionList) {
+ setArguments(((ICPPASTExpressionList) expression).getExpressions());
+ } else {
+ setArguments(new IASTExpression[] {expression});
}
}
-
- public boolean isPackExpansion() {
- return fIsPackExpansion;
- }
-
- public void setIsPackExpansion(boolean val) {
- assertNotFrozen();
- fIsPackExpansion= val;
- }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEqualsInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEqualsInitializer.java
new file mode 100644
index 00000000000..30ccf032322
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTEqualsInitializer.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.internal.core.dom.parser.ASTEqualsInitializer;
+
+/**
+ * Initializer with equals sign (copy initialization)
+ */
+public class CPPASTEqualsInitializer extends ASTEqualsInitializer {
+ public CPPASTEqualsInitializer() {
+ }
+
+ public CPPASTEqualsInitializer(IASTInitializerClause arg) {
+ super(arg);
+ }
+
+ public CPPASTEqualsInitializer copy() {
+ IASTInitializerClause arg = getInitializerClause();
+ CPPASTEqualsInitializer copy = new CPPASTEqualsInitializer(arg == null ? null : arg.copy());
+ copy.setOffsetAndLength(this);
+ return copy;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java
index 1fc061ced49..3155097b477 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.ExpansionOverlapsBoundaryException;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@@ -26,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
@@ -43,7 +45,7 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
ICPPASTFunctionCallExpression, IASTAmbiguityParent {
private IASTExpression functionName;
- private IASTExpression parameter;
+ private IASTInitializerClause[] fArguments;
private IASTImplicitName[] implicitNames = null;
private IType type; // cached type of expression
@@ -51,21 +53,33 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
public CPPASTFunctionCallExpression() {
+ setArguments(null);
}
- public CPPASTFunctionCallExpression(IASTExpression functionName, IASTExpression parameter) {
+ public CPPASTFunctionCallExpression(IASTExpression functionName, IASTInitializerClause[] args) {
setFunctionNameExpression(functionName);
- setParameterExpression(parameter);
+ setArguments(args);
}
public CPPASTFunctionCallExpression copy() {
- CPPASTFunctionCallExpression copy = new CPPASTFunctionCallExpression();
+ IASTInitializerClause[] args = null;
+ if (fArguments.length > 0) {
+ args= new IASTExpression[fArguments.length];
+ for (int i=0; i<fArguments.length; i++) {
+ args[i]= fArguments[i].copy();
+ }
+ }
+
+ CPPASTFunctionCallExpression copy = new CPPASTFunctionCallExpression(null, args);
copy.setFunctionNameExpression(functionName == null ? null : functionName.copy());
- copy.setParameterExpression(parameter == null ? null : parameter.copy());
copy.setOffsetAndLength(this);
return copy;
}
+ public IASTExpression getFunctionNameExpression() {
+ return functionName;
+ }
+
public void setFunctionNameExpression(IASTExpression expression) {
assertNotFrozen();
this.functionName = expression;
@@ -74,25 +88,24 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
expression.setPropertyInParent(FUNCTION_NAME);
}
}
-
- public IASTExpression getFunctionNameExpression() {
- return functionName;
+
+ public IASTInitializerClause[] getArguments() {
+ return fArguments;
}
- public void setParameterExpression(IASTExpression expression) {
+ public void setArguments(IASTInitializerClause[] arguments) {
assertNotFrozen();
- this.parameter = expression;
- if (expression != null) {
- expression.setParent(this);
- expression.setPropertyInParent(PARAMETERS);
+ if (arguments == null) {
+ fArguments= IASTExpression.EMPTY_EXPRESSION_ARRAY;
+ } else {
+ fArguments= arguments;
+ for (IASTInitializerClause arg : arguments) {
+ arg.setParent(this);
+ arg.setPropertyInParent(ARGUMENT);
+ }
}
}
- public IASTExpression getParameterExpression() {
- return parameter;
- }
-
-
public IASTImplicitName[] getImplicitNames() {
if(implicitNames == null) {
ICPPFunction overload = getOperator();
@@ -107,7 +120,7 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
n2.setBinding(overload);
n2.setAlternate(true);
- if(parameter == null) {
+ if (fArguments.length == 0) {
int idEndOffset = ((ASTNode)functionName).getOffset() + ((ASTNode)functionName).getLength();
try {
IToken lparen = functionName.getTrailingSyntax();
@@ -126,10 +139,9 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
n1.setOffsetAndLength(idEndOffset, 0);
n2.setOffsetAndLength(idEndOffset, 0);
}
- }
- else {
+ } else {
n1.computeOperatorOffsets(functionName, true);
- n2.computeOperatorOffsets(parameter, true);
+ n2.computeOperatorOffsets(fArguments[fArguments.length-1], true);
}
implicitNames = new IASTImplicitName[] { n1, n2 };
@@ -147,43 +159,44 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
}
}
- if( functionName != null ) if( !functionName.accept( action ) ) return false;
-
+ if (functionName != null && !functionName.accept(action))
+ return false;
IASTImplicitName[] implicits = action.shouldVisitImplicitNames ? getImplicitNames() : null;
- if(implicits != null && implicits.length > 0)
- if(!implicits[0].accept(action)) return false;
+ if (implicits != null && implicits.length > 0)
+ if (!implicits[0].accept(action))
+ return false;
- if( parameter != null ) if( !parameter.accept( action ) ) return false;
+ for (IASTInitializerClause arg : fArguments) {
+ if (!arg.accept(action))
+ return false;
+ }
- if(implicits != null && implicits.length > 0)
- if(!implicits[1].accept(action)) return false;
+ if (implicits != null && implicits.length > 0)
+ if (!implicits[1].accept(action))
+ return false;
- if( action.shouldVisitExpressions ){
- switch( action.leave( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
- }
- }
+ if (action.shouldVisitExpressions && action.leave(this) == ASTVisitor.PROCESS_ABORT)
+ return false;
+
return true;
}
- public void replace(IASTNode child, IASTNode other) {
- if( child == functionName )
- {
- other.setPropertyInParent( child.getPropertyInParent() );
- other.setParent( child.getParent() );
- functionName = (IASTExpression) other;
- }
- if( child == parameter )
- {
- other.setPropertyInParent( child.getPropertyInParent() );
- other.setParent( child.getParent() );
- parameter = (IASTExpression) other;
- }
- }
+ public void replace(IASTNode child, IASTNode other) {
+ if (child == functionName) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ functionName = (IASTExpression) other;
+ }
+ for (int i = 0; i < fArguments.length; ++i) {
+ if (child == fArguments[i]) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ fArguments[i] = (IASTExpression) other;
+ }
+ }
+ }
public ICPPFunction getOperator() {
if (overload == UNINITIALIZED_FUNCTION) {
@@ -254,4 +267,38 @@ public class CPPASTFunctionCallExpression extends ASTNode implements
}
return null;
}
+
+ @Deprecated
+ public IASTExpression getParameterExpression() {
+ if (fArguments.length == 0)
+ return null;
+ if (fArguments.length == 1) {
+ IASTInitializerClause arg = fArguments[0];
+ if (arg instanceof IASTExpression)
+ return (IASTExpression) arg;
+ return null;
+ }
+
+ CPPASTExpressionList result= new CPPASTExpressionList();
+ for (IASTInitializerClause arg : fArguments) {
+ if (arg instanceof IASTExpression) {
+ result.addExpression(((IASTExpression) arg).copy());
+ }
+ }
+ result.setParent(this);
+ result.setPropertyInParent(ARGUMENT);
+ return result;
+ }
+
+ @Deprecated
+ public void setParameterExpression(IASTExpression expression) {
+ assertNotFrozen();
+ if (expression == null) {
+ setArguments(null);
+ } else if (expression instanceof ICPPASTExpressionList) {
+ setArguments(((ICPPASTExpressionList) expression).getExpressions());
+ } else {
+ setArguments(new IASTExpression[] {expression});
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java
index cd9cf256770..716501b041a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,85 +11,26 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerExpression;
-import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
-import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
-/**
- * Initializer expression.
- */
-public class CPPASTInitializerExpression extends ASTNode implements
- ICPPASTInitializerExpression, IASTAmbiguityParent {
+@Deprecated
+public class CPPASTInitializerExpression extends CPPASTEqualsInitializer implements IASTInitializerExpression {
- private IASTExpression exp;
- private boolean fIsPackExpansion;
-
-
public CPPASTInitializerExpression() {
}
- public CPPASTInitializerExpression(IASTExpression exp) {
- setExpression(exp);
+ public CPPASTInitializerExpression(IASTExpression expression) {
+ setExpression(expression);
}
+ @Override
public CPPASTInitializerExpression copy() {
- CPPASTInitializerExpression copy = new CPPASTInitializerExpression(exp == null ? null : exp.copy());
+ CPPASTInitializerExpression copy= new CPPASTInitializerExpression();
+ IASTInitializerClause init= getInitializerClause();
+ copy.setInitializerClause(init == null ? null : init.copy());
copy.setOffsetAndLength(this);
- copy.fIsPackExpansion= fIsPackExpansion;
return copy;
}
-
- public IASTExpression getExpression() {
- return exp;
- }
-
- public void setExpression(IASTExpression expression) {
- assertNotFrozen();
- this.exp = expression;
- if (expression != null) {
- expression.setParent(this);
- expression.setPropertyInParent(INITIALIZER_EXPRESSION);
- }
- }
-
- @Override
- public boolean accept( ASTVisitor action ){
- if( action.shouldVisitInitializers ){
- switch( action.visit( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
- }
- }
- if( exp != null ) if( !exp.accept( action ) ) return false;
-
- if( action.shouldVisitInitializers ){
- switch( action.leave( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
- }
- }
- return true;
- }
-
- public void replace(IASTNode child, IASTNode other) {
- if( child == exp ) {
- other.setPropertyInParent( child.getPropertyInParent() );
- other.setParent( child.getParent() );
- exp = (IASTExpression) other;
- }
- }
- public boolean isPackExpansion() {
- return fIsPackExpansion;
- }
-
- public void setIsPackExpansion(boolean val) {
- assertNotFrozen();
- fIsPackExpansion= val;
- }
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java
index aaafa5126ac..39d86f66c81 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,77 +12,111 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
+import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* e.g.: int a[]= {1,2,3};
*/
-public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializerList {
- private IASTInitializer [] initializers = null;
+public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializerList, IASTAmbiguityParent {
+
+ private IASTInitializerClause [] initializers = null;
private int initializersPos=-1;
- private int actualLength;
+ private int actualSize;
private boolean fIsPackExpansion;
public CPPASTInitializerList copy() {
CPPASTInitializerList copy = new CPPASTInitializerList();
- for(IASTInitializer initializer : getInitializers())
- copy.addInitializer(initializer == null ? null : initializer.copy());
+ for (IASTInitializerClause initializer : getClauses())
+ copy.addClause(initializer == null ? null : initializer.copy());
copy.setOffsetAndLength(this);
- copy.actualLength= getSize();
- copy.fIsPackExpansion= fIsPackExpansion;
+ copy.actualSize = getSize();
+ copy.fIsPackExpansion = fIsPackExpansion;
return copy;
}
public int getSize() {
- return actualLength;
+ return actualSize;
}
- public IASTInitializer[] getInitializers() {
+ public IASTInitializerClause[] getClauses() {
if (initializers == null)
+ return IASTExpression.EMPTY_EXPRESSION_ARRAY;
+ initializers = ArrayUtil.trimAt(IASTInitializerClause.class, initializers, initializersPos);
+ return initializers;
+ }
+
+ @Deprecated
+ public IASTInitializer[] getInitializers() {
+ IASTInitializerClause[] clauses= getClauses();
+ if (clauses.length == 0)
return IASTInitializer.EMPTY_INITIALIZER_ARRAY;
- initializers = ArrayUtil.trimAt(IASTInitializer.class, initializers, initializersPos);
- return initializers;
+ IASTInitializer[] inits= new IASTInitializer[clauses.length];
+ for (int i = 0; i < inits.length; i++) {
+ IASTInitializerClause clause= clauses[i];
+ if (clause instanceof IASTInitializer) {
+ inits[i]= (IASTInitializer) clause;
+ } else if (clause instanceof IASTExpression) {
+ final CPPASTEqualsInitializer initExpr = new CPPASTEqualsInitializer(((IASTExpression) clause).copy());
+ initExpr.setParent(this);
+ initExpr.setPropertyInParent(NESTED_INITIALIZER);
+ inits[i]= initExpr;
+ }
+ }
+ return inits;
}
- public void addInitializer(IASTInitializer d) {
- assertNotFrozen();
- if (d != null) {
- initializers = (IASTInitializer[]) ArrayUtil.append(IASTInitializer.class, initializers,
- ++initializersPos, d);
- d.setParent(this);
+ public void addClause(IASTInitializerClause d) {
+ assertNotFrozen();
+ if (d != null) {
+ initializers = (IASTInitializerClause[]) ArrayUtil.append( IASTInitializerClause.class, initializers, ++initializersPos, d );
+ d.setParent(this);
d.setPropertyInParent(NESTED_INITIALIZER);
- }
- actualLength++;
- }
+ }
+ actualSize++;
+ }
+
+ @Deprecated
+ public void addInitializer(IASTInitializer d) {
+ assertNotFrozen();
+ if (d instanceof IASTInitializerClause) {
+ addClause((IASTInitializerClause) d);
+ } else if (d instanceof IASTEqualsInitializer) {
+ addClause(((IASTEqualsInitializer) d).getInitializerClause());
+ } else {
+ addClause(null);
+ }
+ }
@Override
public boolean accept( ASTVisitor action ){
- if( action.shouldVisitInitializers ){
- switch( action.visit( this ) ){
+ if (action.shouldVisitInitializers) {
+ switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
}
}
- IASTInitializer [] list = getInitializers();
- for ( int i = 0; i < list.length; i++ ) {
- if( !list[i].accept( action ) ) return false;
- }
-
- if( action.shouldVisitInitializers ){
- switch( action.leave( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
- }
+ IASTInitializerClause[] list = getClauses();
+ for (IASTInitializerClause clause : list) {
+ if (!clause.accept(action))
+ return false;
}
- return true;
+
+ if (action.shouldVisitInitializers && action.leave(this) == ASTVisitor.PROCESS_ABORT)
+ return false;
+
+ return true;
}
-
+
public boolean isPackExpansion() {
return fIsPackExpansion;
}
@@ -91,5 +125,16 @@ public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializer
assertNotFrozen();
fIsPackExpansion= val;
}
-
+
+ public void replace(IASTNode child, IASTNode other) {
+ if (initializers != null) {
+ for (int i = 0; i < initializers.length; ++i) {
+ if (child == initializers[i]) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ initializers[i] = (IASTInitializerClause) other;
+ }
+ }
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java
index 5d8d2493a7b..c829f575af5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNewExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,92 +17,92 @@ import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTExpressionList;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.core.runtime.Assert;
-public class CPPASTNewExpression extends ASTNode implements
- ICPPASTNewExpression, IASTAmbiguityParent {
-
- private boolean global;
- private IASTExpression placement;
- private IASTExpression initializer;
+public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression, IASTAmbiguityParent {
+ private IASTInitializerClause[] placement;
private IASTTypeId typeId;
- private boolean isNewTypeId;
-
- private IASTExpression [] arrayExpressions = null;
-
+ private IASTInitializer initializer;
private IASTImplicitName[] implicitNames = null;
-
+ private boolean isGlobal;
+ private boolean isNewTypeId;
+
+ private IASTExpression[] cachedArraySizes;
public CPPASTNewExpression() {
}
- public CPPASTNewExpression(IASTExpression placement,
- IASTExpression initializer, IASTTypeId typeId) {
- setNewPlacement(placement);
- setNewInitializer(initializer);
+ public CPPASTNewExpression(IASTInitializerClause[] placement, IASTInitializer initializer, IASTTypeId typeId) {
+ setPlacementArguments(placement);
setTypeId(typeId);
+ setInitializer(initializer);
}
public CPPASTNewExpression copy() {
CPPASTNewExpression copy = new CPPASTNewExpression();
- copy.setIsGlobal(global);
+ copy.setIsGlobal(isGlobal);
copy.setIsNewTypeId(isNewTypeId);
- copy.setNewPlacement(placement == null ? null : placement.copy());
- copy.setNewInitializer(initializer == null ? null : initializer.copy());
- copy.setTypeId(typeId == null ? null : typeId.copy());
-
- if(arrayExpressions != null) {
- copy.arrayExpressions = new IASTExpression[arrayExpressions.length];
- for(int i = 0; i < arrayExpressions.length; i++) {
- copy.arrayExpressions[i] = arrayExpressions[i] == null ? null : arrayExpressions[i].copy();
+ if (placement != null) {
+ IASTInitializerClause[] plcmt = new IASTInitializerClause[placement.length];
+ for (int i=0; i<placement.length; i++) {
+ plcmt[i]= placement[i].copy();
}
+ copy.setPlacementArguments(plcmt);
}
-
+ copy.setTypeId(typeId == null ? null : typeId.copy());
+ copy.setInitializer(initializer == null ? null : initializer.copy());
copy.setOffsetAndLength(this);
return copy;
}
public boolean isGlobal() {
- return global;
+ return isGlobal;
}
public void setIsGlobal(boolean value) {
assertNotFrozen();
- global = value;
+ isGlobal = value;
}
- public IASTExpression getNewPlacement() {
- return placement;
+ public IASTInitializerClause[] getPlacementArguments() {
+ return placement;
}
-
- public void setNewPlacement(IASTExpression expression) {
+
+ public void setPlacementArguments(IASTInitializerClause[] args) {
assertNotFrozen();
- placement = expression;
- if (expression != null) {
- expression.setParent(this);
- expression.setPropertyInParent(NEW_PLACEMENT);
+ placement = args;
+ if (args != null) {
+ for (IASTInitializerClause arg : args) {
+ arg.setParent(this);
+ arg.setPropertyInParent(NEW_PLACEMENT);
+ }
}
}
- public IASTExpression getNewInitializer() {
+ public IASTInitializer getInitializer() {
return initializer;
}
- public void setNewInitializer(IASTExpression expression) {
+ public void setInitializer(IASTInitializer expression) {
assertNotFrozen();
initializer = expression;
if (expression != null) {
@@ -132,47 +132,6 @@ public class CPPASTNewExpression extends ASTNode implements
assertNotFrozen();
isNewTypeId = value;
}
-
- public IASTExpression [] getNewTypeIdArrayExpressions() {
- if( arrayExpressions == null ) {
- if (typeId != null) {
- IASTDeclarator dtor= ASTQueries.findInnermostDeclarator(typeId.getAbstractDeclarator());
- if (dtor instanceof IASTArrayDeclarator) {
- IASTArrayDeclarator ad= (IASTArrayDeclarator) dtor;
- IASTArrayModifier[] ams= ad.getArrayModifiers();
- arrayExpressions= new IASTExpression[ams.length];
- for (int i = 0; i < ams.length; i++) {
- IASTArrayModifier am = ams[i];
- arrayExpressions[i]= am.getConstantExpression();
- }
- return arrayExpressions;
- }
- }
- arrayExpressions= IASTExpression.EMPTY_EXPRESSION_ARRAY;
- }
- return arrayExpressions;
- }
-
- public void addNewTypeIdArrayExpression(IASTExpression expression) {
- assertNotFrozen();
- Assert.isNotNull(typeId);
- IASTDeclarator dtor= ASTQueries.findInnermostDeclarator(typeId.getAbstractDeclarator());
- if (dtor instanceof IASTArrayDeclarator == false) {
- Assert.isNotNull(dtor);
- Assert.isTrue(dtor.getParent() == typeId);
- IASTArrayDeclarator adtor= new CPPASTArrayDeclarator(dtor.getName());
- IASTPointerOperator[] ptrOps= dtor.getPointerOperators();
- for (IASTPointerOperator ptr : ptrOps) {
- adtor.addPointerOperator(ptr);
- }
- typeId.setAbstractDeclarator(adtor);
- dtor= adtor;
- }
- IASTArrayModifier mod= new CPPASTArrayModifier(expression);
- ((ASTNode) mod).setOffsetAndLength((ASTNode)expression);
- ((IASTArrayDeclarator) dtor).addArrayModifier(mod);
- }
-
public IASTImplicitName[] getImplicitNames() {
if(implicitNames == null) {
@@ -219,10 +178,17 @@ public class CPPASTNewExpression extends ASTNode implements
}
}
- if( placement != null ) if( !placement.accept( action ) ) return false;
- if( typeId != null ) if( !typeId.accept( action ) ) return false;
- if( initializer != null ) if( !initializer.accept( action ) ) return false;
-
+ if (placement != null) {
+ for (IASTInitializerClause arg : placement) {
+ if (!arg.accept(action))
+ return false;
+ }
+ }
+ if (typeId != null && !typeId.accept(action))
+ return false;
+
+ if (initializer != null && !initializer.accept(action))
+ return false;
if( action.shouldVisitExpressions ){
switch( action.leave( this ) ){
@@ -234,20 +200,17 @@ public class CPPASTNewExpression extends ASTNode implements
return true;
}
- public void replace(IASTNode child, IASTNode other) {
- if( child == placement )
- {
- other.setPropertyInParent( child.getPropertyInParent() );
- other.setParent( child.getParent() );
- placement = (IASTExpression) other;
- }
- if( child == initializer )
- {
- other.setPropertyInParent( child.getPropertyInParent() );
- other.setParent( child.getParent() );
- initializer = (IASTExpression) other;
- }
- }
+ public void replace(IASTNode child, IASTNode other) {
+ if (placement != null) {
+ for (int i = 0; i < placement.length; ++i) {
+ if (child == placement[i]) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
+ placement[i] = (IASTExpression) other;
+ }
+ }
+ }
+ }
public IType getExpressionType() {
IType t= CPPVisitor.createType(getTypeId());
@@ -260,4 +223,113 @@ public class CPPASTNewExpression extends ASTNode implements
public boolean isLValue() {
return false;
}
+
+ @Deprecated
+ public IASTExpression[] getNewTypeIdArrayExpressions() {
+ if (cachedArraySizes == null) {
+ if (typeId != null) {
+ IASTDeclarator dtor = ASTQueries.findInnermostDeclarator(typeId.getAbstractDeclarator());
+ if (dtor instanceof IASTArrayDeclarator) {
+ IASTArrayDeclarator ad = (IASTArrayDeclarator) dtor;
+ IASTArrayModifier[] ams = ad.getArrayModifiers();
+ cachedArraySizes = new IASTExpression[ams.length];
+ for (int i = 0; i < ams.length; i++) {
+ IASTArrayModifier am = ams[i];
+ cachedArraySizes[i] = am.getConstantExpression();
+ }
+ return cachedArraySizes;
+ }
+ }
+ cachedArraySizes = IASTExpression.EMPTY_EXPRESSION_ARRAY;
+ }
+ return cachedArraySizes;
+ }
+
+ @Deprecated
+ public void addNewTypeIdArrayExpression(IASTExpression expression) {
+ assertNotFrozen();
+ Assert.isNotNull(typeId);
+ IASTDeclarator dtor= ASTQueries.findInnermostDeclarator(typeId.getAbstractDeclarator());
+ if (dtor instanceof IASTArrayDeclarator == false) {
+ Assert.isNotNull(dtor);
+ Assert.isTrue(dtor.getParent() == typeId);
+ IASTArrayDeclarator adtor= new CPPASTArrayDeclarator(dtor.getName());
+ IASTPointerOperator[] ptrOps= dtor.getPointerOperators();
+ for (IASTPointerOperator ptr : ptrOps) {
+ adtor.addPointerOperator(ptr);
+ }
+ typeId.setAbstractDeclarator(adtor);
+ dtor= adtor;
+ }
+ IASTArrayModifier mod= new CPPASTArrayModifier(expression);
+ ((ASTNode) mod).setOffsetAndLength((ASTNode)expression);
+ ((IASTArrayDeclarator) dtor).addArrayModifier(mod);
+ }
+
+ @Deprecated
+ public IASTExpression getNewPlacement() {
+ if (placement == null || placement.length == 0)
+ return null;
+ if (placement.length == 1) {
+ if (placement[0] instanceof IASTExpression)
+ return (IASTExpression) placement[0];
+ return null;
+ }
+
+ CASTExpressionList result= new CASTExpressionList();
+ for (IASTInitializerClause arg : placement) {
+ if (arg instanceof IASTExpression) {
+ result.addExpression(((IASTExpression) arg).copy());
+ }
+ }
+ result.setParent(this);
+ result.setPropertyInParent(NEW_PLACEMENT);
+ return result;
+ }
+
+ @Deprecated
+ public void setNewPlacement(IASTExpression expression) {
+ assertNotFrozen();
+ if (expression == null) {
+ setPlacementArguments(null);
+ } else if (expression instanceof IASTExpressionList) {
+ setPlacementArguments(((IASTExpressionList) expression).getExpressions());
+ } else {
+ setPlacementArguments(new IASTExpression[] {expression});
+ }
+ }
+
+ @Deprecated
+ public IASTExpression getNewInitializer() {
+ if (initializer == null || initializer instanceof IASTExpression) {
+ return (IASTExpression) initializer;
+ }
+ if (initializer instanceof ICPPASTConstructorInitializer) {
+ IASTExpression expr= ((ICPPASTConstructorInitializer) initializer).getExpression();
+ if (expr == null) {
+ expr= new CPPASTExpressionList();
+ } else {
+ expr= expr.copy();
+ }
+ expr.setParent(this);
+ expr.setPropertyInParent(NEW_INITIALIZER);
+ return expr;
+ }
+ return null;
+ }
+
+ @Deprecated
+ public void setNewInitializer(IASTExpression expression) {
+ assertNotFrozen();
+ if (expression == null) {
+ setInitializer(null);
+ } else if (expression instanceof IASTInitializer) {
+ setInitializer((IASTInitializer) expression);
+ } else {
+ CPPASTConstructorInitializer ctorInit= new CPPASTConstructorInitializer();
+ ctorInit.setExpression(expression);
+ ctorInit.setOffsetAndLength((ASTNode) expression);
+ setInitializer(ctorInit);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java
index ea60a612a82..8d4bc38fde5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java
@@ -37,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.model.IEnumeration;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
@@ -252,23 +253,21 @@ public class CPPASTQualifiedName extends CPPASTNameBase
IBinding binding = names[namesPos-1].resolveBinding();
if (binding instanceof ICPPClassType) {
ICPPClassType classType = (ICPPClassType) binding;
- if (!canBeFieldAccess(classType)) {
- final boolean isDeclaration = getParent().getParent() instanceof IASTSimpleDeclaration;
- List<IBinding> filtered = filterClassScopeBindings(classType, bindings, isDeclaration);
- if (isDeclaration && nameMatches(classType.getNameCharArray(),
- n.getLookupKey(), isPrefix)) {
- try {
- ICPPConstructor[] constructors = classType.getConstructors();
- for (int i = 0; i < constructors.length; i++) {
- if (!constructors[i].isImplicit()) {
- filtered.add(constructors[i]);
- }
+ final boolean isDeclaration = getParent().getParent() instanceof IASTSimpleDeclaration;
+ List<IBinding> filtered = filterClassScopeBindings(classType, bindings, isDeclaration);
+ if (isDeclaration && nameMatches(classType.getNameCharArray(),
+ n.getLookupKey(), isPrefix)) {
+ try {
+ ICPPConstructor[] constructors = classType.getConstructors();
+ for (int i = 0; i < constructors.length; i++) {
+ if (!constructors[i].isImplicit()) {
+ filtered.add(constructors[i]);
}
- } catch (DOMException e) {
}
+ } catch (DOMException e) {
}
- return filtered.toArray(new IBinding[filtered.size()]);
}
+ return filtered.toArray(new IBinding[filtered.size()]);
}
}
@@ -301,22 +300,24 @@ public class CPPASTQualifiedName extends CPPASTNameBase
private List<IBinding> filterClassScopeBindings(ICPPClassType classType,
IBinding[] bindings, final boolean isDeclaration) {
List<IBinding> filtered = new ArrayList<IBinding>();
-
+ final boolean canBeFieldAccess= canBeFieldAccess(classType);
+
try {
for (final IBinding binding : bindings) {
if (binding instanceof IField) {
IField field = (IField) binding;
- if (!field.isStatic())
+ if (!canBeFieldAccess && !field.isStatic())
continue;
} else if (binding instanceof ICPPMethod) {
ICPPMethod method = (ICPPMethod) binding;
if (method.isImplicit())
continue;
if (!isDeclaration) {
- if (method.isDestructor() || method instanceof ICPPConstructor || !method.isStatic())
+ if (method.isDestructor() || method instanceof ICPPConstructor
+ || (!canBeFieldAccess && !method.isStatic()))
continue;
}
- } else if (binding instanceof IEnumerator || binding instanceof IEnumerator) {
+ } else if (binding instanceof IEnumerator || binding instanceof IEnumeration) {
if (isDeclaration)
continue;
} else if (binding instanceof IType) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java
index 9a1721fe63b..36bea044360 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java
@@ -1,34 +1,33 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM - Initial API and implementation
+ * John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
-/**
- * @author jcamelon
- */
public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatement, IASTAmbiguityParent {
- private IASTExpression retValue;
+ private IASTInitializerClause retValue;
public CPPASTReturnStatement() {
}
- public CPPASTReturnStatement(IASTExpression retValue) {
- setReturnValue(retValue);
+ public CPPASTReturnStatement(IASTInitializerClause retValue) {
+ setReturnArgument(retValue);
}
public CPPASTReturnStatement copy() {
@@ -37,16 +36,28 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
return copy;
}
+ public IASTInitializerClause getReturnArgument() {
+ return retValue;
+ }
+
public IASTExpression getReturnValue() {
- return retValue;
+ if (retValue instanceof IASTExpression) {
+ return (IASTExpression) retValue;
+ }
+ return null;
}
+
public void setReturnValue(IASTExpression returnValue) {
+ setReturnArgument(returnValue);
+ }
+
+ public void setReturnArgument(IASTInitializerClause arg) {
assertNotFrozen();
- retValue = returnValue;
- if (returnValue != null) {
- returnValue.setParent(this);
- returnValue.setPropertyInParent(RETURNVALUE);
+ retValue = arg;
+ if (arg != null) {
+ arg.setParent(this);
+ arg.setPropertyInParent(RETURNVALUE);
}
}
@@ -62,9 +73,8 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
break;
}
}
- if (retValue != null)
- if (!retValue.accept(action))
- return false;
+ if (retValue != null && !retValue.accept(action))
+ return false;
if( action.shouldVisitStatements ){
switch( action.leave( this ) ){
@@ -80,7 +90,7 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
if (child == retValue) {
other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent());
- retValue = (IASTExpression) other;
+ retValue = (IASTInitializerClause) other;
}
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java
index 611ed09ce1a..b477eb1c8f4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeConstructorExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,56 +13,76 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
-import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
public class CPPASTSimpleTypeConstructorExpression extends ASTNode implements
- ICPPASTSimpleTypeConstructorExpression, IASTAmbiguityParent {
+ ICPPASTSimpleTypeConstructorExpression {
- private int st;
- private IASTExpression init;
+ private ICPPASTDeclSpecifier fDeclSpec;
+ private IASTInitializer fInitializer;
+ private IType fType;
public CPPASTSimpleTypeConstructorExpression() {
}
- public CPPASTSimpleTypeConstructorExpression(int st, IASTExpression init) {
- this.st = st;
- setInitialValue(init);
+ public CPPASTSimpleTypeConstructorExpression(ICPPASTDeclSpecifier declSpec, IASTInitializer init) {
+ setDeclSpecifier(declSpec);
+ setInitializer(init);
}
public CPPASTSimpleTypeConstructorExpression copy() {
CPPASTSimpleTypeConstructorExpression copy = new CPPASTSimpleTypeConstructorExpression();
- copy.st = st;
- copy.setInitialValue(init == null ? null : init.copy());
+ copy.setDeclSpecifier(fDeclSpec == null ? null : fDeclSpec.copy());
+ copy.setInitializer(fInitializer == null ? null : fInitializer.copy());
copy.setOffsetAndLength(this);
return copy;
}
- public int getSimpleType() {
- return st;
- }
+ public ICPPASTDeclSpecifier getDeclSpecifier() {
+ return fDeclSpec;
+ }
- public void setSimpleType(int value) {
- assertNotFrozen();
- st = value;
+ public IASTInitializer getInitializer() {
+ return fInitializer;
+ }
+
+ public void setDeclSpecifier(ICPPASTDeclSpecifier declSpec) {
+ assertNotFrozen();
+ fDeclSpec = declSpec;
+ if (declSpec != null) {
+ declSpec.setParent(this);
+ declSpec.setPropertyInParent(TYPE_SPECIFIER);
+ }
}
- public IASTExpression getInitialValue() {
- return init;
+ public void setInitializer(IASTInitializer initializer) {
+ assertNotFrozen();
+ fInitializer = initializer;
+ if (initializer != null) {
+ initializer.setParent(this);
+ initializer.setPropertyInParent(INITIALIZER);
+ }
}
- public void setInitialValue(IASTExpression expression) {
- assertNotFrozen();
- init = expression;
- if (expression != null) {
- expression.setParent(this);
- expression.setPropertyInParent(INITIALIZER_VALUE);
+ public IType getExpressionType() {
+ if (fType == null) {
+ fType= CPPVisitor.createType(fDeclSpec);
}
- }
+ return fType;
+ }
+ public boolean isLValue() {
+ return false;
+ }
+
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitExpressions ){
@@ -72,8 +92,12 @@ public class CPPASTSimpleTypeConstructorExpression extends ASTNode implements
default : break;
}
}
-
- if( init != null ) if( !init.accept( action ) ) return false;
+
+ if (fDeclSpec != null && !fDeclSpec.accept(action))
+ return false;
+
+ if (fInitializer != null && !fInitializer.accept(action))
+ return false;
if( action.shouldVisitExpressions ){
switch( action.leave( this ) ){
@@ -85,20 +109,102 @@ public class CPPASTSimpleTypeConstructorExpression extends ASTNode implements
return true;
}
- public void replace(IASTNode child, IASTNode other) {
- if( child == init )
- {
- other.setPropertyInParent( child.getPropertyInParent() );
- other.setParent( child.getParent() );
- init = (IASTExpression) other;
- }
+ @Deprecated
+ public int getSimpleType() {
+ IType type= getExpressionType();
+ if (type instanceof ICPPBasicType) {
+ ICPPBasicType bt= (ICPPBasicType) type;
+ Kind kind = bt.getKind();
+ switch(kind) {
+ case eBoolean:
+ return t_bool;
+ case eChar:
+ return t_char;
+ case eDouble:
+ return t_double;
+ case eFloat:
+ return t_float;
+ case eInt:
+ if (bt.isShort())
+ return t_short;
+ if (bt.isLong())
+ return t_long;
+ if (bt.isSigned())
+ return t_signed;
+ if (bt.isUnsigned())
+ return t_unsigned;
+ return t_int;
+ case eVoid:
+ return t_void;
+ case eWChar:
+ return t_wchar_t;
+ default:
+ break;
+ }
+ }
+ return t_unspecified;
}
- public IType getExpressionType() {
- return new CPPBasicType(CPPBasicType.getKind(st), 0);
+ @Deprecated
+ public void setSimpleType(int value) {
+ CPPASTSimpleDeclSpecifier declspec = new CPPASTSimpleDeclSpecifier();
+ switch(value) {
+ case t_bool:
+ declspec.setType(Kind.eBoolean);
+ break;
+ case t_char:
+ declspec.setType(Kind.eChar);
+ break;
+ case t_double:
+ declspec.setType(Kind.eDouble);
+ break;
+ case t_float:
+ declspec.setType(Kind.eFloat);
+ break;
+ case t_int:
+ declspec.setType(Kind.eInt);
+ break;
+ case t_long:
+ declspec.setType(Kind.eInt);
+ declspec.setLong(true);
+ break;
+ case t_short:
+ declspec.setType(Kind.eInt);
+ declspec.setShort(true);
+ break;
+ case t_signed:
+ declspec.setType(Kind.eInt);
+ declspec.setSigned(true);
+ break;
+ case t_unsigned:
+ declspec.setType(Kind.eInt);
+ declspec.setUnsigned(true);
+ break;
+ case t_void:
+ declspec.setType(Kind.eVoid);
+ break;
+ case t_wchar_t:
+ declspec.setType(Kind.eWChar);
+ break;
+ default:
+ declspec.setType(Kind.eUnspecified);
+ break;
+ }
+ setDeclSpecifier(declspec);
+ }
+
+ @Deprecated
+ public IASTExpression getInitialValue() {
+ if (fInitializer instanceof ICPPASTConstructorInitializer) {
+ return ((ICPPASTConstructorInitializer) fInitializer).getExpression();
+ }
+ return null;
+ }
+
+ @Deprecated
+ public void setInitialValue(IASTExpression expression) {
+ ICPPASTConstructorInitializer init= new CPPASTConstructorInitializer();
+ init.setExpression(expression);
+ setInitializer(init);
}
-
- public boolean isLValue() {
- return false;
- }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java
index 625464d0de3..39030d0c3b0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTypenameExpression.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,130 +11,63 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
-import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
-import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
-public class CPPASTTypenameExpression extends ASTNode implements
- ICPPASTTypenameExpression, IASTAmbiguityParent {
+@Deprecated
+public class CPPASTTypenameExpression extends CPPASTSimpleTypeConstructorExpression implements ICPPASTTypenameExpression {
- private boolean isTemplate;
- private IASTName name;
- private IASTExpression init;
-
-
public CPPASTTypenameExpression() {
}
- public CPPASTTypenameExpression(IASTName name, IASTExpression init) {
- this(name, init, false);
- }
-
- public CPPASTTypenameExpression(IASTName name, IASTExpression init, boolean isTemplate) {
+ public CPPASTTypenameExpression(IASTName name, IASTExpression expr) {
setName(name);
- setInitialValue(init);
- this.isTemplate = isTemplate;
+ setInitialValue(expr);
}
+ @Override
public CPPASTTypenameExpression copy() {
+ super.copy();
CPPASTTypenameExpression copy = new CPPASTTypenameExpression();
- copy.setName(name == null ? null : name.copy());
- copy.setInitialValue(init == null ? null : init.copy());
- copy.isTemplate = isTemplate;
+ ICPPASTDeclSpecifier declSpec = getDeclSpecifier();
+ IASTInitializer init = getInitializer();
+ copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy());
+ copy.setInitializer(init == null ? null : init.copy());
copy.setOffsetAndLength(this);
return copy;
}
-
- public void setIsTemplate(boolean templateTokenConsumed) {
- assertNotFrozen();
- isTemplate = templateTokenConsumed;
- }
-
- public boolean isTemplate() {
- return isTemplate;
- }
-
public void setName(IASTName name) {
- assertNotFrozen();
- this.name = name;
- if (name != null) {
- name.setParent(this);
- name.setPropertyInParent(TYPENAME);
- }
+ CPPASTNamedTypeSpecifier spec= new CPPASTNamedTypeSpecifier(name);
+ spec.setOffsetAndLength(this);
+ setDeclSpecifier(spec);
}
public IASTName getName() {
- return name;
+ IASTDeclSpecifier spec= getDeclSpecifier();
+ if (spec instanceof ICPPASTNamedTypeSpecifier) {
+ return ((ICPPASTNamedTypeSpecifier) spec).getName();
+ }
+ return null;
}
- public void setInitialValue(IASTExpression expressionList) {
- assertNotFrozen();
- init = expressionList;
- if (expressionList != null) {
- expressionList.setParent(this);
- expressionList.setPropertyInParent(INITIAL_VALUE);
- }
- }
-
- public IASTExpression getInitialValue() {
- return init;
- }
-
- @Override
- public boolean accept( ASTVisitor action ){
- if( action.shouldVisitExpressions ){
- switch( action.visit( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
- }
- }
-
- if( name != null ) if( !name.accept( action ) ) return false;
- if( init != null ) if( !init.accept( action ) ) return false;
-
- if( action.shouldVisitExpressions ){
- switch( action.leave( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
- }
- }
- return true;
- }
-
public int getRoleForName(IASTName n) {
- if( n == name )
+ if (n == getName())
return r_reference;
return r_unclear;
}
- public void replace(IASTNode child, IASTNode other) {
- if( child == init )
- {
- other.setPropertyInParent( child.getPropertyInParent() );
- other.setParent( child.getParent() );
- init = (IASTExpression) other;
- }
-
- }
-
- public IType getExpressionType() {
- IBinding binding = getName().resolvePreBinding();
- if (binding instanceof IType) {
- return (IType) binding;
- }
- return null;
+ @Deprecated
+ public void setIsTemplate(boolean val) {
}
- public boolean isLValue() {
- return false;
- }
+ @Deprecated
+ public boolean isTemplate() {
+ return false;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
index 5013a720675..85c5e4d0b7d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
@@ -25,12 +25,14 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
@@ -55,6 +57,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
@@ -68,7 +71,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
@@ -95,7 +97,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
@@ -121,417 +122,469 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
return DEFAULT_INSTANCE;
}
- public ICPPASTTranslationUnit newTranslationUnit() {
- return newTranslationUnit(null);
+ public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name) {
+ return new CPPASTArrayDeclarator(name);
}
- public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner) {
- CPPASTTranslationUnit tu = new CPPASTTranslationUnit();
-
- if (scanner != null) {
- tu.setLocationResolver(scanner.getLocationResolver());
- }
- tu.setASTNodeFactory(this);
- return tu;
+ public IASTArrayModifier newArrayModifier(IASTExpression expr) {
+ return new CPPASTArrayModifier(expr);
}
- public IASTName newName(char[] name) {
- return new CPPASTName(name);
+ public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript) {
+ return new CPPASTArraySubscriptExpression(arrayExpr, subscript);
}
- public IASTName newName() {
- return new CPPASTName();
+ public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr,
+ IASTInitializerClause subscript) {
+ return new CPPASTArraySubscriptExpression(arrayExpr, subscript);
}
- public ICPPASTOperatorName newOperatorName(char[] name) {
- return new CPPASTOperatorName(name);
+ public IASTASMDeclaration newASMDeclaration(String assembly) {
+ return new CPPASTASMDeclaration(assembly);
}
- public IASTProblem newProblem(int id, char[] arg, boolean error) {
- return new CPPASTProblem(id, arg, error);
+ public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual) {
+ return new CPPASTBaseSpecifier(name, visibility, isVirtual);
}
- public IASTProblemDeclaration newProblemDeclaration(IASTProblem problem) {
- return new CPPASTProblemDeclaration(problem);
+ public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2) {
+ return new CPPASTBinaryExpression(op, expr1, expr2);
}
- public IASTProblemExpression newProblemExpression(IASTProblem problem) {
- return new CPPASTProblemExpression(problem);
+ public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTInitializerClause expr2) {
+ return new CPPASTBinaryExpression(op, expr1, expr2);
}
- public IASTProblemStatement newProblemStatement(IASTProblem problem) {
- return new CPPASTProblemStatement(problem);
+ public IASTBreakStatement newBreakStatement() {
+ return new CPPASTBreakStatement();
}
- public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep) {
- return new CPPASTLiteralExpression(kind, rep.toCharArray());
+ public IASTCaseStatement newCaseStatement(IASTExpression expr) {
+ return new CPPASTCaseStatement(expr);
}
- public ICPPASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand) {
- return new CPPASTUnaryExpression(operator, operand);
+ public ICPPASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand) {
+ return new CPPASTCastExpression(operator, typeId, operand);
}
- public IASTIdExpression newIdExpression(IASTName name) {
- return new CPPASTIdExpression(name);
+ public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body) {
+ return new CPPASTCatchHandler(decl, body);
}
- public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTExpression subscript) {
- return new CPPASTArraySubscriptExpression(arrayExpr, subscript);
+ public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name) {
+ return new CPPASTCompositeTypeSpecifier(key, name);
}
- public ICPPASTExpressionList newExpressionList() {
- return new CPPASTExpressionList();
+ public IASTCompoundStatement newCompoundStatement() {
+ return new CPPASTCompoundStatement();
}
- public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList) {
- return new CPPASTFunctionCallExpression(idExpr, argList);
+ public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3) {
+ return new CPPASTConditionalExpression(expr1, expr2, expr3);
}
- public ICPPASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand) {
- return new CPPASTCastExpression(operator, typeId, operand);
+ @Deprecated
+ public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName id, IASTExpression expression) {
+ ICPPASTConstructorChainInitializer result= new CPPASTConstructorChainInitializer(id, null);
+ result.setInitializerValue(expression);
+ return result;
}
- public ICPPASTNewExpression newNewExpression(IASTExpression placement, IASTExpression initializer, IASTTypeId typeId) {
- return new CPPASTNewExpression(placement, initializer, typeId);
+ public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName id, IASTInitializer init) {
+ return new CPPASTConstructorChainInitializer(id, init);
}
- public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2) {
- return new CPPASTBinaryExpression(op, expr1, expr2);
+ @Deprecated
+ public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp) {
+ ICPPASTConstructorInitializer result= new CPPASTConstructorInitializer(null);
+ result.setExpression(exp);
+ return result;
}
- public IASTConditionalExpression newConditionalExpession(IASTExpression expr1, IASTExpression expr2, IASTExpression expr3) {
- return new CPPASTConditionalExpression(expr1, expr2, expr3);
+ public ICPPASTConstructorInitializer newConstructorInitializer(IASTInitializerClause[] args) {
+ return new CPPASTConstructorInitializer(args);
+ }
+
+ public IASTContinueStatement newContinueStatement() {
+ return new CPPASTContinueStatement();
+ }
+
+ public ICPPASTConversionName newConversionName(IASTTypeId typeId) {
+ return new CPPASTConversionName(typeId);
}
- public IASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer) {
- return new CPPASTTypeIdInitializerExpression(typeId, initializer);
+ public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration) {
+ return new CPPASTDeclarationStatement(declaration);
}
- public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner) {
- return new CPPASTFieldReference(name, owner);
+ public ICPPASTDeclarator newDeclarator(IASTName name) {
+ return new CPPASTDeclarator(name);
}
- public ICPPASTTemplateId newTemplateId(IASTName templateName) {
- return new CPPASTTemplateId(templateName);
+ public IASTDefaultStatement newDefaultStatement() {
+ return new CPPASTDefaultStatement();
}
- public ICPPASTConversionName newConversionName(IASTTypeId typeId) {
- return new CPPASTConversionName(typeId);
+ public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand) {
+ return new CPPASTDeleteExpression(operand);
}
- public ICPPASTQualifiedName newQualifiedName() {
- return new CPPASTQualifiedName();
+ public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition) {
+ return new CPPASTDoStatement(body, condition);
}
- public IASTCaseStatement newCaseStatement(IASTExpression expr) {
- return new CPPASTCaseStatement(expr);
+ public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name) {
+ return new CPPASTElaboratedTypeSpecifier(kind, name);
}
- public IASTDefaultStatement newDefaultStatement() {
- return new CPPASTDefaultStatement();
+ public IASTEnumerationSpecifier newEnumerationSpecifier(IASTName name) {
+ return new CPPASTEnumerationSpecifier(name);
}
- public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement) {
- return new CPPASTLabelStatement(name, nestedStatement);
+ public IASTEnumerator newEnumerator(IASTName name, IASTExpression value) {
+ return new CPPASTEnumerator(name, value);
}
- public IASTExpressionStatement newExpressionStatement(IASTExpression expression) {
- return new CPPASTExpressionStatement(expression);
+ public IASTEqualsInitializer newEqualsInitializer(IASTInitializerClause initClause) {
+ return new CPPASTEqualsInitializer(initClause);
}
- public IASTNullStatement newNullStatement() {
- return new CPPASTNullStatement();
+ public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration) {
+ return new CPPASTExplicitTemplateInstantiation(declaration);
}
- public IASTCompoundStatement newCompoundStatement() {
- return new CPPASTCompoundStatement();
+ @Deprecated
+ public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration) {
+ return new GPPASTExplicitTemplateInstantiation(declaration);
}
- public ICPPASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause) {
- return new CPPASTIfStatement(condition, then, elseClause);
+ public ICPPASTExpressionList newExpressionList() {
+ return new CPPASTExpressionList();
}
- public ICPPASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause) {
- return new CPPASTIfStatement(condition, then, elseClause);
+ public IASTExpressionStatement newExpressionStatement(IASTExpression expression) {
+ return new CPPASTExpressionStatement(expression);
}
- public ICPPASTIfStatement newIfStatement() {
- return new CPPASTIfStatement();
+ public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize) {
+ return new CPPASTFieldDeclarator(name, bitFieldSize);
}
- public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body) {
- return new CPPASTSwitchStatement(controller, body);
+ public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner) {
+ return new CPPASTFieldReference(name, owner);
}
- public ICPPASTSwitchStatement newSwitchStatement(IASTDeclaration controller, IASTStatement body) {
- return new CPPASTSwitchStatement(controller, body);
+ public ICPPASTForStatement newForStatement() {
+ return new CPPASTForStatement();
}
- public ICPPASTSwitchStatement newSwitchStatement() {
- return new CPPASTSwitchStatement();
+ public ICPPASTForStatement newForStatement(IASTStatement init, IASTDeclaration condition,
+ IASTExpression iterationExpression, IASTStatement body) {
+ return new CPPASTForStatement(init, condition, iterationExpression, body);
}
- public ICPPASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body) {
- return new CPPASTWhileStatement(condition, body);
+ public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
+ IASTExpression iterationExpr, IASTStatement body) {
+ return new CPPASTForStatement(init, condition, iterationExpr, body);
}
- public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) {
- return new CPPASTWhileStatement(condition, body);
- }
-
- public ICPPASTWhileStatement newWhileStatement() {
- return new CPPASTWhileStatement();
+ @Deprecated
+ public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList) {
+ CPPASTFunctionCallExpression result = new CPPASTFunctionCallExpression(idExpr, null);
+ result.setParameterExpression(argList);
+ return result;
}
- public IASTDoStatement newDoStatement(IASTStatement body, IASTExpression condition) {
- return new CPPASTDoStatement(body, condition);
+ public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTInitializerClause[] arguments) {
+ return new CPPASTFunctionCallExpression(idExpr, arguments);
}
- public IASTBreakStatement newBreakStatement() {
- return new CPPASTBreakStatement();
- }
-
- public IASTContinueStatement newContinueStatement() {
- return new CPPASTContinueStatement();
+ public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name) {
+ return new CPPASTFunctionDeclarator(name);
}
- public IASTGotoStatement newGotoStatement(IASTName name) {
- return new CPPASTGotoStatement(name);
+ public ICPPASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator,
+ IASTStatement bodyStatement) {
+ return new CPPASTFunctionDefinition(declSpecifier, declarator, bodyStatement);
}
- public IASTReturnStatement newReturnStatement(IASTExpression retValue) {
- return new CPPASTReturnStatement(retValue);
+ public ICPPASTFunctionWithTryBlock newFunctionTryBlock(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator,
+ IASTStatement bodyStatement) {
+ return new CPPASTFunctionWithTryBlock(declSpecifier, declarator, bodyStatement);
}
- public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
- IASTExpression iterationExpr, IASTStatement body) {
- return new CPPASTForStatement(init, condition, iterationExpr, body);
+ public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement) {
+ return new CPPASTCompoundStatementExpression(compoundStatement);
}
- public ICPPASTForStatement newForStatement(IASTStatement init, IASTDeclaration condition,
- IASTExpression iterationExpression, IASTStatement body) {
- return new CPPASTForStatement(init, condition, iterationExpression, body);
+ public IASTGotoStatement newGotoStatement(IASTName name) {
+ return new CPPASTGotoStatement(name);
}
- public ICPPASTForStatement newForStatement() {
- return new CPPASTForStatement();
+ public IASTIdExpression newIdExpression(IASTName name) {
+ return new CPPASTIdExpression(name);
}
- public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration) {
- return new CPPASTDeclarationStatement(declaration);
+ public ICPPASTIfStatement newIfStatement() {
+ return new CPPASTIfStatement();
}
- public ICPPASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) {
- return new CPPASTTypeIdExpression(operator, typeId);
+ public ICPPASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause) {
+ return new CPPASTIfStatement(condition, then, elseClause);
}
- public ICPPASTDeclarator newDeclarator(IASTName name) {
- return new CPPASTDeclarator(name);
+ public ICPPASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause) {
+ return new CPPASTIfStatement(condition, then, elseClause);
}
- public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
- return new CPPASTTypeId(declSpecifier, declarator);
+ @Deprecated
+ public org.eclipse.cdt.core.dom.ast.IASTInitializerExpression newInitializerExpression(IASTExpression expression) {
+ return new CPPASTInitializerExpression(expression);
}
- public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand) {
- return new CPPASTDeleteExpression(operand);
+ public ICPPASTInitializerList newInitializerList() {
+ return new CPPASTInitializerList();
}
- public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) {
- return new CPPASTSimpleDeclaration(declSpecifier);
+ public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement) {
+ return new CPPASTLabelStatement(name, nestedStatement);
}
- public ICPPASTInitializerExpression newInitializerExpression(IASTExpression expression) {
- return new CPPASTInitializerExpression(expression);
+ public ICPPASTLinkageSpecification newLinkageSpecification(String literal) {
+ return new CPPASTLinkageSpecification(literal);
}
- public ICPPASTFunctionDefinition newFunctionDefinition(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator,
- IASTStatement bodyStatement) {
- return new CPPASTFunctionDefinition(declSpecifier, declarator, bodyStatement);
+ public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep) {
+ return new CPPASTLiteralExpression(kind, rep.toCharArray());
}
- public ICPPASTSimpleDeclSpecifier newSimpleDeclSpecifier() {
- return new CPPASTSimpleDeclSpecifier();
+ public IASTName newName() {
+ return new CPPASTName();
}
- public ICPPASTFunctionDeclarator newFunctionDeclarator(IASTName name) {
- return new CPPASTFunctionDeclarator(name);
+ public IASTName newName(char[] name) {
+ return new CPPASTName(name);
}
- public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression) {
- return new CPPASTSimpleTypeConstructorExpression(type, expression);
+ public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName) {
+ return new CPPASTNamespaceAlias(alias, qualifiedName);
}
- public ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate) {
- return new CPPASTTypenameExpression(qualifiedName, expr, isTemplate);
+ public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name) {
+ return new CPPASTNamespaceDefinition(name);
}
- public IASTASMDeclaration newASMDeclaration(String assembly) {
- return new CPPASTASMDeclaration(assembly);
+ @Deprecated
+ public ICPPASTNewExpression newNewExpression(IASTExpression placement, IASTExpression initializer, IASTTypeId typeId) {
+ final ICPPASTNewExpression result = new CPPASTNewExpression(null, null, typeId);
+ result.setNewPlacement(placement);
+ result.setNewInitializer(initializer);
+ return result;
}
- public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName) {
- return new CPPASTNamespaceAlias(alias, qualifiedName);
+ public ICPPASTNewExpression newNewExpression(IASTInitializerClause[] placement, IASTInitializer initializer, IASTTypeId typeId) {
+ return new CPPASTNewExpression(placement, initializer, typeId);
}
- public ICPPASTUsingDeclaration newUsingDeclaration(IASTName name) {
- return new CPPASTUsingDeclaration(name);
+ public IASTNullStatement newNullStatement() {
+ return new CPPASTNullStatement();
}
- public ICPPASTUsingDirective newUsingDirective(IASTName name) {
- return new CPPASTUsingDirective(name);
+ public ICPPASTOperatorName newOperatorName(char[] name) {
+ return new CPPASTOperatorName(name);
}
- public ICPPASTLinkageSpecification newLinkageSpecification(String literal) {
- return new CPPASTLinkageSpecification(literal);
+ public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern) {
+ return new CPPASTPackExpansionExpression(pattern);
}
- public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name) {
- return new CPPASTNamespaceDefinition(name);
+ public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
+ return new CPPASTParameterDeclaration(declSpec, declarator);
}
- public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration) {
- return new CPPASTTemplateDeclaration(declaration);
+ public IASTPointer newPointer() {
+ return new CPPASTPointer();
}
- public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration) {
- return new CPPASTExplicitTemplateInstantiation(declaration);
+ public IGPPASTPointer newPointerGPP() {
+ return new GPPASTPointer();
+ }
+
+ public ICPPASTPointerToMember newPointerToMember(IASTName name) {
+ return new CPPASTPointerToMember(name);
}
- public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration) {
- return new CPPASTTemplateSpecialization(declaration);
+ public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name) {
+ return new GPPASTPointerToMember(name);
}
- public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body) {
- return new CPPASTTryBlockStatement(body);
+ public IASTProblem newProblem(int id, char[] arg, boolean error) {
+ return new CPPASTProblem(id, arg, error);
}
- public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body) {
- return new CPPASTCatchHandler(decl, body);
+ public IASTProblemDeclaration newProblemDeclaration(IASTProblem problem) {
+ return new CPPASTProblemDeclaration(problem);
}
- public IASTEnumerationSpecifier newEnumerationSpecifier(IASTName name) {
- return new CPPASTEnumerationSpecifier(name);
+ public IASTProblemExpression newProblemExpression(IASTProblem problem) {
+ return new CPPASTProblemExpression(problem);
}
- public IASTEnumerator newEnumerator(IASTName name, IASTExpression value) {
- return new CPPASTEnumerator(name, value);
+ public IASTProblemStatement newProblemStatement(IASTProblem problem) {
+ return new CPPASTProblemStatement(problem);
}
- public ICPPASTVisibilityLabel newVisibilityLabel(int visibility) {
- return new CPPASTVisibilityLabel(visibility);
+ public IASTProblemTypeId newProblemTypeId(IASTProblem problem) {
+ return new CPPASTProblemTypeId(problem);
}
- public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual) {
- return new CPPASTBaseSpecifier(name, visibility, isVirtual);
+ public ICPPASTQualifiedName newQualifiedName() {
+ return new CPPASTQualifiedName();
}
- public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name) {
- return new CPPASTCompositeTypeSpecifier(key, name);
+ public ICPPASTReferenceOperator newReferenceOperator() {
+ return new CPPASTReferenceOperator(false);
}
- public ICPPASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name) {
- return new CPPASTNamedTypeSpecifier(name);
+ public ICPPASTReferenceOperator newReferenceOperator(boolean isRValueReference) {
+ return new CPPASTReferenceOperator(isRValueReference);
}
- public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name) {
- return new CPPASTElaboratedTypeSpecifier(kind, name);
+ public IASTReturnStatement newReturnStatement(IASTExpression retValue) {
+ return new CPPASTReturnStatement(retValue);
}
- public IASTPointer newPointer() {
- return new CPPASTPointer();
+ public IASTReturnStatement newReturnStatement(IASTInitializerClause retValue) {
+ return new CPPASTReturnStatement(retValue);
}
- public IGPPASTPointer newPointerGPP() {
- return new GPPASTPointer();
+ public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) {
+ return new CPPASTSimpleDeclaration(declSpecifier);
}
- public ICPPASTReferenceOperator newReferenceOperator() {
- return new CPPASTReferenceOperator(false);
+ public ICPPASTSimpleDeclSpecifier newSimpleDeclSpecifier() {
+ return new CPPASTSimpleDeclSpecifier();
}
- public ICPPASTReferenceOperator newReferenceOperator(boolean isRValueReference) {
- return new CPPASTReferenceOperator(isRValueReference);
+ @Deprecated
+ public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() {
+ return new GPPASTSimpleDeclSpecifier();
}
- public ICPPASTPointerToMember newPointerToMember(IASTName name) {
- return new CPPASTPointerToMember(name);
+ @Deprecated
+ public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression) {
+ CPPASTSimpleTypeConstructorExpression result = new CPPASTSimpleTypeConstructorExpression();
+ result.setSimpleType(type);
+ result.setInitialValue(expression);
+ return result;
}
- public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name) {
- return new GPPASTPointerToMember(name);
+ public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(
+ ICPPASTDeclSpecifier declSpec, IASTInitializer initializer) {
+ return new CPPASTSimpleTypeConstructorExpression(declSpec, initializer);
}
- public ICPPASTInitializerList newInitializerList() {
- return new CPPASTInitializerList();
+ public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId) {
+ return new CPPASTSimpleTypeTemplateParameter(type, name, typeId);
}
- public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp) {
- return new CPPASTConstructorInitializer(exp);
+ public ICPPASTStaticAssertDeclaration newStaticAssertion(IASTExpression condition,
+ ICPPASTLiteralExpression message) {
+ return new CPPASTStaticAssertionDeclaration(condition, message);
}
- public IASTArrayModifier newArrayModifier(IASTExpression expr) {
- return new CPPASTArrayModifier(expr);
+ public ICPPASTSwitchStatement newSwitchStatement() {
+ return new CPPASTSwitchStatement();
}
- public ICPPASTArrayDeclarator newArrayDeclarator(IASTName name) {
- return new CPPASTArrayDeclarator(name);
+ public ICPPASTSwitchStatement newSwitchStatement(IASTDeclaration controller, IASTStatement body) {
+ return new CPPASTSwitchStatement(controller, body);
}
- public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
- return new CPPASTParameterDeclaration(declSpec, declarator);
+ public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body) {
+ return new CPPASTSwitchStatement(controller, body);
+ }
+
+ public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration) {
+ return new CPPASTTemplateDeclaration(declaration);
+ }
+
+ public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression defaultValue) {
+ return new CPPASTTemplatedTypeTemplateParameter(name, defaultValue);
}
- public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName memberInitializerid, IASTExpression initializerValue) {
- return new CPPASTConstructorChainInitializer(memberInitializerid, initializerValue);
+ public ICPPASTTemplateId newTemplateId(IASTName templateName) {
+ return new CPPASTTemplateId(templateName);
}
- public ICPPASTFunctionWithTryBlock newFunctionTryBlock(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator,
- IASTStatement bodyStatement) {
- return new CPPASTFunctionWithTryBlock(declSpecifier, declarator, bodyStatement);
+ public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration) {
+ return new CPPASTTemplateSpecialization(declaration);
}
- public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize) {
- return new CPPASTFieldDeclarator(name, bitFieldSize);
+ public ICPPASTTranslationUnit newTranslationUnit() {
+ return newTranslationUnit(null);
}
- public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId) {
- return new CPPASTSimpleTypeTemplateParameter(type, name, typeId);
+ public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner) {
+ CPPASTTranslationUnit tu = new CPPASTTranslationUnit();
+
+ if (scanner != null) {
+ tu.setLocationResolver(scanner.getLocationResolver());
+ }
+ tu.setASTNodeFactory(this);
+ return tu;
}
- public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression defaultValue) {
- return new CPPASTTemplatedTypeTemplateParameter(name, defaultValue);
+ public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body) {
+ return new CPPASTTryBlockStatement(body);
}
- public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement) {
- return new CPPASTCompoundStatementExpression(compoundStatement);
+ public ICPPASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name) {
+ return new CPPASTNamedTypeSpecifier(name);
}
- public IASTProblemTypeId newProblemTypeId(IASTProblem problem) {
- return new CPPASTProblemTypeId(problem);
+ public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
+ return new CPPASTTypeId(declSpecifier, declarator);
}
- public ICPPASTStaticAssertDeclaration newStaticAssertion(IASTExpression condition,
- ICPPASTLiteralExpression message) {
- return new CPPASTStaticAssertionDeclaration(condition, message);
+ public ICPPASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) {
+ return new CPPASTTypeIdExpression(operator, typeId);
}
- public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern) {
- return new CPPASTPackExpansionExpression(pattern);
+ public IASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer) {
+ return new CPPASTTypeIdInitializerExpression(typeId, initializer);
}
-
+
@Deprecated
- public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() {
- return new GPPASTSimpleDeclSpecifier();
+ public org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate) {
+ return new CPPASTTypenameExpression(qualifiedName, expr);
+ }
+
+ public ICPPASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand) {
+ return new CPPASTUnaryExpression(operator, operand);
}
- /**
- * @deprecated Replaced by {@link #newExplicitTemplateInstantiation(IASTDeclaration)}.
- */
- @Deprecated
- public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration) {
- return new GPPASTExplicitTemplateInstantiation(declaration);
+ public ICPPASTUsingDeclaration newUsingDeclaration(IASTName name) {
+ return new CPPASTUsingDeclaration(name);
}
+ public ICPPASTUsingDirective newUsingDirective(IASTName name) {
+ return new CPPASTUsingDirective(name);
+ }
+ public ICPPASTVisibilityLabel newVisibilityLabel(int visibility) {
+ return new CPPASTVisibilityLabel(visibility);
+ }
+
+ public ICPPASTWhileStatement newWhileStatement() {
+ return new CPPASTWhileStatement();
+ }
+
+ public ICPPASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body) {
+ return new CPPASTWhileStatement(condition, body);
+ }
+
+ public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) {
+ return new CPPASTWhileStatement(condition, body);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java
index 75cf9a85905..55cdcaac118 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,9 +13,11 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IType;
@@ -51,8 +53,14 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
if (parent instanceof IASTDeclarator) {
IASTDeclarator dtor = (IASTDeclarator) parent;
IASTInitializer initializer = dtor.getInitializer();
- if (initializer instanceof IASTInitializerExpression)
- return ((IASTInitializerExpression) initializer).getExpression();
+ if (initializer instanceof IASTEqualsInitializer) {
+ IASTInitializerClause clause= ((IASTEqualsInitializer) initializer).getInitializerClause();
+ if (clause instanceof IASTExpression)
+ return (IASTExpression) clause;
+ if (clause instanceof IASTInitializerList) {
+ // mstodo handle braced init list
+ }
+ }
}
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java
index c502fddf109..f90408c2f8c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
@@ -117,8 +116,7 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope {
}
if (!type) {
if (parent instanceof ICPPASTBaseSpecifier ||
- parent instanceof ICPPASTConstructorChainInitializer ||
- parent instanceof ICPPASTTypenameExpression) {
+ parent instanceof ICPPASTConstructorChainInitializer) {
type= true;
} else if (parent instanceof ICPPASTNamedTypeSpecifier) {
ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) parent;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java
index 157a94eb970..d8e851ddf60 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,9 +17,10 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
@@ -396,20 +397,25 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
IASTDeclarator dtor= findDeclarator(name);
if (dtor != null) {
IASTInitializer init= dtor.getInitializer();
- if (init instanceof IASTInitializerExpression) {
- IASTExpression expr= ((IASTInitializerExpression) init).getExpression();
- if (expr != null)
- return Value.create(expr, maxDepth);
- } else if (init instanceof ICPPASTConstructorInitializer) {
- IType type= SemanticUtil.getUltimateTypeUptoPointers(getType());
- if (type instanceof IPointerType || type instanceof IBasicType) {
- IASTExpression expr= ((ICPPASTConstructorInitializer) init).getExpression();
- if (expr != null)
- return Value.create(expr, maxDepth);
+ if (init != null) {
+ IASTInitializerClause clause= null;
+ if (init instanceof IASTEqualsInitializer) {
+ clause= ((IASTEqualsInitializer) init).getInitializerClause();
+ } else if (init instanceof ICPPASTConstructorInitializer) {
+ IASTInitializerClause[] args= ((ICPPASTConstructorInitializer) init).getArguments();
+ if (args.length == 1 && args[0] instanceof IASTExpression) {
+ IType type= SemanticUtil.getUltimateTypeUptoPointers(getType());
+ if (type instanceof IPointerType || type instanceof IBasicType) {
+ clause= args[0];
+ }
+ }
}
- }
- if (init != null)
+ if (clause instanceof IASTExpression) {
+ return Value.create((IASTExpression) clause, maxDepth);
+ }
+ // mstodo handle braced init list
return Value.UNKNOWN;
+ }
}
return null;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index d073069b6b9..691d7fe1ef1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -32,11 +32,14 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
@@ -76,8 +79,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializer;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
@@ -86,6 +87,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpandable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
@@ -103,7 +105,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
@@ -221,7 +222,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
loop: for(;;) {
boolean forceTemplate= false;
if (qname != null && LT(1) == IToken.t_template) {
- consume().getEndOffset();
+ consume();
forceTemplate= true;
}
@@ -695,11 +696,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
int lt1;
int conditionCount= 0;
BinaryOperator lastOperator= null;
- IASTExpression expr= castExpression(castCtx);
+ IASTInitializerClause expr= castExpression(castCtx);
loop: while(true) {
- // typically after a binary operator there cannot be a throw expression
+ // Typically after a binary operator there cannot be a throw expression
boolean allowThrow= false;
+ // Brace initializers are allowed on the right hand side of an expression
+ boolean allowBraceInitializer= false;
lt1= LT(1);
switch(lt1) {
case IToken.tQUESTION:
@@ -730,18 +733,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
allowAssignment= true; // assignment expressions will be subsumed by the conditional expression
allowThrow= true;
break;
-
- case IToken.tELLIPSIS:
- if ((!allowComma && conditionCount == 0))
- break loop;
-
- // Precedence: To the left just stronger than ',', to the right no other choice.
- lastOperator= new BinaryOperator(lastOperator, expr, lt1, 12, Integer.MAX_VALUE);
- expr= nodeFactory.newPackExpansionExpression(null);
- setRange(expr, 0, consume().getEndOffset());
- if (LT(1) == IToken.tCOMMA)
- continue loop;
- break loop;
case IToken.tCOMMA:
allowThrow= true;
@@ -766,6 +757,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
break loop;
// Assignments group right to left
lastOperator= new BinaryOperator(lastOperator, expr, lt1, 21, 20);
+ allowBraceInitializer= true;
break;
case IToken.tOR:
@@ -837,15 +829,17 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
consume(); // consume operator
if (allowThrow && LT(1) == IToken.t_throw) {
expr= throwExpression();
- switch (LT(1)) {
- case IToken.tCOLON:
- case IToken.tCOMMA:
- break;
- default:
- break loop;
- }
- }
- expr= castExpression(castCtx); // next cast expression
+ } else if (allowBraceInitializer && LT(1) == IToken.tLBRACE) {
+ expr= bracedInitList();
+ } else {
+ expr= castExpression(castCtx); // next cast expression
+ continue loop;
+ }
+
+ // For throw and braced initializers we require that the assignment expression ends.
+ lt1= LT(1);
+ if (lt1 != IToken.tCOLON && lt1 != IToken.tCOMMA)
+ break loop;
}
// Check for incomplete conditional expression
@@ -855,6 +849,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return buildExpression(lastOperator, expr);
}
+ @Override
+ protected IASTExpression buildBinaryExpression(int operator, IASTExpression expr1, IASTInitializerClause expr2, int lastOffset) {
+ IASTBinaryExpression result = nodeFactory.newBinaryExpression(operator, expr1, expr2);
+ int o = ((ASTNode) expr1).getOffset();
+ ((ASTNode) result).setOffsetAndLength(o, lastOffset - o);
+ return result;
+ }
+
private IASTExpression throwExpression() throws EndOfFileException, BacktrackException {
IToken throwToken = consume();
IASTExpression throwExpression = null;
@@ -902,7 +904,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
* and I for initializer the potential patterns (with the new omitted) are:
* easy: T, T(I)
* medium: (P) T(I), (P) (T)(I)
- * hard: (T), (P) T, (P) T, (P) (T), (T)(I)
+ * hard: (T), (P) T, (P) (T), (T)(I)
*/
protected IASTExpression newExpression() throws BacktrackException, EndOfFileException {
IToken la = LA(1);
@@ -917,15 +919,15 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
consume();
// consider placement first (P) ...
- IASTExpression plcmt= null;
+ List<IASTInitializerClause> plcmt= null;
IASTTypeId typeid= null;
boolean isNewTypeId= true;
- IASTExpression init= null;
+ IASTInitializer init= null;
int endOffset= 0;
IToken mark= mark();
IToken end= null;
try {
- plcmt= expression();
+ plcmt= expressionList();
endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset();
if (LT(1) == IToken.tLPAREN) {
@@ -949,18 +951,18 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
typeid= null;
}
- if (typeid != null && plcmt != null && LT(1) == IToken.tLPAREN) {
+ int lt1= LT(1);
+ if (typeid != null && plcmt != null && (lt1 == IToken.tLPAREN || lt1 == IToken.tLBRACE)) {
// (P)(T)(I) or (P) T (I)
- consume(IToken.tLPAREN);
- init= possiblyEmptyExpressionList(IToken.tRPAREN);
- endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset();
+ init= bracedOrCtorStyleInitializer();
+ endOffset= calculateEndOffset(init);
return newExpression(isGlobal, plcmt, typeid, isNewTypeId, init, offset, endOffset);
}
// (T) ...
backup(mark);
IASTTypeId typeid2= null;
- IASTExpression init2= null;
+ IASTInitializer init2= null;
int endOffset2;
try {
typeid2= typeId(DeclarationOptions.TYPEID);
@@ -968,16 +970,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
throw backtrack;
endOffset2= consumeOrEOC(IToken.tRPAREN).getEndOffset();
- if (LT(1) == IToken.tLPAREN) {
+ lt1= LT(1);
+ if (lt1 == IToken.tLPAREN || lt1 == IToken.tLBRACE) {
if (plcmt != null &&
ASTQueries.findTypeRelevantDeclarator(typeid2.getAbstractDeclarator()) instanceof IASTArrayDeclarator) {
throwBacktrack(LA(1));
}
// (T)(I)
- consume(IToken.tLPAREN);
- init2= possiblyEmptyExpressionList(IToken.tRPAREN);
- endOffset2= consumeOrEOC(IToken.tRPAREN).getEndOffset();
+ init2= bracedOrCtorStyleInitializer();
+ endOffset2= calculateEndOffset(init2);
}
} catch (BacktrackException e) {
if (plcmt == null)
@@ -1008,20 +1010,27 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
final IASTTypeId typeid = typeId(DeclarationOptions.TYPEID_NEW);
if (typeid == null)
throw backtrack;
+
int endOffset = calculateEndOffset(typeid);
- IASTExpression init= null;
- if (LT(1) == IToken.tLPAREN) {
+ IASTInitializer init= null;
+ final int lt1= LT(1);
+ if (lt1 == IToken.tLPAREN || lt1 == IToken.tLBRACE) {
// T(I)
- consume(IToken.tLPAREN);
- init= possiblyEmptyExpressionList(IToken.tRPAREN);
- endOffset= consumeOrEOC(IToken.tRPAREN).getEndOffset();
+ init= bracedOrCtorStyleInitializer();
+ endOffset= calculateEndOffset(init);
}
return newExpression(isGlobal, null, typeid, true, init, offset, endOffset);
}
- private IASTExpression newExpression(boolean isGlobal, IASTExpression placement, IASTTypeId typeid,
- boolean isNewTypeId, IASTExpression init, int offset, int endOffset) {
- ICPPASTNewExpression result = nodeFactory.newNewExpression(placement, init, typeid);
+
+ private IASTExpression newExpression(boolean isGlobal, List<IASTInitializerClause> plcmt, IASTTypeId typeid,
+ boolean isNewTypeId, IASTInitializer init, int offset, int endOffset) {
+
+ IASTInitializerClause[] plcmtArray= null;
+ if (plcmt != null && !plcmt.isEmpty()) {
+ plcmtArray= plcmt.toArray(new IASTInitializerClause[plcmt.size()]);
+ }
+ ICPPASTNewExpression result = nodeFactory.newNewExpression(plcmtArray, init, typeid);
result.setIsGlobal(isGlobal);
result.setIsNewTypeId(isNewTypeId);
((ASTNode) result).setOffsetAndLength(offset, endOffset - offset);
@@ -1089,12 +1098,61 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
}
+ /**
+ * postfix-expression:
+ * [gnu-extension, compound literals in c++]
+ * ( type-name ) { initializer-list }
+ * ( type-name ) { initializer-list , }
+ *
+ * primary-expression
+ * postfix-expression [ expression ]
+ * postfix-expression [ braced-init-list ]
+ * postfix-expression ( expression-list_opt )
+ * simple-type-specifier ( expression-list_opt )
+ * simple-type-specifier braced-init-list
+ * typename-specifier ( expression-list_opt )
+ * typename-specifier braced-init-list
+ * postfix-expression . templateopt id-expression
+ * postfix-expression -> templateopt id-expression
+ * postfix-expression . pseudo-destructor-name
+ * postfix-expression -> pseudo-destructor-name
+ * postfix-expression ++
+ * postfix-expression --
+ * dynamic_cast < type-id > ( expression )
+ * static_cast < type-id > ( expression )
+ * reinterpret_cast < type-id > ( expression )
+ * const_cast < type-id > ( expression )
+ * typeid ( expression )
+ * typeid ( type-id )
+ */
private IASTExpression postfixExpression(CastExprCtx ctx) throws EndOfFileException, BacktrackException {
IASTExpression firstExpression = null;
boolean isTemplate = false;
- switch (LT(1)) {
+ switch (LT(1)) {
+ case IToken.t_dynamic_cast:
+ firstExpression = specialCastExpression(ICPPASTCastExpression.op_dynamic_cast);
+ break;
+ case IToken.t_static_cast:
+ firstExpression = specialCastExpression(ICPPASTCastExpression.op_static_cast);
+ break;
+ case IToken.t_reinterpret_cast:
+ firstExpression = specialCastExpression(ICPPASTCastExpression.op_reinterpret_cast);
+ break;
+ case IToken.t_const_cast:
+ firstExpression = specialCastExpression(ICPPASTCastExpression.op_const_cast);
+ break;
+
+ case IToken.t_typeid:
+ // 'typeid' ( expression )
+ // 'typeid' ( type-id )
+ int so = consume().getOffset();
+ firstExpression = parseTypeidInParenthesisOrUnaryExpression(true, so,
+ ICPPASTTypeIdExpression.op_typeid, ICPPASTUnaryExpression.op_typeid, ctx);
+ break;
+
case IToken.tLPAREN:
+ // Gnu-extension: compound literals in c++
// ( type-name ) { initializer-list }
// ( type-name ) { initializer-list , }
IToken m = mark();
@@ -1104,7 +1162,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (t != null) {
consume(IToken.tRPAREN);
if (LT(1) == IToken.tLBRACE) {
- IASTInitializer i = initializerClause(false);
+ IASTInitializer i = bracedInitList();
firstExpression= nodeFactory.newTypeIdInitializerExpression(t, i);
setRange(firstExpression, offset, calculateEndOffset(i));
break;
@@ -1116,132 +1174,80 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
firstExpression= primaryExpression(ctx);
break;
+ // typename-specifier ( expression-list_opt )
+ // typename-specifier braced-init-list
+ // simple-type-specifier ( expression-list_opt )
+ // simple-type-specifier braced-init-list
case IToken.t_typename:
- int typenameOffset= consume().getOffset();
-
- boolean templateTokenConsumed = false;
- if (LT(1) == IToken.t_template) {
- consume();
- templateTokenConsumed = true;
- }
- IASTName name = qualifiedName(CastExprCtx.eNotBExpr); // treat as not in binary to force template arguments
- if (LT(1) != IToken.tLPAREN) {
- throwBacktrack(LA(1));
- }
-
- ICPPASTTypenameExpression result = nodeFactory.newTypenameExpression(name, null, templateTokenConsumed);
- setRange(result, typenameOffset, calculateEndOffset(name));
- firstExpression = result;
- break;
- // simple-type-specifier ( assignment-expression , .. )
case IToken.t_char:
- firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_char);
- break;
case IToken.t_wchar_t:
- firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_wchar_t);
- break;
case IToken.t_bool:
- firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_bool);
- break;
case IToken.t_short:
- firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_short);
- break;
case IToken.t_int:
- firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_int);
- break;
case IToken.t_long:
- firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_long);
- break;
case IToken.t_signed:
- firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_signed);
- break;
case IToken.t_unsigned:
- firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_unsigned);
- break;
case IToken.t_float:
- firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_float);
- break;
case IToken.t_double:
- firstExpression = simpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression.t_double);
- break;
- case IToken.t_dynamic_cast:
- firstExpression = specialCastExpression(ICPPASTCastExpression.op_dynamic_cast);
- break;
- case IToken.t_static_cast:
- firstExpression = specialCastExpression(ICPPASTCastExpression.op_static_cast);
- break;
- case IToken.t_reinterpret_cast:
- firstExpression = specialCastExpression(ICPPASTCastExpression.op_reinterpret_cast);
- break;
- case IToken.t_const_cast:
- firstExpression = specialCastExpression(ICPPASTCastExpression.op_const_cast);
- break;
- case IToken.t_typeid:
- int so = consume().getOffset();
- firstExpression = parseTypeidInParenthesisOrUnaryExpression(true, so,
- ICPPASTTypeIdExpression.op_typeid, ICPPASTUnaryExpression.op_typeid, ctx);
- break;
-
+ case IToken.t_decltype:
+ case IGCCToken.t_typeof:
+ firstExpression = simpleTypeConstructorExpression(simpleTypeSpecifier());
+ break;
+
default:
firstExpression = primaryExpression(ctx);
+ if (firstExpression instanceof IASTIdExpression && LT(1) == IToken.tLBRACE) {
+ IASTName name = ((IASTIdExpression) firstExpression).getName();
+ ICPPASTDeclSpecifier declSpec= nodeFactory.newTypedefNameSpecifier(name);
+ firstExpression = simpleTypeConstructorExpression(setRange(declSpec, name));
+ }
break;
}
- IASTExpression secondExpression = null;
+
for (;;) {
switch (LT(1)) {
case IToken.tLBRACKET:
- // array access
- consume();
- int lastOffset;
- secondExpression = expression();
- switch (LT(1)) {
- case IToken.tRBRACKET:
- case IToken.tEOC:
- lastOffset = consume().getEndOffset();
- break;
- default:
- throw backtrack;
+ // postfix-expression [ expression ]
+ // postfix-expression [ braced-init-list ]
+ consume(IToken.tLBRACKET);
+ IASTInitializerClause expression;
+ if (LT(1) == IToken.tLBRACE) {
+ expression= bracedInitList();
+ } else {
+ expression= expression();
}
-
- IASTArraySubscriptExpression s = nodeFactory.newArraySubscriptExpression(firstExpression, secondExpression);
- ((ASTNode) s).setOffsetAndLength(((ASTNode) firstExpression)
- .getOffset(), lastOffset - ((ASTNode) firstExpression).getOffset());
- firstExpression = s;
+ int endOffset= consumeOrEOC(IToken.tRBRACKET).getEndOffset();
+ IASTArraySubscriptExpression s = nodeFactory.newArraySubscriptExpression(firstExpression, expression);
+ firstExpression= setRange(s, firstExpression, endOffset);
break;
case IToken.tLPAREN:
- // function call
- consume();
-
- if (LT(1) != IToken.tRPAREN)
- secondExpression = expression();
- else
- secondExpression = null;
- switch (LT(1)) {
- case IToken.tRPAREN:
- case IToken.tEOC:
- lastOffset = consume().getEndOffset();
- break;
- default:
- throw backtrack;
- }
+ // postfix-expression ( expression-list_opt )
+ // simple-type-specifier ( expression-list_opt ) // cannot be distinguished
+ consume(IToken.tLPAREN);
+ IASTInitializerClause[] initArray;
+ if (LT(1) == IToken.tRPAREN) {
+ initArray= IASTExpression.EMPTY_EXPRESSION_ARRAY;
+ } else {
+ final List<IASTInitializerClause> exprList = expressionList();
+ initArray = exprList.toArray(new IASTInitializerClause[exprList.size()]);
+ }
+ endOffset = consumeOrEOC(IToken.tRPAREN).getEndOffset();
- IASTFunctionCallExpression fce = nodeFactory.newFunctionCallExpression(firstExpression, secondExpression);
- ((ASTNode) fce).setOffsetAndLength(((ASTNode) firstExpression)
- .getOffset(), lastOffset - ((ASTNode) firstExpression).getOffset());
- firstExpression = fce;
+ IASTFunctionCallExpression fce = nodeFactory.newFunctionCallExpression(firstExpression, initArray);
+ firstExpression= setRange(fce, firstExpression, endOffset);
break;
+
case IToken.tINCR:
- int offset = consume().getEndOffset();
- firstExpression = buildUnaryExpression(
- IASTUnaryExpression.op_postFixIncr, firstExpression,
- ((ASTNode) firstExpression).getOffset(), offset);
+ endOffset = consume().getEndOffset();
+ firstExpression = buildUnaryExpression(IASTUnaryExpression.op_postFixIncr, firstExpression,
+ ((ASTNode) firstExpression).getOffset(), endOffset);
break;
case IToken.tDECR:
- offset = consume().getEndOffset();
- firstExpression = buildUnaryExpression(
- IASTUnaryExpression.op_postFixDecr, firstExpression,
- ((ASTNode) firstExpression).getOffset(), offset);
+ endOffset = consume().getEndOffset();
+ firstExpression = buildUnaryExpression(IASTUnaryExpression.op_postFixDecr, firstExpression,
+ ((ASTNode) firstExpression).getOffset(), endOffset);
break;
+
case IToken.tDOT:
// member access
IToken dot = consume();
@@ -1293,7 +1299,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
}
- @Override
+ @Override
protected IASTAmbiguousExpression createAmbiguousExpression() {
return new CPPASTAmbiguousExpression();
}
@@ -1313,20 +1319,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
- protected IASTExpression simpleTypeConstructorExpression(int operator) throws EndOfFileException, BacktrackException {
- int startingOffset = LA(1).getOffset();
- consume();
- consume(IToken.tLPAREN);
- IASTExpression operand = null;
- if (LT(1) != IToken.tRPAREN)
- operand = expression();
- int l = consume(IToken.tRPAREN).getEndOffset();
- ICPPASTSimpleTypeConstructorExpression result = nodeFactory.newSimpleTypeConstructorExpression(operator, operand);
- ((ASTNode) result).setOffsetAndLength(startingOffset, l - startingOffset);
- return result;
+ private IASTExpression simpleTypeConstructorExpression(ICPPASTDeclSpecifier declSpec) throws EndOfFileException, BacktrackException {
+ IASTInitializer initializer = bracedOrCtorStyleInitializer();
+ ICPPASTSimpleTypeConstructorExpression result = nodeFactory.newSimpleTypeConstructorExpression(
+ declSpec, initializer);
+ return setRange(result, declSpec, calculateEndOffset(initializer));
}
-
@Override
protected IASTExpression primaryExpression(CastExprCtx ctx) throws EndOfFileException, BacktrackException {
IToken t = null;
@@ -2063,62 +2062,44 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return fdef;
}
-
- /**
- * This method parses a constructor chain ctorinitializer: :
- * meminitializerlist meminitializerlist: meminitializer | meminitializer ,
- * meminitializerlist meminitializer: meminitializerid | ( expressionlist? )
- * meminitializerid: ::? nestednamespecifier? classname identifier
- *
- * @throws BacktrackException
- * request a backtrack
- */
+ /**
+ * ctor-initializer:
+ * : mem-initializer-list
+ * mem-initializer-list:
+ * mem-initializer ...?
+ * mem-initializer ...?, mem-initializer-list
+ * mem-initializer:
+ * mem-initializer-id ( expression-list? )
+ * mem-initializer-id braced-init-list
+ * mem-initializer-id:
+ * ::? nested-name-specifier? class-name
+ * identifier
+ */
protected void ctorInitializer(ICPPASTFunctionDefinition fdef) throws EndOfFileException, BacktrackException {
- consume();
- ctorLoop: for (;;) {
- int offset= LA(1).getOffset();
- IASTName name = qualifiedName(CastExprCtx.eNotBExpr);
-
+ consume(IToken.tCOLON);
+ loop: for(;;) {
+ final int offset= LA(1).getOffset();
+ final IASTName name = qualifiedName(CastExprCtx.eNotBExpr);
+ final IASTInitializer init;
int endOffset;
- IASTExpression expressionList = null;
- switch (LT(1)) {
- case IToken.tLPAREN:
- consume();
-
- if (LT(1) != IToken.tRPAREN)
- expressionList = expression();
-
- switch (LT(1)) {
- case IToken.tRPAREN:
- case IToken.tEOC:
- endOffset = consume().getEndOffset();
- break;
- default:
- throw backtrack;
- }
- break;
- case IToken.tEOC:
- endOffset = consume().getEndOffset();
- break;
- default:
- throw backtrack;
+ if (LT(1) != IToken.tEOC) {
+ init = bracedOrCtorStyleInitializer();
+ endOffset= calculateEndOffset(init);
+ } else {
+ init= null;
+ endOffset= calculateEndOffset(name);
}
-
- ICPPASTConstructorChainInitializer ctorInitializer = nodeFactory.newConstructorChainInitializer(name, expressionList);
+ ICPPASTConstructorChainInitializer ctorInitializer = nodeFactory.newConstructorChainInitializer(name, init);
if (LT(1) == IToken.tELLIPSIS) {
ctorInitializer.setIsPackExpansion(true);
endOffset= consume().getEndOffset();
- }
- setRange(ctorInitializer, offset, endOffset);
- fdef.addMemberInitializer(ctorInitializer);
+ }
+ fdef.addMemberInitializer(setRange(ctorInitializer, offset, endOffset));
- switch (LT(1)) {
- case IToken.tCOMMA:
- consume();
- break;
- case IToken.tLBRACE:
- case IToken.tEOC:
- break ctorLoop;
+ if (LT(1) == IToken.tCOMMA) {
+ consume();
+ } else {
+ break loop;
}
}
}
@@ -2177,6 +2158,15 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
*/
@Override
protected Decl declSpecifierSeq(final DeclarationOptions option) throws BacktrackException, EndOfFileException {
+ return declSpecifierSeq(option.fAllowEmptySpecifier, false);
+ }
+
+ private ICPPASTDeclSpecifier simpleTypeSpecifier() throws BacktrackException, EndOfFileException {
+ Decl d= declSpecifierSeq(false, true);
+ return (ICPPASTDeclSpecifier) d.fDeclSpec1;
+ }
+
+ private Decl declSpecifierSeq(final boolean allowEmpty, final boolean single) throws BacktrackException, EndOfFileException {
int storageClass = IASTDeclSpecifier.sc_unspecified;
int simpleType = IASTSimpleDeclSpecifier.t_unspecified;
int options= 0;
@@ -2362,7 +2352,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (encounteredRawType || encounteredTypename)
break declSpecifiers;
- if (option.fAllowEmptySpecifier && LT(1) != IToken.tCOMPLETION) {
+ if (allowEmpty && LT(1) != IToken.tCOMPLETION) {
if ((options & FORBID_IN_EMPTY_DECLSPEC) == 0 && storageClass == IASTDeclSpecifier.sc_unspecified) {
altResult= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
returnToken= mark();
@@ -2456,10 +2446,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (encounteredRawType && encounteredTypename)
throwBacktrack(LA(1));
+
+ if (single)
+ break declSpecifiers;
}
// check for empty specification
- if (!encounteredRawType && !encounteredTypename && LT(1) != IToken.tEOC && !option.fAllowEmptySpecifier) {
+ if (!encounteredRawType && !encounteredTypename && LT(1) != IToken.tEOC && !allowEmpty) {
throwBacktrack(LA(1));
}
@@ -2590,14 +2583,22 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
switch(lt1) {
case 0:
return dtor1;
+
+ case IToken.tLBRACE:
+ if (option.fAllowBracedInitializer || option == DeclarationOptions.TYPEID_NEW
+ || ASTQueries.findTypeRelevantDeclarator(dtor1) instanceof IASTFunctionDeclarator)
+ return dtor1;
+
+ dtor1= null;
+ throwBacktrack(LA(1));
+ break;
+
case IToken.tCOLON:
// a colon can be used after a type-id in a conditional expression
if (option != DeclarationOptions.CPP_MEMBER && option != DeclarationOptions.GLOBAL)
break;
//$FALL-THROUGH$
-
- case IToken.tLBRACE:
- case IToken.t_throw: case IToken.t_try:
+ case IToken.t_throw: case IToken.t_try:
case IToken.t_const: case IToken.t_volatile:
if (ASTQueries.findTypeRelevantDeclarator(dtor1) instanceof IASTFunctionDeclarator) {
return dtor1;
@@ -2615,7 +2616,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
bt= e;
}
- if (!option.fAllowConstructorInitializer || !canHaveConstructorInitializer(declspec, dtor1)) {
+ if (!option.fAllowCtorStyleInitializer || !canHaveConstructorInitializer(declspec, dtor1)) {
if (bt != null)
throw bt;
return dtor1;
@@ -2734,15 +2735,46 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private IASTDeclarator initDeclarator(DtorStrategy strategy, IASTDeclSpecifier declspec, DeclarationOptions option)
throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
final IASTDeclarator dtor= declarator(strategy, option);
- if (option.fAllowInitializer) {
- if (LTcatchEOF(1) == IToken.tASSIGN && LTcatchEOF(2) == IToken.tLBRACE)
- throw new FoundAggregateInitializer(declspec, dtor);
-
- IASTInitializer initializer= optionalCPPInitializer(dtor, option);
- if (initializer != null) {
- dtor.setInitializer(initializer);
- adjustLength(dtor, initializer);
- }
+ if (option.fAllowInitializer) {
+ final IASTDeclarator typeRelevantDtor = ASTQueries.findTypeRelevantDeclarator(dtor);
+ if (option != DeclarationOptions.PARAMETER && typeRelevantDtor instanceof IASTFunctionDeclarator) {
+ // Function declarations don't have initializers
+ // For member functions we need to consider pure-virtual syntax
+ if (option == DeclarationOptions.CPP_MEMBER && LTcatchEOF(1) == IToken.tASSIGN
+ && LTcatchEOF(2) == IToken.tINTEGER) {
+ consume();
+ IToken t = consume();
+ char[] image = t.getCharImage();
+ if (image.length != 1 || image[0] != '0') {
+ throwBacktrack(t);
+ }
+ ((ICPPASTFunctionDeclarator) typeRelevantDtor).setPureVirtual(true);
+ adjustEndOffset(dtor, t.getEndOffset()); // we can only adjust the offset of the outermost dtor.
+ }
+ } else {
+ if (LTcatchEOF(1) == IToken.tASSIGN && LTcatchEOF(2) == IToken.tLBRACE)
+ throw new FoundAggregateInitializer(declspec, dtor);
+
+ IASTInitializer initializer= optionalInitializer(option);
+ if (initializer != null) {
+ if (initializer instanceof IASTInitializerList
+ && ((IASTInitializerList) initializer).getSize() == 0) {
+ // Avoid ambiguity between constructor with body and variable with initializer
+ switch (LTcatchEOF(1)) {
+ case IToken.tCOMMA:
+ case IToken.tSEMI:
+ case IToken.tRPAREN:
+ break;
+ case 0:
+ throw backtrack;
+ default:
+ throwBacktrack(LA(1));
+ }
+ }
+ dtor.setInitializer(initializer);
+ adjustLength(dtor, initializer);
+ }
+ }
}
return dtor;
}
@@ -2751,112 +2783,175 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected IASTDeclarator addInitializer(FoundAggregateInitializer e, DeclarationOptions option) throws EndOfFileException {
final IASTDeclarator d = e.fDeclarator;
try {
- IASTInitializer i = optionalCPPInitializer(e.fDeclarator, option);
+ IASTInitializer i = optionalInitializer(option);
if (i != null) {
d.setInitializer(i);
((ASTNode) d).setLength(calculateEndOffset(i) - ((ASTNode) d).getOffset());
}
} catch (BacktrackException e1) {
// mstodo add problem node
+ failParse();
}
return d;
}
- protected IASTInitializer optionalCPPInitializer(IASTDeclarator d, DeclarationOptions option) throws EndOfFileException, BacktrackException {
- // handle initializer
+ /**
+ * initializer:
+ * brace-or-equal-initializer
+ * ( expression-list )
+ *
+ * brace-or-equal-initializer:
+ * = initializer-clause
+ * braced-init-list
+ */
+ private IASTInitializer optionalInitializer(DeclarationOptions option) throws EndOfFileException, BacktrackException {
final int lt1= LTcatchEOF(1);
+
+ // = initializer-clause
if (lt1 == IToken.tASSIGN) {
- consume();
- // for member functions we need to consider pure-virtual syntax
- if (option == DeclarationOptions.CPP_MEMBER && LTcatchEOF(1) == IToken.tINTEGER) {
- IASTDeclarator relDtor = ASTQueries.findTypeRelevantDeclarator(d);
- // note the declarator for a member function cannot be ambiguous because it cannot be abstract
- if (relDtor instanceof ICPPASTFunctionDeclarator) {
- // check for pure virtual
- IToken t = consume();
- char[] image = t.getCharImage();
- if (image.length != 1 || image[0] != '0') {
- throwBacktrack(t);
- }
+ int offset= consume().getOffset();
+ IASTInitializerClause initClause = initClause(false);
+ IASTEqualsInitializer initExpr= nodeFactory.newEqualsInitializer(initClause);
+ return setRange(initExpr, offset, calculateEndOffset(initClause));
+ }
- ((ICPPASTFunctionDeclarator) relDtor).setPureVirtual(true);
- adjustEndOffset(d, t.getEndOffset()); // we can only adjust the offset of the outermost dtor.
- return null;
- }
- }
- try {
- return initializerClause(false);
- } catch (EndOfFileException eof) {
- failParse();
- throw eof;
- }
- } else if (option.fAllowConstructorInitializer && lt1 == IToken.tLPAREN) {
- if (d instanceof IASTFunctionDeclarator && d.getNestedDeclarator() == null) {
- // constructor initializer doesn't make sense for a function
- // declarator,
- // we must have an object to initialize, a function doesn't
- // work.
- return null;
- }
- // initializer in constructor
- IToken t = consume(); // EAT IT!
- int o = t.getOffset();
- IASTExpression astExpression = expression();
- if( astExpression == null )
- throwBacktrack( t );
- int l = consumeOrEOC(IToken.tRPAREN).getEndOffset();
- ICPPASTConstructorInitializer result = nodeFactory.newConstructorInitializer(astExpression);
- ((ASTNode) result).setOffsetAndLength(o, l - o);
- return result;
+ // braced-init-list
+ if (option.fAllowBracedInitializer && lt1 == IToken.tLBRACE) {
+ return bracedInitList();
}
+
+ // ( expression-list )
+ if (option.fAllowCtorStyleInitializer && lt1 == IToken.tLPAREN) {
+ return ctorStyleInitializer(false);
+ }
return null;
}
+
+ private IASTInitializer bracedOrCtorStyleInitializer() throws EndOfFileException, BacktrackException {
+ final int lt1= LT(1);
+ if (lt1 == IToken.tLPAREN) {
+ return ctorStyleInitializer(true);
+ }
+ return bracedInitList();
+ }
+ /**
+ * ( expression-list_opt )
+ */
+ private ICPPASTConstructorInitializer ctorStyleInitializer(boolean optionalExpressionList)
+ throws EndOfFileException, BacktrackException {
+ IASTInitializerClause[] initArray;
+ int offset = consume(IToken.tLPAREN).getOffset();
+
+ // ( )
+ if (optionalExpressionList && LT(1) == IToken.tRPAREN) {
+ initArray= IASTExpression.EMPTY_EXPRESSION_ARRAY;
+ } else {
+ final List<IASTInitializerClause> exprList = expressionList();
+ initArray = exprList.toArray(new IASTInitializerClause[exprList.size()]);
+ }
+ int endOffset = consumeOrEOC(IToken.tRPAREN).getEndOffset();
+ return setRange(nodeFactory.newConstructorInitializer(initArray), offset, endOffset);
+ }
+
+ private List<IASTInitializerClause> expressionList() throws EndOfFileException, BacktrackException {
+ return initializerList(false);
+ }
- protected ICPPASTInitializer initializerClause(boolean inAggregateInitializer) throws EndOfFileException,
+ /**
+ * initializer-clause:
+ * assignment-expression
+ * braced-init-list
+ */
+ private IASTInitializerClause initClause(boolean inBraces) throws EndOfFileException,
BacktrackException {
+ // braced-init-list
if (LT(1) == IToken.tLBRACE) {
- return initializerList();
+ return bracedInitList();
}
- // no brace, so try an assignment expression
+ // assignment expression
final BinaryExprCtx ctx = fInTemplateParameterList ? BinaryExprCtx.eTmplID : BinaryExprCtx.eNoTmplID;
IASTExpression assignmentExpression = expression(ExprKind.eAssignment, ctx);
- if (inAggregateInitializer && skipTrivialExpressionsInAggregateInitializers) {
+ if (inBraces && skipTrivialExpressionsInAggregateInitializers) {
if (!ASTQueries.canContainName(assignmentExpression))
return null;
}
-
- ICPPASTInitializerExpression result = nodeFactory.newInitializerExpression(assignmentExpression);
- setRange(result, assignmentExpression);
- return result;
+ return assignmentExpression;
}
- private ICPPASTInitializerList initializerList() throws EndOfFileException, BacktrackException {
- int startingOffset = consume(IToken.tLBRACE).getOffset();
-
+ /**
+ * braced-init-list:
+ * { initializer-list ,opt }
+ * { }
+ */
+ private ICPPASTInitializerList bracedInitList() throws EndOfFileException, BacktrackException {
+ int offset = consume(IToken.tLBRACE).getOffset();
+
+ // { }
+ if (LT(1) == IToken.tRBRACE) {
+ return setRange(nodeFactory.newInitializerList(), offset, consume().getEndOffset());
+ }
+
+ // { initializer-list ,opt }
+ List<IASTInitializerClause> initList= initializerList(true);
+ if (LT(1) == IToken.tCOMMA)
+ consume();
+
+ int endOffset= consumeOrEOC(IToken.tRBRACE).getEndOffset();
ICPPASTInitializerList result = nodeFactory.newInitializerList();
+ for (IASTInitializerClause init : initList) {
+ result.addClause(init);
+ }
+ return setRange(result, offset, endOffset);
+ }
+
+ /**
+ * initializerList:
+ * initializer-clause ...opt
+ * initializer-list , initializer-clause ...opt
+ */
+ private List<IASTInitializerClause> initializerList(boolean inAggregateInit) throws EndOfFileException,
+ BacktrackException {
+ List<IASTInitializerClause> result= null;
// List of initializer clauses
- while (LT(1) != IToken.tRBRACE && LT(1) != IToken.tEOC) {
- // Clause may be null, add to initializer anyways, such that the
- // actual size can be computed.
- ICPPASTInitializer clause = initializerClause(true);
+ loop: for(;;) {
+ // Clause may be null, add to initializer anyways, such that the size can be computed.
+ IASTInitializerClause clause = initClause(inAggregateInit);
if (LT(1) == IToken.tELLIPSIS) {
- clause.setIsPackExpansion(true);
- adjustEndOffset(clause, consume().getEndOffset());
+ final int endOffset = consume(IToken.tELLIPSIS).getEndOffset();
+ if (clause instanceof ICPPASTPackExpandable) {
+ // Mark initializer lists directly as pack expansions
+ ((ICPPASTPackExpandable) clause).setIsPackExpansion(true);
+ adjustEndOffset(clause, endOffset);
+ } else if (clause instanceof IASTExpression){
+ // Wrap pack expanded assignment expressions
+ IASTExpression packExpansion= nodeFactory.newPackExpansionExpression((IASTExpression) clause);
+ clause= setRange(packExpansion, clause, endOffset);
+ }
}
- result.addInitializer(clause);
- if (LT(1) == IToken.tRBRACE || LT(1) == IToken.tEOC)
+ if (result == null) {
+ result= new ArrayList<IASTInitializerClause>();
+ }
+ result.add(clause);
+ if (LT(1) != IToken.tCOMMA)
break;
- consume(IToken.tCOMMA); // Allow for trailing commas
+ switch(LT(2)) {
+ case IToken.tRBRACE:
+ case IToken.tRPAREN:
+ case IToken.tEOC:
+ break loop;
+ }
+ consume(IToken.tCOMMA);
}
- int endOffset = consume().getEndOffset(); // tRBRACE
- setRange(result, startingOffset, endOffset);
+
+ if (result == null)
+ return Collections.emptyList();
+
return result;
}
-
@Override
protected ICPPASTTypeId typeId(DeclarationOptions option) throws EndOfFileException {
if (!canBeTypeSpecifier()) {
@@ -3986,4 +4081,22 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
return for_statement;
}
+
+ @Override
+ protected IASTStatement parseReturnStatement() throws EndOfFileException, BacktrackException {
+ final int offset= consume(IToken.t_return).getOffset(); // t_return
+
+ // Optional expression
+ IASTInitializerClause expr = null;
+ final int lt1 = LT(1);
+ if (lt1 == IToken.tLBRACE) {
+ expr= bracedInitList();
+ } else if (lt1 != IToken.tSEMI) {
+ expr = expression();
+ }
+ // Semicolon
+ final int endOffset= consumeOrEOC(IToken.tSEMI).getEndOffset();
+
+ return setRange(nodeFactory.newReturnStatement(expr), offset, endOffset);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
index fc48735332a..0d16e654ce9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
@@ -41,15 +41,15 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -83,6 +83,7 @@ import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
@@ -554,8 +555,8 @@ public class CPPSemantics {
}
if (parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
parent = parent.getParent();
- IASTExpression exp = ((IASTFunctionCallExpression)parent).getParameterExpression();
- data.setFunctionArguments(exp);
+ IASTInitializerClause[] args = ((IASTFunctionCallExpression)parent).getArguments();
+ data.setFunctionArguments(args);
}
} else if (parent instanceof ICPPASTFieldReference) {
IASTNode grand= parent.getParent();
@@ -565,20 +566,30 @@ public class CPPSemantics {
grand = grand.getParent();
}
if (parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
- IASTExpression exp = ((IASTFunctionCallExpression)parent.getParent()).getParameterExpression();
+ IASTInitializerClause[] exp = ((IASTFunctionCallExpression)parent.getParent()).getArguments();
data.setFunctionArguments(exp);
}
} else if (parent instanceof ICPPASTNamedTypeSpecifier && parent.getParent() instanceof IASTTypeId) {
IASTTypeId typeId = (IASTTypeId) parent.getParent();
if (typeId.getParent() instanceof ICPPASTNewExpression) {
ICPPASTNewExpression newExp = (ICPPASTNewExpression) typeId.getParent();
- IASTExpression init = newExp.getNewInitializer();
- data.setFunctionArguments(init);
+ IASTInitializer init = newExp.getInitializer();
+ if (init == null) {
+ data.setFunctionArguments();
+ } else if (init instanceof ICPPASTConstructorInitializer) {
+ data.setFunctionArguments(((ICPPASTConstructorInitializer) init).getArguments());
+ } else {
+ // mstodo handle braced init list
+ }
}
} else if (parent instanceof ICPPASTConstructorChainInitializer) {
ICPPASTConstructorChainInitializer ctorinit = (ICPPASTConstructorChainInitializer) parent;
- IASTExpression val = ctorinit.getInitializerValue();
- data.setFunctionArguments(val);
+ IASTInitializer init = ctorinit.getInitializer();
+ if (init instanceof ICPPASTConstructorInitializer) {
+ data.setFunctionArguments(((ICPPASTConstructorInitializer) init).getArguments());
+ } else {
+ // mstodo handle braced init list
+ }
}
return data;
@@ -2350,8 +2361,8 @@ public class CPPSemantics {
// target is an object or reference being initialized
IASTDeclarator dtor = (IASTDeclarator) node.getParent();
return CPPVisitor.createType(dtor);
- } else if (prop == IASTInitializerExpression.INITIALIZER_EXPRESSION) {
- IASTInitializerExpression initExp = (IASTInitializerExpression) node.getParent();
+ } else if (prop == IASTEqualsInitializer.INITIALIZER) {
+ IASTEqualsInitializer initExp = (IASTEqualsInitializer) node.getParent();
if (initExp.getParent() instanceof IASTDeclarator) {
IASTDeclarator dtor = (IASTDeclarator) initExp.getParent();
return CPPVisitor.createType(dtor);
@@ -2363,30 +2374,24 @@ public class CPPSemantics {
IASTBinaryExpression binaryExp = (IASTBinaryExpression) node.getParent();
IASTExpression exp = binaryExp.getOperand1();
return exp.getExpressionType();
- } else if (prop == IASTFunctionCallExpression.PARAMETERS ||
- (prop == IASTExpressionList.NESTED_EXPRESSION &&
- node.getParent().getPropertyInParent() == IASTFunctionCallExpression.PARAMETERS)) {
+ } else if (prop == IASTFunctionCallExpression.ARGUMENT) {
// target is a parameter of a function
// if this function call refers to an overloaded function, there is more than one possibility
// for the target type
- IASTFunctionCallExpression fnCall = null;
- int idx = -1;
- if (prop == IASTFunctionCallExpression.PARAMETERS) {
- fnCall = (IASTFunctionCallExpression) node.getParent();
- idx = 0;
- } else {
- IASTExpressionList list = (IASTExpressionList) node.getParent();
- fnCall = (IASTFunctionCallExpression) list.getParent();
- IASTExpression[] exps = list.getExpressions();
- for (int i = 0; i < exps.length; i++) {
- if (exps[i] == node) {
- idx = i;
- break;
- }
- }
- }
+ IASTFunctionCallExpression fnCall = (IASTFunctionCallExpression) node.getParent();
+ int idx = 0;
+ final IASTInitializerClause[] arguments = fnCall.getArguments();
+ for (IASTInitializerClause arg : arguments) {
+ if (arg == node)
+ break;
+ idx++;
+ }
+ if (idx >= arguments.length)
+ return null;
+
IFunctionType[] types = getPossibleFunctions(fnCall);
- if (types == null) return null;
+ if (types == null)
+ return null;
IType[] result = null;
for (int i = 0; i < types.length && types[i] != null; i++) {
IType[] pts = null;
@@ -2596,21 +2601,13 @@ public class CPPSemantics {
public static ICPPFunction findOverloadedOperator(IASTFunctionCallExpression exp, ICPPClassType type) {
char[] name = OverloadableOperator.PAREN.toCharArray();
- IASTExpression param = exp.getParameterExpression();
- IASTExpression[] args;
- if (param instanceof IASTExpressionList) {
- IASTExpression[] actualArgs = ((IASTExpressionList)param).getExpressions();
- ArrayList<IASTExpression> argsToPass = new ArrayList<IASTExpression>(actualArgs.length + 1);
- argsToPass.add(exp.getFunctionNameExpression());
- for (IASTExpression e : actualArgs) {
- argsToPass.add(e);
- }
- args = argsToPass.toArray(new IASTExpression[argsToPass.size()]);
- } else if (param != null) {
- args = new IASTExpression[] { exp.getFunctionNameExpression(), param };
- } else {
- args = new IASTExpression[] { exp.getFunctionNameExpression() };
+ IASTInitializerClause[] args = exp.getArguments();
+ ArrayList<IASTInitializerClause> argsToPass = new ArrayList<IASTInitializerClause>(args.length + 1);
+ argsToPass.add(exp.getFunctionNameExpression());
+ for (IASTInitializerClause e : args) {
+ argsToPass.add(e);
}
+ args = argsToPass.toArray(new IASTInitializerClause[argsToPass.size()]);
return findOverloadedOperator(exp, args, type, name, NonMemberMode.none);
}
@@ -2627,17 +2624,15 @@ public class CPPSemantics {
IASTExpression sizeExpression = new CPPASTTypeIdExpression(IASTTypeIdExpression.op_sizeof, typeId);
sizeExpression.setParent(exp);
- IASTExpression placement = exp.getNewPlacement();
- List<IASTExpression> args = new ArrayList<IASTExpression>();
+ IASTInitializerClause[] placement = exp.getPlacementArguments();
+ List<IASTInitializerClause> args = new ArrayList<IASTInitializerClause>();
args.add(sizeExpression);
- if (placement instanceof IASTExpressionList) {
- for (IASTExpression p : ((IASTExpressionList) placement).getExpressions())
+ if (placement != null) {
+ for (IASTInitializerClause p : placement) {
args.add(p);
- } else if (placement != null) {
- args.add(placement);
- }
-
- IASTExpression[] argArray = args.toArray(new IASTExpression[args.size()]);
+ }
+ }
+ IASTInitializerClause[] argArray = args.toArray(new IASTInitializerClause[args.size()]);
return findOverloadedOperator(exp, argArray, type, op.toCharArray(), NonMemberMode.all);
}
@@ -2758,7 +2753,7 @@ public class CPPSemantics {
}
enum NonMemberMode {none, limited, all}
- private static ICPPFunction findOverloadedOperator(IASTExpression parent, IASTExpression[] args, IType methodLookupType,
+ private static ICPPFunction findOverloadedOperator(IASTExpression parent, IASTInitializerClause[] args, IType methodLookupType,
char[] operatorName, NonMemberMode mode) {
ICPPClassType callToObjectOfClassType= null;
@@ -2820,7 +2815,10 @@ public class CPPSemantics {
// 13.3.1.2.3
// However, if no operand type has class type, only those non-member functions ...
if (mode == NonMemberMode.limited) {
- IType type2= args.length < 2 ? null : getUltimateTypeUptoPointers(args[1].getExpressionType());
+ IType type2= null;
+ if (args.length >= 2 && args[1] instanceof IASTExpression) {
+ type2= getUltimateTypeUptoPointers(((IASTExpression) args[1]).getExpressionType());
+ }
if (funcData.foundItems != null && !(methodLookupType instanceof ICPPClassType) && !(type2 instanceof ICPPClassType)) {
IEnumeration enum1= null;
IEnumeration enum2= null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
index bdc3b98b0ce..42324e7a76e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
@@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
@@ -39,7 +40,6 @@ import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -56,7 +56,6 @@ import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
-import org.eclipse.cdt.core.dom.ast.IASTTypeIdInitializerExpression;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IBasicType;
@@ -106,7 +105,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
@@ -817,26 +815,37 @@ public class CPPVisitor extends ASTQueries {
} else if (parent instanceof ICPPASTTemplateDeclaration) {
return CPPTemplates.getContainingScope(node);
}
- } else if (node instanceof IASTInitializerExpression) {
- IASTNode parent = node.getParent();
- while (!(parent instanceof IASTDeclarator || parent instanceof IASTTypeIdInitializerExpression))
- parent = parent.getParent();
- if(parent instanceof IASTDeclarator) {
- IASTDeclarator dtor = (IASTDeclarator) parent;
- IASTName name = dtor.getName();
- if (name instanceof ICPPASTQualifiedName) {
- IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
- return getContainingScope(ns[ns.length - 1]);
- }
+ } else if (node instanceof IASTInitializer) {
+ if (node instanceof ICPPASTConstructorChainInitializer) {
+ // The name of the member initializer is resolved in the scope of the
+ // owner of the ctor.
+ ICPPASTConstructorChainInitializer initializer = (ICPPASTConstructorChainInitializer) node;
+ IASTFunctionDefinition fdef= (IASTFunctionDefinition) initializer.getParent();
+ IBinding binding = fdef.getDeclarator().getName().resolveBinding();
+ try {
+ return binding.getScope();
+ } catch (DOMException e) {
+ }
+ } else {
+ IASTNode parent = node.getParent();
+ if (parent instanceof IASTDeclarator) {
+ IASTDeclarator dtor = (IASTDeclarator) parent;
+ IASTName name = dtor.getName();
+ if (name instanceof ICPPASTQualifiedName) {
+ IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
+ return getContainingScope(ns[ns.length - 1]);
+ }
+ } else if (parent instanceof ICPPASTConstructorChainInitializer) {
+ // The initializer for the member initializer is resolved in
+ // the body of the ctor.
+ IASTNode temp = getContainingBlockItem(node);
+ if (temp instanceof IASTFunctionDefinition) {
+ IASTCompoundStatement body = (IASTCompoundStatement) ((IASTFunctionDefinition)temp).getBody();
+ return body.getScope();
+ }
+ node= parent;
+ }
}
- } else if (node instanceof ICPPASTConstructorChainInitializer) {
- ICPPASTConstructorChainInitializer initializer = (ICPPASTConstructorChainInitializer) node;
- IASTFunctionDefinition fdef= (IASTFunctionDefinition) initializer.getParent();
- IBinding binding = fdef.getDeclarator().getName().resolveBinding();
- try {
- return binding.getScope();
- } catch (DOMException e) {
- }
} else if (node instanceof IASTExpression) {
IASTNode parent = node.getParent();
if (parent instanceof IASTForStatement) {
@@ -849,27 +858,21 @@ public class CPPVisitor extends ASTQueries {
return ((ICPPASTWhileStatement) parent).getScope();
} else if (parent instanceof IASTCompoundStatement) {
return ((IASTCompoundStatement) parent).getScope();
- } else if (parent instanceof ICPPASTConstructorChainInitializer) {
- IASTNode temp = getContainingBlockItem(parent);
- if (temp instanceof IASTFunctionDefinition) {
- IASTCompoundStatement body = (IASTCompoundStatement) ((IASTFunctionDefinition)temp).getBody();
- return body.getScope();
- }
- } else if (parent instanceof IASTArrayModifier || parent instanceof IASTInitializer) {
+ } else if (parent instanceof IASTArrayModifier) {
IASTNode d = parent.getParent();
- while (!(d instanceof IASTDeclarator || d instanceof IASTTypeIdInitializerExpression)) {
+ while (!(d instanceof IASTDeclarator || d instanceof IASTExpression)) {
d = d.getParent();
}
- if(d instanceof IASTDeclarator) {
- IASTDeclarator dtor = (IASTDeclarator) d;
- while (dtor.getNestedDeclarator() != null)
- dtor = dtor.getNestedDeclarator();
- IASTName name = dtor.getName();
- if (name instanceof ICPPASTQualifiedName) {
- IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
- return getContainingScope(ns[ns.length - 1]);
- }
- }
+ if (d instanceof IASTDeclarator) {
+ IASTDeclarator dtor = (IASTDeclarator) d;
+ while (dtor.getNestedDeclarator() != null)
+ dtor = dtor.getNestedDeclarator();
+ IASTName name = dtor.getName();
+ if (name instanceof ICPPASTQualifiedName) {
+ IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
+ return getContainingScope(ns[ns.length - 1]);
+ }
+ }
} else if (parent instanceof ICPPASTTemplateId &&
node.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) {
node= parent; // template-id
@@ -1433,7 +1436,6 @@ public class CPPVisitor extends ASTQueries {
case KIND_COMPOSITE:
if (prop == IASTNamedTypeSpecifier.NAME ||
prop == ICPPASTPointerToMember.NAME ||
- prop == ICPPASTTypenameExpression.TYPENAME ||
prop == ICPPASTUsingDeclaration.NAME ||
prop == ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.NAME ||
prop == ICPPASTTemplateId.TEMPLATE_NAME ||
@@ -1707,13 +1709,16 @@ public class CPPVisitor extends ASTQueries {
type = createType(type, declarator);
// C++ specification 8.3.4.3 and 8.5.1.4
- IASTInitializer initializer= declarator.getInitializer();
- if (initializer instanceof IASTInitializerList) {
+ IASTNode initClause= declarator.getInitializer();
+ if (initClause instanceof IASTEqualsInitializer) {
+ initClause= ((IASTEqualsInitializer) initClause).getInitializerClause();
+ }
+ if (initClause instanceof IASTInitializerList) {
IType t= SemanticUtil.getNestedType(type, TDEF);
if (t instanceof IArrayType) {
IArrayType at= (IArrayType) t;
if (at.getSize() == null) {
- type= new CPPArrayType(at.getType(), Value.create(((IASTInitializerList) initializer).getSize()));
+ type= new CPPArrayType(at.getType(), Value.create(((IASTInitializerList) initClause).getSize()));
}
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
index 3bc91ff21b5..a6739ee5254 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
@@ -27,12 +27,12 @@ import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
-import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@@ -556,25 +556,7 @@ public class LookupData {
return false;
}
- public void setFunctionArguments(IASTExpression args) {
- IASTExpression[] exprs;
- if (args instanceof IASTExpressionList) {
- ASTNodeProperty prop = args.getPropertyInParent();
- if (prop == IASTFunctionCallExpression.PARAMETERS || prop == ICPPASTNewExpression.NEW_INITIALIZER
- || prop == ICPPASTConstructorChainInitializer.INITIALIZER) {
- exprs= ((IASTExpressionList) args).getExpressions();
- } else {
- exprs= new IASTExpression[] {args};
- }
- } else if (args != null) {
- exprs= new IASTExpression[] { args };
- } else {
- exprs = IASTExpression.EMPTY_EXPRESSION_ARRAY;
- }
- setFunctionArguments(exprs);
- }
-
- public void setFunctionArguments(IASTExpression... exprs) {
+ public void setFunctionArguments(IASTInitializerClause... exprs) {
functionArgs= exprs;
if (exprs.length != 0) {
IASTNode node= exprs[0];
@@ -607,13 +589,17 @@ public class LookupData {
functionArgTypes[i] = SemanticUtil.getSimplifiedType(CPPVisitor.createParameterType(
pdecls[i], true));
}
- } else if (functionArgs instanceof IASTExpression[]) {
- IASTExpression[] exprs= (IASTExpression[]) functionArgs;
+ } else if (functionArgs instanceof IASTInitializerClause[]) {
+ IASTInitializerClause[] exprs= (IASTInitializerClause[]) functionArgs;
functionArgTypes= new IType[exprs.length];
for (int i = 0; i < exprs.length; i++) {
- IASTExpression e = exprs[i];
- IType etype= e.getExpressionType();
- functionArgTypes[i]= SemanticUtil.getSimplifiedType(etype);
+ IASTInitializerClause e = exprs[i];
+ if (e instanceof IASTExpression) {
+ IType etype= ((IASTExpression) e).getExpressionType();
+ functionArgTypes[i]= SemanticUtil.getSimplifiedType(etype);
+ } else {
+ // mstodo handle braced init list
+ }
}
}
}
@@ -623,12 +609,14 @@ public class LookupData {
public BitSet getFunctionArgumentLValues() {
if (functionArgLValues == null) {
functionArgLValues= new BitSet();
- IASTExpression[] args= getFunctionArguments();
+ IASTInitializerClause[] args= getFunctionArguments();
if (args != null) {
for (int i = 0; i < args.length; i++) {
- final IASTExpression arg = args[i];
- if (arg != null) {
- functionArgLValues.set(i, arg.isLValue());
+ final IASTInitializerClause arg = args[i];
+ if (arg instanceof IASTExpression) {
+ functionArgLValues.set(i, ((IASTExpression) arg).isLValue());
+ } else {
+ // mstodo handle braced init list
}
}
} else {
@@ -653,9 +641,9 @@ public class LookupData {
functionArgs= parameters;
}
- public IASTExpression[] getFunctionArguments() {
- if (functionArgs instanceof IASTExpression[])
- return (IASTExpression[]) functionArgs;
+ public IASTInitializerClause[] getFunctionArguments() {
+ if (functionArgs instanceof IASTInitializerClause[])
+ return (IASTInitializerClause[]) functionArgs;
return null;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java
index 75380101325..ce5714b5aa0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -27,7 +27,6 @@ import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
@@ -81,9 +80,6 @@ public class DeclaratorWriter extends NodeWriter {
name.accept(visitor);
IASTInitializer init = getInitializer(declarator);
if(init!= null) {
- if (! (init instanceof ICPPASTConstructorInitializer)) {
- scribe.print(EQUALS);
- }
init.accept(visitor);
}
}
@@ -109,7 +105,6 @@ public class DeclaratorWriter extends NodeWriter {
private void writeInitializer(IASTStandardFunctionDeclarator funcDec) {
IASTInitializer init = getInitializer(funcDec);
if(init != null) {
- scribe.print(EQUALS);
init.accept(visitor);
}
}
@@ -219,7 +214,6 @@ public class DeclaratorWriter extends NodeWriter {
writeArrayModifiers(arrDecl, arrMods);
IASTInitializer initializer = getInitializer(arrDecl);
if(initializer != null) {
- scribe.print(EQUALS);
initializer.accept(visitor);
}
}
@@ -253,7 +247,6 @@ public class DeclaratorWriter extends NodeWriter {
fieldDecl.getBitFieldSize().accept(visitor);
IASTInitializer initializer = getInitializer(fieldDecl);
if(initializer != null) {
- scribe.print(EQUALS);
initializer.accept(visitor);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java
index 33ad9d12aa3..6f3c8f2d40c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -12,8 +12,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
@@ -43,8 +44,8 @@ public class InitializerWriter extends NodeWriter{
}
protected void writeInitializer(IASTInitializer initializer) {
- if (initializer instanceof IASTInitializerExpression) {
- ((IASTInitializerExpression) initializer).getExpression().accept(visitor);
+ if (initializer instanceof IASTEqualsInitializer) {
+ writeEqualsInitializer((IASTEqualsInitializer) initializer);
}else if (initializer instanceof IASTInitializerList) {
writeInitializerList((IASTInitializerList) initializer);
}else if (initializer instanceof ICPPASTConstructorInitializer) {
@@ -59,23 +60,29 @@ public class InitializerWriter extends NodeWriter{
}
+ private void writeEqualsInitializer(IASTEqualsInitializer initializer) {
+ scribe.print(EQUALS);
+ IASTInitializerClause init = initializer.getInitializerClause();
+ if (init != null) {
+ init.accept(visitor);
+ }
+ }
+
private void writeConstructorChainInitializer(ICPPASTConstructorChainInitializer initializer) {
initializer.getMemberInitializerId().accept(visitor);
- scribe.print('(');
- initializer.getInitializerValue().accept(visitor);
- scribe.print(')');
+ initializer.getInitializer().accept(visitor);
}
private void writeInitializerList(IASTInitializerList initList) {
scribe.printLBrace();
- IASTInitializer[] inits = initList.getInitializers();
+ IASTInitializerClause[] inits = initList.getClauses();
writeNodeList(inits);
scribe.printRBrace();
}
private void writeConstructorInitializer(ICPPASTConstructorInitializer ctorInit) {
scribe.print('(');
- ctorInit.getExpression().accept(visitor);
+ writeNodeList(ctorInit.getArguments());
scribe.print(')');
}
@@ -85,7 +92,7 @@ public class InitializerWriter extends NodeWriter{
writeDesignator(designator);
}
scribe.print(EQUALS);
- desigInit.getOperandInitializer().accept(visitor);
+ desigInit.getOperand().accept(visitor);
}
private void writeDesignator(ICASTDesignator designator) {
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
index bfb37a8764e..c80856438f7 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
@@ -40,6 +40,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
@@ -53,7 +54,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
-import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTInitializerList;
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
@@ -408,8 +409,8 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
if (!startNode(node)) { return PROCESS_SKIP; }
try {
- if (node instanceof IASTInitializerExpression) {
- visit((IASTInitializerExpression)node);
+ if (node instanceof IASTEqualsInitializer) {
+ visit((IASTEqualsInitializer) node);
} else if (node instanceof IASTInitializerList) {
visit((IASTInitializerList)node);
} else if (node instanceof ICASTDesignatedInitializer) {
@@ -956,7 +957,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
if (!startNode(node)) { return PROCESS_SKIP; }
try {
// format like a function call
- formatFunctionCallArguments(node.getExpression());
+ formatFunctionCallArguments(node.getArguments());
} finally {
endOfNode(node);
}
@@ -965,10 +966,10 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
private int visit(ICPPASTConstructorChainInitializer node) {
final IASTName member= node.getMemberInitializerId();
- if (member!= null) {
+ final IASTInitializer init= node.getInitializer();
+ if (member!= null && init != null) {
member.accept(this);
- // format like a function call
- formatFunctionCallArguments(node.getInitializerValue());
+ init.accept(this);
} else {
formatRaw(node);
}
@@ -1825,9 +1826,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
private int visit(IASTFunctionCallExpression node) {
node.getFunctionNameExpression().accept(this);
- IASTExpression paramExpr= node.getParameterExpression();
+ IASTInitializerClause[] paramExpr= node.getArguments();
if (peekNextToken() == Token.tIDENTIFIER) {
- skipNode(paramExpr);
+ skipNode(node);
} else {
formatFunctionCallArguments(paramExpr);
}
@@ -1839,17 +1840,10 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
*
* @param argumentExpr the argument expression, may be <code>null</code>
*/
- private void formatFunctionCallArguments(IASTExpression argumentExpr) {
- final List<IASTExpression> expressions;
- if (argumentExpr != null) {
- if (argumentExpr instanceof IASTExpressionList) {
- // argument list
- final IASTExpressionList exprList= (IASTExpressionList)argumentExpr;
- expressions= Arrays.asList(exprList.getExpressions());
- } else {
- // single argument
- expressions= Collections.singletonList(argumentExpr);
- }
+ private void formatFunctionCallArguments(IASTInitializerClause[] args) {
+ final List<IASTInitializerClause> expressions;
+ if (args != null) {
+ expressions= Arrays.asList(args);
} else {
// no arguments
expressions= Collections.emptyList();
@@ -1941,10 +1935,11 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
return PROCESS_SKIP;
}
- private int visit(IASTInitializerExpression node) {
+ private int visit(IASTEqualsInitializer node) {
if (node.getPropertyInParent() == IASTInitializerList.NESTED_INITIALIZER) {
+ assert false;
// nested initializer expression, no need to apply extra alignment
- node.getExpression().accept(this);
+ // node.getExpression().accept(this);
} else {
// declaration initializer
Alignment expressionAlignment= scribe.createAlignment(
@@ -1960,7 +1955,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
try {
scribe.alignFragment(expressionAlignment, 0);
- node.getExpression().accept(this);
+ node.getInitializerClause().accept(this);
ok = true;
} catch (AlignmentException e) {
@@ -1975,7 +1970,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
private int visit(IASTInitializerList node) {
scribe.printComment();
- final List<IASTInitializer> initializers = Arrays.asList(node.getInitializers());
+ final List<IASTInitializerClause> initializers = Arrays.asList(node.getClauses());
if (initializers.isEmpty() && preferences.keep_empty_initializer_list_on_one_line) {
scribe.printNextToken(Token.tLBRACE, preferences.insert_space_before_opening_brace_in_initializer_list);
scribe.printNextToken(Token.tRBRACE, preferences.insert_space_between_empty_braces_in_initializer_list);
@@ -2071,7 +2066,6 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
}
operand.accept(this);
break;
- case IASTUnaryExpression.op_typeof:
case IASTUnaryExpression.op_alignOf:
default:
int operatorToken= peekNextToken();
@@ -2277,9 +2271,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
scribe.space();
// placement
- final IASTExpression newPlacement= node.getNewPlacement();
+ final IASTInitializerClause[] newPlacement= node.getPlacementArguments();
if (newPlacement != null) {
- formatParenthesizedExpression(newPlacement);
+ formatFunctionCallArguments(newPlacement);
}
// type-id
@@ -2295,9 +2289,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
}
// initializer
- final IASTExpression newInitializer= node.getNewInitializer();
- if (newInitializer != null || peekNextToken() == Token.tLPAREN) {
- formatFunctionCallArguments(newInitializer);
+ final IASTInitializer newInitializer= node.getInitializer();
+ if (newInitializer != null) {
+ visit(newInitializer);
}
return PROCESS_SKIP;
}
@@ -2324,6 +2318,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
}
private int visit(ICPPASTSimpleTypeConstructorExpression node) {
+ // tletodo The first part of the expression can consist of multiple tokens
scribe.printNextToken(peekNextToken());
final IASTExpression operand= node.getInitialValue();
formatParenthesizedExpression(operand);
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOParser64.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOParser64.java
index fdd2b895f52..36c3ea43c2a 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOParser64.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOParser64.java
@@ -118,7 +118,6 @@ public class MachOParser64 extends AbstractCExtension implements IBinaryParser {
return cppfilt;
}
- @SuppressWarnings("deprecation")
protected IPath getCPPFiltPath() {
ICConfigExtensionReference ref = getConfigExtensionReference();
String value = ref.getExtensionData("c++filt"); //$NON-NLS-1$

Back to the top