mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed ArrayStoreException, ClassCastException and NPE.
This commit is contained in:
parent
82e5b126c8
commit
d07c30d618
6 changed files with 87 additions and 15 deletions
|
@ -148,6 +148,9 @@ public class Value implements IValue {
|
||||||
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG3));
|
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG3));
|
||||||
buf.putLong(lv);
|
buf.putLong(lv);
|
||||||
}
|
}
|
||||||
|
} else if (fFixedValue != null) {
|
||||||
|
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG4));
|
||||||
|
buf.putCharArray(fFixedValue);
|
||||||
} else {
|
} else {
|
||||||
buf.putByte((ITypeMarshalBuffer.VALUE));
|
buf.putByte((ITypeMarshalBuffer.VALUE));
|
||||||
fEvaluation.marshal(buf, true);
|
fEvaluation.marshal(buf, true);
|
||||||
|
@ -169,7 +172,10 @@ public class Value implements IValue {
|
||||||
long val= buf.getLong();
|
long val= buf.getLong();
|
||||||
return Value.create(val);
|
return Value.create(val);
|
||||||
}
|
}
|
||||||
|
if ((firstByte & ITypeMarshalBuffer.FLAG4) != 0) {
|
||||||
|
char[] fixedValue = buf.getCharArray();
|
||||||
|
return new Value(fixedValue, null);
|
||||||
|
}
|
||||||
ISerializableEvaluation eval= buf.unmarshalEvaluation();
|
ISerializableEvaluation eval= buf.unmarshalEvaluation();
|
||||||
if (eval instanceof ICPPEvaluation)
|
if (eval instanceof ICPPEvaluation)
|
||||||
return new Value(null, (ICPPEvaluation) eval);
|
return new Value(null, (ICPPEvaluation) eval);
|
||||||
|
|
|
@ -179,12 +179,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
T[] newArray= array.clone();
|
T[] newArray= array.clone();
|
||||||
for (int i = 0; i < newArray.length; i++) {
|
for (int i = 0; i < newArray.length; i++) {
|
||||||
IBinding specializedMember = specialClass.specializeMember(array[i], point);
|
IBinding specializedMember = specialClass.specializeMember(array[i], point);
|
||||||
try {
|
newArray[i]= (T) specializedMember;
|
||||||
newArray[i]= (T) specializedMember;
|
|
||||||
} catch (ArrayStoreException e) {
|
|
||||||
throw new ArrayStoreException("Can't cast " + specializedMember.getClass() + //$NON-NLS-1$
|
|
||||||
" to " + array.getClass().getComponentType().getName()); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return newArray;
|
return newArray;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
@ -43,7 +44,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFunctionCall;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFunctionCall;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.LookupData;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.LookupData;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
|
||||||
|
|
||||||
public class CPPASTFunctionCallExpression extends ASTNode
|
public class CPPASTFunctionCallExpression extends ASTNode
|
||||||
implements ICPPASTFunctionCallExpression, IASTAmbiguityParent {
|
implements ICPPASTFunctionCallExpression, IASTAmbiguityParent {
|
||||||
|
@ -301,7 +301,7 @@ public class CPPASTFunctionCallExpression extends ASTNode
|
||||||
ICPPEvaluation[] args= new ICPPEvaluation[fArguments.length + 1];
|
ICPPEvaluation[] args= new ICPPEvaluation[fArguments.length + 1];
|
||||||
args[0]= functionName.getEvaluation();
|
args[0]= functionName.getEvaluation();
|
||||||
for (int i = 1; i < args.length; i++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
args[i]= ((ICPPASTExpression) fArguments[i - 1]).getEvaluation();
|
args[i]= ((ICPPASTInitializerClause) fArguments[i - 1]).getEvaluation();
|
||||||
}
|
}
|
||||||
return new EvalFunctionCall(args);
|
return new EvalFunctionCall(args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,24 +20,31 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
|
||||||
|
@ -47,11 +54,76 @@ import org.eclipse.core.runtime.Assert;
|
||||||
public class CPPClassSpecialization extends CPPSpecialization
|
public class CPPClassSpecialization extends CPPSpecialization
|
||||||
implements ICPPClassSpecialization, ICPPInternalClassTypeMixinHost {
|
implements ICPPClassSpecialization, ICPPInternalClassTypeMixinHost {
|
||||||
|
|
||||||
public final static class RecursionResolvingBinding extends ProblemBinding {
|
public static class RecursionResolvingBinding extends ProblemBinding implements ICPPMember {
|
||||||
public RecursionResolvingBinding(IASTNode node, char[] arg) {
|
public static RecursionResolvingBinding createFor(IBinding original, IASTNode point) {
|
||||||
|
if (original instanceof ICPPMethod)
|
||||||
|
return new RecursionResolvingMethod(point, original.getNameCharArray());
|
||||||
|
if (original instanceof ICPPField)
|
||||||
|
return new RecursionResolvingField(point, original.getNameCharArray());
|
||||||
|
return new RecursionResolvingBinding(point, original.getNameCharArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
private RecursionResolvingBinding(IASTNode node, char[] arg) {
|
||||||
super(node, IProblemBinding.SEMANTIC_RECURSION_IN_LOOKUP, arg);
|
super(node, IProblemBinding.SEMANTIC_RECURSION_IN_LOOKUP, arg);
|
||||||
Assert.isTrue(CPPASTNameBase.sAllowRecursionBindings, getMessage());
|
Assert.isTrue(CPPASTNameBase.sAllowRecursionBindings, getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVisibility() {
|
||||||
|
return ICPPASTVisibilityLabel.v_public;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPClassType getClassOwner() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static class RecursionResolvingField extends RecursionResolvingBinding implements ICPPField {
|
||||||
|
public RecursionResolvingField(IASTNode node, char[] arg) {
|
||||||
|
super(node, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICompositeType getCompositeTypeOwner() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static class RecursionResolvingMethod extends RecursionResolvingBinding implements ICPPMethod {
|
||||||
|
public RecursionResolvingMethod(IASTNode node, char[] arg) {
|
||||||
|
super(node, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPParameter[] getParameters() {
|
||||||
|
return ICPPParameter.EMPTY_CPPPARAMETER_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRequiredArgumentCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IScope getFunctionScope() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNoReturn() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDestructor() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPFunctionType getType() {
|
||||||
|
return new ProblemFunctionType(getID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPClassSpecializationScope specScope;
|
private ICPPClassSpecializationScope specScope;
|
||||||
|
@ -87,7 +159,7 @@ public class CPPClassSpecialization extends CPPSpecialization
|
||||||
fInProgress.set(set);
|
fInProgress.set(set);
|
||||||
}
|
}
|
||||||
if (!set.add(original))
|
if (!set.add(original))
|
||||||
return new RecursionResolvingBinding(point, original.getNameCharArray());
|
return RecursionResolvingBinding.createFor(original, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
IBinding result= CPPTemplates.createSpecialization(this, original, point);
|
IBinding result= CPPTemplates.createSpecialization(this, original, point);
|
||||||
|
|
|
@ -114,8 +114,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
||||||
fInProgress.set(set);
|
fInProgress.set(set);
|
||||||
}
|
}
|
||||||
if (!set.add(original))
|
if (!set.add(original))
|
||||||
return new RecursionResolvingBinding(null, null);
|
return RecursionResolvingBinding.createFor(original, point);
|
||||||
|
|
||||||
}
|
}
|
||||||
IBinding newSpec= CPPTemplates.createSpecialization(this, original, point);
|
IBinding newSpec= CPPTemplates.createSpecialization(this, original, point);
|
||||||
set.remove(original);
|
set.remove(original);
|
||||||
|
|
|
@ -132,7 +132,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||||
fInProgress.set(set);
|
fInProgress.set(set);
|
||||||
}
|
}
|
||||||
if (!set.add(original))
|
if (!set.add(original))
|
||||||
return new RecursionResolvingBinding(null, null);
|
return RecursionResolvingBinding.createFor(original, point);
|
||||||
}
|
}
|
||||||
IBinding newSpec= CPPTemplates.createSpecialization(this, original, point);
|
IBinding newSpec= CPPTemplates.createSpecialization(this, original, point);
|
||||||
set.remove(original);
|
set.remove(original);
|
||||||
|
|
Loading…
Add table
Reference in a new issue