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 c676ddf34e
commit 7c9a82c2b1
20 changed files with 552 additions and 566 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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