1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2010-03-29 04:27:20 +00:00
parent c602341aad
commit 666817a093
5 changed files with 108 additions and 101 deletions

View file

@ -40,5 +40,4 @@ public interface ICPPASTFieldReference extends IASTFieldReference, IASTImplicitN
* @since 5.1
*/
public ICPPASTFieldReference copy();
}

View file

@ -42,7 +42,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
private IType type;
private ICPPFunction overload= UNINITIALIZED_FUNCTION;
private IASTImplicitName[] implicitNames = null;
public CPPASTBinaryExpression() {
}
@ -86,7 +86,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
public void setOperand1(IASTExpression expression) {
assertNotFrozen();
operand1 = expression;
operand1 = expression;
if (expression != null) {
expression.setParent(this);
expression.setPropertyInParent(OPERAND_ONE);
@ -106,19 +106,23 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
setInitOperand2(expression);
}
/**
* @see org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner#getImplicitNames()
*/
public IASTImplicitName[] getImplicitNames() {
if (implicitNames == null) {
ICPPFunction overload = getOverload();
if (overload == null)
return implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this);
operatorName.setBinding(overload);
operatorName.setOperator(true);
operatorName.computeOperatorOffsets(operand1, true);
implicitNames = new IASTImplicitName[] { operatorName };
if (overload == null) {
implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
} else {
CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this);
operatorName.setBinding(overload);
operatorName.setOperator(true);
operatorName.computeOperatorOffsets(operand1, true);
implicitNames = new IASTImplicitName[] { operatorName };
}
}
return implicitNames;
}
@ -135,21 +139,20 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
default : break;
}
}
if (operand1 != null && !operand1.accept(action))
return false;
if (action.shouldVisitImplicitNames) {
for (IASTImplicitName name : getImplicitNames()) {
if (!name.accept(action))
return false;
}
}
if (operand2 != null && !operand2.accept(action))
return false;
if (action.shouldVisitExpressions && action.leave(this) == ASTVisitor.PROCESS_ABORT)
return false;
@ -173,9 +176,9 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
if (stack.fState == 0) {
if (action.shouldVisitExpressions) {
switch (action.visit(expr)) {
case ASTVisitor.PROCESS_ABORT :
case ASTVisitor.PROCESS_ABORT :
return false;
case ASTVisitor.PROCESS_SKIP:
case ASTVisitor.PROCESS_SKIP:
stack= stack.fNext;
continue;
}
@ -188,7 +191,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
stack= n;
continue;
}
if (op1 != null && !op1.accept(action))
if (op1 != null && !op1.accept(action))
return false;
}
if (stack.fState == 1) {
@ -199,19 +202,19 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
}
}
stack.fState= 2;
IASTExpression op2 = expr.getOperand2();
if (op2 instanceof IASTBinaryExpression) {
N n= new N((IASTBinaryExpression) op2);
n.fNext= stack;
stack= n;
continue;
}
if (op2 != null && !op2.accept(action))
}
if (op2 != null && !op2.accept(action))
return false;
}
if (action.shouldVisitExpressions && action.leave(expr) == ASTVisitor.PROCESS_ABORT)
if (action.shouldVisitExpressions && action.leave(expr) == ASTVisitor.PROCESS_ABORT)
return false;
stack= stack.fNext;
@ -246,7 +249,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
return overload = CPPSemantics.findOverloadedOperator(this);
}
public boolean isLValue() {
ICPPFunction op = getOverload();
if (op != null) {
@ -329,8 +332,8 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
case ICPPASTBinaryExpression.op_pmdot:
if (type2 instanceof ICPPPointerToMemberType) {
return ((ICPPPointerToMemberType) type2).getType();
}
return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, getRawSignature().toCharArray());
}
return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, getRawSignature().toCharArray());
}
return type1;
}

View file

@ -25,14 +25,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpression {
private IASTExpression operand;
private boolean isGlobal;
private boolean isVectored;
private IASTImplicitName[] implicitNames = null;
public CPPASTDeleteExpression() {
}
@ -82,17 +80,17 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
public boolean isVectored() {
return isVectored;
}
/**
* Try to resolve both the destructor and operator delete.
*/
public IASTImplicitName[] getImplicitNames() {
if(implicitNames == null) {
if (implicitNames == null) {
List<IASTImplicitName> names = new ArrayList<IASTImplicitName>();
if(!isVectored) {
if (!isVectored) {
ICPPFunction destructor = CPPSemantics.findDestructor(this);
if(destructor != null) {
if (destructor != null) {
CPPASTImplicitName destructorName = new CPPASTImplicitName(destructor.getNameCharArray(), this);
destructorName.setBinding(destructor);
destructorName.computeOperatorOffsets(operand, false);
@ -100,9 +98,9 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
}
}
if(!isGlobal) {
if (!isGlobal) {
ICPPFunction deleteOperator = CPPSemantics.findOverloadedOperator(this);
if(deleteOperator != null) {
if (deleteOperator != null) {
CPPASTImplicitName deleteName = new CPPASTImplicitName(deleteOperator.getNameCharArray(), this);
deleteName.setOperator(true);
deleteName.setBinding(deleteOperator);
@ -111,7 +109,7 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
}
}
if(names.isEmpty())
if (names.isEmpty())
implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
else
implicitNames = names.toArray(new IASTImplicitName[names.size()]);
@ -120,35 +118,36 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
return implicitNames;
}
@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;
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(action.shouldVisitImplicitNames) {
if (action.shouldVisitImplicitNames) {
for(IASTImplicitName name : getImplicitNames()) {
if(!name.accept(action)) return false;
if (!name.accept(action))
return false;
}
}
if( operand != null ) if( !operand.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 (operand != null && !operand.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 IType getExpressionType() {
return CPPSemantics.VOID_TYPE;
}

View file

@ -63,7 +63,7 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
copy.setIsNewTypeId(isNewTypeId);
if (placement != null) {
IASTInitializerClause[] plcmt = new IASTInitializerClause[placement.length];
for (int i=0; i<placement.length; i++) {
for (int i= 0; i < placement.length; i++) {
plcmt[i]= placement[i].copy();
}
copy.setPlacementArguments(plcmt);
@ -133,13 +133,15 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
isNewTypeId = value;
}
/**
* @see org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner#getImplicitNames()
*/
public IASTImplicitName[] getImplicitNames() {
if(implicitNames == null) {
if (implicitNames == null) {
ICPPFunction operatorFunction = CPPSemantics.findOverloadedOperator(this);
if(operatorFunction == null) {
if (operatorFunction == null) {
implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
}
else {
} else {
CPPASTImplicitName operatorName = new CPPASTImplicitName(operatorFunction.getNameCharArray(), this);
operatorName.setOperator(true);
operatorName.setBinding(operatorFunction);
@ -150,8 +152,7 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
return implicitNames;
}
/**
* Returns true if this expression is allocating an array.
* @since 5.1
@ -163,18 +164,18 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
@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;
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(action.shouldVisitImplicitNames) {
if (action.shouldVisitImplicitNames) {
for(IASTImplicitName name : getImplicitNames()) {
if(!name.accept(action)) return false;
if (!name.accept(action)) return false;
}
}
@ -190,11 +191,11 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
if (initializer != null && !initializer.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) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true;
default: break;
}
}
return true;

View file

@ -50,10 +50,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpression, IASTAmbiguityParent {
private int op;
private IASTExpression operand;
private ICPPFunction overload = UNINITIALIZED_FUNCTION;
private IASTImplicitName[] implicitNames = null;
public CPPASTUnaryExpression() {
}
@ -89,25 +89,29 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
expression.setPropertyInParent(OPERAND);
}
}
public boolean isPostfixOperator() {
return op == op_postFixDecr || op == op_postFixIncr;
}
/**
* @see org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner#getImplicitNames()
*/
public IASTImplicitName[] getImplicitNames() {
if (implicitNames == null) {
ICPPFunction overload = getOverload();
if (overload == null)
return implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this);
operatorName.setOperator(true);
operatorName.setBinding(overload);
operatorName.computeOperatorOffsets(operand, isPostfixOperator());
implicitNames = new IASTImplicitName[] { operatorName };
if (overload == null) {
implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
} else {
CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this);
operatorName.setOperator(true);
operatorName.setBinding(overload);
operatorName.computeOperatorOffsets(operand, isPostfixOperator());
implicitNames = new IASTImplicitName[] { operatorName };
}
}
return implicitNames;
return implicitNames;
}
@Override
@ -116,28 +120,29 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true;
default : break;
default: break;
}
}
final boolean isPostfix = isPostfixOperator();
if (!isPostfix && action.shouldVisitImplicitNames) {
if (!isPostfix && action.shouldVisitImplicitNames) {
for (IASTImplicitName name : getImplicitNames()) {
if (!name.accept(action))
return false;
}
}
if (operand != null && !operand.accept(action))
return false;
if (isPostfix && action.shouldVisitImplicitNames) {
if (isPostfix && action.shouldVisitImplicitNames) {
for (IASTImplicitName name : getImplicitNames()) {
if (!name.accept(action)) return false;
if (!name.accept(action))
return false;
}
}
if (action.shouldVisitExpressions) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
@ -196,7 +201,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
}
return null;
}
public IType getExpressionType() {
final int op= getOperator();
switch (op) {
@ -221,7 +226,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
IType type= operand.getExpressionType();
type = SemanticUtil.getNestedType(type, TDEF | REF);
return new CPPPointerType(type);
}
}
if (op == op_star) {
IType type= operand.getExpressionType();
@ -238,7 +243,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
return CPPUnknownClass.createUnnamedInstance();
}
return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, this.getRawSignature().toCharArray());
}
}
IType origType= operand.getExpressionType();
IType type = SemanticUtil.getUltimateTypeUptoPointers(origType);
@ -265,7 +270,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
}
return origType;
}
public boolean isLValue() {
ICPPFunction op = getOverload();
if (op != null) {