1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-07-08 20:03:24 -07:00
parent 8fac40ce1b
commit 77e792334f
20 changed files with 552 additions and 566 deletions

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -30,7 +30,7 @@ public interface ITypeMarshalBuffer {
final static byte PROBLEM_TYPE= 9;
final static byte VALUE= 10;
final static byte DEPENDENT_EXPRESSION_TYPE= 11;
final static byte
EVAL_BINARY= 1,
EVAL_BINARY_TYPE_ID = 2,
@ -47,16 +47,16 @@ public interface ITypeMarshalBuffer {
EVAL_TYPE_ID= 13,
EVAL_UNARY= 14,
EVAL_UNARY_TYPE_ID = 15;
static final byte KIND_MASK= 15;
final static int FLAG1 = 0x10;
final static int FLAG2 = 0x20;
final static int FLAG3 = 0x40;
final static int FLAG4 = 0x80;
CoreException unmarshallingError();
IType unmarshalType() throws CoreException;
IValue unmarshalValue() throws CoreException;
IBinding unmarshalBinding() throws CoreException;

View file

@ -8,7 +8,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import java.util.ArrayList;
@ -45,15 +45,15 @@ import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer;
import org.eclipse.core.runtime.CoreException;
/**
* Represents values of variables, enumerators or expressions. The primary purpose of the representation
* is to support instantiation of templates with non-type template parameters.
* Represents values of variables, enumerators or expressions. The primary purpose of
* the representation is to support instantiation of templates with non-type template parameters.
*/
public class Value implements IValue {
public static final int MAX_RECURSION_DEPTH = 25;
public final static IValue UNKNOWN= new Value("<unknown>".toCharArray(), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY); //$NON-NLS-1$
public final static IValue NOT_INITIALIZED= new Value("<__>".toCharArray(), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY); //$NON-NLS-1$
private static final int[] NO_INT = {};
private static final String SCOPE_OP = "::"; //$NON-NLS-1$
private static final char UNIQUE_CHAR = '_';
private static final char TEMPLATE_PARAM_CHAR = '#';
@ -62,16 +62,16 @@ public class Value implements IValue {
private static final char UNARY_OP_CHAR = '$';
private static final char BINARY_OP_CHAR = '@';
private static final char CONDITIONAL_CHAR= '?';
private static final char SEPARATOR = ',';
private final static IValue[] TYPICAL= {
new Value(new char[] {'0'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'1'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'2'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'3'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'4'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'5'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'0'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'1'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'2'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'3'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'4'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'5'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY),
new Value(new char[] {'6'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY)};
@ -113,13 +113,13 @@ public class Value implements IValue {
private final char[] fExpression;
private final ICPPUnknownBinding[] fUnknownBindings;
private char[] fSignature;
private Value(char[] rep, ICPPUnknownBinding[] unknown) {
assert rep != null;
fExpression= rep;
fUnknownBindings= unknown;
}
@Override
public char[] getInternalExpression() {
return fExpression;
@ -129,7 +129,7 @@ public class Value implements IValue {
public IBinding[] getUnknownBindings() {
return fUnknownBindings;
}
@Override
public char[] getSignature() {
if (fSignature == null) {
@ -152,12 +152,12 @@ public class Value implements IValue {
}
return fSignature;
}
@Override
public Long numericalValue() {
return parseLong(fExpression);
}
public void marshall(TypeMarshalBuffer buf) throws CoreException {
if (UNKNOWN == this) {
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG1));
@ -182,12 +182,12 @@ public class Value implements IValue {
}
}
}
public static IValue unmarshal(TypeMarshalBuffer buf) throws CoreException {
int firstByte= buf.getByte();
if (firstByte == TypeMarshalBuffer.NULL_TYPE)
return null;
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0)
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0)
return Value.UNKNOWN;
if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
int val= buf.getInt();
@ -197,7 +197,7 @@ public class Value implements IValue {
long val= buf.getLong();
return Value.create(val);
}
char[] expr = buf.getCharArray();
final int len= buf.getShort();
ICPPUnknownBinding[] unknowns= new ICPPUnknownBinding[len];
@ -215,7 +215,7 @@ public class Value implements IValue {
public int hashCode() {
return CharArrayUtils.hash(fExpression);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof IValue)) {
@ -224,11 +224,11 @@ public class Value implements IValue {
final IValue rhs = (IValue) obj;
if (!CharArrayUtils.equals(fExpression, rhs.getInternalExpression()))
return false;
IBinding[] rhsUnknowns= rhs.getUnknownBindings();
if (fUnknownBindings.length != rhsUnknowns.length)
return false;
for (int i = 0; i < rhsUnknowns.length; i++) {
final IBinding rhsUnknown = rhsUnknowns[i];
if (rhsUnknown instanceof ICPPUnknownBinding) {
@ -241,7 +241,7 @@ public class Value implements IValue {
}
return true;
}
@Override
public String toString() {
return new String(getSignature());
@ -255,7 +255,7 @@ public class Value implements IValue {
return TYPICAL[(int) value];
return new Value(toCharArray(value), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY);
}
/**
* Creates a value representing the given template parameter.
*/
@ -272,7 +272,7 @@ public class Value implements IValue {
}
/**
* Tests whether the value is a template parameter (or parameter pack),
* Tests whether the value is a template parameter (or parameter pack),
* returns the parameter id of the parameter, or <code>-1</code> if it is not a template parameter.
*/
public static int isTemplateParameter(IValue tval) {
@ -292,7 +292,7 @@ public class Value implements IValue {
}
return -1;
}
/**
* Tests whether the value directly references some template parameter.
*/
@ -351,7 +351,7 @@ public class Value implements IValue {
}
if (result != -1)
return new int[] {result};
return NO_INT;
}
@ -365,7 +365,7 @@ public class Value implements IValue {
Object obj= evaluate(expr, unknownSigs, unknown, maxRecursionDepth);
if (obj instanceof Number)
return create(((Number) obj).longValue());
ICPPUnknownBinding[] ua;
if (unknown.isEmpty()) {
ua= ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY;
@ -377,18 +377,18 @@ public class Value implements IValue {
}
return UNKNOWN;
}
/**
* Creates a value off its canonical representation.
*/
public static IValue fromInternalRepresentation(char[] rep, ICPPUnknownBinding[] unknown) {
if (CharArrayUtils.equals(rep, UNKNOWN.getInternalExpression()))
return UNKNOWN;
Long l= parseLong(rep);
if (l != null)
if (l != null)
return create(l.longValue());
return new Value(rep, unknown);
}
@ -399,11 +399,11 @@ public class Value implements IValue {
StringBuilder buf= new StringBuilder(10);
buf.append(UNIQUE_CHAR);
buf.append(++sUnique);
return new Value(extractChars(buf), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY);
return new Value(extractChars(buf), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY);
}
/**
* Computes the canonical representation of the value of the expression.
* Computes the canonical representation of the value of the expression.
* Returns a {@code Number} for numerical values or a {@code String}, otherwise.
* @throws UnknownValueException
*/
@ -411,7 +411,7 @@ public class Value implements IValue {
List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException {
if (maxdepth < 0 || e == null)
throw UNKNOWN_EX;
if (e instanceof IASTArraySubscriptExpression) {
throw UNKNOWN_EX;
}
@ -465,7 +465,7 @@ public class Value implements IValue {
case IASTLiteralExpression.lk_char_constant:
try {
final char[] image= litEx.getValue();
if (image.length > 1 && image[0] == 'L')
if (image.length > 1 && image[0] == 'L')
return ExpressionEvaluator.getChar(image, 2);
return ExpressionEvaluator.getChar(image, 1);
} catch (EvalException e1) {
@ -489,7 +489,7 @@ public class Value implements IValue {
}
throw UNKNOWN_EX;
}
/**
* Extract a value off a binding.
*/
@ -502,11 +502,11 @@ public class Value implements IValue {
final ICPPTemplateNonTypeParameter tp = (ICPPTemplateNonTypeParameter) b;
return createTemplateParamExpression(tp.getParameterID(), tp.isParameterPack());
}
if (b instanceof ICPPUnknownBinding) {
return createReference((ICPPUnknownBinding) b, unknownSigs, unknowns);
}
IValue value= null;
if (b instanceof IInternalVariable) {
value= ((IInternalVariable) b).getInitialValue(maxdepth - 1);
@ -514,10 +514,10 @@ public class Value implements IValue {
value= ((IVariable) b).getInitialValue();
} else if (b instanceof IEnumerator) {
value= ((IEnumerator) b).getValue();
}
}
if (value != null)
return evaluateValue(value, unknownSigs, unknowns);
throw UNKNOWN_EX;
}
@ -532,21 +532,21 @@ public class Value implements IValue {
}
return "" + REFERENCE_CHAR + idx.toString(); //$NON-NLS-1$
}
private static Object evaluateValue(IValue cv, Map<String, Integer> unknownSigs,
List<ICPPUnknownBinding> unknowns) throws UnknownValueException {
if (cv == Value.UNKNOWN)
if (cv == Value.UNKNOWN)
throw UNKNOWN_EX;
Long lv= cv.numericalValue();
if (lv != null)
return lv;
final IBinding[] oldUnknowns = cv.getUnknownBindings();
final char[] expr= cv.getInternalExpression();
if (oldUnknowns.length == 0)
return new String(expr);
StringBuilder buf= new StringBuilder(expr.length);
boolean skipToSeparator= false;
for (int i = 0; i < expr.length; i++) {
@ -557,7 +557,7 @@ public class Value implements IValue {
if (idx >= oldUnknowns.length)
throw UNKNOWN_EX;
final IBinding old = oldUnknowns[idx];
if (!(old instanceof ICPPUnknownBinding))
if (!(old instanceof ICPPUnknownBinding))
throw UNKNOWN_EX;
buf.append(createReference((ICPPUnknownBinding) old, unknownSigs, unknowns));
@ -576,7 +576,7 @@ public class Value implements IValue {
}
return buf.toString();
}
private static Object evaluateUnaryExpression(IASTUnaryExpression ue,
Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth)
throws UnknownValueException {
@ -599,11 +599,11 @@ public class Value implements IValue {
unaryOp == IASTUnaryExpression.op_sizeofParameterPack) {
throw UNKNOWN_EX;
}
final Object value= evaluate(ue.getOperand(), unknownSigs, unknowns, maxdepth);
return combineUnary(unaryOp, value);
return combineUnary(unaryOp, value);
}
private static Object combineUnary(final int unaryOp, final Object value) throws UnknownValueException {
switch (unaryOp) {
case IASTUnaryExpression.op_bracketedPrimary:
@ -628,8 +628,8 @@ public class Value implements IValue {
return v == 0 ? 1 : 0;
}
throw UNKNOWN_EX;
}
}
switch (unaryOp) {
case IASTUnaryExpression.op_prefixIncr:
case IASTUnaryExpression.op_postFixIncr:
@ -643,7 +643,7 @@ public class Value implements IValue {
throw UNKNOWN_EX;
}
private static Object evaluateBinaryExpression(IASTBinaryExpression be,
private static Object evaluateBinaryExpression(IASTBinaryExpression be,
Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth)
throws UnknownValueException {
final Object o1= evaluate(be.getOperand1(), unknownSigs, unknowns, maxdepth);
@ -652,7 +652,7 @@ public class Value implements IValue {
final int op= be.getOperator();
return combineBinary(op, o1, o2);
}
private static Object combineBinary(final int op, final Object o1, final Object o2)
throws UnknownValueException {
if (o1 instanceof Number && o2 instanceof Number) {
@ -737,10 +737,10 @@ public class Value implements IValue {
default:
throw UNKNOWN_EX;
}
return "" + BINARY_OP_CHAR + op + SEPARATOR + o1.toString() + SEPARATOR + o2.toString(); //$NON-NLS-1$
}
public static IValue reevaluate(IValue val, int packOffset, IBinding[] resolvedUnknowns,
ICPPTemplateParameterMap map, int maxdepth) {
try {
@ -752,10 +752,10 @@ public class Value implements IValue {
Object obj= reevaluate(reeval, maxdepth);
if (reeval.pos != reeval.fExpression.length)
return UNKNOWN;
if (obj instanceof Number)
return create(((Number) obj).longValue());
ICPPUnknownBinding[] ua;
if (unknown.isEmpty()) {
ua= ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY;
@ -768,7 +768,7 @@ public class Value implements IValue {
return UNKNOWN;
}
private static Object reevaluate(Reevaluation reeval, int maxdepth)
private static Object reevaluate(Reevaluation reeval, int maxdepth)
throws UnknownValueException {
if (maxdepth < 0)
throw UNKNOWN_EX;
@ -778,16 +778,16 @@ public class Value implements IValue {
final int length = buf.length;
if (idx >= length)
throw UNKNOWN_EX;
final char c= buf[idx];
switch (c) {
case BINARY_OP_CHAR:
case BINARY_OP_CHAR:
int op= parseNonNegative(buf, idx + 1);
reeval.nextSeperator();
Object o1= reevaluate(reeval, maxdepth);
Object o2= reevaluate(reeval, maxdepth);
return combineBinary(op, o1, o2);
case UNARY_OP_CHAR:
case UNARY_OP_CHAR:
op= parseNonNegative(buf, idx + 1);
reeval.nextSeperator();
o1= reevaluate(reeval, maxdepth);
@ -806,7 +806,7 @@ public class Value implements IValue {
}
return "" + CONDITIONAL_CHAR + SEPARATOR + cond.toString() + SEPARATOR + //$NON-NLS-1$
po.toString() + SEPARATOR + neg.toString();
case REFERENCE_CHAR:
case REFERENCE_CHAR:
int num= parseNonNegative(buf, idx + 1);
final IBinding[] resolvedUnknowns= reeval.fResolvedUnknown;
if (num >= resolvedUnknowns.length)
@ -825,7 +825,7 @@ public class Value implements IValue {
return evaluateValue(val, reeval.fUnknownSigs, reeval.fUnknowns);
}
return createTemplateParamExpression(num, false);
case TEMPLATE_PARAM_PACK_CHAR:
num= parseHex(buf, idx + 1);
reeval.nextSeperator();
@ -843,7 +843,7 @@ public class Value implements IValue {
return evaluateValue(val, reeval.fUnknownSigs, reeval.fUnknowns);
}
return createTemplateParamExpression(num, true);
default:
reeval.nextSeperator();
return parseLong(buf, idx);
@ -858,13 +858,13 @@ public class Value implements IValue {
final int len= value.length;
int result = 0;
boolean ok= false;
for(; offset < len; offset++) {
for (; offset < len; offset++) {
final int digit= (value[offset] - '0');
if (digit < 0 || digit > 9)
break;
if (result > maxvalue)
return -1;
result= result * 10 + digit;
ok= true;
}
@ -880,7 +880,7 @@ public class Value implements IValue {
int result = 0;
boolean ok= false;
final int len= value.length;
for(; offset < len; offset++) {
for (; offset < len; offset++) {
int digit= (value[offset] - '0');
if (digit < 0 || digit > 9) {
digit += '0' - 'a' + 10;
@ -893,13 +893,13 @@ public class Value implements IValue {
}
if ((result & 0xf0000000) != 0)
throw UNKNOWN_EX;
result= (result << 4) + digit;
ok= true;
}
if (!ok)
throw UNKNOWN_EX;
return result;
}
@ -911,26 +911,26 @@ public class Value implements IValue {
final int len= value.length;
boolean negative= false;
long result = 0;
boolean ok= false;
if (offset < len && value[offset] == '-') {
negative = true;
offset++;
}
for(; offset < len; offset++) {
for (; offset < len; offset++) {
final int digit= (value[offset] - '0');
if (digit < 0 || digit > 9)
break;
if (result > maxvalue)
throw UNKNOWN_EX;
result= result * 10 + digit;
ok= true;
}
if (!ok)
throw UNKNOWN_EX;
return negative ? -result : result;
}
@ -943,18 +943,18 @@ public class Value implements IValue {
boolean negative= false;
long result = 0;
int i= 0;
if (len > 0 && value[0] == '-') {
negative = true;
i++;
}
if (i == len)
return null;
for(; i < len; i++) {
for (; i < len; i++) {
if (result > maxvalue)
return null;
final int digit= (value[i] - '0');
if (digit < 0 || digit > 9)
return null;
@ -993,7 +993,7 @@ public class Value implements IValue {
}
public static IValue create(ICPPEvaluation eval, IASTNode point) {
// compute value of evaluation
// Compute value of evaluation
return Value.UNKNOWN;
}
}

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -50,7 +49,7 @@ public class EvalBinary implements ICPPEvaluation {
private final ICPPEvaluation fArg1;
private final ICPPEvaluation fArg2;
private ICPPFunction fOverload= CPPFunction.UNINITIALIZED_FUNCTION;
private IType fType;
@ -81,7 +80,7 @@ public class EvalBinary implements ICPPEvaluation {
public boolean isFunctionSet() {
return false;
}
@Override
public IType getTypeOrFunctionSet(IASTNode point) {
if (fType == null) {
@ -121,11 +120,11 @@ public class EvalBinary implements ICPPEvaluation {
@Override
public ValueCategory getValueCategory(IASTNode point) {
if (isTypeDependent())
if (isTypeDependent())
return ValueCategory.PRVALUE;
ICPPFunction overload = getOverload(point);
if (overload != null)
if (overload != null)
return ExpressionTypes.valueCategoryFromFunctionCall(overload);
switch (fOperator) {
@ -144,12 +143,12 @@ public class EvalBinary implements ICPPEvaluation {
return LVALUE;
case IASTBinaryExpression.op_pmdot:
if (!(getTypeOrFunctionSet(point) instanceof ICPPFunctionType))
if (!(getTypeOrFunctionSet(point) instanceof ICPPFunctionType))
return fArg1.getValueCategory(point);
break;
case IASTBinaryExpression.op_pmarrow:
if (!(getTypeOrFunctionSet(point) instanceof ICPPFunctionType))
if (!(getTypeOrFunctionSet(point) instanceof ICPPFunctionType))
return LVALUE;
break;
}
@ -186,15 +185,15 @@ public class EvalBinary implements ICPPEvaluation {
public IType computeType(IASTNode point) {
// Check for overloaded operator.
ICPPFunction o= getOverload(point);
if (o != null)
if (o != null)
return typeFromFunctionCall(o);
final IType originalType1 = fArg1.getTypeOrFunctionSet(point);
final IType type1 = prvalueTypeWithResolvedTypedefs(originalType1);
if (type1 instanceof ISemanticProblem) {
return type1;
}
final IType originalType2 = fArg2.getTypeOrFunctionSet(point);
final IType type2 = prvalueTypeWithResolvedTypedefs(originalType2);
if (type2 instanceof ISemanticProblem) {
@ -206,7 +205,6 @@ public class EvalBinary implements ICPPEvaluation {
return ExpressionTypes.restoreTypedefs(type, originalType1, originalType2);
}
switch (fOperator) {
case op_arrayAccess:
if (type1 instanceof IPointerType) {
@ -216,7 +214,7 @@ public class EvalBinary implements ICPPEvaluation {
return glvalueType(((IPointerType) type2).getType());
}
return ProblemType.UNKNOWN_FOR_EXPRESSION;
case IASTBinaryExpression.op_lessEqual:
case IASTBinaryExpression.op_lessThan:
case IASTBinaryExpression.op_greaterEqual:
@ -230,10 +228,10 @@ public class EvalBinary implements ICPPEvaluation {
case IASTBinaryExpression.op_plus:
if (type1 instanceof IPointerType) {
return ExpressionTypes.restoreTypedefs(type1, originalType1);
}
}
if (type2 instanceof IPointerType) {
return ExpressionTypes.restoreTypedefs(type2, originalType2);
}
}
break;
case IASTBinaryExpression.op_minus:
@ -268,7 +266,7 @@ public class EvalBinary implements ICPPEvaluation {
buffer.marshalEvaluation(fArg1, includeValue);
buffer.marshalEvaluation(fArg2, includeValue);
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte();
ICPPEvaluation arg1= (ICPPEvaluation) buffer.unmarshalEvaluation();

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
@ -33,10 +32,10 @@ import org.eclipse.core.runtime.CoreException;
public class EvalBinaryTypeId implements ICPPEvaluation {
private final Operator fOperator;
private final IType fType1, fType2;
private boolean fCheckedValueDependent;
private boolean fIsValueDependent;
public EvalBinaryTypeId(Operator kind, IType type1, IType type2) {
fOperator= kind;
fType1= type1;
@ -105,7 +104,7 @@ public class EvalBinaryTypeId implements ICPPEvaluation {
buffer.marshalType(fType1);
buffer.marshalType(fType2);
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte();
IType arg1= buffer.unmarshalType();

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType;
@ -35,7 +34,7 @@ import org.eclipse.core.runtime.CoreException;
public class EvalBinding implements ICPPEvaluation {
private final IBinding fBinding;
private final boolean fFixedType;
private IType fType;
private boolean fCheckedIsValueDependent;
private boolean fIsValueDependent;
@ -56,7 +55,7 @@ public class EvalBinding implements ICPPEvaluation {
public IType getFixedType() {
return fFixedType ? fType : null;
}
@Override
public boolean isInitializerList() {
return false;
@ -75,9 +74,9 @@ public class EvalBinding implements ICPPEvaluation {
}
return fIsTypeDependent;
}
private boolean computeIsTypeDependent() {
if (fBinding instanceof ICPPUnknownBinding)
if (fBinding instanceof ICPPUnknownBinding)
return true;
IType t= null;
@ -105,26 +104,26 @@ public class EvalBinding implements ICPPEvaluation {
}
return fIsValueDependent;
}
private boolean computeIsValueDependent() {
if (fBinding instanceof IEnumerator) {
return Value.isDependentValue(((IEnumerator) fBinding).getValue());
}
}
if (fBinding instanceof ICPPTemplateNonTypeParameter) {
return true;
}
if (fBinding instanceof IVariable) {
return Value.isDependentValue(((IVariable) fBinding).getInitialValue());
}
}
if (fBinding instanceof IFunction) {
return false;
}
}
if (fBinding instanceof ICPPUnknownBinding) {
return true;
}
}
return false;
}
@Override
public IType getTypeOrFunctionSet(IASTNode point) {
if (fType == null) {
@ -132,42 +131,42 @@ public class EvalBinding implements ICPPEvaluation {
}
return fType;
}
private IType computeType(IASTNode point) {
if (fBinding instanceof IEnumerator) {
return ((IEnumerator) fBinding).getType();
}
}
if (fBinding instanceof ICPPTemplateNonTypeParameter) {
IType type= ((ICPPTemplateNonTypeParameter) fBinding).getType();
if (CPPTemplates.isDependentType(type))
return new TypeOfDependentExpression(this);
return prvalueType(type);
}
}
if (fBinding instanceof IVariable) {
final IType type = ((IVariable) fBinding).getType();
if (CPPTemplates.isDependentType(type))
return new TypeOfDependentExpression(this);
return SemanticUtil.mapToAST(glvalueType(type), point);
}
}
if (fBinding instanceof IFunction) {
final IFunctionType type = ((IFunction) fBinding).getType();
if (CPPTemplates.isDependentType(type))
return new TypeOfDependentExpression(this);
return SemanticUtil.mapToAST(type, point);
}
}
return ProblemType.UNKNOWN_FOR_EXPRESSION;
}
@Override
public IValue getValue(IASTNode point) {
return Value.create(this, point);
}
@Override
public ValueCategory getValueCategory(IASTNode point) {
if (fBinding instanceof ICPPTemplateNonTypeParameter)
return ValueCategory.PRVALUE;
if (fBinding instanceof IVariable || fBinding instanceof IFunction) {
return ValueCategory.LVALUE;
}
@ -180,7 +179,7 @@ public class EvalBinding implements ICPPEvaluation {
buffer.marshalBinding(fBinding);
buffer.marshalType(fFixedType ? fType : null);
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
IBinding binding= buffer.unmarshalBinding();
IType type= buffer.unmarshalType();

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall;
@ -31,9 +30,9 @@ public class EvalComma implements ICPPEvaluation {
private final ICPPEvaluation[] fArguments;
private ICPPFunction[] fOverloads;
private IType fType;
public EvalComma(ICPPEvaluation[] evals) {
fArguments= evals;
}
@ -54,9 +53,9 @@ public class EvalComma implements ICPPEvaluation {
@Override
public boolean isTypeDependent() {
if (fType != null)
if (fType != null)
return fType instanceof TypeOfDependentExpression;
for (ICPPEvaluation arg : fArguments) {
if (arg.isTypeDependent())
return true;
@ -83,12 +82,12 @@ public class EvalComma implements ICPPEvaluation {
private ICPPFunction[] computeOverloads(IASTNode point) {
if (fArguments.length < 2)
return NO_FUNCTIONS;
if (isTypeDependent())
return NO_FUNCTIONS;
ICPPFunction[] overloads = new ICPPFunction[fArguments.length - 1];
ICPPEvaluation e1= fArguments[0];
ICPPEvaluation e1= fArguments[0];
for (int i = 1; i < fArguments.length; i++) {
ICPPEvaluation e2 = fArguments[i];
ICPPFunction overload = CPPSemantics.findOverloadedOperatorComma(point, e1, e2);
@ -99,7 +98,7 @@ public class EvalComma implements ICPPEvaluation {
e1= new EvalFixed(typeFromFunctionCall(overload), valueCategoryFromFunctionCall(overload), Value.UNKNOWN);
if (e1.getTypeOrFunctionSet(point) instanceof ISemanticProblem) {
e1= e2;
}
}
}
}
return overloads;
@ -112,11 +111,11 @@ public class EvalComma implements ICPPEvaluation {
}
return fType;
}
private IType computeType(IASTNode point) {
if (isTypeDependent()) {
return new TypeOfDependentExpression(this);
}
}
ICPPFunction[] overloads = getOverloads(point);
if (overloads.length > 0) {
ICPPFunction last = overloads[overloads.length - 1];
@ -126,7 +125,7 @@ public class EvalComma implements ICPPEvaluation {
}
return fArguments[fArguments.length-1].getTypeOrFunctionSet(point);
}
@Override
public IValue getValue(IASTNode point) {
return Value.create(this, point);
@ -152,7 +151,7 @@ public class EvalComma implements ICPPEvaluation {
buffer.marshalEvaluation(arg, includeValue);
}
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
int len= buffer.getShort();
ICPPEvaluation[] args = new ICPPEvaluation[len];

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
@ -77,7 +76,7 @@ public class EvalCompound implements ICPPEvaluation {
buffer.putByte(ITypeMarshalBuffer.EVAL_COMPOUND);
buffer.marshalEvaluation(fDelegate, includeValue);
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation();
return new EvalCompound(arg);

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
@ -45,12 +44,12 @@ import org.eclipse.core.runtime.CoreException;
public class EvalConditional implements ICPPEvaluation {
private final ICPPEvaluation fCondition, fPositive, fNegative;
private final boolean fPositiveThrows, fNegativeThrows;
private ValueCategory fValueCategory;
private IType fType;
private ICPPFunction fOverload;
public EvalConditional(ICPPEvaluation arg1, ICPPEvaluation arg2, ICPPEvaluation arg3,
boolean positiveThrows, boolean negativeThrows) {
// Gnu-extension: Empty positive expression is replaced by condition.
@ -85,7 +84,7 @@ public class EvalConditional implements ICPPEvaluation {
public boolean isInitializerList() {
return false;
}
@Override
public boolean isFunctionSet() {
return false;
@ -95,7 +94,7 @@ public class EvalConditional implements ICPPEvaluation {
evaluate(point);
return fOverload;
}
@Override
public IType getTypeOrFunctionSet(IASTNode point) {
evaluate(point);
@ -106,36 +105,36 @@ public class EvalConditional implements ICPPEvaluation {
public IValue getValue(IASTNode point) {
return Value.create(this, point);
}
@Override
public ValueCategory getValueCategory(IASTNode point) {
evaluate(point);
return fValueCategory;
}
@Override
public boolean isTypeDependent() {
final ICPPEvaluation positive = fPositive == null ? fCondition : fPositive;
return positive.isTypeDependent() || fNegative.isTypeDependent();
}
@Override
public boolean isValueDependent() {
return fCondition.isValueDependent() || (fPositive != null && fPositive.isValueDependent())
|| fNegative.isValueDependent();
}
private void evaluate(IASTNode point) {
if (fValueCategory != null)
return;
fValueCategory= PRVALUE;
final ICPPEvaluation positive = fPositive == null ? fCondition : fPositive;
IType t2 = positive.getTypeOrFunctionSet(point);
IType t3 = fNegative.getTypeOrFunctionSet(point);
final IType uqt2= getNestedType(t2, TDEF | REF | CVTYPE);
final IType uqt3= getNestedType(t3, TDEF | REF | CVTYPE);
if (uqt2 instanceof ISemanticProblem || uqt2 instanceof ICPPUnknownType) {
@ -146,7 +145,7 @@ public class EvalConditional implements ICPPEvaluation {
fType= uqt3;
return;
}
final boolean void2= isVoidType(uqt2);
final boolean void3= isVoidType(uqt3);
@ -163,7 +162,7 @@ public class EvalConditional implements ICPPEvaluation {
}
return;
}
final ValueCategory vcat2= positive.getValueCategory(point);
final ValueCategory vcat3= fNegative.getValueCategory(point);
@ -177,8 +176,8 @@ public class EvalConditional implements ICPPEvaluation {
fValueCategory= PRVALUE;
}
return;
}
}
final boolean isClassType2 = uqt2 instanceof ICPPClassType;
final boolean isClassType3 = uqt3 instanceof ICPPClassType;
@ -211,7 +210,7 @@ public class EvalConditional implements ICPPEvaluation {
}
return;
}
// 5.16-5: At least one class type but no conversion
if (isClassType2 || isClassType3) {
fOverload = CPPSemantics.findOverloadedConditionalOperator(point, positive, fNegative);
@ -293,13 +292,13 @@ public class EvalConditional implements ICPPEvaluation {
firstByte |= ITypeMarshalBuffer.FLAG1;
if (fNegativeThrows)
firstByte |= ITypeMarshalBuffer.FLAG2;
buffer.putByte((byte) firstByte);
buffer.marshalEvaluation(fCondition, includeValue);
buffer.marshalEvaluation(fPositive, includeValue);
buffer.marshalEvaluation(fNegative, includeValue);
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
boolean pth= (firstByte & ITypeMarshalBuffer.FLAG1) != 0;
boolean nth= (firstByte & ITypeMarshalBuffer.FLAG2) != 0;

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -30,9 +29,9 @@ import org.eclipse.core.runtime.CoreException;
* Performs evaluation of an expression.
*/
public class EvalFixed implements ICPPEvaluation {
public static final ICPPEvaluation INCOMPLETE = new EvalFixed(
ProblemType.UNKNOWN_FOR_EXPRESSION, PRVALUE, Value.UNKNOWN);
public static final ICPPEvaluation INCOMPLETE =
new EvalFixed(ProblemType.UNKNOWN_FOR_EXPRESSION, PRVALUE, Value.UNKNOWN);
private final IType fType;
private final IValue fValue;
private final ValueCategory fValueCategory;
@ -108,7 +107,7 @@ public class EvalFixed implements ICPPEvaluation {
int firstByte = ITypeMarshalBuffer.EVAL_FIXED;
if (includeValue)
firstByte |= ITypeMarshalBuffer.FLAG1;
switch(fValueCategory) {
switch (fValueCategory) {
case LVALUE:
firstByte |= ITypeMarshalBuffer.FLAG2;
break;
@ -118,30 +117,30 @@ public class EvalFixed implements ICPPEvaluation {
default:
break;
}
buffer.putByte((byte) firstByte);
buffer.marshalType(fType);
if (includeValue) {
buffer.marshalValue(fValue);
}
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
final boolean readValue= (firstByte & ITypeMarshalBuffer.FLAG1) != 0;
IValue value;
ValueCategory cat;
switch (firstByte & (ITypeMarshalBuffer.FLAG2 | ITypeMarshalBuffer.FLAG3)) {
case ITypeMarshalBuffer.FLAG2:
cat= LVALUE;
break;
case ITypeMarshalBuffer.FLAG3:
cat= PRVALUE;
break;
default:
cat= XVALUE;
break;
case ITypeMarshalBuffer.FLAG2:
cat= LVALUE;
break;
case ITypeMarshalBuffer.FLAG3:
cat= PRVALUE;
break;
default:
cat= XVALUE;
break;
}
IType type= buffer.unmarshalType();
value= readValue ? buffer.unmarshalValue() : Value.UNKNOWN;
return new EvalFixed(type, cat, value);

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType;
@ -41,7 +40,7 @@ public class EvalFunctionCall implements ICPPEvaluation {
private final ICPPEvaluation[] fArguments;
private ICPPFunction fOverload= CPPFunction.UNINITIALIZED_FUNCTION;
private IType fType;
public EvalFunctionCall(ICPPEvaluation[] args) {
fArguments= args;
}
@ -88,36 +87,36 @@ public class EvalFunctionCall implements ICPPEvaluation {
private ICPPFunction computeOverload(IASTNode point) {
if (isTypeDependent())
return null;
IType t= SemanticUtil.getNestedType(fArguments[0].getTypeOrFunctionSet(point), TDEF|REF|CVTYPE);
if (t instanceof ICPPClassType) {
return CPPSemantics.findOverloadedOperator(point, fArguments, t, OverloadableOperator.PAREN, LookupMode.NO_GLOBALS);
}
return null;
}
@Override
public IType getTypeOrFunctionSet(IASTNode point) {
if (fType == null)
if (fType == null)
fType= computeType(point);
return fType;
}
private IType computeType(IASTNode point) {
if (isTypeDependent())
if (isTypeDependent())
return new TypeOfDependentExpression(this);
ICPPFunction overload = getOverload(point);
if (overload != null)
if (overload != null)
return ExpressionTypes.typeFromFunctionCall(overload);
final ICPPEvaluation arg0 = fArguments[0];
IType t= SemanticUtil.getNestedType(arg0.getTypeOrFunctionSet(point), TDEF|REF|CVTYPE);
if (t instanceof ICPPClassType) {
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
}
if (t instanceof IPointerType) {
t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TDEF | REF | CVTYPE);
}
@ -142,7 +141,7 @@ public class EvalFunctionCall implements ICPPEvaluation {
if (overload != null)
return valueCategoryFromFunctionCall(overload);
IType t= fArguments[0].getTypeOrFunctionSet(point);
if (t instanceof IPointerType) {
t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TDEF | REF | CVTYPE);
@ -161,7 +160,7 @@ public class EvalFunctionCall implements ICPPEvaluation {
buffer.marshalEvaluation(arg, includeValue);
}
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
int len= buffer.getShort();
ICPPEvaluation[] args = new ICPPEvaluation[len];

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
@ -32,7 +31,7 @@ import org.eclipse.core.runtime.CoreException;
public class EvalFunctionSet implements ICPPEvaluation {
private final CPPFunctionSet fFunctionSet;
private final boolean fAddressOf;
public EvalFunctionSet(CPPFunctionSet set, boolean addressOf) {
fFunctionSet= set;
fAddressOf= addressOf;
@ -101,7 +100,7 @@ public class EvalFunctionSet implements ICPPEvaluation {
firstByte |= ITypeMarshalBuffer.FLAG1;
if (args != null)
firstByte |= ITypeMarshalBuffer.FLAG2;
buffer.putByte((byte) firstByte);
buffer.putShort((short) bindings.length);
for (ICPPFunction binding : bindings) {
@ -111,7 +110,7 @@ public class EvalFunctionSet implements ICPPEvaluation {
// mstodo marshall arguments
}
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
final boolean addressOf= (firstByte & ITypeMarshalBuffer.FLAG1) != 0;
int bindingCount= buffer.getShort();

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -60,7 +59,7 @@ public class EvalID implements ICPPEvaluation {
fQualified= qualified;
fTemplateArgs= templateArgs;
}
public ICPPEvaluation getFieldOwner() {
return fFieldOwner;
}
@ -68,7 +67,7 @@ public class EvalID implements ICPPEvaluation {
public IBinding getNameOwner() {
return fNameOwner;
}
public char[] getName() {
return fName;
}
@ -80,11 +79,11 @@ public class EvalID implements ICPPEvaluation {
public boolean isQualified() {
return fQualified;
}
public ICPPTemplateArgument[] getTemplateArgs() {
return fTemplateArgs;
}
@Override
public boolean isInitializerList() {
return false;
@ -99,22 +98,22 @@ public class EvalID implements ICPPEvaluation {
public boolean isTypeDependent() {
return true;
}
@Override
public boolean isValueDependent() {
return true;
}
@Override
public IType getTypeOrFunctionSet(IASTNode point) {
return new TypeOfDependentExpression(this);
}
@Override
public IValue getValue(IASTNode point) {
return Value.create(this, point);
}
@Override
public ValueCategory getValueCategory(IASTNode point) {
return PRVALUE;
@ -129,7 +128,7 @@ public class EvalID implements ICPPEvaluation {
firstByte |= ITypeMarshalBuffer.FLAG2;
if (fTemplateArgs != null)
firstByte |= ITypeMarshalBuffer.FLAG3;
buffer.putByte((byte) firstByte);
buffer.marshalEvaluation(fFieldOwner, false);
buffer.putCharArray(fName);
@ -138,7 +137,7 @@ public class EvalID implements ICPPEvaluation {
// mstodo marshall arguments
}
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
final boolean addressOf= (firstByte & ITypeMarshalBuffer.FLAG1) != 0;
final boolean qualified= (firstByte & ITypeMarshalBuffer.FLAG2) != 0;
@ -155,7 +154,7 @@ public class EvalID implements ICPPEvaluation {
public static ICPPEvaluation create(IASTIdExpression expr) {
final IASTName name = expr.getName();
IBinding binding = name.resolvePreBinding();
if (binding instanceof IProblemBinding || binding instanceof IType || binding instanceof ICPPConstructor)
if (binding instanceof IProblemBinding || binding instanceof IType || binding instanceof ICPPConstructor)
return EvalFixed.INCOMPLETE;
if (binding instanceof CPPFunctionSet) {
return new EvalFunctionSet((CPPFunctionSet) binding, isAddressOf(expr));
@ -164,7 +163,7 @@ public class EvalID implements ICPPEvaluation {
IBinding owner = binding.getOwner();
if (owner instanceof IProblemBinding)
return EvalFixed.INCOMPLETE;
ICPPEvaluation fieldOwner= null;
IType fieldOwnerType= withinNonStaticMethod(expr);
if (fieldOwnerType != null) {
@ -175,20 +174,20 @@ public class EvalID implements ICPPEvaluation {
if (lastName instanceof ICPPASTTemplateId) {
templateArgs= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) lastName);
}
return new EvalID(fieldOwner, owner, name.getSimpleID(), isAddressOf(expr),
return new EvalID(fieldOwner, owner, name.getSimpleID(), isAddressOf(expr),
name instanceof ICPPASTQualifiedName, templateArgs);
}
/**
* 9.3.1-3 Transformation to class member access within a non-static member function.
* 9.3.1-3 Transformation to class member access within a non-static member function.
*/
if (binding instanceof ICPPMember && !(binding instanceof IType)
if (binding instanceof ICPPMember && !(binding instanceof IType)
&& !(binding instanceof ICPPConstructor) &&!((ICPPMember) binding).isStatic()) {
IType fieldOwnerType= withinNonStaticMethod(expr);
if (fieldOwnerType != null) {
return new EvalMemberAccess(fieldOwnerType, LVALUE, binding, true);
}
}
if (binding instanceof IEnumerator) {
IType type= ((IEnumerator) binding).getType();
if (type instanceof ICPPEnumeration) {
@ -206,7 +205,7 @@ public class EvalID implements ICPPEvaluation {
}
}
return new EvalBinding(binding, null);
}
}
if (binding instanceof ICPPTemplateNonTypeParameter || binding instanceof IVariable
|| binding instanceof IFunction) {
return new EvalBinding(binding, null);
@ -239,7 +238,7 @@ public class EvalID implements ICPPEvaluation {
e= unary.getOperand();
} else {
return op == IASTUnaryExpression.op_amper;
}
}
}
return false;
}

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
@ -32,7 +31,7 @@ public class EvalInitList implements ICPPEvaluation {
public EvalInitList(ICPPEvaluation[] clauses) {
fClauses= clauses;
}
public ICPPEvaluation[] getClauses() {
return fClauses;
}
@ -88,7 +87,7 @@ public class EvalInitList implements ICPPEvaluation {
buffer.marshalEvaluation(arg, includeValue);
}
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
int len= buffer.getShort();
ICPPEvaluation[] args = new ICPPEvaluation[len];

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -70,7 +69,7 @@ public class EvalMemberAccess implements ICPPEvaluation {
public IType getOwnerType() {
return fOwnerType;
}
public ValueCategory getOwnerValueCategory() {
return fOwnerValueCategory;
}
@ -101,7 +100,7 @@ public class EvalMemberAccess implements ICPPEvaluation {
}
return fIsTypeDependent;
}
private boolean computeIsTypeDependent() {
IType t;
if (fMember instanceof ICPPUnknownBinding) {
@ -126,71 +125,71 @@ public class EvalMemberAccess implements ICPPEvaluation {
}
return fIsValueDependent;
}
private boolean computeIsValueDependent() {
if (fMember instanceof ICPPUnknownBinding) {
return true;
}
}
if (fMember instanceof IEnumerator) {
return Value.isDependentValue(((IEnumerator) fMember).getValue());
}
}
if (fMember instanceof IVariable) {
return Value.isDependentValue(((IVariable) fMember).getInitialValue());
}
}
if (fMember instanceof IFunction) {
return false;
}
}
return false;
}
public static IType getFieldOwnerType(IType fieldOwnerExpressionType, boolean isDeref, IASTNode point, Collection<ICPPFunction> functionBindings,
boolean returnUnnamed) {
IType type= fieldOwnerExpressionType;
if (!isDeref)
return type;
// Bug 205964: as long as the type is a class type, recurse.
// Bug 205964: as long as the type is a class type, recurse.
// Be defensive and allow a max of 20 levels.
for (int j = 0; j < 20; j++) {
IType classType= getUltimateTypeUptoPointers(type);
if (!(classType instanceof ICPPClassType))
if (!(classType instanceof ICPPClassType))
break;
IScope scope = ((ICPPClassType) classType).getCompositeScope();
if (scope == null || scope instanceof ICPPInternalUnknownScope)
break;
/*
* 13.5.6-1: An expression x->m is interpreted as (x.operator->())->m for a
* class object x of type T
*
*
* Construct an AST fragment for x.operator-> which the lookup routines can
* examine for type information.
*/
ICPPEvaluation[] args= {new EvalFixed(type, LVALUE, Value.UNKNOWN)};
ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType, OverloadableOperator.ARROW, LookupMode.NO_GLOBALS);
if (op == null)
if (op == null)
break;
if (functionBindings != null)
functionBindings.add(op);
type= typeFromFunctionCall(op);
type= SemanticUtil.mapToAST(type, point);
}
IType prValue= prvalueTypeWithResolvedTypedefs(type);
if (prValue instanceof IPointerType) {
return glvalueType(((IPointerType) prValue).getType());
}
if (CPPTemplates.isDependentType(type))
return returnUnnamed ? CPPUnknownClass.createUnnamedInstance() : null;
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
}
@Override
public IType getTypeOrFunctionSet(IASTNode point) {
if (fType == null) {
@ -198,14 +197,14 @@ public class EvalMemberAccess implements ICPPEvaluation {
}
return fType;
}
private IType computeType(IASTNode point) {
if (fMember instanceof ICPPUnknownBinding) {
return new TypeOfDependentExpression(this);
}
if (fMember instanceof IEnumerator) {
return ((IEnumerator) fMember).getType();
}
}
if (fMember instanceof IVariable) {
IType e2 = ((IVariable) fMember).getType();
e2= SemanticUtil.getNestedType(e2, TDEF);
@ -220,15 +219,15 @@ public class EvalMemberAccess implements ICPPEvaluation {
} else {
e2= glvalueType(e2);
}
}
}
return SemanticUtil.mapToAST(e2, point);
}
}
if (fMember instanceof IFunction) {
return SemanticUtil.mapToAST(((IFunction) fMember).getType(), point);
}
return ProblemType.UNKNOWN_FOR_EXPRESSION;
}
private IType addQualifiersForAccess(ICPPField field, IType fieldType, IType ownerType) {
CVQualifier cvq1 = SemanticUtil.getCVQualifier(ownerType);
CVQualifier cvq2 = SemanticUtil.getCVQualifier(fieldType);
@ -248,7 +247,7 @@ public class EvalMemberAccess implements ICPPEvaluation {
public IValue getValue(IASTNode point) {
return Value.create(this, point);
}
@Override
public ValueCategory getValueCategory(IASTNode point) {
if (fMember instanceof IVariable) {
@ -256,7 +255,7 @@ public class EvalMemberAccess implements ICPPEvaluation {
e2= SemanticUtil.getNestedType(e2, TDEF);
if (e2 instanceof ICPPReferenceType) {
return LVALUE;
}
}
if (fMember instanceof ICPPField && !((ICPPField) fMember).isStatic()) {
if (fIsPointerDeref)
return LVALUE;
@ -264,7 +263,7 @@ public class EvalMemberAccess implements ICPPEvaluation {
return fOwnerValueCategory;
}
return LVALUE;
}
}
if (fMember instanceof IFunction) {
return LVALUE;
}
@ -281,12 +280,12 @@ public class EvalMemberAccess implements ICPPEvaluation {
} else if (fOwnerValueCategory == XVALUE) {
firstByte |= ITypeMarshalBuffer.FLAG3;
}
buffer.putByte((byte) firstByte);
buffer.marshalType(fOwnerType);
buffer.marshalBinding(fMember);
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
boolean isDeref= (firstByte & ITypeMarshalBuffer.FLAG1) != 0;
ValueCategory ownerValueCat;
@ -297,7 +296,7 @@ public class EvalMemberAccess implements ICPPEvaluation {
} else {
ownerValueCat= PRVALUE;
}
IType ownerType= buffer.unmarshalType();
IBinding member= buffer.unmarshalBinding();
return new EvalMemberAccess(ownerType, ownerValueCat, member, isDeref);

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType;
@ -31,7 +30,7 @@ public class EvalTypeId implements ICPPEvaluation {
private final IType fInputType;
private final ICPPEvaluation[] fArguments;
private IType fOutputType;
public EvalTypeId(IType type, ICPPEvaluation... argument) {
fInputType= type;
fArguments= argument;
@ -44,7 +43,7 @@ public class EvalTypeId implements ICPPEvaluation {
public ICPPEvaluation[] getArguments() {
return fArguments;
}
@Override
public boolean isInitializerList() {
return false;
@ -62,7 +61,7 @@ public class EvalTypeId implements ICPPEvaluation {
}
return fOutputType;
}
private IType computeType() {
if (CPPTemplates.isDependentType(fInputType))
return new TypeOfDependentExpression(this);
@ -103,7 +102,7 @@ public class EvalTypeId implements ICPPEvaluation {
int firstByte = ITypeMarshalBuffer.EVAL_TYPE_ID;
if (includeValue)
firstByte |= ITypeMarshalBuffer.FLAG1;
buffer.putByte((byte) firstByte);
buffer.marshalType(fInputType);
if (includeValue) {
@ -113,7 +112,7 @@ public class EvalTypeId implements ICPPEvaluation {
}
}
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
IType type= buffer.unmarshalType();
ICPPEvaluation[] args= null;

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -42,12 +41,12 @@ import org.eclipse.core.runtime.CoreException;
public class EvalUnary implements ICPPEvaluation {
private static final ICPPEvaluation ZERO_EVAL = new EvalFixed(CPPSemantics.INT_TYPE, PRVALUE, Value.create(0));
private final int fOperator;
private final ICPPEvaluation fArgument;
private ICPPFunction fOverload= CPPFunction.UNINITIALIZED_FUNCTION;
private IType fType;
public EvalUnary(int operator, ICPPEvaluation operand) {
fOperator= operator;
fArgument= operand;
@ -60,7 +59,7 @@ public class EvalUnary implements ICPPEvaluation {
public ICPPEvaluation getArgument() {
return fArgument;
}
@Override
public boolean isInitializerList() {
return false;
@ -73,7 +72,7 @@ public class EvalUnary implements ICPPEvaluation {
@Override
public boolean isTypeDependent() {
if (fType != null)
if (fType != null)
return fType instanceof TypeOfDependentExpression;
switch(fOperator) {
@ -115,10 +114,10 @@ public class EvalUnary implements ICPPEvaluation {
OverloadableOperator op = OverloadableOperator.fromUnaryExpression(fOperator);
if (op == null)
return null;
if (fArgument.isTypeDependent())
return null;
IType type = fArgument.getTypeOrFunctionSet(point);
type = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE);
if (!CPPSemantics.isUserDefined(type))
@ -132,20 +131,20 @@ public class EvalUnary implements ICPPEvaluation {
}
return CPPSemantics.findOverloadedOperator(point, args, type, op, LookupMode.LIMITED_GLOBALS);
}
@Override
public IType getTypeOrFunctionSet(IASTNode point) {
if (fType == null)
if (fType == null)
fType= computeType(point);
return fType;
}
private IType computeType(IASTNode point) {
if (isTypeDependent())
if (isTypeDependent())
return new TypeOfDependentExpression(this);
ICPPFunction overload = getOverload(point);
if (overload != null)
if (overload != null)
return ExpressionTypes.typeFromFunctionCall(overload);
switch (fOperator) {
@ -163,7 +162,7 @@ public class EvalUnary implements ICPPEvaluation {
type = prvalueTypeWithResolvedTypedefs(type);
if (type instanceof IPointerType) {
return glvalueType(((IPointerType) type).getType());
}
}
if (type instanceof ISemanticProblem) {
return type;
}
@ -212,7 +211,7 @@ public class EvalUnary implements ICPPEvaluation {
buffer.putByte((byte) fOperator);
buffer.marshalEvaluation(fArgument, includeValue);
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte();
ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation();

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
@ -31,7 +30,7 @@ public class EvalUnaryTypeID implements ICPPEvaluation {
private final int fOperator;
private final IType fOrigType;
private IType fType;
public EvalUnaryTypeID(int operator, IType type) {
fOperator= operator;
fOrigType= type;
@ -44,7 +43,7 @@ public class EvalUnaryTypeID implements ICPPEvaluation {
public IType getArgument() {
return fOrigType;
}
@Override
public boolean isInitializerList() {
return false;
@ -82,7 +81,7 @@ public class EvalUnaryTypeID implements ICPPEvaluation {
case op_is_polymorphic:
case op_is_union:
return CPPTemplates.isDependentType(fOrigType);
case op_typeid:
case op_typeof:
return false;
@ -92,11 +91,11 @@ public class EvalUnaryTypeID implements ICPPEvaluation {
@Override
public IType getTypeOrFunctionSet(IASTNode point) {
if (fType == null)
if (fType == null)
fType= computeType(point);
return fType;
}
private IType computeType(IASTNode point) {
switch (fOperator) {
case op_sizeof:
@ -120,7 +119,7 @@ public class EvalUnaryTypeID implements ICPPEvaluation {
case op_is_union:
return CPPBasicType.BOOLEAN;
case op_typeof:
if (isTypeDependent())
if (isTypeDependent())
return new TypeOfDependentExpression(this);
return fOrigType;
}
@ -143,7 +142,7 @@ public class EvalUnaryTypeID implements ICPPEvaluation {
buffer.putByte((byte) fOperator);
buffer.marshalType(fType);
}
public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte();
IType arg= buffer.unmarshalType();

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.db;
import org.eclipse.cdt.core.CCorePlugin;
@ -29,13 +29,13 @@ import org.eclipse.core.runtime.CoreException;
* For marshalling types to byte arrays.
*/
public class TypeMarshalBuffer implements ITypeMarshalBuffer {
public final static byte[] EMPTY= { 0, 0, 0, 0, 0, 0 };
public final static byte NULL_TYPE= 0;
public final static byte INDIRECT_TYPE= (byte) -1;
public final static byte BINDING_TYPE= (byte) -2;
public final static byte UNSTORABLE_TYPE= (byte) -3;
public final static IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
public static final byte[] EMPTY= { 0, 0, 0, 0, 0, 0 };
public static final byte NULL_TYPE= 0;
public static final byte INDIRECT_TYPE= (byte) -1;
public static final byte BINDING_TYPE= (byte) -2;
public static final byte UNSTORABLE_TYPE= (byte) -3;
public static final IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
static {
assert EMPTY.length == Database.TYPE_SIZE;
@ -83,14 +83,14 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
putByte((byte) 0);
putRecordPointer(pb.getRecord());
}
}
}
}
@Override
public IBinding unmarshalBinding() throws CoreException {
if (fPos >= fBuffer.length)
throw unmarshallingError();
byte firstByte= fBuffer[fPos];
if (firstByte == BINDING_TYPE) {
fPos+= 2;
@ -99,12 +99,12 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
} else if (firstByte == NULL_TYPE || firstByte == UNSTORABLE_TYPE) {
fPos++;
return null;
}
}
IType type= fLinkage.unmarshalType(this);
if (type == null || type instanceof IBinding)
return (IBinding) type;
throw unmarshallingError();
}
@ -126,10 +126,10 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
public IType unmarshalType() throws CoreException {
if (fPos >= fBuffer.length)
throw unmarshallingError();
byte firstByte= fBuffer[fPos];
if (firstByte == BINDING_TYPE) {
fPos+= 2;
fPos += 2;
long rec= getRecordPointer();
return (IType) fLinkage.getNode(rec);
} else if (firstByte == NULL_TYPE) {
@ -139,7 +139,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
fPos++;
return UNSTORABLE_TYPE_PROBLEM;
}
return fLinkage.unmarshalType(this);
}
@ -150,18 +150,18 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
} else {
eval.marshal(this, includeValues);
}
}
}
@Override
public ISerializableEvaluation unmarshalEvaluation() throws CoreException {
if (fPos >= fBuffer.length)
throw unmarshallingError();
byte firstByte= fBuffer[fPos];
if (firstByte == NULL_TYPE) {
fPos++;
return null;
}
}
return fLinkage.unmarshalEvaluation(this);
}
@ -171,14 +171,14 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
((Value) value).marshall(this);
} else {
putByte(NULL_TYPE);
}
}
}
@Override
public IValue unmarshalValue() throws CoreException {
if (fPos >= fBuffer.length)
throw unmarshallingError();
return Value.unmarshal(this);
}
@ -209,7 +209,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
@Override
public int getByte() throws CoreException {
if (fPos+1 > fBuffer.length)
if (fPos + 1 > fBuffer.length)
throw unmarshallingError();
return 0xff & fBuffer[fPos++];
}
@ -218,6 +218,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
public CoreException unmarshallingError() {
return new CoreException(CCorePlugin.createStatus("Unmarshalling error")); //$NON-NLS-1$
}
public CoreException marshallingError() {
return new CoreException(CCorePlugin.createStatus("Marshalling error")); //$NON-NLS-1$
}
@ -225,31 +226,31 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
@Override
public void putShort(short value) {
request(2);
fBuffer[fPos++]= (byte)(value >> 8);
fBuffer[fPos++]= (byte)(value);
fBuffer[fPos++]= (byte) (value >> 8);
fBuffer[fPos++]= (byte) (value);
}
@Override
public int getShort() throws CoreException {
if (fPos+2 > fBuffer.length)
if (fPos + 2 > fBuffer.length)
throw unmarshallingError();
final int byte1 = 0xff & fBuffer[fPos++];
final int byte2 = 0xff & fBuffer[fPos++];
return (((byte1 << 8) | (byte2 & 0xff)));
}
public void putInt(int value) {
request(4);
fPos += 4;
int p= fPos;
fBuffer[--p]= (byte)(value); value >>= 8;
fBuffer[--p]= (byte)(value); value >>= 8;
fBuffer[--p]= (byte)(value); value >>= 8;
fBuffer[--p]= (byte)(value);
fBuffer[--p]= (byte) (value); value >>= 8;
fBuffer[--p]= (byte) (value); value >>= 8;
fBuffer[--p]= (byte) (value); value >>= 8;
fBuffer[--p]= (byte) (value);
}
public int getInt() throws CoreException {
if (fPos+4 > fBuffer.length)
if (fPos + 4 > fBuffer.length)
throw unmarshallingError();
int result= 0;
result |= fBuffer[fPos++] & 0xff; result <<= 8;
@ -264,19 +265,19 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
request(8);
fPos += 8;
int p= fPos;
fBuffer[--p]= (byte)(value); value >>= 8;
fBuffer[--p]= (byte)(value); value >>= 8;
fBuffer[--p]= (byte)(value); value >>= 8;
fBuffer[--p]= (byte)(value); value >>= 8;
fBuffer[--p]= (byte)(value); value >>= 8;
fBuffer[--p]= (byte)(value); value >>= 8;
fBuffer[--p]= (byte)(value); value >>= 8;
fBuffer[--p]= (byte)(value);
fBuffer[--p]= (byte) (value); value >>= 8;
fBuffer[--p]= (byte) (value); value >>= 8;
fBuffer[--p]= (byte) (value); value >>= 8;
fBuffer[--p]= (byte) (value); value >>= 8;
fBuffer[--p]= (byte) (value); value >>= 8;
fBuffer[--p]= (byte) (value); value >>= 8;
fBuffer[--p]= (byte) (value); value >>= 8;
fBuffer[--p]= (byte) (value);
}
@Override
public long getLong() throws CoreException {
if (fPos+8 > fBuffer.length)
if (fPos + 8 > fBuffer.length)
throw unmarshallingError();
long result= 0;
result |= fBuffer[fPos++] & 0xff; result <<= 8;
@ -293,7 +294,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
private void putRecordPointer(long record) {
request(Database.PTR_SIZE);
Chunk.putRecPtr(record, fBuffer, fPos);
fPos+= Database.PTR_SIZE;
fPos += Database.PTR_SIZE;
}
private long getRecordPointer() throws CoreException {

View file

@ -13,11 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
@ -119,6 +114,11 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
/**
* Container for c++-entities.
*/
@ -127,15 +127,15 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
public final static int CACHE_BASES= 1;
public final static int CACHE_INSTANCES= 2;
public final static int CACHE_INSTANCE_SCOPE= 3;
private final static int FIRST_NAMESPACE_CHILD_OFFSET= PDOMLinkage.RECORD_SIZE;
@SuppressWarnings("hiding")
private final static int RECORD_SIZE= FIRST_NAMESPACE_CHILD_OFFSET + Database.PTR_SIZE;
// Only used when writing to database, which is single-threaded
private final LinkedList<Runnable> postProcesses = new LinkedList<Runnable>();
private final LinkedList<Runnable> postProcesses = new LinkedList<Runnable>();
public PDOMCPPLinkage(PDOM pdom, long record) {
super(pdom, record);
}
@ -168,13 +168,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
class ConfigureTemplateParameters implements Runnable {
private final IPDOMCPPTemplateParameter[] fPersisted;
private final ICPPTemplateParameter[] fOriginal;
public ConfigureTemplateParameters(ICPPTemplateParameter[] original, IPDOMCPPTemplateParameter[] params) {
fOriginal= original;
fPersisted= params;
postProcesses.add(this);
}
@Override
public void run() {
for (int i = 0; i < fOriginal.length; i++) {
@ -184,18 +184,18 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
}
}
class ConfigurePartialSpecialization implements Runnable {
IPDOMPartialSpecialization partial;
ICPPClassTemplatePartialSpecialization binding;
public ConfigurePartialSpecialization(IPDOMPartialSpecialization partial,
ICPPClassTemplatePartialSpecialization binding) {
this.partial = partial;
this.binding = binding;
postProcesses.add(this);
}
@Override
public void run() {
try {
@ -209,7 +209,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
}
}
class ConfigureFunctionTemplate implements Runnable {
private final PDOMCPPFunctionTemplate fTemplate;
private final IPDOMCPPTemplateParameter[] fTemplateParameters;
@ -217,7 +217,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
private final ICPPFunctionType fOriginalFunctionType;
private final ICPPParameter[] fOriginalParameters;
private final IType[] fOriginalExceptionSpec;
public ConfigureFunctionTemplate(ICPPFunctionTemplate original, PDOMCPPFunctionTemplate template) throws DOMException {
fTemplate = template;
fTemplateParameters= template.getTemplateParameters();
@ -227,7 +227,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
fOriginalExceptionSpec= template.extractExceptionSpec(original);
postProcesses.add(this);
}
@Override
public void run() {
for (int i = 0; i < fOriginalTemplateParameters.length; i++) {
@ -238,7 +238,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
fTemplate.initData(fOriginalFunctionType, fOriginalParameters, fOriginalExceptionSpec);
}
}
/**
* Adds or returns existing binding for the given name.
*/
@ -255,7 +255,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
addImplicitMethods(pdomBinding, (ICPPClassType) binding);
}
}
handlePostProcesses();
return pdomBinding;
}
@ -277,18 +277,18 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (cannotAdapt(inputBinding)) {
return null;
}
PDOMBinding pdomBinding= attemptFastAdaptBinding(inputBinding);
if (pdomBinding == null) {
// assign names to anonymous types.
IBinding binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(inputBinding);
if (binding == null)
if (binding == null)
return null;
final PDOMNode parent= adaptOrAddParent(true, binding);
if (parent == null)
return null;
long fileLocalRec[]= {0};
pdomBinding = adaptBinding(parent, binding, fileLocalRec);
if (pdomBinding != null) {
@ -349,9 +349,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
PDOMNode parent2= null;
// template parameters are created directly by their owners.
if (binding instanceof ICPPTemplateParameter)
if (binding instanceof ICPPTemplateParameter)
return null;
if (binding instanceof ICPPSpecialization) {
IBinding specialized = ((ICPPSpecialization) binding).getSpecializedBinding();
PDOMBinding pdomSpecialized= addBinding(specialized, null);
@ -427,7 +427,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
insertIntoNestedBindingsIndex(pdomBinding);
}
}
return pdomBinding;
}
@ -438,8 +438,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
((PDOMCPPNamespace) node).addToList(record + FIRST_NAMESPACE_CHILD_OFFSET);
}
}
private PDOMBinding createSpecialization(PDOMNode parent, PDOMBinding orig, IBinding special)
private PDOMBinding createSpecialization(PDOMNode parent, PDOMBinding orig, IBinding special)
throws CoreException, DOMException {
PDOMBinding result= null;
if (special instanceof ICPPDeferredClassInstance) {
@ -465,7 +465,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
result= new PDOMCPPFieldSpecialization(this, parent, (ICPPField) special, orig);
} else if (special instanceof ICPPFunctionTemplate) {
if (special instanceof ICPPConstructor) {
result= new PDOMCPPConstructorTemplateSpecialization( this, parent, (ICPPConstructor) special, orig);
result= new PDOMCPPConstructorTemplateSpecialization( this, parent, (ICPPConstructor) special, orig);
} else if (special instanceof ICPPMethod) {
result= new PDOMCPPMethodTemplateSpecialization( this, parent, (ICPPMethod) special, orig);
} else if (special instanceof ICPPFunction) {
@ -486,10 +486,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} else if (special instanceof ICPPUsingDeclaration) {
result= new PDOMCPPUsingDeclarationSpecialization(this, parent, (ICPPUsingDeclaration) special, orig);
}
return result;
}
private void addImplicitMethods(PDOMBinding type, ICPPClassType binding) throws CoreException {
try {
final long fileLocalRec= type.getLocalToFileRec();
@ -537,7 +537,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} else if (binding instanceof ICPPFunction) {
return CPP_FUNCTION_INSTANCE;
} else if (binding instanceof ICPPClassType) {
return CPP_CLASS_INSTANCE;
return CPP_CLASS_INSTANCE;
}
} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
if (binding instanceof ICPPClassTemplatePartialSpecializationSpecialization)
@ -619,7 +619,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} else if (binding instanceof ITypedef) {
return CPPTYPEDEF;
}
return 0;
}
@ -682,7 +682,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (fileLocalRecHolder == null)
return glob;
final long loc= getLocalToFileRec(parent, binding, glob);
if (loc == 0)
if (loc == 0)
return glob;
fileLocalRecHolder[0]= loc;
return CPPFindBinding.findBinding(getIndex(), this, binding, loc);
@ -693,7 +693,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (fileLocalRecHolder == null)
return glob;
final long loc= getLocalToFileRec(parent, binding, glob);
if (loc == 0)
if (loc == 0)
return glob;
fileLocalRecHolder[0]= loc;
return CPPFindBinding.findBinding(btree, this, binding, loc);
@ -705,7 +705,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (parent instanceof IPDOMMemberOwner) {
PDOMBinding glob= CPPFindBinding.findBinding(parent, this, binding, 0);
final long loc= getLocalToFileRec(parent, binding, glob);
if (loc == 0)
if (loc == 0)
return glob;
fileLocalRecHolder[0]= loc;
return CPPFindBinding.findBinding(parent, this, binding, loc);
@ -714,7 +714,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
/**
* Adapts the parent of the given binding to an object contained in this linkage. May return
* Adapts the parent of the given binding to an object contained in this linkage. May return
* <code>null</code> if the binding cannot be adapted or the binding does not exist and addParent
* is set to <code>false</code>.
* @param binding the binding to adapt
@ -747,7 +747,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
owner= owner.getOwner();
}
}
if (owner == null)
return this;
@ -766,7 +766,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
postProcesses.removeFirst().run();
}
}
@Override
public PDOMNode getNode(long record, int nodeType) throws CoreException {
switch (nodeType) {
@ -863,7 +863,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
@Override
public void onCreateName(PDOMFile file, IASTName name, PDOMName pdomName) throws CoreException {
super.onCreateName(file, name, pdomName);
IASTNode parentNode= name.getParent();
if (parentNode instanceof ICPPASTQualifiedName) {
if (name != ((ICPPASTQualifiedName) parentNode).getLastName())
@ -897,7 +897,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
IScope container= CPPVisitor.getContainingScope(name);
boolean doit= false;
PDOMCPPNamespace containerNS= null;
IASTNode node= ASTInternal.getPhysicalNodeOfScope(container);
if (node instanceof IASTTranslationUnit) {
doit= true;
@ -931,7 +931,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
}
}
} else if (parentNode instanceof ICPPASTFunctionDeclarator) {
} else if (parentNode instanceof ICPPASTFunctionDeclarator) {
if (parentNode.getParent() instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration grandparentNode = (IASTSimpleDeclaration) parentNode.getParent();
if (grandparentNode.getDeclSpecifier() instanceof ICPPASTDeclSpecifier) {
@ -974,7 +974,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
@Override
public void onDeleteName(PDOMName pdomName) throws CoreException {
super.onDeleteName(pdomName);
if (pdomName.isBaseSpecifier()) {
PDOMName derivedClassName= (PDOMName) pdomName.getEnclosingDefinition();
if (derivedClassName != null) {
@ -1031,22 +1031,22 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (file != null) {
return file;
}
}
}
if (binding instanceof ICPPMember) {
return null;
}
return super.getLocalToFile(binding, glob);
}
@Override
@Override
public PDOMBinding addTypeBinding(IBinding type) throws CoreException {
return addBinding(type, null);
}
@Override
public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= buffer.getByte();
switch((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.ARRAY_TYPE:
return CPPArrayType.unmarshal(firstByte, buffer);
case ITypeMarshalBuffer.BASIC_TYPE:
@ -1068,14 +1068,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
case ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE:
return TypeOfDependentExpression.unmarshal(firstByte, buffer);
}
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$
}
@Override
public ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= buffer.getByte();
switch((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.EVAL_BINARY:
return EvalBinary.unmarshal(firstByte, buffer);
case ITypeMarshalBuffer.EVAL_BINARY_TYPE_ID: