mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36:01 +02:00
Differentiating typeid-nodes from typeof-nodes.
This commit is contained in:
parent
3c104b3f4c
commit
bac604f82e
4 changed files with 51 additions and 35 deletions
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -21,9 +22,28 @@ public interface IASTTypeIdExpression extends IASTExpression {
|
||||||
public static final int op_sizeof = 0;
|
public static final int op_sizeof = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>op_last</code> defined for sub-interfaces to extend.
|
* For c++, only.
|
||||||
*/
|
*/
|
||||||
public static final int op_last = op_sizeof;
|
public static final int op_typeid = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For gnu-parsers, only.
|
||||||
|
* <code>op_alignOf</code> is used for __alignOf( typeId ) type expressions.
|
||||||
|
*/
|
||||||
|
public static final int op_alignof = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For gnu-parsers, only.
|
||||||
|
* <code>op_typeof</code> is used for typeof( typeId ) type expressions.
|
||||||
|
*/
|
||||||
|
public static final int op_typeof = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated constants should be declared here, to avoid using the same constant in different
|
||||||
|
* interfaces.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final int op_last = op_alignof;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the operator for the expression.
|
* Get the operator for the expression.
|
||||||
|
@ -52,8 +72,6 @@ public interface IASTTypeIdExpression extends IASTExpression {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type Id.
|
* Get the type Id.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public IASTTypeId getTypeId();
|
public IASTTypeId getTypeId();
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
@ -17,7 +18,11 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||||
*/
|
*/
|
||||||
public interface ICPPASTTypeIdExpression extends IASTTypeIdExpression {
|
public interface ICPPASTTypeIdExpression extends IASTTypeIdExpression {
|
||||||
|
|
||||||
public static final int op_typeid = IASTTypeIdExpression.op_last + 1;
|
public static final int op_typeid = IASTTypeIdExpression.op_typeid;
|
||||||
|
|
||||||
public static final int op_last = op_typeid;
|
/**
|
||||||
|
* @deprecated all constants should be declared in {@link IASTTypeIdExpression}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final int op_last = IASTTypeIdExpression.op_last;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.gnu;
|
package org.eclipse.cdt.core.dom.ast.gnu;
|
||||||
|
|
||||||
|
@ -23,17 +24,17 @@ public interface IGNUASTTypeIdExpression extends IASTTypeIdExpression {
|
||||||
/**
|
/**
|
||||||
* <code>op_typeof</code> is used for typeof( typeId ) type expressions.
|
* <code>op_typeof</code> is used for typeof( typeId ) type expressions.
|
||||||
*/
|
*/
|
||||||
public static final int op_typeof = IASTTypeIdExpression.op_last + 1;
|
public static final int op_typeof = IASTTypeIdExpression.op_typeof;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>op_alignOf</code> is used for __alignOf( typeId ) type
|
* <code>op_alignOf</code> is used for __alignOf( typeId ) type
|
||||||
* expressions.
|
* expressions.
|
||||||
*/
|
*/
|
||||||
public static final int op_alignof = IASTTypeIdExpression.op_last + 2;
|
public static final int op_alignof = IASTTypeIdExpression.op_alignof;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>op_last</code> is available for sub-interfaces.
|
* @deprecated all constants must be declared in {@link IASTTypeIdExpression}
|
||||||
*/
|
*/
|
||||||
public static final int op_last = op_alignof;
|
@Deprecated
|
||||||
|
public static final int op_last = IASTTypeIdExpression.op_last;
|
||||||
}
|
}
|
||||||
|
|
|
@ -568,24 +568,16 @@ public class ExpressionWriter extends NodeWriter{
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTypeIdExp(IASTTypeIdExpression typeIdExp) {
|
private String getTypeIdExp(IASTTypeIdExpression typeIdExp) {
|
||||||
int type = typeIdExp.getOperator();
|
final int type = typeIdExp.getOperator();
|
||||||
if (type <= IASTTypeIdExpression.op_last) {
|
switch(type) {
|
||||||
if(type == IASTTypeIdExpression.op_sizeof) {
|
case IASTTypeIdExpression.op_sizeof:
|
||||||
return SIZEOF_OP + "("; //$NON-NLS-1$
|
return SIZEOF_OP + "("; //$NON-NLS-1$
|
||||||
}
|
case ICPPASTTypeIdExpression.op_typeid:
|
||||||
}else {
|
return TYPEID_OP;
|
||||||
if (typeIdExp instanceof ICPPASTTypeIdExpression) {
|
case IGNUASTTypeIdExpression.op_alignof:
|
||||||
if(type == ICPPASTTypeIdExpression.op_typeid) {
|
return ALIGNOF_OP + "("; //$NON-NLS-1$
|
||||||
return TYPEID_OP;
|
case IGNUASTTypeIdExpression.op_typeof:
|
||||||
}
|
return TYPEOF_OP;
|
||||||
}else if (typeIdExp instanceof IGNUASTTypeIdExpression) {
|
|
||||||
switch (type) {//TODO HSR Emanuel: check if there can't be GNUTypeIdExpressions here, see #162470
|
|
||||||
case IGNUASTTypeIdExpression.op_alignof:
|
|
||||||
return ALIGNOF_OP + "("; //$NON-NLS-1$
|
|
||||||
case IGNUASTTypeIdExpression.op_typeof:
|
|
||||||
return TYPEOF_OP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Unknown TypeId Type"); //$NON-NLS-1$
|
throw new IllegalArgumentException("Unknown TypeId Type"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue