1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 03:45:35 +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 * @since 5.1
*/ */
public ICPPASTFieldReference copy(); public ICPPASTFieldReference copy();
} }

View file

@ -42,7 +42,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
private IType type; private IType type;
private ICPPFunction overload= UNINITIALIZED_FUNCTION; private ICPPFunction overload= UNINITIALIZED_FUNCTION;
private IASTImplicitName[] implicitNames = null; private IASTImplicitName[] implicitNames = null;
public CPPASTBinaryExpression() { public CPPASTBinaryExpression() {
} }
@ -86,7 +86,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
public void setOperand1(IASTExpression expression) { public void setOperand1(IASTExpression expression) {
assertNotFrozen(); assertNotFrozen();
operand1 = expression; operand1 = expression;
if (expression != null) { if (expression != null) {
expression.setParent(this); expression.setParent(this);
expression.setPropertyInParent(OPERAND_ONE); expression.setPropertyInParent(OPERAND_ONE);
@ -106,19 +106,23 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
setInitOperand2(expression); setInitOperand2(expression);
} }
/**
* @see org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner#getImplicitNames()
*/
public IASTImplicitName[] getImplicitNames() { public IASTImplicitName[] getImplicitNames() {
if (implicitNames == null) { if (implicitNames == null) {
ICPPFunction overload = getOverload(); ICPPFunction overload = getOverload();
if (overload == null) if (overload == null) {
return implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY; implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
} else {
CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this); CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this);
operatorName.setBinding(overload); operatorName.setBinding(overload);
operatorName.setOperator(true); operatorName.setOperator(true);
operatorName.computeOperatorOffsets(operand1, true); operatorName.computeOperatorOffsets(operand1, true);
implicitNames = new IASTImplicitName[] { operatorName }; implicitNames = new IASTImplicitName[] { operatorName };
}
} }
return implicitNames; return implicitNames;
} }
@ -135,21 +139,20 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
default : break; default : break;
} }
} }
if (operand1 != null && !operand1.accept(action)) if (operand1 != null && !operand1.accept(action))
return false; return false;
if (action.shouldVisitImplicitNames) { if (action.shouldVisitImplicitNames) {
for (IASTImplicitName name : getImplicitNames()) { for (IASTImplicitName name : getImplicitNames()) {
if (!name.accept(action)) if (!name.accept(action))
return false; return false;
} }
} }
if (operand2 != null && !operand2.accept(action)) if (operand2 != null && !operand2.accept(action))
return false; return false;
if (action.shouldVisitExpressions && action.leave(this) == ASTVisitor.PROCESS_ABORT) if (action.shouldVisitExpressions && action.leave(this) == ASTVisitor.PROCESS_ABORT)
return false; return false;
@ -173,9 +176,9 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
if (stack.fState == 0) { if (stack.fState == 0) {
if (action.shouldVisitExpressions) { if (action.shouldVisitExpressions) {
switch (action.visit(expr)) { switch (action.visit(expr)) {
case ASTVisitor.PROCESS_ABORT : case ASTVisitor.PROCESS_ABORT :
return false; return false;
case ASTVisitor.PROCESS_SKIP: case ASTVisitor.PROCESS_SKIP:
stack= stack.fNext; stack= stack.fNext;
continue; continue;
} }
@ -188,7 +191,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
stack= n; stack= n;
continue; continue;
} }
if (op1 != null && !op1.accept(action)) if (op1 != null && !op1.accept(action))
return false; return false;
} }
if (stack.fState == 1) { if (stack.fState == 1) {
@ -199,19 +202,19 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
} }
} }
stack.fState= 2; stack.fState= 2;
IASTExpression op2 = expr.getOperand2(); IASTExpression op2 = expr.getOperand2();
if (op2 instanceof IASTBinaryExpression) { if (op2 instanceof IASTBinaryExpression) {
N n= new N((IASTBinaryExpression) op2); N n= new N((IASTBinaryExpression) op2);
n.fNext= stack; n.fNext= stack;
stack= n; stack= n;
continue; continue;
} }
if (op2 != null && !op2.accept(action)) if (op2 != null && !op2.accept(action))
return false; return false;
} }
if (action.shouldVisitExpressions && action.leave(expr) == ASTVisitor.PROCESS_ABORT) if (action.shouldVisitExpressions && action.leave(expr) == ASTVisitor.PROCESS_ABORT)
return false; return false;
stack= stack.fNext; stack= stack.fNext;
@ -246,7 +249,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
return overload = CPPSemantics.findOverloadedOperator(this); return overload = CPPSemantics.findOverloadedOperator(this);
} }
public boolean isLValue() { public boolean isLValue() {
ICPPFunction op = getOverload(); ICPPFunction op = getOverload();
if (op != null) { if (op != null) {
@ -329,8 +332,8 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
case ICPPASTBinaryExpression.op_pmdot: case ICPPASTBinaryExpression.op_pmdot:
if (type2 instanceof ICPPPointerToMemberType) { if (type2 instanceof ICPPPointerToMemberType) {
return ((ICPPPointerToMemberType) type2).getType(); 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; 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 { public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpression {
private IASTExpression operand; private IASTExpression operand;
private boolean isGlobal; private boolean isGlobal;
private boolean isVectored; private boolean isVectored;
private IASTImplicitName[] implicitNames = null; private IASTImplicitName[] implicitNames = null;
public CPPASTDeleteExpression() { public CPPASTDeleteExpression() {
} }
@ -82,17 +80,17 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
public boolean isVectored() { public boolean isVectored() {
return isVectored; return isVectored;
} }
/** /**
* Try to resolve both the destructor and operator delete. * Try to resolve both the destructor and operator delete.
*/ */
public IASTImplicitName[] getImplicitNames() { public IASTImplicitName[] getImplicitNames() {
if(implicitNames == null) { if (implicitNames == null) {
List<IASTImplicitName> names = new ArrayList<IASTImplicitName>(); List<IASTImplicitName> names = new ArrayList<IASTImplicitName>();
if(!isVectored) { if (!isVectored) {
ICPPFunction destructor = CPPSemantics.findDestructor(this); ICPPFunction destructor = CPPSemantics.findDestructor(this);
if(destructor != null) { if (destructor != null) {
CPPASTImplicitName destructorName = new CPPASTImplicitName(destructor.getNameCharArray(), this); CPPASTImplicitName destructorName = new CPPASTImplicitName(destructor.getNameCharArray(), this);
destructorName.setBinding(destructor); destructorName.setBinding(destructor);
destructorName.computeOperatorOffsets(operand, false); destructorName.computeOperatorOffsets(operand, false);
@ -100,9 +98,9 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
} }
} }
if(!isGlobal) { if (!isGlobal) {
ICPPFunction deleteOperator = CPPSemantics.findOverloadedOperator(this); ICPPFunction deleteOperator = CPPSemantics.findOverloadedOperator(this);
if(deleteOperator != null) { if (deleteOperator != null) {
CPPASTImplicitName deleteName = new CPPASTImplicitName(deleteOperator.getNameCharArray(), this); CPPASTImplicitName deleteName = new CPPASTImplicitName(deleteOperator.getNameCharArray(), this);
deleteName.setOperator(true); deleteName.setOperator(true);
deleteName.setBinding(deleteOperator); 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; implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
else else
implicitNames = names.toArray(new IASTImplicitName[names.size()]); implicitNames = names.toArray(new IASTImplicitName[names.size()]);
@ -120,35 +118,36 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
return implicitNames; return implicitNames;
} }
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept(ASTVisitor action) {
if( action.shouldVisitExpressions ){ if (action.shouldVisitExpressions) {
switch( action.visit( this ) ){ switch(action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
if(action.shouldVisitImplicitNames) { if (action.shouldVisitImplicitNames) {
for(IASTImplicitName name : getImplicitNames()) { 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 (operand != null && !operand.accept(action))
return false;
if( action.shouldVisitExpressions ){
switch( action.leave( this ) ){ if (action.shouldVisitExpressions) {
case ASTVisitor.PROCESS_ABORT : return false; switch (action.leave(this)) {
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_ABORT: return false;
default : break; case ASTVisitor.PROCESS_SKIP: return true;
default: break;
} }
} }
return true; return true;
} }
public IType getExpressionType() { public IType getExpressionType() {
return CPPSemantics.VOID_TYPE; return CPPSemantics.VOID_TYPE;
} }

View file

@ -63,7 +63,7 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
copy.setIsNewTypeId(isNewTypeId); copy.setIsNewTypeId(isNewTypeId);
if (placement != null) { if (placement != null) {
IASTInitializerClause[] plcmt = new IASTInitializerClause[placement.length]; 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(); plcmt[i]= placement[i].copy();
} }
copy.setPlacementArguments(plcmt); copy.setPlacementArguments(plcmt);
@ -133,13 +133,15 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
isNewTypeId = value; isNewTypeId = value;
} }
/**
* @see org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner#getImplicitNames()
*/
public IASTImplicitName[] getImplicitNames() { public IASTImplicitName[] getImplicitNames() {
if(implicitNames == null) { if (implicitNames == null) {
ICPPFunction operatorFunction = CPPSemantics.findOverloadedOperator(this); ICPPFunction operatorFunction = CPPSemantics.findOverloadedOperator(this);
if(operatorFunction == null) { if (operatorFunction == null) {
implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY; implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
} } else {
else {
CPPASTImplicitName operatorName = new CPPASTImplicitName(operatorFunction.getNameCharArray(), this); CPPASTImplicitName operatorName = new CPPASTImplicitName(operatorFunction.getNameCharArray(), this);
operatorName.setOperator(true); operatorName.setOperator(true);
operatorName.setBinding(operatorFunction); operatorName.setBinding(operatorFunction);
@ -150,8 +152,7 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
return implicitNames; return implicitNames;
} }
/** /**
* Returns true if this expression is allocating an array. * Returns true if this expression is allocating an array.
* @since 5.1 * @since 5.1
@ -163,18 +164,18 @@ public class CPPASTNewExpression extends ASTNode implements ICPPASTNewExpression
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept(ASTVisitor action) {
if( action.shouldVisitExpressions ){ if (action.shouldVisitExpressions) {
switch( action.visit( this ) ){ switch(action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
if(action.shouldVisitImplicitNames) { if (action.shouldVisitImplicitNames) {
for(IASTImplicitName name : getImplicitNames()) { 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)) if (initializer != null && !initializer.accept(action))
return false; return false;
if( action.shouldVisitExpressions ){ if (action.shouldVisitExpressions) {
switch( action.leave( this ) ){ switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
return true; 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 { public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpression, IASTAmbiguityParent {
private int op; private int op;
private IASTExpression operand; private IASTExpression operand;
private ICPPFunction overload = UNINITIALIZED_FUNCTION; private ICPPFunction overload = UNINITIALIZED_FUNCTION;
private IASTImplicitName[] implicitNames = null; private IASTImplicitName[] implicitNames = null;
public CPPASTUnaryExpression() { public CPPASTUnaryExpression() {
} }
@ -89,25 +89,29 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
expression.setPropertyInParent(OPERAND); expression.setPropertyInParent(OPERAND);
} }
} }
public boolean isPostfixOperator() { public boolean isPostfixOperator() {
return op == op_postFixDecr || op == op_postFixIncr; return op == op_postFixDecr || op == op_postFixIncr;
} }
/**
* @see org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner#getImplicitNames()
*/
public IASTImplicitName[] getImplicitNames() { public IASTImplicitName[] getImplicitNames() {
if (implicitNames == null) { if (implicitNames == null) {
ICPPFunction overload = getOverload(); ICPPFunction overload = getOverload();
if (overload == null) if (overload == null) {
return implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY; implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
} else {
CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this); CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this);
operatorName.setOperator(true); operatorName.setOperator(true);
operatorName.setBinding(overload); operatorName.setBinding(overload);
operatorName.computeOperatorOffsets(operand, isPostfixOperator()); operatorName.computeOperatorOffsets(operand, isPostfixOperator());
implicitNames = new IASTImplicitName[] { operatorName }; implicitNames = new IASTImplicitName[] { operatorName };
}
} }
return implicitNames; return implicitNames;
} }
@Override @Override
@ -116,28 +120,29 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
switch (action.visit(this)) { switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT: return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
final boolean isPostfix = isPostfixOperator(); final boolean isPostfix = isPostfixOperator();
if (!isPostfix && action.shouldVisitImplicitNames) { if (!isPostfix && action.shouldVisitImplicitNames) {
for (IASTImplicitName name : getImplicitNames()) { for (IASTImplicitName name : getImplicitNames()) {
if (!name.accept(action)) if (!name.accept(action))
return false; return false;
} }
} }
if (operand != null && !operand.accept(action)) if (operand != null && !operand.accept(action))
return false; return false;
if (isPostfix && action.shouldVisitImplicitNames) { if (isPostfix && action.shouldVisitImplicitNames) {
for (IASTImplicitName name : getImplicitNames()) { for (IASTImplicitName name : getImplicitNames()) {
if (!name.accept(action)) return false; if (!name.accept(action))
return false;
} }
} }
if (action.shouldVisitExpressions) { if (action.shouldVisitExpressions) {
switch (action.leave(this)) { switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false; case ASTVisitor.PROCESS_ABORT: return false;
@ -196,7 +201,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
} }
return null; return null;
} }
public IType getExpressionType() { public IType getExpressionType() {
final int op= getOperator(); final int op= getOperator();
switch (op) { switch (op) {
@ -221,7 +226,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
IType type= operand.getExpressionType(); IType type= operand.getExpressionType();
type = SemanticUtil.getNestedType(type, TDEF | REF); type = SemanticUtil.getNestedType(type, TDEF | REF);
return new CPPPointerType(type); return new CPPPointerType(type);
} }
if (op == op_star) { if (op == op_star) {
IType type= operand.getExpressionType(); IType type= operand.getExpressionType();
@ -238,7 +243,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
return CPPUnknownClass.createUnnamedInstance(); return CPPUnknownClass.createUnnamedInstance();
} }
return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, this.getRawSignature().toCharArray()); return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, this.getRawSignature().toCharArray());
} }
IType origType= operand.getExpressionType(); IType origType= operand.getExpressionType();
IType type = SemanticUtil.getUltimateTypeUptoPointers(origType); IType type = SemanticUtil.getUltimateTypeUptoPointers(origType);
@ -265,7 +270,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
} }
return origType; return origType;
} }
public boolean isLValue() { public boolean isLValue() {
ICPPFunction op = getOverload(); ICPPFunction op = getOverload();
if (op != null) { if (op != null) {