mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 00:36:16 +02:00
Cosmetics.
This commit is contained in:
parent
cd70847e0a
commit
c602341aad
2 changed files with 37 additions and 45 deletions
|
@ -43,7 +43,6 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
private ICPPFunction overload= UNINITIALIZED_FUNCTION;
|
private ICPPFunction overload= UNINITIALIZED_FUNCTION;
|
||||||
private IASTImplicitName[] implicitNames = null;
|
private IASTImplicitName[] implicitNames = null;
|
||||||
|
|
||||||
|
|
||||||
public CPPASTBinaryExpression() {
|
public CPPASTBinaryExpression() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,9 +107,9 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
return implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
|
||||||
|
|
||||||
CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this);
|
CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this);
|
||||||
|
@ -123,7 +122,6 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
return implicitNames;
|
return implicitNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (operand1 instanceof IASTBinaryExpression || operand2 instanceof IASTBinaryExpression) {
|
if (operand1 instanceof IASTBinaryExpression || operand2 instanceof IASTBinaryExpression) {
|
||||||
|
@ -132,8 +130,8 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +168,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
|
|
||||||
public static boolean acceptWithoutRecursion(IASTBinaryExpression bexpr, ASTVisitor action) {
|
public static boolean acceptWithoutRecursion(IASTBinaryExpression bexpr, ASTVisitor action) {
|
||||||
N stack= new N(bexpr);
|
N stack= new N(bexpr);
|
||||||
while(stack != null) {
|
while (stack != null) {
|
||||||
IASTBinaryExpression expr= stack.fExpression;
|
IASTBinaryExpression expr= stack.fExpression;
|
||||||
if (stack.fState == 0) {
|
if (stack.fState == 0) {
|
||||||
if (action.shouldVisitExpressions) {
|
if (action.shouldVisitExpressions) {
|
||||||
|
@ -196,7 +194,8 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
if (stack.fState == 1) {
|
if (stack.fState == 1) {
|
||||||
if (action.shouldVisitImplicitNames) {
|
if (action.shouldVisitImplicitNames) {
|
||||||
for (IASTImplicitName name : ((IASTImplicitNameOwner) expr).getImplicitNames()) {
|
for (IASTImplicitName name : ((IASTImplicitNameOwner) expr).getImplicitNames()) {
|
||||||
if(!name.accept(action)) return false;
|
if (!name.accept(action))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stack.fState= 2;
|
stack.fState= 2;
|
||||||
|
@ -300,7 +299,6 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case IASTBinaryExpression.op_lessEqual:
|
case IASTBinaryExpression.op_lessEqual:
|
||||||
case IASTBinaryExpression.op_lessThan:
|
case IASTBinaryExpression.op_lessThan:
|
||||||
|
@ -311,11 +309,13 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
case IASTBinaryExpression.op_equals:
|
case IASTBinaryExpression.op_equals:
|
||||||
case IASTBinaryExpression.op_notequals:
|
case IASTBinaryExpression.op_notequals:
|
||||||
return new CPPBasicType(Kind.eBoolean, 0, this);
|
return new CPPBasicType(Kind.eBoolean, 0, this);
|
||||||
|
|
||||||
case IASTBinaryExpression.op_plus:
|
case IASTBinaryExpression.op_plus:
|
||||||
if (type2 instanceof IPointerType) {
|
if (type2 instanceof IPointerType) {
|
||||||
return type2;
|
return type2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IASTBinaryExpression.op_minus:
|
case IASTBinaryExpression.op_minus:
|
||||||
if (type2 instanceof IPointerType) {
|
if (type2 instanceof IPointerType) {
|
||||||
if (type1 instanceof IPointerType) {
|
if (type1 instanceof IPointerType) {
|
||||||
|
@ -324,6 +324,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
return type1;
|
return type1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ICPPASTBinaryExpression.op_pmarrow:
|
case ICPPASTBinaryExpression.op_pmarrow:
|
||||||
case ICPPASTBinaryExpression.op_pmdot:
|
case ICPPASTBinaryExpression.op_pmdot:
|
||||||
if (type2 instanceof ICPPPointerToMemberType) {
|
if (type2 instanceof ICPPPointerToMemberType) {
|
||||||
|
@ -333,5 +334,4 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
}
|
}
|
||||||
return type1;
|
return type1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,11 +94,10 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
return op == op_postFixDecr || op == op_postFixIncr;
|
return op == op_postFixDecr || op == op_postFixIncr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
return implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
|
||||||
|
|
||||||
CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this);
|
CPPASTImplicitName operatorName = new CPPASTImplicitName(overload.getNameCharArray(), this);
|
||||||
|
@ -111,7 +110,6 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
return implicitNames;
|
return implicitNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (action.shouldVisitExpressions) {
|
if (action.shouldVisitExpressions) {
|
||||||
|
@ -124,17 +122,19 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
|
|
||||||
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)) return false;
|
if (!name.accept(action))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operand != null && !operand.accept(action)) return false;
|
if (operand != null && !operand.accept(action))
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
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;
|
||||||
|
@ -156,20 +156,17 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ICPPFunction getOverload() {
|
public ICPPFunction getOverload() {
|
||||||
if (overload != UNINITIALIZED_FUNCTION)
|
if (overload != UNINITIALIZED_FUNCTION)
|
||||||
return overload;
|
return overload;
|
||||||
|
|
||||||
overload = CPPSemantics.findOverloadedOperator(this);
|
overload = CPPSemantics.findOverloadedOperator(this);
|
||||||
if(overload != null && op == op_amper && computePointerToMemberType() instanceof CPPPointerToMemberType)
|
if (overload != null && op == op_amper && computePointerToMemberType() instanceof CPPPointerToMemberType)
|
||||||
overload = null;
|
overload = null;
|
||||||
|
|
||||||
return overload;
|
return overload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private IType computePointerToMemberType() {
|
private IType computePointerToMemberType() {
|
||||||
IASTNode child= operand;
|
IASTNode child= operand;
|
||||||
boolean inParenthesis= false;
|
boolean inParenthesis= false;
|
||||||
|
@ -200,7 +197,6 @@ 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) {
|
||||||
|
@ -215,11 +211,11 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
|
|
||||||
if (op == op_amper) { // check for pointer to member
|
if (op == op_amper) { // check for pointer to member
|
||||||
IType ptm = computePointerToMemberType();
|
IType ptm = computePointerToMemberType();
|
||||||
if(ptm != null)
|
if (ptm != null)
|
||||||
return ptm;
|
return ptm;
|
||||||
|
|
||||||
IType operator = findOperatorReturnType();
|
IType operator = findOperatorReturnType();
|
||||||
if(operator != null)
|
if (operator != null)
|
||||||
return operator;
|
return operator;
|
||||||
|
|
||||||
IType type= operand.getExpressionType();
|
IType type= operand.getExpressionType();
|
||||||
|
@ -227,7 +223,6 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
return new CPPPointerType(type);
|
return new CPPPointerType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (op == op_star) {
|
if (op == op_star) {
|
||||||
IType type= operand.getExpressionType();
|
IType type= operand.getExpressionType();
|
||||||
type = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE);
|
type = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE);
|
||||||
|
@ -235,7 +230,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
IType operator = findOperatorReturnType();
|
IType operator = findOperatorReturnType();
|
||||||
if(operator != null) {
|
if (operator != null) {
|
||||||
return operator;
|
return operator;
|
||||||
} else if (type instanceof IPointerType || type instanceof IArrayType) {
|
} else if (type instanceof IPointerType || type instanceof IArrayType) {
|
||||||
return ((ITypeContainer) type).getType();
|
return ((ITypeContainer) type).getType();
|
||||||
|
@ -245,11 +240,10 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
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);
|
||||||
IType operator = findOperatorReturnType();
|
IType operator = findOperatorReturnType();
|
||||||
if(operator != null) {
|
if (operator != null) {
|
||||||
return operator;
|
return operator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +289,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
|
|
||||||
private IType findOperatorReturnType() {
|
private IType findOperatorReturnType() {
|
||||||
ICPPFunction operatorFunction = getOverload();
|
ICPPFunction operatorFunction = getOverload();
|
||||||
if(operatorFunction != null) {
|
if (operatorFunction != null) {
|
||||||
try {
|
try {
|
||||||
return operatorFunction.getType().getReturnType();
|
return operatorFunction.getType().getReturnType();
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
|
@ -304,6 +298,4 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue