Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-04-10 15:17:12 +0000
committerMarkus Schorn2008-04-10 15:17:12 +0000
commit3a72e413b238a7011515404339bf9b9977f0a897 (patch)
tree9f40cedcaa65a919cba156cc982415753f08c949 /core/org.eclipse.cdt.core/parser
parent68059d36750738ede1e3c44c3d146b46764db3db (diff)
downloadorg.eclipse.cdt-3a72e413b238a7011515404339bf9b9977f0a897.tar.gz
org.eclipse.cdt-3a72e413b238a7011515404339bf9b9977f0a897.tar.xz
org.eclipse.cdt-3a72e413b238a7011515404339bf9b9977f0a897.zip
Differentiating typeid-nodes from typeof-nodes for unary expressions, bug 162470.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUnaryExpression.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/IGNUASTUnaryExpression.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java210
4 files changed, 108 insertions, 147 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java
index 3700f55b7ad..51ee0f0f33c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java
@@ -90,9 +90,33 @@ public interface IASTUnaryExpression extends IASTExpression {
public static final int op_bracketedPrimary = 11;
/**
+ * for c++, only. <code>op_throw</code> throw exp
+ */
+ public static final int op_throw = 12;
+
+ /**
+ * for c++, only. <code>op_typeid</code> = typeid( exp )
+ */
+ public static final int op_typeid = 13;
+
+ /**
+ * for gnu parsers, only. <code>op_typeof</code> is used for typeof( unaryExpression ) type
+ * expressions.
+ */
+ public static final int op_typeof = 14;
+
+ /**
+ * for gnu parsers, only. <code>op_alignOf</code> is used for __alignOf( unaryExpression ) type
+ * expressions.
+ */
+ public static final int op_alignOf = 15;
+
+ /**
* <code>op_last</code> is made available for subclasses.
+ * @deprecated all constants must be defined in this interface
*/
- public static final int op_last = op_bracketedPrimary;
+ @Deprecated
+ public static final int op_last = op_alignOf;
/**
* Get the operator/kind.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUnaryExpression.java
index 4eed08c0c4b..d2104044bc0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUnaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTUnaryExpression.java
@@ -20,16 +20,16 @@ public interface ICPPASTUnaryExpression extends IASTUnaryExpression {
/**
* <code>op_throw</code> throw exp
*/
- public static final int op_throw = IASTUnaryExpression.op_last + 1;
+ public static final int op_throw = IASTUnaryExpression.op_throw;
/**
* <code>op_typeid</code> = typeid( exp )
*/
- public static final int op_typeid = IASTUnaryExpression.op_last + 2;
+ public static final int op_typeid = IASTUnaryExpression.op_typeid;
/**
- * <code>op_last</code> is provided for subinterfaces.
+ * @deprecated all constants to be defined in {@link IASTUnaryExpression}
*/
- public static final int op_last = op_typeid;
-
+ @Deprecated
+ public static final int op_last = IASTUnaryExpression.op_last;
}
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 6578842d487..e53696427c4 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
@@ -24,16 +24,17 @@ public interface IGNUASTUnaryExpression extends IASTUnaryExpression {
* <code>op_typeof</code> is used for typeof( unaryExpression ) type
* expressions.
*/
- public static final int op_typeof = IASTUnaryExpression.op_last + 1;
+ public static final int op_typeof = IASTUnaryExpression.op_typeof;
/**
* <code>op_alignOf</code> is used for __alignOf( unaryExpression ) type
* expressions.
*/
- public static final int op_alignOf = IASTUnaryExpression.op_last + 2;
+ public static final int op_alignOf = IASTUnaryExpression.op_alignOf;
/**
- * <code>op_last</code> is available for sub-interfaces.
+ * @deprecated all constants to be defined in {@link IASTUnaryExpression}.
*/
- public static final int op_last = op_alignOf;
+ @Deprecated
+ public static final int op_last = IASTUnaryExpression.op_last;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
index b0638bbb40d..4d4c9e34b34 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java
@@ -231,163 +231,99 @@ public class ExpressionWriter extends NodeWriter{
private boolean isPrefixExpression(IASTUnaryExpression unExp) {
int unaryExpressionType = unExp.getOperator();
- if (unaryExpressionType <= IASTUnaryExpression.op_last) {
- switch (unaryExpressionType) {
- case IASTUnaryExpression.op_prefixDecr:
- case IASTUnaryExpression.op_prefixIncr:
- case IASTUnaryExpression.op_plus:
- case IASTUnaryExpression.op_minus:
- case IASTUnaryExpression.op_star:
- case IASTUnaryExpression.op_amper:
- case IASTUnaryExpression.op_tilde:
- case IASTUnaryExpression.op_not:
- case IASTUnaryExpression.op_sizeof:
- case IASTUnaryExpression.op_bracketedPrimary:
+ switch (unaryExpressionType) {
+ case IASTUnaryExpression.op_prefixDecr:
+ case IASTUnaryExpression.op_prefixIncr:
+ case IASTUnaryExpression.op_plus:
+ case IASTUnaryExpression.op_minus:
+ case IASTUnaryExpression.op_star:
+ case IASTUnaryExpression.op_amper:
+ case IASTUnaryExpression.op_tilde:
+ case IASTUnaryExpression.op_not:
+ case IASTUnaryExpression.op_sizeof:
+ case IASTUnaryExpression.op_bracketedPrimary:
+ case ICPPASTUnaryExpression.op_throw:
+ case ICPPASTUnaryExpression.op_typeid:
+ case IGNUASTUnaryExpression.op_alignOf:
+ case IGNUASTUnaryExpression.op_typeof:
+ return true;
- return true;
-
- default:
- return false;
- }
- }
- if (unExp instanceof ICPPASTUnaryExpression) {
- switch (unaryExpressionType) {
- case ICPPASTUnaryExpression.op_throw:
- case ICPPASTUnaryExpression.op_typeid:
- return true;
- default:
- return false;
- }
- }else if (unExp instanceof IGNUASTUnaryExpression) {
- switch (unaryExpressionType) {
- case IGNUASTUnaryExpression.op_alignOf:
- case IGNUASTUnaryExpression.op_typeof:
- return true;
- default:
- return false;
- }
+ default:
+ return false;
}
- return false;
}
private boolean isPostfixExpression(IASTUnaryExpression unExp) {
int unaryExpressionType = unExp.getOperator();
- if (unaryExpressionType <= IASTUnaryExpression.op_last) {
- switch (unaryExpressionType) {
- case IASTUnaryExpression.op_postFixDecr:
- case IASTUnaryExpression.op_postFixIncr:
- case IASTUnaryExpression.op_bracketedPrimary:
+ switch (unaryExpressionType) {
+ case IASTUnaryExpression.op_postFixDecr:
+ case IASTUnaryExpression.op_postFixIncr:
+ case IASTUnaryExpression.op_bracketedPrimary:
+ case ICPPASTUnaryExpression.op_typeid:
+ case IGNUASTUnaryExpression.op_alignOf:
+ case IGNUASTUnaryExpression.op_typeof:
+ return true;
- return true;
-
- default:
- return false;
- }
- }
- if (unExp instanceof ICPPASTUnaryExpression) {
- return unaryExpressionType == ICPPASTUnaryExpression.op_typeid;
- }else if (unExp instanceof IGNUASTUnaryExpression) {
- switch (unaryExpressionType) {
- case IGNUASTUnaryExpression.op_alignOf:
- case IGNUASTUnaryExpression.op_typeof:
- return true;
- default:
- return false;
- }
+ default:
+ return false;
}
- return false;
}
private String getPrefixOperator(IASTUnaryExpression unExp) {
int unaryExpressionType = unExp.getOperator();
- if (unaryExpressionType <= IASTUnaryExpression.op_last) {
- switch (unaryExpressionType) {
- case IASTUnaryExpression.op_prefixDecr:
- return DECREMENT_OP;
- case IASTUnaryExpression.op_prefixIncr:
- return INCREMENT_OP;
- case IASTUnaryExpression.op_plus:
- return UNARY_PLUS_OP;
- case IASTUnaryExpression.op_minus:
- return UNARY_MINUS_OP;
- case IASTUnaryExpression.op_star:
- return STAR_OP;
- case IASTUnaryExpression.op_amper:
- return AMPERSAND_OP;
- case IASTUnaryExpression.op_tilde:
- return TILDE_OP;
- case IASTUnaryExpression.op_not:
- return NOT_OP;
- case IASTUnaryExpression.op_sizeof:
- return SIZEOF_OP;
- case IASTUnaryExpression.op_bracketedPrimary:
- return OPEN_BRACKET_OP;
- default:
- System.err.println("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
- throw new IllegalArgumentException("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
- }
- }
- if (unExp instanceof ICPPASTUnaryExpression) {
- switch (unaryExpressionType) {
- case ICPPASTUnaryExpression.op_throw:
- return THROW;
- case ICPPASTUnaryExpression.op_typeid:
- return TYPEID_OP;
- default:
- System.err.println("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
- throw new IllegalArgumentException("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
- }
- }else if (unExp instanceof IGNUASTUnaryExpression) {
- switch (unaryExpressionType) {
- case IGNUASTUnaryExpression.op_alignOf:
- return ALIGNOF_OP;
- case IGNUASTUnaryExpression.op_typeof:
- return TYPEOF_OP;
- default:
- System.err.println("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
- throw new IllegalArgumentException("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
- }
- }
- System.err.println("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
+ switch (unaryExpressionType) {
+ case IASTUnaryExpression.op_prefixDecr:
+ return DECREMENT_OP;
+ case IASTUnaryExpression.op_prefixIncr:
+ return INCREMENT_OP;
+ case IASTUnaryExpression.op_plus:
+ return UNARY_PLUS_OP;
+ case IASTUnaryExpression.op_minus:
+ return UNARY_MINUS_OP;
+ case IASTUnaryExpression.op_star:
+ return STAR_OP;
+ case IASTUnaryExpression.op_amper:
+ return AMPERSAND_OP;
+ case IASTUnaryExpression.op_tilde:
+ return TILDE_OP;
+ case IASTUnaryExpression.op_not:
+ return NOT_OP;
+ case IASTUnaryExpression.op_sizeof:
+ return SIZEOF_OP;
+ case IASTUnaryExpression.op_bracketedPrimary:
+ return OPEN_BRACKET_OP;
+ case ICPPASTUnaryExpression.op_throw:
+ return THROW;
+ case ICPPASTUnaryExpression.op_typeid:
+ return TYPEID_OP;
+ case IGNUASTUnaryExpression.op_alignOf:
+ return ALIGNOF_OP;
+ case IGNUASTUnaryExpression.op_typeof:
+ return TYPEOF_OP;
+ default:
+ System.err.println("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
throw new IllegalArgumentException("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
+ }
}
private String getPostfixOperator(IASTUnaryExpression unExp) {
int unaryExpressionType = unExp.getOperator();
- if (unaryExpressionType <= IASTUnaryExpression.op_last) {
- switch (unaryExpressionType) {
- case IASTUnaryExpression.op_postFixDecr:
- return DECREMENT_OP;
- case IASTUnaryExpression.op_postFixIncr:
- return INCREMENT_OP;
- case IASTUnaryExpression.op_bracketedPrimary:
- return CLOSING_BRACKET_OP;
- default:
- System.err.println("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
- throw new IllegalArgumentException("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
- }
- }
- if (unExp instanceof ICPPASTUnaryExpression) {
- switch (unaryExpressionType) {
- case ICPPASTUnaryExpression.op_typeid:
- return CLOSING_BRACKET_OP;
- default:
- System.err.println("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
- throw new IllegalArgumentException("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
- }
- }else if (unExp instanceof IGNUASTUnaryExpression) {
- switch (unaryExpressionType) {
- case IGNUASTUnaryExpression.op_alignOf:
- case IGNUASTUnaryExpression.op_typeof:
- return CLOSING_BRACKET_OP;
- default:
- System.err.println("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
+ switch (unaryExpressionType) {
+ case IASTUnaryExpression.op_postFixDecr:
+ return DECREMENT_OP;
+ case IASTUnaryExpression.op_postFixIncr:
+ return INCREMENT_OP;
+ case ICPPASTUnaryExpression.op_typeid:
+ return CLOSING_BRACKET_OP;
+ case IASTUnaryExpression.op_bracketedPrimary:
+ case IGNUASTUnaryExpression.op_alignOf:
+ case IGNUASTUnaryExpression.op_typeof:
+ return CLOSING_BRACKET_OP;
+ default:
+ System.err.println("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
throw new IllegalArgumentException("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
- }
}
- System.err.println("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
- throw new IllegalArgumentException("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
}
private void writeBinaryExpression(IASTBinaryExpression binExp) {

Back to the top