mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Cosmetics.
This commit is contained in:
parent
c4dc0ee219
commit
aaa7803609
2 changed files with 45 additions and 53 deletions
|
@ -35,11 +35,10 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||||
|
|
||||||
|
|
||||||
public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionList, IASTAmbiguityParent {
|
public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionList, IASTAmbiguityParent {
|
||||||
private static final ICPPFunction[] NO_FUNCTIONS = new ICPPFunction[0];
|
private static final ICPPFunction[] NO_FUNCTIONS = new ICPPFunction[0];
|
||||||
|
|
||||||
private IASTExpression [] expressions = new IASTExpression[2];
|
private IASTExpression[] expressions = new IASTExpression[2];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Caution: may contain nulls.
|
* Caution: may contain nulls.
|
||||||
|
@ -48,7 +47,6 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
|
||||||
private IASTImplicitName[] implicitNames;
|
private IASTImplicitName[] implicitNames;
|
||||||
private ICPPFunction[] overloads = null;
|
private ICPPFunction[] overloads = null;
|
||||||
|
|
||||||
|
|
||||||
public CPPASTExpressionList copy() {
|
public CPPASTExpressionList copy() {
|
||||||
CPPASTExpressionList copy = new CPPASTExpressionList();
|
CPPASTExpressionList copy = new CPPASTExpressionList();
|
||||||
for(IASTExpression expr : getExpressions())
|
for(IASTExpression expr : getExpressions())
|
||||||
|
@ -57,9 +55,9 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTExpression [] getExpressions() {
|
public IASTExpression[] getExpressions() {
|
||||||
if( expressions == null ) return IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
if (expressions == null) return IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||||
return (IASTExpression[]) ArrayUtil.trim( IASTExpression.class, expressions );
|
return (IASTExpression[]) ArrayUtil.trim(IASTExpression.class, expressions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addExpression(IASTExpression expression) {
|
public void addExpression(IASTExpression expression) {
|
||||||
|
@ -72,40 +70,39 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
|
||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTExpression[] exps = getExpressions();
|
IASTExpression[] exps = getExpressions();
|
||||||
IASTImplicitName[] implicits = action.shouldVisitImplicitNames ? computeImplicitNames() : null;
|
IASTImplicitName[] implicits = action.shouldVisitImplicitNames ? computeImplicitNames() : null;
|
||||||
|
|
||||||
for(int i = 0, n = exps.length; i < n; i++) {
|
for (int i = 0, n = exps.length; i < n; i++) {
|
||||||
if(!exps[i].accept(action)) {
|
if (!exps[i].accept(action)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(i < n-1 && implicits != null && implicits[i] != null) {
|
if (i < n - 1 && implicits != null && implicits[i] != null) {
|
||||||
if(!implicits[i].accept(action)) {
|
if (!implicits[i].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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of implicit names where each element of the array
|
* Returns an array of implicit names where each element of the array
|
||||||
* represents a comma between the expression in the same index and the
|
* represents a comma between the expression in the same index and the
|
||||||
|
@ -113,9 +110,9 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
|
||||||
* for commas that do not resolve to overloaded operators.
|
* for commas that do not resolve to overloaded operators.
|
||||||
*/
|
*/
|
||||||
private IASTImplicitName[] computeImplicitNames() {
|
private IASTImplicitName[] computeImplicitNames() {
|
||||||
if(implicitNames == null) {
|
if (implicitNames == null) {
|
||||||
IASTExpression[] exprs = getExpressions(); // has to be at least two
|
IASTExpression[] exprs = getExpressions(); // has to be at least two
|
||||||
if(exprs.length < 2)
|
if (exprs.length < 2)
|
||||||
return implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
|
return implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
|
||||||
|
|
||||||
implicitNames = new IASTImplicitName[exprs.length-1];
|
implicitNames = new IASTImplicitName[exprs.length-1];
|
||||||
|
@ -123,7 +120,7 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
|
||||||
ICPPFunction[] overloads = getOverloads();
|
ICPPFunction[] overloads = getOverloads();
|
||||||
for(int i = 0; i < overloads.length; i++) {
|
for(int i = 0; i < overloads.length; i++) {
|
||||||
ICPPFunction overload = overloads[i];
|
ICPPFunction overload = overloads[i];
|
||||||
if(overload != null && !(overload instanceof CPPImplicitFunction)) {
|
if (overload != null && !(overload instanceof CPPImplicitFunction)) {
|
||||||
CPPASTImplicitName operatorName = new CPPASTImplicitName(OverloadableOperator.COMMA, this);
|
CPPASTImplicitName operatorName = new CPPASTImplicitName(OverloadableOperator.COMMA, this);
|
||||||
operatorName.setBinding(overload);
|
operatorName.setBinding(overload);
|
||||||
operatorName.computeOperatorOffsets(exprs[i], true);
|
operatorName.computeOperatorOffsets(exprs[i], true);
|
||||||
|
@ -135,16 +132,14 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
|
||||||
return implicitNames;
|
return implicitNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IASTImplicitName[] getImplicitNames() {
|
public IASTImplicitName[] getImplicitNames() {
|
||||||
return (IASTImplicitName[])ArrayUtil.removeNulls(IASTImplicitName.class, computeImplicitNames());
|
return (IASTImplicitName[])ArrayUtil.removeNulls(IASTImplicitName.class, computeImplicitNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ICPPFunction[] getOverloads() {
|
private ICPPFunction[] getOverloads() {
|
||||||
if(overloads == null) {
|
if (overloads == null) {
|
||||||
IASTExpression[] exprs = getExpressions();
|
IASTExpression[] exprs = getExpressions();
|
||||||
if(exprs.length < 2)
|
if (exprs.length < 2)
|
||||||
return overloads = NO_FUNCTIONS;
|
return overloads = NO_FUNCTIONS;
|
||||||
|
|
||||||
ASTNodeProperty prop = getPropertyInParent();
|
ASTNodeProperty prop = getPropertyInParent();
|
||||||
|
@ -181,7 +176,7 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( expressions == null ) return;
|
if (expressions == null) return;
|
||||||
for (int i = 0; i < expressions.length; ++i) {
|
for (int i = 0; i < expressions.length; ++i) {
|
||||||
if (child == expressions[i]) {
|
if (child == expressions[i]) {
|
||||||
other.setPropertyInParent(child.getPropertyInParent());
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* 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
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ public class CPPASTExpressionStatement extends ASTNode implements
|
||||||
|
|
||||||
private IASTExpression expression;
|
private IASTExpression expression;
|
||||||
|
|
||||||
|
|
||||||
public CPPASTExpressionStatement() {
|
public CPPASTExpressionStatement() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,32 +53,30 @@ public class CPPASTExpressionStatement extends ASTNode implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
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( expression != null ) if( !expression.accept( action ) ) return false;
|
if (expression != null && !expression.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;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( child == expression )
|
if (child == expression) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
expression = (IASTExpression) other;
|
||||||
expression = (IASTExpression) other;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue