mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Cosmetics.
This commit is contained in:
parent
5adfb67a9d
commit
ff8baa2754
2 changed files with 30 additions and 37 deletions
|
@ -48,7 +48,7 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
|
|
||||||
private static final int FULLY_RESOLVED = 1;
|
private static final int FULLY_RESOLVED = 1;
|
||||||
private static final int RESOLUTION_IN_PROGRESS = 1 << 1;
|
private static final int RESOLUTION_IN_PROGRESS = 1 << 1;
|
||||||
private int bits = 0;
|
private int bits;
|
||||||
|
|
||||||
protected IFunctionType type;
|
protected IFunctionType type;
|
||||||
|
|
||||||
|
@ -112,9 +112,6 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IFunction#getParameters()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IParameter[] getParameters() {
|
public IParameter[] getParameters() {
|
||||||
int j= -1;
|
int j= -1;
|
||||||
|
@ -140,8 +137,8 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
IASTName[] names = ((ICASTKnRFunctionDeclarator) dtor).getParameterNames();
|
IASTName[] names = ((ICASTKnRFunctionDeclarator) dtor).getParameterNames();
|
||||||
IParameter[] result = new IParameter[names.length];
|
IParameter[] result = new IParameter[names.length];
|
||||||
if (names.length > 0) {
|
if (names.length > 0) {
|
||||||
// Ensures that the list of parameters is created in the same order as the K&R C parameter
|
// Ensures that the list of parameters is created in the same order as
|
||||||
// names
|
// the K&R C parameter names
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (int i = 0; i < names.length; i++) {
|
||||||
IASTDeclarator decl = CVisitor.getKnRParameterDeclarator(
|
IASTDeclarator decl = CVisitor.getKnRParameterDeclarator(
|
||||||
(ICASTKnRFunctionDeclarator) dtor, names[i]);
|
(ICASTKnRFunctionDeclarator) dtor, names[i]);
|
||||||
|
@ -233,7 +230,7 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
IASTDeclarator knrParamDtor = null;
|
IASTDeclarator knrParamDtor = null;
|
||||||
if (parent instanceof IASTParameterDeclaration) {
|
if (parent instanceof IASTParameterDeclaration) {
|
||||||
IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) parent.getParent();
|
IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) parent.getParent();
|
||||||
IASTParameterDeclaration [] ps = fdtor.getParameters();
|
IASTParameterDeclaration[] ps = fdtor.getParameters();
|
||||||
for (; idx < ps.length; idx++) {
|
for (; idx < ps.length; idx++) {
|
||||||
if (parent == ps[idx])
|
if (parent == ps[idx])
|
||||||
break;
|
break;
|
||||||
|
@ -241,8 +238,8 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
} else if (parent instanceof IASTSimpleDeclaration) {
|
} else if (parent instanceof IASTSimpleDeclaration) {
|
||||||
//KnR: name in declaration list
|
//KnR: name in declaration list
|
||||||
fKnRDtor = (ICASTKnRFunctionDeclarator) parent.getParent();
|
fKnRDtor = (ICASTKnRFunctionDeclarator) parent.getParent();
|
||||||
IASTName [] ps = fKnRDtor.getParameterNames();
|
IASTName[] ps = fKnRDtor.getParameterNames();
|
||||||
char [] n = paramName.toCharArray();
|
char[] n = paramName.toCharArray();
|
||||||
for (; idx < ps.length; idx++) {
|
for (; idx < ps.length; idx++) {
|
||||||
if (CharArrayUtils.equals(ps[idx].toCharArray(), n))
|
if (CharArrayUtils.equals(ps[idx].toCharArray(), n))
|
||||||
break;
|
break;
|
||||||
|
@ -250,7 +247,7 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
} else {
|
} else {
|
||||||
//KnR: name in name list
|
//KnR: name in name list
|
||||||
fKnRDtor = (ICASTKnRFunctionDeclarator) parent;
|
fKnRDtor = (ICASTKnRFunctionDeclarator) parent;
|
||||||
IASTName [] ps = fKnRDtor.getParameterNames();
|
IASTName[] ps = fKnRDtor.getParameterNames();
|
||||||
for (; idx < ps.length; idx++) {
|
for (; idx < ps.length; idx++) {
|
||||||
if (ps[idx] == paramName)
|
if (ps[idx] == paramName)
|
||||||
break;
|
break;
|
||||||
|
@ -265,14 +262,14 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
IASTParameterDeclaration temp = null;
|
IASTParameterDeclaration temp = null;
|
||||||
if (definition != null) {
|
if (definition != null) {
|
||||||
if (definition instanceof IASTStandardFunctionDeclarator) {
|
if (definition instanceof IASTStandardFunctionDeclarator) {
|
||||||
IASTParameterDeclaration [] parameters = ((IASTStandardFunctionDeclarator)definition).getParameters();
|
IASTParameterDeclaration[] parameters = ((IASTStandardFunctionDeclarator)definition).getParameters();
|
||||||
if (parameters.length > idx) {
|
if (parameters.length > idx) {
|
||||||
temp = parameters[idx];
|
temp = parameters[idx];
|
||||||
ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName().setBinding(binding);
|
ASTQueries.findInnermostDeclarator(temp.getDeclarator()).getName().setBinding(binding);
|
||||||
}
|
}
|
||||||
} else if (definition instanceof ICASTKnRFunctionDeclarator) {
|
} else if (definition instanceof ICASTKnRFunctionDeclarator) {
|
||||||
fKnRDtor = (ICASTKnRFunctionDeclarator) definition;
|
fKnRDtor = (ICASTKnRFunctionDeclarator) definition;
|
||||||
IASTName [] parameterNames = fKnRDtor.getParameterNames();
|
IASTName[] parameterNames = fKnRDtor.getParameterNames();
|
||||||
if (parameterNames.length > idx) {
|
if (parameterNames.length > idx) {
|
||||||
IASTName n = parameterNames[idx];
|
IASTName n = parameterNames[idx];
|
||||||
n.setBinding(binding);
|
n.setBinding(binding);
|
||||||
|
@ -298,19 +295,19 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateParameterBindings(IASTFunctionDeclarator fdtor) {
|
protected void updateParameterBindings(IASTFunctionDeclarator fdtor) {
|
||||||
IParameter [] params = getParameters();
|
IParameter[] params = getParameters();
|
||||||
if (fdtor instanceof IASTStandardFunctionDeclarator) {
|
if (fdtor instanceof IASTStandardFunctionDeclarator) {
|
||||||
IASTParameterDeclaration [] nps = ((IASTStandardFunctionDeclarator)fdtor).getParameters();
|
IASTParameterDeclaration[] nps = ((IASTStandardFunctionDeclarator) fdtor).getParameters();
|
||||||
if (params.length < nps.length)
|
if (params.length < nps.length)
|
||||||
return;
|
return;
|
||||||
for (int i = 0; i < nps.length; i++) {
|
for (int i = 0; i < nps.length; i++) {
|
||||||
IASTName name = ASTQueries.findInnermostDeclarator(nps[i].getDeclarator()).getName();
|
IASTName name = ASTQueries.findInnermostDeclarator(nps[i].getDeclarator()).getName();
|
||||||
name.setBinding(params[i]);
|
name.setBinding(params[i]);
|
||||||
if (params[i] instanceof CParameter)
|
if (params[i] instanceof CParameter)
|
||||||
((CParameter)params[i]).addDeclaration(name);
|
((CParameter) params[i]).addDeclaration(name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IASTName [] ns = ((ICASTKnRFunctionDeclarator)fdtor).getParameterNames();
|
IASTName[] ns = ((ICASTKnRFunctionDeclarator) fdtor).getParameterNames();
|
||||||
if (params.length > 0 && params.length != ns.length)
|
if (params.length > 0 && params.length != ns.length)
|
||||||
return; //problem
|
return; //problem
|
||||||
|
|
||||||
|
@ -321,7 +318,7 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
if (dtor != null) {
|
if (dtor != null) {
|
||||||
dtor.getName().setBinding(params[i]);
|
dtor.getName().setBinding(params[i]);
|
||||||
if (params[i] instanceof CParameter)
|
if (params[i] instanceof CParameter)
|
||||||
((CParameter)params[i]).addDeclaration(dtor.getName());
|
((CParameter) params[i]).addDeclaration(dtor.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,54 +23,50 @@ public class CFunctionType implements IFunctionType, ISerializableType {
|
||||||
private final IType[] parameters;
|
private final IType[] parameters;
|
||||||
private final IType returnType;
|
private final IType returnType;
|
||||||
|
|
||||||
public CFunctionType( IType returnType, IType [] types ) {
|
public CFunctionType(IType returnType, IType[] types) {
|
||||||
this.returnType = returnType;
|
this.returnType = returnType;
|
||||||
this.parameters = types;
|
this.parameters = types;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSameType( IType o ){
|
public boolean isSameType(IType o) {
|
||||||
if( o == this )
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
if( o instanceof ITypedef )
|
if (o instanceof ITypedef)
|
||||||
return o.isSameType( this );
|
return o.isSameType(this);
|
||||||
if( o instanceof IFunctionType ){
|
if (o instanceof IFunctionType) {
|
||||||
IFunctionType ft = (IFunctionType) o;
|
IFunctionType ft = (IFunctionType) o;
|
||||||
IType [] fps;
|
IType[] fps;
|
||||||
fps = ft.getParameterTypes();
|
fps = ft.getParameterTypes();
|
||||||
if( fps.length != parameters.length )
|
if (fps.length != parameters.length)
|
||||||
return false;
|
return false;
|
||||||
if( ! returnType.isSameType( ft.getReturnType() ) )
|
if (!returnType.isSameType(ft.getReturnType()))
|
||||||
return false;
|
return false;
|
||||||
for( int i = 0; i < parameters.length; i++ )
|
for (int i = 0; i < parameters.length; i++) {
|
||||||
if( ! parameters[i].isSameType( fps[i] ) )
|
if (!parameters[i].isSameType(fps[i]))
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IFunctionType#getReturnType()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IType getReturnType() {
|
public IType getReturnType() {
|
||||||
return returnType;
|
return returnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IFunctionType#getParameterTypes()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IType[] getParameterTypes() {
|
public IType[] getParameterTypes() {
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone(){
|
public Object clone() {
|
||||||
IType t = null;
|
IType t = null;
|
||||||
try {
|
try {
|
||||||
t = (IType) super.clone();
|
t = (IType) super.clone();
|
||||||
} catch ( CloneNotSupportedException e ) {
|
} catch (CloneNotSupportedException e) {
|
||||||
//not going to happen
|
//not going to happen
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
|
@ -102,7 +98,7 @@ public class CFunctionType implements IFunctionType, ISerializableType {
|
||||||
if (((firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0)) {
|
if (((firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0)) {
|
||||||
len= buffer.getInt();
|
len= buffer.getInt();
|
||||||
} else {
|
} else {
|
||||||
len= (firstBytes & (ITypeMarshalBuffer.LAST_FLAG-1))/ITypeMarshalBuffer.FIRST_FLAG;
|
len= (firstBytes & (ITypeMarshalBuffer.LAST_FLAG - 1)) / ITypeMarshalBuffer.FIRST_FLAG;
|
||||||
}
|
}
|
||||||
IType rt= buffer.unmarshalType();
|
IType rt= buffer.unmarshalType();
|
||||||
IType[] pars= new IType[len];
|
IType[] pars= new IType[len];
|
||||||
|
|
Loading…
Add table
Reference in a new issue