From 8fac40ce1bb884ecc6eaa8cd18d345893803752e Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 29 Jun 2012 15:39:12 -0700 Subject: [PATCH 01/14] Cosmetics. --- .../cdt/core/dom/ast/cpp/ICPPASTInitializerClause.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerClause.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerClause.java index 03d7ede44de..669a66ec9c7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerClause.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTInitializerClause.java @@ -6,22 +6,20 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.core.dom.ast.cpp; import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; /** - * C++ specific initializer clause + * C++ specific initializer clause. * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. * @since 5.5 */ public interface ICPPASTInitializerClause extends IASTInitializerClause { - /** * Returns the evaluation object for this expression. * @noreference This method is not intended to be referenced by clients. From 77e792334f6d74072ab0e60e8a21f878927f743d Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 8 Jul 2012 20:03:24 -0700 Subject: [PATCH 02/14] Cosmetics. --- .../core/dom/parser/ITypeMarshalBuffer.java | 12 +- .../cdt/internal/core/dom/parser/Value.java | 162 ++++----- .../parser/cpp/semantics/CPPTemplates.java | 331 +++++++++--------- .../dom/parser/cpp/semantics/EvalBinary.java | 34 +- .../cpp/semantics/EvalBinaryTypeId.java | 11 +- .../dom/parser/cpp/semantics/EvalBinding.java | 43 ++- .../dom/parser/cpp/semantics/EvalComma.java | 29 +- .../parser/cpp/semantics/EvalCompound.java | 7 +- .../parser/cpp/semantics/EvalConditional.java | 43 ++- .../dom/parser/cpp/semantics/EvalFixed.java | 37 +- .../cpp/semantics/EvalFunctionCall.java | 29 +- .../parser/cpp/semantics/EvalFunctionSet.java | 11 +- .../core/dom/parser/cpp/semantics/EvalID.java | 41 ++- .../parser/cpp/semantics/EvalInitList.java | 9 +- .../cpp/semantics/EvalMemberAccess.java | 67 ++-- .../dom/parser/cpp/semantics/EvalTypeId.java | 15 +- .../dom/parser/cpp/semantics/EvalUnary.java | 33 +- .../parser/cpp/semantics/EvalUnaryTypeID.java | 19 +- .../core/pdom/db/TypeMarshalBuffer.java | 85 ++--- .../core/pdom/dom/cpp/PDOMCPPLinkage.java | 100 +++--- 20 files changed, 552 insertions(+), 566 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java index b4ead75e4c5..f3dbae212dc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -30,7 +30,7 @@ public interface ITypeMarshalBuffer { final static byte PROBLEM_TYPE= 9; final static byte VALUE= 10; final static byte DEPENDENT_EXPRESSION_TYPE= 11; - + final static byte EVAL_BINARY= 1, EVAL_BINARY_TYPE_ID = 2, @@ -47,16 +47,16 @@ public interface ITypeMarshalBuffer { EVAL_TYPE_ID= 13, EVAL_UNARY= 14, EVAL_UNARY_TYPE_ID = 15; - + static final byte KIND_MASK= 15; - + final static int FLAG1 = 0x10; final static int FLAG2 = 0x20; final static int FLAG3 = 0x40; final static int FLAG4 = 0x80; CoreException unmarshallingError(); - + IType unmarshalType() throws CoreException; IValue unmarshalValue() throws CoreException; IBinding unmarshalBinding() throws CoreException; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index 76c8d107687..808165c5c65 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -8,7 +8,7 @@ * Contributors: * Markus Schorn - initial API and implementation * Sergey Prigogin (Google) - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; import java.util.ArrayList; @@ -45,15 +45,15 @@ import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer; import org.eclipse.core.runtime.CoreException; /** - * Represents values of variables, enumerators or expressions. The primary purpose of the representation - * is to support instantiation of templates with non-type template parameters. + * Represents values of variables, enumerators or expressions. The primary purpose of + * the representation is to support instantiation of templates with non-type template parameters. */ public class Value implements IValue { public static final int MAX_RECURSION_DEPTH = 25; public final static IValue UNKNOWN= new Value("".toCharArray(), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY); //$NON-NLS-1$ public final static IValue NOT_INITIALIZED= new Value("<__>".toCharArray(), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY); //$NON-NLS-1$ private static final int[] NO_INT = {}; - + private static final String SCOPE_OP = "::"; //$NON-NLS-1$ private static final char UNIQUE_CHAR = '_'; private static final char TEMPLATE_PARAM_CHAR = '#'; @@ -62,16 +62,16 @@ public class Value implements IValue { private static final char UNARY_OP_CHAR = '$'; private static final char BINARY_OP_CHAR = '@'; private static final char CONDITIONAL_CHAR= '?'; - + private static final char SEPARATOR = ','; private final static IValue[] TYPICAL= { - new Value(new char[] {'0'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), - new Value(new char[] {'1'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), - new Value(new char[] {'2'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), - new Value(new char[] {'3'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), - new Value(new char[] {'4'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), - new Value(new char[] {'5'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), + new Value(new char[] {'0'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), + new Value(new char[] {'1'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), + new Value(new char[] {'2'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), + new Value(new char[] {'3'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), + new Value(new char[] {'4'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), + new Value(new char[] {'5'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY), new Value(new char[] {'6'}, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY)}; @@ -113,13 +113,13 @@ public class Value implements IValue { private final char[] fExpression; private final ICPPUnknownBinding[] fUnknownBindings; private char[] fSignature; - + private Value(char[] rep, ICPPUnknownBinding[] unknown) { assert rep != null; fExpression= rep; fUnknownBindings= unknown; } - + @Override public char[] getInternalExpression() { return fExpression; @@ -129,7 +129,7 @@ public class Value implements IValue { public IBinding[] getUnknownBindings() { return fUnknownBindings; } - + @Override public char[] getSignature() { if (fSignature == null) { @@ -152,12 +152,12 @@ public class Value implements IValue { } return fSignature; } - + @Override public Long numericalValue() { return parseLong(fExpression); } - + public void marshall(TypeMarshalBuffer buf) throws CoreException { if (UNKNOWN == this) { buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG1)); @@ -182,12 +182,12 @@ public class Value implements IValue { } } } - + public static IValue unmarshal(TypeMarshalBuffer buf) throws CoreException { int firstByte= buf.getByte(); if (firstByte == TypeMarshalBuffer.NULL_TYPE) return null; - if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) + if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) return Value.UNKNOWN; if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) { int val= buf.getInt(); @@ -197,7 +197,7 @@ public class Value implements IValue { long val= buf.getLong(); return Value.create(val); } - + char[] expr = buf.getCharArray(); final int len= buf.getShort(); ICPPUnknownBinding[] unknowns= new ICPPUnknownBinding[len]; @@ -215,7 +215,7 @@ public class Value implements IValue { public int hashCode() { return CharArrayUtils.hash(fExpression); } - + @Override public boolean equals(Object obj) { if (!(obj instanceof IValue)) { @@ -224,11 +224,11 @@ public class Value implements IValue { final IValue rhs = (IValue) obj; if (!CharArrayUtils.equals(fExpression, rhs.getInternalExpression())) return false; - + IBinding[] rhsUnknowns= rhs.getUnknownBindings(); if (fUnknownBindings.length != rhsUnknowns.length) return false; - + for (int i = 0; i < rhsUnknowns.length; i++) { final IBinding rhsUnknown = rhsUnknowns[i]; if (rhsUnknown instanceof ICPPUnknownBinding) { @@ -241,7 +241,7 @@ public class Value implements IValue { } return true; } - + @Override public String toString() { return new String(getSignature()); @@ -255,7 +255,7 @@ public class Value implements IValue { return TYPICAL[(int) value]; return new Value(toCharArray(value), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY); } - + /** * Creates a value representing the given template parameter. */ @@ -272,7 +272,7 @@ public class Value implements IValue { } /** - * Tests whether the value is a template parameter (or parameter pack), + * Tests whether the value is a template parameter (or parameter pack), * returns the parameter id of the parameter, or -1 if it is not a template parameter. */ public static int isTemplateParameter(IValue tval) { @@ -292,7 +292,7 @@ public class Value implements IValue { } return -1; } - + /** * Tests whether the value directly references some template parameter. */ @@ -351,7 +351,7 @@ public class Value implements IValue { } if (result != -1) return new int[] {result}; - + return NO_INT; } @@ -365,7 +365,7 @@ public class Value implements IValue { Object obj= evaluate(expr, unknownSigs, unknown, maxRecursionDepth); if (obj instanceof Number) return create(((Number) obj).longValue()); - + ICPPUnknownBinding[] ua; if (unknown.isEmpty()) { ua= ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY; @@ -377,18 +377,18 @@ public class Value implements IValue { } return UNKNOWN; } - + /** * Creates a value off its canonical representation. */ public static IValue fromInternalRepresentation(char[] rep, ICPPUnknownBinding[] unknown) { if (CharArrayUtils.equals(rep, UNKNOWN.getInternalExpression())) return UNKNOWN; - + Long l= parseLong(rep); - if (l != null) + if (l != null) return create(l.longValue()); - + return new Value(rep, unknown); } @@ -399,11 +399,11 @@ public class Value implements IValue { StringBuilder buf= new StringBuilder(10); buf.append(UNIQUE_CHAR); buf.append(++sUnique); - return new Value(extractChars(buf), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY); + return new Value(extractChars(buf), ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY); } /** - * Computes the canonical representation of the value of the expression. + * Computes the canonical representation of the value of the expression. * Returns a {@code Number} for numerical values or a {@code String}, otherwise. * @throws UnknownValueException */ @@ -411,7 +411,7 @@ public class Value implements IValue { List unknowns, int maxdepth) throws UnknownValueException { if (maxdepth < 0 || e == null) throw UNKNOWN_EX; - + if (e instanceof IASTArraySubscriptExpression) { throw UNKNOWN_EX; } @@ -465,7 +465,7 @@ public class Value implements IValue { case IASTLiteralExpression.lk_char_constant: try { final char[] image= litEx.getValue(); - if (image.length > 1 && image[0] == 'L') + if (image.length > 1 && image[0] == 'L') return ExpressionEvaluator.getChar(image, 2); return ExpressionEvaluator.getChar(image, 1); } catch (EvalException e1) { @@ -489,7 +489,7 @@ public class Value implements IValue { } throw UNKNOWN_EX; } - + /** * Extract a value off a binding. */ @@ -502,11 +502,11 @@ public class Value implements IValue { final ICPPTemplateNonTypeParameter tp = (ICPPTemplateNonTypeParameter) b; return createTemplateParamExpression(tp.getParameterID(), tp.isParameterPack()); } - + if (b instanceof ICPPUnknownBinding) { return createReference((ICPPUnknownBinding) b, unknownSigs, unknowns); } - + IValue value= null; if (b instanceof IInternalVariable) { value= ((IInternalVariable) b).getInitialValue(maxdepth - 1); @@ -514,10 +514,10 @@ public class Value implements IValue { value= ((IVariable) b).getInitialValue(); } else if (b instanceof IEnumerator) { value= ((IEnumerator) b).getValue(); - } + } if (value != null) return evaluateValue(value, unknownSigs, unknowns); - + throw UNKNOWN_EX; } @@ -532,21 +532,21 @@ public class Value implements IValue { } return "" + REFERENCE_CHAR + idx.toString(); //$NON-NLS-1$ } - + private static Object evaluateValue(IValue cv, Map unknownSigs, List unknowns) throws UnknownValueException { - if (cv == Value.UNKNOWN) + if (cv == Value.UNKNOWN) throw UNKNOWN_EX; - + Long lv= cv.numericalValue(); if (lv != null) return lv; - + final IBinding[] oldUnknowns = cv.getUnknownBindings(); final char[] expr= cv.getInternalExpression(); if (oldUnknowns.length == 0) return new String(expr); - + StringBuilder buf= new StringBuilder(expr.length); boolean skipToSeparator= false; for (int i = 0; i < expr.length; i++) { @@ -557,7 +557,7 @@ public class Value implements IValue { if (idx >= oldUnknowns.length) throw UNKNOWN_EX; final IBinding old = oldUnknowns[idx]; - if (!(old instanceof ICPPUnknownBinding)) + if (!(old instanceof ICPPUnknownBinding)) throw UNKNOWN_EX; buf.append(createReference((ICPPUnknownBinding) old, unknownSigs, unknowns)); @@ -576,7 +576,7 @@ public class Value implements IValue { } return buf.toString(); } - + private static Object evaluateUnaryExpression(IASTUnaryExpression ue, Map unknownSigs, List unknowns, int maxdepth) throws UnknownValueException { @@ -599,11 +599,11 @@ public class Value implements IValue { unaryOp == IASTUnaryExpression.op_sizeofParameterPack) { throw UNKNOWN_EX; } - + final Object value= evaluate(ue.getOperand(), unknownSigs, unknowns, maxdepth); - return combineUnary(unaryOp, value); + return combineUnary(unaryOp, value); } - + private static Object combineUnary(final int unaryOp, final Object value) throws UnknownValueException { switch (unaryOp) { case IASTUnaryExpression.op_bracketedPrimary: @@ -628,8 +628,8 @@ public class Value implements IValue { return v == 0 ? 1 : 0; } throw UNKNOWN_EX; - } - + } + switch (unaryOp) { case IASTUnaryExpression.op_prefixIncr: case IASTUnaryExpression.op_postFixIncr: @@ -643,7 +643,7 @@ public class Value implements IValue { throw UNKNOWN_EX; } - private static Object evaluateBinaryExpression(IASTBinaryExpression be, + private static Object evaluateBinaryExpression(IASTBinaryExpression be, Map unknownSigs, List unknowns, int maxdepth) throws UnknownValueException { final Object o1= evaluate(be.getOperand1(), unknownSigs, unknowns, maxdepth); @@ -652,7 +652,7 @@ public class Value implements IValue { final int op= be.getOperator(); return combineBinary(op, o1, o2); } - + private static Object combineBinary(final int op, final Object o1, final Object o2) throws UnknownValueException { if (o1 instanceof Number && o2 instanceof Number) { @@ -737,10 +737,10 @@ public class Value implements IValue { default: throw UNKNOWN_EX; } - + return "" + BINARY_OP_CHAR + op + SEPARATOR + o1.toString() + SEPARATOR + o2.toString(); //$NON-NLS-1$ } - + public static IValue reevaluate(IValue val, int packOffset, IBinding[] resolvedUnknowns, ICPPTemplateParameterMap map, int maxdepth) { try { @@ -752,10 +752,10 @@ public class Value implements IValue { Object obj= reevaluate(reeval, maxdepth); if (reeval.pos != reeval.fExpression.length) return UNKNOWN; - + if (obj instanceof Number) return create(((Number) obj).longValue()); - + ICPPUnknownBinding[] ua; if (unknown.isEmpty()) { ua= ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY; @@ -768,7 +768,7 @@ public class Value implements IValue { return UNKNOWN; } - private static Object reevaluate(Reevaluation reeval, int maxdepth) + private static Object reevaluate(Reevaluation reeval, int maxdepth) throws UnknownValueException { if (maxdepth < 0) throw UNKNOWN_EX; @@ -778,16 +778,16 @@ public class Value implements IValue { final int length = buf.length; if (idx >= length) throw UNKNOWN_EX; - + final char c= buf[idx]; switch (c) { - case BINARY_OP_CHAR: + case BINARY_OP_CHAR: int op= parseNonNegative(buf, idx + 1); reeval.nextSeperator(); Object o1= reevaluate(reeval, maxdepth); Object o2= reevaluate(reeval, maxdepth); return combineBinary(op, o1, o2); - case UNARY_OP_CHAR: + case UNARY_OP_CHAR: op= parseNonNegative(buf, idx + 1); reeval.nextSeperator(); o1= reevaluate(reeval, maxdepth); @@ -806,7 +806,7 @@ public class Value implements IValue { } return "" + CONDITIONAL_CHAR + SEPARATOR + cond.toString() + SEPARATOR + //$NON-NLS-1$ po.toString() + SEPARATOR + neg.toString(); - case REFERENCE_CHAR: + case REFERENCE_CHAR: int num= parseNonNegative(buf, idx + 1); final IBinding[] resolvedUnknowns= reeval.fResolvedUnknown; if (num >= resolvedUnknowns.length) @@ -825,7 +825,7 @@ public class Value implements IValue { return evaluateValue(val, reeval.fUnknownSigs, reeval.fUnknowns); } return createTemplateParamExpression(num, false); - + case TEMPLATE_PARAM_PACK_CHAR: num= parseHex(buf, idx + 1); reeval.nextSeperator(); @@ -843,7 +843,7 @@ public class Value implements IValue { return evaluateValue(val, reeval.fUnknownSigs, reeval.fUnknowns); } return createTemplateParamExpression(num, true); - + default: reeval.nextSeperator(); return parseLong(buf, idx); @@ -858,13 +858,13 @@ public class Value implements IValue { final int len= value.length; int result = 0; boolean ok= false; - for(; offset < len; offset++) { + for (; offset < len; offset++) { final int digit= (value[offset] - '0'); if (digit < 0 || digit > 9) break; if (result > maxvalue) return -1; - + result= result * 10 + digit; ok= true; } @@ -880,7 +880,7 @@ public class Value implements IValue { int result = 0; boolean ok= false; final int len= value.length; - for(; offset < len; offset++) { + for (; offset < len; offset++) { int digit= (value[offset] - '0'); if (digit < 0 || digit > 9) { digit += '0' - 'a' + 10; @@ -893,13 +893,13 @@ public class Value implements IValue { } if ((result & 0xf0000000) != 0) throw UNKNOWN_EX; - + result= (result << 4) + digit; ok= true; } if (!ok) throw UNKNOWN_EX; - + return result; } @@ -911,26 +911,26 @@ public class Value implements IValue { final int len= value.length; boolean negative= false; long result = 0; - + boolean ok= false; if (offset < len && value[offset] == '-') { negative = true; offset++; } - for(; offset < len; offset++) { + for (; offset < len; offset++) { final int digit= (value[offset] - '0'); if (digit < 0 || digit > 9) break; - + if (result > maxvalue) throw UNKNOWN_EX; - + result= result * 10 + digit; ok= true; } if (!ok) throw UNKNOWN_EX; - + return negative ? -result : result; } @@ -943,18 +943,18 @@ public class Value implements IValue { boolean negative= false; long result = 0; int i= 0; - + if (len > 0 && value[0] == '-') { negative = true; i++; } if (i == len) return null; - - for(; i < len; i++) { + + for (; i < len; i++) { if (result > maxvalue) return null; - + final int digit= (value[i] - '0'); if (digit < 0 || digit > 9) return null; @@ -993,7 +993,7 @@ public class Value implements IValue { } public static IValue create(ICPPEvaluation eval, IASTNode point) { - // compute value of evaluation + // Compute value of evaluation return Value.UNKNOWN; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 3b6521e49fd..b42087adb35 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -162,13 +162,13 @@ public class CPPTemplates { * Instantiates a class template with the given arguments. May return null. */ public static IBinding instantiate(ICPPClassTemplate template, ICPPTemplateArgument[] args, IASTNode point) { - return instantiate(template, args, false, false, point); + return instantiate(template, args, false, false, point); } - + /** * Instantiates a class template with the given arguments. May return null. */ - private static IBinding instantiate(ICPPClassTemplate template, ICPPTemplateArgument[] args, + private static IBinding instantiate(ICPPClassTemplate template, ICPPTemplateArgument[] args, boolean isDefinition, boolean isExplicitSpecialization, IASTNode point) { try { // Add default arguments, if necessary. @@ -180,7 +180,7 @@ public class CPPTemplates { if (template instanceof ICPPTemplateTemplateParameter || hasDependentArgument(arguments)) { return deferredInstance(template, arguments); } - + if (template instanceof ICPPClassTemplatePartialSpecialization) { return instantiatePartialSpecialization((ICPPClassTemplatePartialSpecialization) template, arguments, isDefinition, null, point); } @@ -191,7 +191,7 @@ public class CPPTemplates { final int length= Math.max(numArgs, numParams); CPPTemplateParameterMap map= new CPPTemplateParameterMap(numParams); - + boolean isPack= false; ICPPTemplateParameter param= null; for (int i = 0; i < length; i++) { @@ -220,9 +220,9 @@ public class CPPTemplates { } else { // Parameter pack with empty arguments. assert isPack; - } + } } - + if (isPack) { int packOffset= numParams-1; int packSize= numArgs - packOffset; @@ -240,8 +240,8 @@ public class CPPTemplates { if (result != null) return result; } - - return instantiatePrimaryTemplate(template, arguments, map, isDefinition, point); + + return instantiatePrimaryTemplate(template, arguments, map, isDefinition, point); } catch (DOMException e) { return e.getProblem(); } @@ -295,7 +295,7 @@ public class CPPTemplates { scope= CPPVisitor.getContainingScope(internalScope.getPhysicalNode()); if (scope == internalScope) return null; - } else { + } else { scope= scope.getParent(); } } @@ -310,7 +310,7 @@ public class CPPTemplates { if (instance != null) { return instance; } - + IBinding owner= template.getOwner(); instance = CPPTemplates.createInstance(owner, template, map, arguments, point); addInstance(template, arguments, instance); @@ -319,7 +319,7 @@ public class CPPTemplates { /** * Instantiates a partial class template specialization. - * @param point + * @param point */ private static IBinding instantiatePartialSpecialization( ICPPClassTemplatePartialSpecialization partialSpec, ICPPTemplateArgument[] args, boolean isDef, @@ -340,13 +340,13 @@ public class CPPTemplates { return instance; } - /** + /** * Instantiates the selected template, without looking for specializations. May return null. - * @param map + * @param map */ - private static IBinding instantiatePrimaryTemplate(ICPPClassTemplate template, ICPPTemplateArgument[] arguments, + private static IBinding instantiatePrimaryTemplate(ICPPClassTemplate template, ICPPTemplateArgument[] arguments, CPPTemplateParameterMap map, boolean isDef, IASTNode point) throws DOMException { - + assert !(template instanceof ICPPClassTemplatePartialSpecialization); ICPPTemplateInstance instance= getInstance(template, arguments, isDef); if (instance != null) { @@ -396,7 +396,7 @@ public class CPPTemplates { ICPPTemplateArgument[] arguments, IASTNode point) throws DOMException { if (template instanceof ICPPClassTemplatePartialSpecialization) return arguments; - + boolean havePackExpansion= false; for (int i = 0; i < arguments.length; i++) { ICPPTemplateArgument arg = arguments[i]; @@ -407,38 +407,38 @@ public class CPPTemplates { havePackExpansion= true; } } - + ICPPTemplateParameter[] tpars = template.getTemplateParameters(); int tparCount = tpars.length; final int argCount = arguments.length; - + if (tparCount == argCount) return arguments; - + if (tparCount == 0) return null; - + // More arguments allowed if we have a parameter pack. if (tparCount < argCount) { if (tpars[tparCount-1].isParameterPack()) return arguments; - + if (havePackExpansion && tparCount+1 == argCount) return arguments; return null; - } - + } + // Fewer arguments are allowed with a pack expansion if (havePackExpansion) return arguments; - + // Fewer arguments are allowed with default arguments if (tpars[tparCount-1].isParameterPack()) tparCount--; - - if (tparCount == argCount) + + if (tparCount == argCount) return arguments; - + ICPPTemplateArgument[] completeArgs= new ICPPTemplateArgument[tparCount]; CPPTemplateParameterMap map= new CPPTemplateParameterMap(tparCount); for (int i = 0; i < tparCount; i++) { @@ -463,7 +463,7 @@ public class CPPTemplates { arg= SemanticUtil.getSimplifiedArgument(arg); if (!isValidArgument(arg)) { return null; - } + } } map.put(tpar, arg); completeArgs[i]= arg; @@ -503,7 +503,7 @@ public class CPPTemplates { return args; } - /** + /** * Extracts the IASTName of a template parameter. */ public static IASTName getTemplateParameterName(ICPPASTTemplateParameter param) { @@ -585,7 +585,7 @@ public class CPPTemplates { public static IBinding createBinding(ICPPASTTemplateParameter tp) { if (tp instanceof ICPPASTSimpleTypeTemplateParameter) { return new CPPTemplateTypeParameter(((ICPPASTSimpleTypeTemplateParameter) tp).getName(), tp.isParameterPack()); - } + } if (tp instanceof ICPPASTTemplatedTypeTemplateParameter) { return new CPPTemplateTemplateParameter(((ICPPASTTemplatedTypeTemplateParameter) tp).getName(), tp.isParameterPack()); } @@ -593,7 +593,7 @@ public class CPPTemplates { final IASTDeclarator dtor = ((ICPPASTParameterDeclaration) tp).getDeclarator(); return new CPPTemplateNonTypeParameter(ASTQueries.findInnermostDeclarator(dtor).getName()); } - + public static IBinding createBinding(ICPPASTTemplateId id) { if (!isClassTemplate(id)) { //functions are instantiated as part of the resolution process @@ -611,7 +611,7 @@ public class CPPTemplates { return result; } } - + IASTNode parentOfName = id.getParent(); boolean isLastName= true; if (parentOfName instanceof ICPPASTQualifiedName) { @@ -629,7 +629,7 @@ public class CPPTemplates { isDeclaration= true; } else if (parentOfName instanceof ICPPASTCompositeTypeSpecifier) { isDefinition= true; - } + } if (isDeclaration || isDefinition) { IASTNode parentOfDeclaration = declaration.getParent(); if (parentOfDeclaration instanceof ICPPASTExplicitTemplateInstantiation) { @@ -649,7 +649,7 @@ public class CPPTemplates { if (template instanceof ICPPConstructor) { template= template.getOwner(); } - + if (template instanceof ICPPUnknownClassType) { IBinding owner= template.getOwner(); if (owner instanceof ICPPUnknownBinding) { @@ -659,7 +659,7 @@ public class CPPTemplates { } } - if (!(template instanceof ICPPClassTemplate) || template instanceof ICPPClassTemplatePartialSpecialization) + if (!(template instanceof ICPPClassTemplate) || template instanceof ICPPClassTemplatePartialSpecialization) return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TYPE, templateName.toCharArray()); final ICPPClassTemplate classTemplate = (ICPPClassTemplate) template; @@ -668,12 +668,12 @@ public class CPPTemplates { ICPPASTTemplateDeclaration tdecl= getTemplateDeclaration(id); if (tdecl != null) { if (argsAreTrivial(classTemplate.getTemplateParameters(), args)) { - result= classTemplate; + result= classTemplate; } else { args= addDefaultArguments(classTemplate, args, id); if (args == null) { return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray()); - } + } ICPPClassTemplatePartialSpecialization partialSpec= findPartialSpecialization(classTemplate, args); if (isDeclaration || isDefinition) { if (partialSpec == null) { @@ -681,7 +681,7 @@ public class CPPTemplates { if (template instanceof ICPPInternalClassTemplate) ((ICPPInternalClassTemplate) template).addPartialSpecialization(partialSpec); return partialSpec; - } + } } if (partialSpec == null) return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TYPE, templateName.toCharArray()); @@ -716,10 +716,10 @@ public class CPPTemplates { if (parentOfName instanceof ICPPASTElaboratedTypeSpecifier || parentOfName instanceof ICPPASTCompositeTypeSpecifier || - parentOfName instanceof ICPPASTNamedTypeSpecifier || + parentOfName instanceof ICPPASTNamedTypeSpecifier || parentOfName instanceof ICPPASTBaseSpecifier) return true; - + if (parentOfName instanceof IASTDeclarator) { IASTDeclarator rel= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) parentOfName); return !(rel instanceof IASTFunctionDeclarator); @@ -728,7 +728,7 @@ public class CPPTemplates { } - public static ICPPTemplateInstance createInstance(IBinding owner, ICPPTemplateDefinition template, + public static ICPPTemplateInstance createInstance(IBinding owner, ICPPTemplateDefinition template, CPPTemplateParameterMap tpMap, ICPPTemplateArgument[] args, IASTNode point) { if (owner instanceof ICPPSpecialization) { ICPPTemplateParameterMap map= ((ICPPSpecialization) owner).getTemplateParameterMap(); @@ -736,7 +736,7 @@ public class CPPTemplates { tpMap.putAll(map); } } - + ICPPTemplateInstance instance = null; if (template instanceof ICPPClassType) { instance = new CPPClassInstance((ICPPClassType) template, owner, tpMap, args); @@ -838,7 +838,7 @@ public class CPPTemplates { } return spec; } - + private static ICPPClassSpecialization getSpecializationContext(IBinding owner) { if (!(owner instanceof ICPPClassSpecialization)) return null; @@ -847,17 +847,18 @@ public class CPPTemplates { for(;;) { IBinding o1 = within.getOwner(); IBinding o2 = orig.getOwner(); - if (!(o1 instanceof ICPPClassSpecialization && o2 instanceof ICPPClassType)) + if (!(o1 instanceof ICPPClassSpecialization && o2 instanceof ICPPClassType)) return within; ICPPClassSpecialization nextWithin = (ICPPClassSpecialization) o1; orig= (ICPPClassType) o2; - if (orig.isSameType(nextWithin)) + if (orig.isSameType(nextWithin)) return within; within= nextWithin; } } -public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, int maxdepth, IASTNode point) { + public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpMap, int packOffset, + ICPPClassSpecialization within, int maxdepth, IASTNode point) { if (value == null) return null; IBinding[] unknowns= value.getUnknownBindings(); @@ -882,11 +883,11 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } } } - + if (resolvedUnknowns != null) return Value.reevaluate(value, packOffset, resolvedUnknowns, tpMap, maxdepth); - - if (Value.referencesTemplateParameter(value)) + + if (Value.referencesTemplateParameter(value)) return Value.reevaluate(value, packOffset, unknowns, tpMap, maxdepth); return value; @@ -901,7 +902,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM final ICPPFunctionType ft = (ICPPFunctionType) type; final IType rt = ft.getReturnType(); int r = determinePackSize(rt, tpMap); - if (r < 0) + if (r < 0) return r; IType[] ps = ft.getParameterTypes(); for (IType pt : ps) { @@ -910,7 +911,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM return r; } return r; - } + } if (type instanceof ICPPTemplateParameter) { final ICPPTemplateParameter tpar = (ICPPTemplateParameter) type; @@ -921,7 +922,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM return PACK_SIZE_DEFER; } return PACK_SIZE_NOT_FOUND; - } + } int r= PACK_SIZE_NOT_FOUND; if (type instanceof ICPPUnknownBinding) { @@ -943,7 +944,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM if (type instanceof ICPPParameterPackType) return PACK_SIZE_NOT_FOUND; - + if (type instanceof IArrayType) { IArrayType at= (IArrayType) type; IValue asize= at.getSize(); @@ -955,7 +956,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM if (type instanceof ITypeContainer) { final ITypeContainer typeContainer = (ITypeContainer) type; r= combine(r, determinePackSize(typeContainer.getType(), tpMap)); - } + } return r; } @@ -1002,13 +1003,13 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM * Instantiates types contained in an array. * @param types an array of types * @param tpMap template argument map - * @param point + * @param point * @return an array containing instantiated types. */ public static IType[] instantiateTypes(IType[] types, ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) { if (types == null) return null; - + // Don't create a new array until it's really needed. IType[] result = types; int j= 0; @@ -1050,7 +1051,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM /** * Instantiates arguments contained in an array. - * @param point + * @param point */ public static ICPPTemplateArgument[] instantiateArguments(ICPPTemplateArgument[] args, ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) @@ -1098,7 +1099,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM /** * Instantiates an argument - * @param point + * @param point */ static ICPPTemplateArgument instantiateArgument(ICPPTemplateArgument arg, ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) { @@ -1113,14 +1114,14 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM return arg; return new CPPTemplateArgument(instValue, instType); } - + final IType orig= arg.getTypeValue(); final IType inst= instantiateType(orig, tpMap, packOffset, within, point); if (orig == inst) return arg; return new CPPTemplateArgument(inst); } - + private static CPPTemplateParameterMap instantiateArgumentMap(ICPPTemplateParameterMap orig, ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) { final Integer[] positions = orig.getAllParameterPositions(); @@ -1146,7 +1147,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM /** * Instantiates the given type with the provided map and packoffset. * The context is used to replace templates with their specialization, where appropriate. - * @param point + * @param point */ public static IType instantiateType(IType type, ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) { @@ -1173,7 +1174,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } } return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs()); - } + } if (type instanceof ICPPTemplateParameter) { final ICPPTemplateParameter tpar = (ICPPTemplateParameter) type; @@ -1198,7 +1199,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM return t; } return type; - } + } if (type instanceof ICPPUnknownBinding) { IBinding binding= resolveUnknown((ICPPUnknownBinding) type, tpMap, packOffset, within, point); @@ -1212,7 +1213,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM IType unwound= getNestedType(type, TDEF); if (unwound instanceof ICPPClassType && unwound.isSameType(within.getSpecializedBinding())) { // Convert (partial) class-templates (specializations) to the more specialized version. - if (within instanceof ICPPClassTemplate || !(unwound instanceof ICPPClassTemplate)) + if (within instanceof ICPPClassTemplate || !(unwound instanceof ICPPClassTemplate)) return within; } IBinding typeAsBinding= (IBinding) type; @@ -1221,18 +1222,18 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM final IType ownerAsType = getNestedType((IType) owner, TDEF); Object newOwner= owner; if (ownerAsType instanceof ICPPClassType && ownerAsType.isSameType(within.getSpecializedBinding())) { - // Convert (partial) class-templates (specializations) that are used as owner of + // Convert (partial) class-templates (specializations) that are used as owner of // another binding, to the more specialized version. newOwner= within; } else { newOwner= instantiateType(ownerAsType, tpMap, packOffset, within, point); } - + if (newOwner != owner && newOwner instanceof ICPPClassSpecialization) { return (IType) ((ICPPClassSpecialization) newOwner).specializeMember(typeAsBinding, point); } } - + if (unwound instanceof ICPPTemplateInstance && !(unwound instanceof ICPPDeferredClassInstance)) { // Argument of a class specialization can be a nested class subject to specialization. final ICPPTemplateInstance classInstance = (ICPPTemplateInstance) unwound; @@ -1245,8 +1246,8 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM return new CPPClassInstance((ICPPClassType) origClass, classInstance.getOwner(), tparMap, args); } } - } - } + } + } if (type instanceof ITypeContainer) { final ITypeContainer typeContainer = (ITypeContainer) type; @@ -1259,7 +1260,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM if (newMemberOfClass instanceof IQualifierType) { newMemberOfClass = ((IQualifierType) newMemberOfClass).getType(); } - if (!(newMemberOfClass instanceof ICPPClassType || newMemberOfClass instanceof UniqueType + if (!(newMemberOfClass instanceof ICPPClassType || newMemberOfClass instanceof UniqueType || newMemberOfClass instanceof ICPPUnknownBinding)) { return new ProblemType(ISemanticProblem.BINDING_INVALID_TYPE); } @@ -1268,7 +1269,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM ptm.isConst(), ptm.isVolatile(), ptm.isRestrict()); } return typeContainer; - } + } if (typeContainer instanceof IArrayType) { IArrayType at= (IArrayType) typeContainer; IValue asize= at.getSize(); @@ -1281,9 +1282,9 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } if (newNestedType != nestedType) { return SemanticUtil.replaceNestedType(typeContainer, newNestedType); - } + } return typeContainer; - } + } return type; } catch (DOMException e) { @@ -1303,14 +1304,14 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM * correspond to a template declaration. */ public static ICPPASTTemplateDeclaration getTemplateDeclaration(IASTName name) { - if (name == null) + if (name == null) return null; // first look for a related sequence of template declarations ICPPASTInternalTemplateDeclaration tdecl= getInnerTemplateDeclaration(name); if (tdecl == null) return null; - + name= name.getLastName(); IASTNode parent= name.getParent(); if (!(parent instanceof ICPPASTQualifiedName)) { @@ -1319,23 +1320,23 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } // one name: use innermost template declaration return tdecl; - } - + } + // last name can be associated even if it is not a template-id final ICPPASTQualifiedName qname= (ICPPASTQualifiedName) parent; final IASTName lastName = qname.getLastName(); final boolean lastIsTemplate= tdecl.isAssociatedWithLastName(); - if (name == lastName) { + if (name == lastName) { if (lastIsTemplate) { return tdecl; } return null; - } - + } + // not the last name, search for the matching template declaration - if (!(name instanceof ICPPASTTemplateId)) + if (!(name instanceof ICPPASTTemplateId)) return null; - + if (lastIsTemplate) { // skip one tdecl= getDirectlyEnclosingTemplateDeclaration(tdecl); @@ -1353,7 +1354,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM // not enough template declarations return null; } - + public static void associateTemplateDeclarations(ICPPASTInternalTemplateDeclaration tdecl) { // Find innermost template declaration IASTDeclaration decl= tdecl.getDeclaration(); @@ -1362,7 +1363,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM decl= tdecl.getDeclaration(); } final ICPPASTInternalTemplateDeclaration innerMostTDecl= tdecl; - + // Find name declared within the template declaration final IASTName declName= getNameForDeclarationInTemplateDeclaration(decl); @@ -1399,14 +1400,14 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM if (n instanceof ICPPASTTemplateId) { if (depIDCount > 0 || usesTemplateParameter((ICPPASTTemplateId) n, tparnames)) { depIDCount++; - } - } - if (depIDCount == 0) { + } + } + if (depIDCount == 0) { owner= n; } } - - if (qname.getLastName() instanceof ICPPASTTemplateId + + if (qname.getLastName() instanceof ICPPASTTemplateId || paramTDeclCount > depIDCount // not enough template ids || ns.length < 2 // ::name ) { @@ -1415,7 +1416,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } else { lastIsTemplate= false; } - + nestingLevel= 0; if (owner != null) { int consumesTDecl= 0; @@ -1467,7 +1468,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } } } - + node= innerMostTDecl; while(node instanceof ICPPASTInternalTemplateDeclaration) { if (--nestingLevel < 0) @@ -1530,7 +1531,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM return PROCESS_SKIP; return PROCESS_CONTINUE; } - + if (names.containsKey(name.getLookupKey())) { IASTNode parent= name.getParent(); if (parent instanceof ICPPASTQualifiedName) { @@ -1575,14 +1576,14 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } else if (declspec instanceof IASTElaboratedTypeSpecifier) { name= ((IASTElaboratedTypeSpecifier) declspec).getName(); } - } + } } else if (decl instanceof IASTFunctionDefinition) { IASTFunctionDefinition fdef= (IASTFunctionDefinition) decl; name= ASTQueries.findInnermostDeclarator(fdef.getDeclarator()).getName(); } return name; } - + private static ICPPASTInternalTemplateDeclaration getInnerTemplateDeclaration(final IASTName name) { IASTNode parent = name.getParent(); @@ -1600,22 +1601,22 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM parent = parent.getParent(); } } - if (!(parent instanceof IASTDeclaration)) + if (!(parent instanceof IASTDeclaration)) return null; - + parent = parent.getParent(); - if (parent instanceof ICPPASTInternalTemplateDeclaration) + if (parent instanceof ICPPASTInternalTemplateDeclaration) return (ICPPASTInternalTemplateDeclaration) parent; return null; } - + private static ICPPASTInternalTemplateDeclaration getDirectlyEnclosingTemplateDeclaration( ICPPASTInternalTemplateDeclaration tdecl ) { final IASTNode parent= tdecl.getParent(); - if (parent instanceof ICPPASTInternalTemplateDeclaration) + if (parent instanceof ICPPASTInternalTemplateDeclaration) return (ICPPASTInternalTemplateDeclaration) parent; - + return null; } @@ -1680,12 +1681,12 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM return false; } for (int i=0; i < args.length; i++) { - if (!specArgs[i].isSameValue(args[i])) + if (!specArgs[i].isSameValue(args[i])) return false; } return true; } - + /** * @param id the template id containing the template arguments * @return an array of template arguments, currently modeled as IType objects. @@ -1712,13 +1713,13 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } return result; } - + static ICPPFunction[] instantiateForFunctionCall(ICPPFunction[] fns, ICPPTemplateArgument[] tmplArgs, List fnArgs, List argCats, boolean withImpliedObjectArg, IASTNode point) { // Extract template arguments. boolean requireTemplate= tmplArgs != null; boolean haveTemplate= false; - + for (final ICPPFunction func : fns) { if (func instanceof ICPPConstructor || (func instanceof ICPPMethod && ((ICPPMethod) func).isDestructor())) requireTemplate= false; @@ -1726,11 +1727,11 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM if (func instanceof ICPPFunctionTemplate) { ICPPFunctionTemplate template= (ICPPFunctionTemplate) func; try { - if (containsDependentType(fnArgs)) + if (containsDependentType(fnArgs)) return new ICPPFunction[] {CPPUnknownFunction.createForSample(template)}; if (requireTemplate) { - if (hasDependentArgument(tmplArgs)) + if (hasDependentArgument(tmplArgs)) return new ICPPFunction[] {CPPUnknownFunction.createForSample(template)}; } } catch (DOMException e) { @@ -1741,9 +1742,9 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } } - if (!haveTemplate && !requireTemplate) + if (!haveTemplate && !requireTemplate) return fns; - + final List result= new ArrayList(fns.length); for (ICPPFunction fn : fns) { if (fn != null) { @@ -1767,7 +1768,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM fnArgs= fnArgs.subList(1, fnArgs.size()); argCats= argCats.subList(1, argCats.size()); } - + CPPTemplateParameterMap map= new CPPTemplateParameterMap(fnArgs.size()); try { ICPPTemplateArgument[] args= TemplateArgumentDeduction.deduceForFunctionCall(template, tmplArgs, fnArgs, argCats, map, point); @@ -1775,9 +1776,9 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM IBinding instance= instantiateFunctionTemplate(template, args, map, point); if (instance instanceof ICPPFunction) { final ICPPFunction f = (ICPPFunction) instance; - if (isValidType(f.getType())) + if (isValidType(f.getType())) return f; - } + } } } catch (DOMException e) { } @@ -1786,7 +1787,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM /** * 14.8.2.3 Deducing conversion function template arguments - * @param point + * @param point */ static ICPPFunction[] instantiateConversionTemplates(ICPPFunction[] functions, IType conversionType, IASTNode point) { boolean checkedForDependentType= false; @@ -1798,7 +1799,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM if (f instanceof ICPPFunctionTemplate) { ICPPFunctionTemplate template= (ICPPFunctionTemplate) f; inst= null; - + // Extract template arguments and parameter types. if (!checkedForDependentType) { try { @@ -1818,12 +1819,12 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM IBinding instance= instantiateFunctionTemplate(template, args, map, point); if (instance instanceof ICPPFunction) { inst= (ICPPFunction) instance; - } + } } } catch (DOMException e) { // try next candidate } - } + } if (result != functions || f != inst) { if (result == functions) { result= new ICPPFunction[functions.length]; @@ -1836,11 +1837,11 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } return result; } - + /** * 14.8.2.6 Deducing template arguments from a function declaration - * @param point - * @return + * @param point + * @return */ static ICPPFunction instantiateForFunctionDeclaration(ICPPFunctionTemplate template, ICPPTemplateArgument[] args, ICPPFunctionType functionType, IASTNode point) { @@ -1851,7 +1852,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM IBinding instance= instantiateFunctionTemplate(template, args, map, point); if (instance instanceof ICPPFunction) { return (ICPPFunction) instance; - } + } } } catch (DOMException e) { // try next candidate @@ -1863,14 +1864,14 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM /** * 14.8.2.2 Deducing template arguments taking the address of a function template [temp.deduct.funcaddr] */ - static ICPPFunction instantiateForAddressOfFunction(ICPPFunctionTemplate template, IFunctionType target, + static ICPPFunction instantiateForAddressOfFunction(ICPPFunctionTemplate template, IFunctionType target, ICPPTemplateArgument[] args, IASTNode point) { try { if (target != null && isDependentType(target)) { return CPPUnknownFunction.createForSample(template); } - - if (template instanceof ICPPConstructor || args == null) + + if (template instanceof ICPPConstructor || args == null) args= ICPPTemplateArgument.EMPTY_ARGUMENTS; CPPTemplateParameterMap map= new CPPTemplateParameterMap(4); @@ -1879,7 +1880,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM IBinding instance= instantiateFunctionTemplate(template, args, map, point); if (instance instanceof ICPPFunction) { return (ICPPFunction) instance; - } + } } } catch (DOMException e) { } @@ -1895,10 +1896,10 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM return -1; if (f2 == null) return 1; - + int s1 = compareSpecialization(f1, f2, mode, point); int s2 = compareSpecialization(f2, f1, mode, point); - + if (s1 == s2) return 0; if (s1 < 0 || s2 > 0) @@ -1910,7 +1911,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM private static ICPPFunction transferFunctionTemplate(ICPPFunctionTemplate f, IASTNode point) throws DOMException { final ICPPTemplateParameter[] tpars = f.getTemplateParameters(); final int argLen = tpars.length; - + // Create arguments and map ICPPTemplateArgument[] args = new ICPPTemplateArgument[argLen]; CPPTemplateParameterMap map = new CPPTemplateParameterMap(argLen); @@ -1920,7 +1921,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM args[i]= arg; if (tpar.isParameterPack()) { map.put(tpar, new ICPPTemplateArgument[] {arg}); - } else { + } else { map.put(tpar, arg); } } @@ -1928,12 +1929,12 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM IBinding result = instantiateFunctionTemplate(f, args, map, point); if (result instanceof ICPPFunction) return (ICPPFunction) result; - + return null; } private static CPPTemplateArgument uniqueArg(final ICPPTemplateParameter tpar) throws DOMException { - final CPPTemplateArgument arg; + final CPPTemplateArgument arg; if (tpar instanceof ICPPTemplateNonTypeParameter) { arg = new CPPTemplateArgument(Value.unique(), ((ICPPTemplateNonTypeParameter) tpar).getType()); } else { @@ -2047,7 +2048,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM if (bestMatch == null) return null; - + return instantiatePartialSpecialization(bestMatch, args, isDef, bestMap, point); } @@ -2056,7 +2057,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM * is more specialized, = 0 otherwise. * @param spec1 * @param spec2 - * @param point + * @param point * @return * @throws DOMException */ @@ -2095,7 +2096,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM final ICPPTemplateArgument[] targs2 = f2.getTemplateArguments(); if (targs1.length != targs2.length) return false; - + // Transfer arguments of specialization 1 final int tpars1Len = tpars1.length; ICPPTemplateArgument[] args = new ICPPTemplateArgument[tpars1Len]; @@ -2107,12 +2108,12 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM transferMap.put(param, arg); } final ICPPTemplateArgument[] transferredArgs1 = instantiateArguments(targs1, transferMap, -1, null, point); - + // Deduce arguments for specialization 2 final CPPTemplateParameterMap deductionMap= new CPPTemplateParameterMap(2); if (!TemplateArgumentDeduction.fromTemplateArguments(tpars2, targs2, transferredArgs1, deductionMap, point)) return false; - + // Compare for (int i = 0; i < targs2.length; i++) { ICPPTemplateArgument transferredArg2= instantiateArgument(targs2[i], deductionMap, -1, null, point); @@ -2145,12 +2146,12 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } } } - + static boolean isValidArgument(ICPPTemplateArgument arg) { return arg != null && isValidType(arg.isTypeValue() ? arg.getTypeValue() : arg.getTypeOfNonTypeValue()); } - static ICPPTemplateArgument matchTemplateParameterAndArgument(ICPPTemplateParameter param, + static ICPPTemplateArgument matchTemplateParameterAndArgument(ICPPTemplateParameter param, ICPPTemplateArgument arg, CPPTemplateParameterMap map, IASTNode point) { if (arg == null || !isValidType(arg.getTypeValue())) { return null; @@ -2160,8 +2161,8 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM if (t != null && ! (t instanceof ICPPTemplateDefinition)) return arg; return null; - } - + } + if (param instanceof ICPPTemplateTemplateParameter) { IType t= arg.getTypeValue(); while (!(t instanceof ICPPTemplateDefinition)) { @@ -2186,8 +2187,8 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } return arg; - } - + } + if (param instanceof ICPPTemplateNonTypeParameter) { if (!arg.isNonTypeValue()) return null; @@ -2204,7 +2205,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM return new CPPTemplateArgument(arg.getNonTypeValue(), pType); } return null; - + } catch (DOMException e) { return null; } @@ -2212,7 +2213,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM assert false; return null; } - + private static boolean matchTemplateTemplateParameters(ICPPTemplateParameter[] pParams, ICPPTemplateParameter[] aParams) throws DOMException { int pi=0; @@ -2220,17 +2221,17 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM while (pi < pParams.length && ai < aParams.length) { final ICPPTemplateParameter pp = pParams[pi]; final ICPPTemplateParameter ap = aParams[ai]; - + // A parameter pack does not match a regular template parameter. if (ap.isParameterPack() && !pp.isParameterPack()) return false; - - + + boolean pb= pp instanceof ICPPTemplateTypeParameter; boolean ab= ap instanceof ICPPTemplateTypeParameter; if (pb != ab) return false; - + if (pb) { // Both are template type parameters } else { @@ -2247,7 +2248,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM assert false; return false; } - + if (!matchTemplateTemplateParameters(((ICPPTemplateTemplateParameter) pp).getTemplateParameters(), ((ICPPTemplateTemplateParameter) ap).getTemplateParameters()) ) return false; @@ -2262,7 +2263,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM return true; return false; } - + return ai == aParams.length; } @@ -2305,7 +2306,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM if (argType == null) return false; } - if (!argType.isSameType((IType) par)) + if (!argType.isSameType((IType) par)) return false; } else { if (arg.isTypeValue()) @@ -2325,11 +2326,11 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } return false; } - + public static boolean isDependentArgument(ICPPTemplateArgument arg) { - if (arg.isTypeValue()) + if (arg.isTypeValue()) return isDependentType(arg.getTypeValue()); - + return Value.isDependentValue(arg.getNonTypeValue()); } @@ -2348,12 +2349,12 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } return false; } - + public static boolean isDependentType(IType t) { while (true) { if (t instanceof ICPPUnknownType) return true; - + if (t instanceof ICPPFunctionType) { final ICPPFunctionType ft = (ICPPFunctionType) t; if (containsDependentType(ft.getParameterTypes())) @@ -2385,7 +2386,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } } } - + public static boolean containsDependentArg(ObjectMap tpMap) { for (Object arg : tpMap.valueArray()) { if (isDependentType((IType)arg)) @@ -2406,7 +2407,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM final IBinding owner= unknown.getOwner(); if (!(owner instanceof ICPPTemplateTypeParameter || owner instanceof ICPPUnknownClassType)) return unknown; - + IBinding result = unknown; IType t = CPPTemplates.instantiateType((IType) owner, tpMap, packOffset, within, point); if (t != null) { @@ -2428,7 +2429,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } else { result= new CPPUnknownBinding((ICPPUnknownBinding) t, unknown.getNameCharArray()); } - } + } } else if (t instanceof ICPPClassType) { IScope s = ((ICPPClassType) t).getCompositeScope(); if (s != null) { @@ -2445,7 +2446,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM return new ProblemBinding(unknown.getUnknownName(), IProblemBinding.SEMANTIC_BAD_SCOPE); } } - + return result; } @@ -2486,7 +2487,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM public static boolean haveSameArguments(ICPPTemplateInstance i1, ICPPTemplateInstance i2) { final ICPPTemplateArgument[] m1= i1.getTemplateArguments(); final ICPPTemplateArgument[] m2= i2.getTemplateArguments(); - + if (m1 == null || m2 == null || m1.length != m2.length) return false; @@ -2523,7 +2524,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM } return types; } - + /** * @deprecated for backwards compatibility, only. */ @@ -2533,7 +2534,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM Integer[] keys= tpmap.getAllParameterPositions(); if (keys.length == 0) return ObjectMap.EMPTY_MAP; - + List defs= new ArrayList(); IBinding owner= b; while (owner != null) { @@ -2547,7 +2548,7 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM Collections.reverse(defs); ObjectMap result= new ObjectMap(keys.length); - for (int key: keys) { + for (int key : keys) { int nestingLevel= key >> 16; int numParam= key & 0xffff; @@ -2568,9 +2569,9 @@ public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpM public static IBinding findDeclarationForSpecialization(IBinding binding) { while (binding instanceof ICPPSpecialization) { - if (ASTInternal.hasDeclaration(binding)) + if (ASTInternal.hasDeclaration(binding)) return binding; - + IBinding original= ((ICPPSpecialization) binding).getSpecializedBinding(); if (original == null) return binding; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java index 5f90c8de82e..c762f12a9a7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; @@ -50,7 +49,7 @@ public class EvalBinary implements ICPPEvaluation { private final ICPPEvaluation fArg1; private final ICPPEvaluation fArg2; - + private ICPPFunction fOverload= CPPFunction.UNINITIALIZED_FUNCTION; private IType fType; @@ -81,7 +80,7 @@ public class EvalBinary implements ICPPEvaluation { public boolean isFunctionSet() { return false; } - + @Override public IType getTypeOrFunctionSet(IASTNode point) { if (fType == null) { @@ -121,11 +120,11 @@ public class EvalBinary implements ICPPEvaluation { @Override public ValueCategory getValueCategory(IASTNode point) { - if (isTypeDependent()) + if (isTypeDependent()) return ValueCategory.PRVALUE; - + ICPPFunction overload = getOverload(point); - if (overload != null) + if (overload != null) return ExpressionTypes.valueCategoryFromFunctionCall(overload); switch (fOperator) { @@ -144,12 +143,12 @@ public class EvalBinary implements ICPPEvaluation { return LVALUE; case IASTBinaryExpression.op_pmdot: - if (!(getTypeOrFunctionSet(point) instanceof ICPPFunctionType)) + if (!(getTypeOrFunctionSet(point) instanceof ICPPFunctionType)) return fArg1.getValueCategory(point); break; case IASTBinaryExpression.op_pmarrow: - if (!(getTypeOrFunctionSet(point) instanceof ICPPFunctionType)) + if (!(getTypeOrFunctionSet(point) instanceof ICPPFunctionType)) return LVALUE; break; } @@ -186,15 +185,15 @@ public class EvalBinary implements ICPPEvaluation { public IType computeType(IASTNode point) { // Check for overloaded operator. ICPPFunction o= getOverload(point); - if (o != null) + if (o != null) return typeFromFunctionCall(o); - + final IType originalType1 = fArg1.getTypeOrFunctionSet(point); final IType type1 = prvalueTypeWithResolvedTypedefs(originalType1); if (type1 instanceof ISemanticProblem) { return type1; } - + final IType originalType2 = fArg2.getTypeOrFunctionSet(point); final IType type2 = prvalueTypeWithResolvedTypedefs(originalType2); if (type2 instanceof ISemanticProblem) { @@ -206,7 +205,6 @@ public class EvalBinary implements ICPPEvaluation { return ExpressionTypes.restoreTypedefs(type, originalType1, originalType2); } - switch (fOperator) { case op_arrayAccess: if (type1 instanceof IPointerType) { @@ -216,7 +214,7 @@ public class EvalBinary implements ICPPEvaluation { return glvalueType(((IPointerType) type2).getType()); } return ProblemType.UNKNOWN_FOR_EXPRESSION; - + case IASTBinaryExpression.op_lessEqual: case IASTBinaryExpression.op_lessThan: case IASTBinaryExpression.op_greaterEqual: @@ -230,10 +228,10 @@ public class EvalBinary implements ICPPEvaluation { case IASTBinaryExpression.op_plus: if (type1 instanceof IPointerType) { return ExpressionTypes.restoreTypedefs(type1, originalType1); - } + } if (type2 instanceof IPointerType) { return ExpressionTypes.restoreTypedefs(type2, originalType2); - } + } break; case IASTBinaryExpression.op_minus: @@ -268,7 +266,7 @@ public class EvalBinary implements ICPPEvaluation { buffer.marshalEvaluation(fArg1, includeValue); buffer.marshalEvaluation(fArg2, includeValue); } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { int op= buffer.getByte(); ICPPEvaluation arg1= (ICPPEvaluation) buffer.unmarshalEvaluation(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java index f710e0b834e..7ef770b186a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; @@ -33,10 +32,10 @@ import org.eclipse.core.runtime.CoreException; public class EvalBinaryTypeId implements ICPPEvaluation { private final Operator fOperator; private final IType fType1, fType2; - + private boolean fCheckedValueDependent; private boolean fIsValueDependent; - + public EvalBinaryTypeId(Operator kind, IType type1, IType type2) { fOperator= kind; fType1= type1; @@ -105,7 +104,7 @@ public class EvalBinaryTypeId implements ICPPEvaluation { buffer.marshalType(fType1); buffer.marshalType(fType2); } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { int op= buffer.getByte(); IType arg1= buffer.unmarshalType(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java index b353d5f4040..8567ea3b666 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType; @@ -35,7 +34,7 @@ import org.eclipse.core.runtime.CoreException; public class EvalBinding implements ICPPEvaluation { private final IBinding fBinding; private final boolean fFixedType; - + private IType fType; private boolean fCheckedIsValueDependent; private boolean fIsValueDependent; @@ -56,7 +55,7 @@ public class EvalBinding implements ICPPEvaluation { public IType getFixedType() { return fFixedType ? fType : null; } - + @Override public boolean isInitializerList() { return false; @@ -75,9 +74,9 @@ public class EvalBinding implements ICPPEvaluation { } return fIsTypeDependent; } - + private boolean computeIsTypeDependent() { - if (fBinding instanceof ICPPUnknownBinding) + if (fBinding instanceof ICPPUnknownBinding) return true; IType t= null; @@ -105,26 +104,26 @@ public class EvalBinding implements ICPPEvaluation { } return fIsValueDependent; } - + private boolean computeIsValueDependent() { if (fBinding instanceof IEnumerator) { return Value.isDependentValue(((IEnumerator) fBinding).getValue()); - } + } if (fBinding instanceof ICPPTemplateNonTypeParameter) { return true; } if (fBinding instanceof IVariable) { return Value.isDependentValue(((IVariable) fBinding).getInitialValue()); - } + } if (fBinding instanceof IFunction) { return false; - } + } if (fBinding instanceof ICPPUnknownBinding) { return true; - } + } return false; } - + @Override public IType getTypeOrFunctionSet(IASTNode point) { if (fType == null) { @@ -132,42 +131,42 @@ public class EvalBinding implements ICPPEvaluation { } return fType; } - + private IType computeType(IASTNode point) { if (fBinding instanceof IEnumerator) { return ((IEnumerator) fBinding).getType(); - } + } if (fBinding instanceof ICPPTemplateNonTypeParameter) { IType type= ((ICPPTemplateNonTypeParameter) fBinding).getType(); if (CPPTemplates.isDependentType(type)) return new TypeOfDependentExpression(this); return prvalueType(type); - } + } if (fBinding instanceof IVariable) { final IType type = ((IVariable) fBinding).getType(); if (CPPTemplates.isDependentType(type)) return new TypeOfDependentExpression(this); return SemanticUtil.mapToAST(glvalueType(type), point); - } + } if (fBinding instanceof IFunction) { final IFunctionType type = ((IFunction) fBinding).getType(); if (CPPTemplates.isDependentType(type)) return new TypeOfDependentExpression(this); return SemanticUtil.mapToAST(type, point); - } + } return ProblemType.UNKNOWN_FOR_EXPRESSION; } - + @Override public IValue getValue(IASTNode point) { return Value.create(this, point); } - + @Override public ValueCategory getValueCategory(IASTNode point) { if (fBinding instanceof ICPPTemplateNonTypeParameter) return ValueCategory.PRVALUE; - + if (fBinding instanceof IVariable || fBinding instanceof IFunction) { return ValueCategory.LVALUE; } @@ -180,7 +179,7 @@ public class EvalBinding implements ICPPEvaluation { buffer.marshalBinding(fBinding); buffer.marshalType(fFixedType ? fType : null); } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { IBinding binding= buffer.unmarshalBinding(); IType type= buffer.unmarshalType(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java index 5925b119095..13a284e8c59 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall; @@ -31,9 +30,9 @@ public class EvalComma implements ICPPEvaluation { private final ICPPEvaluation[] fArguments; private ICPPFunction[] fOverloads; - + private IType fType; - + public EvalComma(ICPPEvaluation[] evals) { fArguments= evals; } @@ -54,9 +53,9 @@ public class EvalComma implements ICPPEvaluation { @Override public boolean isTypeDependent() { - if (fType != null) + if (fType != null) return fType instanceof TypeOfDependentExpression; - + for (ICPPEvaluation arg : fArguments) { if (arg.isTypeDependent()) return true; @@ -83,12 +82,12 @@ public class EvalComma implements ICPPEvaluation { private ICPPFunction[] computeOverloads(IASTNode point) { if (fArguments.length < 2) return NO_FUNCTIONS; - + if (isTypeDependent()) return NO_FUNCTIONS; - + ICPPFunction[] overloads = new ICPPFunction[fArguments.length - 1]; - ICPPEvaluation e1= fArguments[0]; + ICPPEvaluation e1= fArguments[0]; for (int i = 1; i < fArguments.length; i++) { ICPPEvaluation e2 = fArguments[i]; ICPPFunction overload = CPPSemantics.findOverloadedOperatorComma(point, e1, e2); @@ -99,7 +98,7 @@ public class EvalComma implements ICPPEvaluation { e1= new EvalFixed(typeFromFunctionCall(overload), valueCategoryFromFunctionCall(overload), Value.UNKNOWN); if (e1.getTypeOrFunctionSet(point) instanceof ISemanticProblem) { e1= e2; - } + } } } return overloads; @@ -112,11 +111,11 @@ public class EvalComma implements ICPPEvaluation { } return fType; } - + private IType computeType(IASTNode point) { if (isTypeDependent()) { return new TypeOfDependentExpression(this); - } + } ICPPFunction[] overloads = getOverloads(point); if (overloads.length > 0) { ICPPFunction last = overloads[overloads.length - 1]; @@ -126,7 +125,7 @@ public class EvalComma implements ICPPEvaluation { } return fArguments[fArguments.length-1].getTypeOrFunctionSet(point); } - + @Override public IValue getValue(IASTNode point) { return Value.create(this, point); @@ -152,7 +151,7 @@ public class EvalComma implements ICPPEvaluation { buffer.marshalEvaluation(arg, includeValue); } } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { int len= buffer.getShort(); ICPPEvaluation[] args = new ICPPEvaluation[len]; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java index c602e10c936..f4621924a41 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; @@ -77,7 +76,7 @@ public class EvalCompound implements ICPPEvaluation { buffer.putByte(ITypeMarshalBuffer.EVAL_COMPOUND); buffer.marshalEvaluation(fDelegate, includeValue); } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation(); return new EvalCompound(arg); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java index 023e432448f..67bc4c3c1ee 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; @@ -45,12 +44,12 @@ import org.eclipse.core.runtime.CoreException; public class EvalConditional implements ICPPEvaluation { private final ICPPEvaluation fCondition, fPositive, fNegative; private final boolean fPositiveThrows, fNegativeThrows; - + private ValueCategory fValueCategory; private IType fType; private ICPPFunction fOverload; - + public EvalConditional(ICPPEvaluation arg1, ICPPEvaluation arg2, ICPPEvaluation arg3, boolean positiveThrows, boolean negativeThrows) { // Gnu-extension: Empty positive expression is replaced by condition. @@ -85,7 +84,7 @@ public class EvalConditional implements ICPPEvaluation { public boolean isInitializerList() { return false; } - + @Override public boolean isFunctionSet() { return false; @@ -95,7 +94,7 @@ public class EvalConditional implements ICPPEvaluation { evaluate(point); return fOverload; } - + @Override public IType getTypeOrFunctionSet(IASTNode point) { evaluate(point); @@ -106,36 +105,36 @@ public class EvalConditional implements ICPPEvaluation { public IValue getValue(IASTNode point) { return Value.create(this, point); } - + @Override public ValueCategory getValueCategory(IASTNode point) { evaluate(point); return fValueCategory; } - + @Override public boolean isTypeDependent() { final ICPPEvaluation positive = fPositive == null ? fCondition : fPositive; return positive.isTypeDependent() || fNegative.isTypeDependent(); } - + @Override public boolean isValueDependent() { return fCondition.isValueDependent() || (fPositive != null && fPositive.isValueDependent()) || fNegative.isValueDependent(); } - + private void evaluate(IASTNode point) { if (fValueCategory != null) return; - + fValueCategory= PRVALUE; - + final ICPPEvaluation positive = fPositive == null ? fCondition : fPositive; - + IType t2 = positive.getTypeOrFunctionSet(point); IType t3 = fNegative.getTypeOrFunctionSet(point); - + final IType uqt2= getNestedType(t2, TDEF | REF | CVTYPE); final IType uqt3= getNestedType(t3, TDEF | REF | CVTYPE); if (uqt2 instanceof ISemanticProblem || uqt2 instanceof ICPPUnknownType) { @@ -146,7 +145,7 @@ public class EvalConditional implements ICPPEvaluation { fType= uqt3; return; } - + final boolean void2= isVoidType(uqt2); final boolean void3= isVoidType(uqt3); @@ -163,7 +162,7 @@ public class EvalConditional implements ICPPEvaluation { } return; } - + final ValueCategory vcat2= positive.getValueCategory(point); final ValueCategory vcat3= fNegative.getValueCategory(point); @@ -177,8 +176,8 @@ public class EvalConditional implements ICPPEvaluation { fValueCategory= PRVALUE; } return; - } - + } + final boolean isClassType2 = uqt2 instanceof ICPPClassType; final boolean isClassType3 = uqt3 instanceof ICPPClassType; @@ -211,7 +210,7 @@ public class EvalConditional implements ICPPEvaluation { } return; } - + // 5.16-5: At least one class type but no conversion if (isClassType2 || isClassType3) { fOverload = CPPSemantics.findOverloadedConditionalOperator(point, positive, fNegative); @@ -293,13 +292,13 @@ public class EvalConditional implements ICPPEvaluation { firstByte |= ITypeMarshalBuffer.FLAG1; if (fNegativeThrows) firstByte |= ITypeMarshalBuffer.FLAG2; - + buffer.putByte((byte) firstByte); buffer.marshalEvaluation(fCondition, includeValue); buffer.marshalEvaluation(fPositive, includeValue); buffer.marshalEvaluation(fNegative, includeValue); } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { boolean pth= (firstByte & ITypeMarshalBuffer.FLAG1) != 0; boolean nth= (firstByte & ITypeMarshalBuffer.FLAG2) != 0; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java index 28d1ba27c61..fbd99448f59 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; @@ -30,9 +29,9 @@ import org.eclipse.core.runtime.CoreException; * Performs evaluation of an expression. */ public class EvalFixed implements ICPPEvaluation { - public static final ICPPEvaluation INCOMPLETE = new EvalFixed( - ProblemType.UNKNOWN_FOR_EXPRESSION, PRVALUE, Value.UNKNOWN); - + public static final ICPPEvaluation INCOMPLETE = + new EvalFixed(ProblemType.UNKNOWN_FOR_EXPRESSION, PRVALUE, Value.UNKNOWN); + private final IType fType; private final IValue fValue; private final ValueCategory fValueCategory; @@ -108,7 +107,7 @@ public class EvalFixed implements ICPPEvaluation { int firstByte = ITypeMarshalBuffer.EVAL_FIXED; if (includeValue) firstByte |= ITypeMarshalBuffer.FLAG1; - switch(fValueCategory) { + switch (fValueCategory) { case LVALUE: firstByte |= ITypeMarshalBuffer.FLAG2; break; @@ -118,30 +117,30 @@ public class EvalFixed implements ICPPEvaluation { default: break; } - + buffer.putByte((byte) firstByte); buffer.marshalType(fType); if (includeValue) { buffer.marshalValue(fValue); } } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { final boolean readValue= (firstByte & ITypeMarshalBuffer.FLAG1) != 0; IValue value; ValueCategory cat; switch (firstByte & (ITypeMarshalBuffer.FLAG2 | ITypeMarshalBuffer.FLAG3)) { - case ITypeMarshalBuffer.FLAG2: - cat= LVALUE; - break; - case ITypeMarshalBuffer.FLAG3: - cat= PRVALUE; - break; - default: - cat= XVALUE; - break; + case ITypeMarshalBuffer.FLAG2: + cat= LVALUE; + break; + case ITypeMarshalBuffer.FLAG3: + cat= PRVALUE; + break; + default: + cat= XVALUE; + break; } - + IType type= buffer.unmarshalType(); value= readValue ? buffer.unmarshalValue() : Value.UNKNOWN; return new EvalFixed(type, cat, value); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java index dde693d47b3..2c2db81fb2e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType; @@ -41,7 +40,7 @@ public class EvalFunctionCall implements ICPPEvaluation { private final ICPPEvaluation[] fArguments; private ICPPFunction fOverload= CPPFunction.UNINITIALIZED_FUNCTION; private IType fType; - + public EvalFunctionCall(ICPPEvaluation[] args) { fArguments= args; } @@ -88,36 +87,36 @@ public class EvalFunctionCall implements ICPPEvaluation { private ICPPFunction computeOverload(IASTNode point) { if (isTypeDependent()) return null; - + IType t= SemanticUtil.getNestedType(fArguments[0].getTypeOrFunctionSet(point), TDEF|REF|CVTYPE); if (t instanceof ICPPClassType) { return CPPSemantics.findOverloadedOperator(point, fArguments, t, OverloadableOperator.PAREN, LookupMode.NO_GLOBALS); } return null; } - + @Override public IType getTypeOrFunctionSet(IASTNode point) { - if (fType == null) + if (fType == null) fType= computeType(point); return fType; } - + private IType computeType(IASTNode point) { - if (isTypeDependent()) + if (isTypeDependent()) return new TypeOfDependentExpression(this); - + ICPPFunction overload = getOverload(point); - if (overload != null) + if (overload != null) return ExpressionTypes.typeFromFunctionCall(overload); - + final ICPPEvaluation arg0 = fArguments[0]; IType t= SemanticUtil.getNestedType(arg0.getTypeOrFunctionSet(point), TDEF|REF|CVTYPE); if (t instanceof ICPPClassType) { return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION); } - + if (t instanceof IPointerType) { t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TDEF | REF | CVTYPE); } @@ -142,7 +141,7 @@ public class EvalFunctionCall implements ICPPEvaluation { if (overload != null) return valueCategoryFromFunctionCall(overload); - + IType t= fArguments[0].getTypeOrFunctionSet(point); if (t instanceof IPointerType) { t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TDEF | REF | CVTYPE); @@ -161,7 +160,7 @@ public class EvalFunctionCall implements ICPPEvaluation { buffer.marshalEvaluation(arg, includeValue); } } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { int len= buffer.getShort(); ICPPEvaluation[] args = new ICPPEvaluation[len]; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java index 4be4f8ac06c..ce16b11a6b4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; @@ -32,7 +31,7 @@ import org.eclipse.core.runtime.CoreException; public class EvalFunctionSet implements ICPPEvaluation { private final CPPFunctionSet fFunctionSet; private final boolean fAddressOf; - + public EvalFunctionSet(CPPFunctionSet set, boolean addressOf) { fFunctionSet= set; fAddressOf= addressOf; @@ -101,7 +100,7 @@ public class EvalFunctionSet implements ICPPEvaluation { firstByte |= ITypeMarshalBuffer.FLAG1; if (args != null) firstByte |= ITypeMarshalBuffer.FLAG2; - + buffer.putByte((byte) firstByte); buffer.putShort((short) bindings.length); for (ICPPFunction binding : bindings) { @@ -111,7 +110,7 @@ public class EvalFunctionSet implements ICPPEvaluation { // mstodo marshall arguments } } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { final boolean addressOf= (firstByte & ITypeMarshalBuffer.FLAG1) != 0; int bindingCount= buffer.getShort(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java index 3bf54753c7b..962def2afec 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; @@ -60,7 +59,7 @@ public class EvalID implements ICPPEvaluation { fQualified= qualified; fTemplateArgs= templateArgs; } - + public ICPPEvaluation getFieldOwner() { return fFieldOwner; } @@ -68,7 +67,7 @@ public class EvalID implements ICPPEvaluation { public IBinding getNameOwner() { return fNameOwner; } - + public char[] getName() { return fName; } @@ -80,11 +79,11 @@ public class EvalID implements ICPPEvaluation { public boolean isQualified() { return fQualified; } - + public ICPPTemplateArgument[] getTemplateArgs() { return fTemplateArgs; } - + @Override public boolean isInitializerList() { return false; @@ -99,22 +98,22 @@ public class EvalID implements ICPPEvaluation { public boolean isTypeDependent() { return true; } - + @Override public boolean isValueDependent() { return true; } - + @Override public IType getTypeOrFunctionSet(IASTNode point) { return new TypeOfDependentExpression(this); } - + @Override public IValue getValue(IASTNode point) { return Value.create(this, point); } - + @Override public ValueCategory getValueCategory(IASTNode point) { return PRVALUE; @@ -129,7 +128,7 @@ public class EvalID implements ICPPEvaluation { firstByte |= ITypeMarshalBuffer.FLAG2; if (fTemplateArgs != null) firstByte |= ITypeMarshalBuffer.FLAG3; - + buffer.putByte((byte) firstByte); buffer.marshalEvaluation(fFieldOwner, false); buffer.putCharArray(fName); @@ -138,7 +137,7 @@ public class EvalID implements ICPPEvaluation { // mstodo marshall arguments } } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { final boolean addressOf= (firstByte & ITypeMarshalBuffer.FLAG1) != 0; final boolean qualified= (firstByte & ITypeMarshalBuffer.FLAG2) != 0; @@ -155,7 +154,7 @@ public class EvalID implements ICPPEvaluation { public static ICPPEvaluation create(IASTIdExpression expr) { final IASTName name = expr.getName(); IBinding binding = name.resolvePreBinding(); - if (binding instanceof IProblemBinding || binding instanceof IType || binding instanceof ICPPConstructor) + if (binding instanceof IProblemBinding || binding instanceof IType || binding instanceof ICPPConstructor) return EvalFixed.INCOMPLETE; if (binding instanceof CPPFunctionSet) { return new EvalFunctionSet((CPPFunctionSet) binding, isAddressOf(expr)); @@ -164,7 +163,7 @@ public class EvalID implements ICPPEvaluation { IBinding owner = binding.getOwner(); if (owner instanceof IProblemBinding) return EvalFixed.INCOMPLETE; - + ICPPEvaluation fieldOwner= null; IType fieldOwnerType= withinNonStaticMethod(expr); if (fieldOwnerType != null) { @@ -175,20 +174,20 @@ public class EvalID implements ICPPEvaluation { if (lastName instanceof ICPPASTTemplateId) { templateArgs= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) lastName); } - return new EvalID(fieldOwner, owner, name.getSimpleID(), isAddressOf(expr), + return new EvalID(fieldOwner, owner, name.getSimpleID(), isAddressOf(expr), name instanceof ICPPASTQualifiedName, templateArgs); } /** - * 9.3.1-3 Transformation to class member access within a non-static member function. + * 9.3.1-3 Transformation to class member access within a non-static member function. */ - if (binding instanceof ICPPMember && !(binding instanceof IType) + if (binding instanceof ICPPMember && !(binding instanceof IType) && !(binding instanceof ICPPConstructor) &&!((ICPPMember) binding).isStatic()) { IType fieldOwnerType= withinNonStaticMethod(expr); if (fieldOwnerType != null) { return new EvalMemberAccess(fieldOwnerType, LVALUE, binding, true); } } - + if (binding instanceof IEnumerator) { IType type= ((IEnumerator) binding).getType(); if (type instanceof ICPPEnumeration) { @@ -206,7 +205,7 @@ public class EvalID implements ICPPEvaluation { } } return new EvalBinding(binding, null); - } + } if (binding instanceof ICPPTemplateNonTypeParameter || binding instanceof IVariable || binding instanceof IFunction) { return new EvalBinding(binding, null); @@ -239,7 +238,7 @@ public class EvalID implements ICPPEvaluation { e= unary.getOperand(); } else { return op == IASTUnaryExpression.op_amper; - } + } } return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java index 408f9cfac5f..3b5e432cf2b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; @@ -32,7 +31,7 @@ public class EvalInitList implements ICPPEvaluation { public EvalInitList(ICPPEvaluation[] clauses) { fClauses= clauses; } - + public ICPPEvaluation[] getClauses() { return fClauses; } @@ -88,7 +87,7 @@ public class EvalInitList implements ICPPEvaluation { buffer.marshalEvaluation(arg, includeValue); } } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { int len= buffer.getShort(); ICPPEvaluation[] args = new ICPPEvaluation[len]; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java index 8123662d07d..e6eb6eb4437 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; @@ -70,7 +69,7 @@ public class EvalMemberAccess implements ICPPEvaluation { public IType getOwnerType() { return fOwnerType; } - + public ValueCategory getOwnerValueCategory() { return fOwnerValueCategory; } @@ -101,7 +100,7 @@ public class EvalMemberAccess implements ICPPEvaluation { } return fIsTypeDependent; } - + private boolean computeIsTypeDependent() { IType t; if (fMember instanceof ICPPUnknownBinding) { @@ -126,71 +125,71 @@ public class EvalMemberAccess implements ICPPEvaluation { } return fIsValueDependent; } - + private boolean computeIsValueDependent() { if (fMember instanceof ICPPUnknownBinding) { return true; - } + } if (fMember instanceof IEnumerator) { return Value.isDependentValue(((IEnumerator) fMember).getValue()); - } + } if (fMember instanceof IVariable) { return Value.isDependentValue(((IVariable) fMember).getInitialValue()); - } + } if (fMember instanceof IFunction) { return false; - } + } return false; } - + public static IType getFieldOwnerType(IType fieldOwnerExpressionType, boolean isDeref, IASTNode point, Collection functionBindings, boolean returnUnnamed) { IType type= fieldOwnerExpressionType; if (!isDeref) return type; - - // Bug 205964: as long as the type is a class type, recurse. + + // Bug 205964: as long as the type is a class type, recurse. // Be defensive and allow a max of 20 levels. for (int j = 0; j < 20; j++) { IType classType= getUltimateTypeUptoPointers(type); - if (!(classType instanceof ICPPClassType)) + if (!(classType instanceof ICPPClassType)) break; - + IScope scope = ((ICPPClassType) classType).getCompositeScope(); if (scope == null || scope instanceof ICPPInternalUnknownScope) break; - + /* * 13.5.6-1: An expression x->m is interpreted as (x.operator->())->m for a * class object x of type T - * + * * Construct an AST fragment for x.operator-> which the lookup routines can * examine for type information. */ - + ICPPEvaluation[] args= {new EvalFixed(type, LVALUE, Value.UNKNOWN)}; ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType, OverloadableOperator.ARROW, LookupMode.NO_GLOBALS); - if (op == null) + if (op == null) break; if (functionBindings != null) functionBindings.add(op); - + type= typeFromFunctionCall(op); type= SemanticUtil.mapToAST(type, point); } - + IType prValue= prvalueTypeWithResolvedTypedefs(type); if (prValue instanceof IPointerType) { return glvalueType(((IPointerType) prValue).getType()); } - + if (CPPTemplates.isDependentType(type)) return returnUnnamed ? CPPUnknownClass.createUnnamedInstance() : null; return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION); } - + @Override public IType getTypeOrFunctionSet(IASTNode point) { if (fType == null) { @@ -198,14 +197,14 @@ public class EvalMemberAccess implements ICPPEvaluation { } return fType; } - + private IType computeType(IASTNode point) { if (fMember instanceof ICPPUnknownBinding) { return new TypeOfDependentExpression(this); } if (fMember instanceof IEnumerator) { return ((IEnumerator) fMember).getType(); - } + } if (fMember instanceof IVariable) { IType e2 = ((IVariable) fMember).getType(); e2= SemanticUtil.getNestedType(e2, TDEF); @@ -220,15 +219,15 @@ public class EvalMemberAccess implements ICPPEvaluation { } else { e2= glvalueType(e2); } - } + } return SemanticUtil.mapToAST(e2, point); - } + } if (fMember instanceof IFunction) { return SemanticUtil.mapToAST(((IFunction) fMember).getType(), point); } return ProblemType.UNKNOWN_FOR_EXPRESSION; } - + private IType addQualifiersForAccess(ICPPField field, IType fieldType, IType ownerType) { CVQualifier cvq1 = SemanticUtil.getCVQualifier(ownerType); CVQualifier cvq2 = SemanticUtil.getCVQualifier(fieldType); @@ -248,7 +247,7 @@ public class EvalMemberAccess implements ICPPEvaluation { public IValue getValue(IASTNode point) { return Value.create(this, point); } - + @Override public ValueCategory getValueCategory(IASTNode point) { if (fMember instanceof IVariable) { @@ -256,7 +255,7 @@ public class EvalMemberAccess implements ICPPEvaluation { e2= SemanticUtil.getNestedType(e2, TDEF); if (e2 instanceof ICPPReferenceType) { return LVALUE; - } + } if (fMember instanceof ICPPField && !((ICPPField) fMember).isStatic()) { if (fIsPointerDeref) return LVALUE; @@ -264,7 +263,7 @@ public class EvalMemberAccess implements ICPPEvaluation { return fOwnerValueCategory; } return LVALUE; - } + } if (fMember instanceof IFunction) { return LVALUE; } @@ -281,12 +280,12 @@ public class EvalMemberAccess implements ICPPEvaluation { } else if (fOwnerValueCategory == XVALUE) { firstByte |= ITypeMarshalBuffer.FLAG3; } - + buffer.putByte((byte) firstByte); buffer.marshalType(fOwnerType); buffer.marshalBinding(fMember); } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { boolean isDeref= (firstByte & ITypeMarshalBuffer.FLAG1) != 0; ValueCategory ownerValueCat; @@ -297,7 +296,7 @@ public class EvalMemberAccess implements ICPPEvaluation { } else { ownerValueCat= PRVALUE; } - + IType ownerType= buffer.unmarshalType(); IBinding member= buffer.unmarshalBinding(); return new EvalMemberAccess(ownerType, ownerValueCat, member, isDeref); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java index d788d3204a3..7ffadea8273 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType; @@ -31,7 +30,7 @@ public class EvalTypeId implements ICPPEvaluation { private final IType fInputType; private final ICPPEvaluation[] fArguments; private IType fOutputType; - + public EvalTypeId(IType type, ICPPEvaluation... argument) { fInputType= type; fArguments= argument; @@ -44,7 +43,7 @@ public class EvalTypeId implements ICPPEvaluation { public ICPPEvaluation[] getArguments() { return fArguments; } - + @Override public boolean isInitializerList() { return false; @@ -62,7 +61,7 @@ public class EvalTypeId implements ICPPEvaluation { } return fOutputType; } - + private IType computeType() { if (CPPTemplates.isDependentType(fInputType)) return new TypeOfDependentExpression(this); @@ -103,7 +102,7 @@ public class EvalTypeId implements ICPPEvaluation { int firstByte = ITypeMarshalBuffer.EVAL_TYPE_ID; if (includeValue) firstByte |= ITypeMarshalBuffer.FLAG1; - + buffer.putByte((byte) firstByte); buffer.marshalType(fInputType); if (includeValue) { @@ -113,7 +112,7 @@ public class EvalTypeId implements ICPPEvaluation { } } } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { IType type= buffer.unmarshalType(); ICPPEvaluation[] args= null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java index 3faecff3a4c..2058d62e861 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; @@ -42,12 +41,12 @@ import org.eclipse.core.runtime.CoreException; public class EvalUnary implements ICPPEvaluation { private static final ICPPEvaluation ZERO_EVAL = new EvalFixed(CPPSemantics.INT_TYPE, PRVALUE, Value.create(0)); - + private final int fOperator; private final ICPPEvaluation fArgument; private ICPPFunction fOverload= CPPFunction.UNINITIALIZED_FUNCTION; private IType fType; - + public EvalUnary(int operator, ICPPEvaluation operand) { fOperator= operator; fArgument= operand; @@ -60,7 +59,7 @@ public class EvalUnary implements ICPPEvaluation { public ICPPEvaluation getArgument() { return fArgument; } - + @Override public boolean isInitializerList() { return false; @@ -73,7 +72,7 @@ public class EvalUnary implements ICPPEvaluation { @Override public boolean isTypeDependent() { - if (fType != null) + if (fType != null) return fType instanceof TypeOfDependentExpression; switch(fOperator) { @@ -115,10 +114,10 @@ public class EvalUnary implements ICPPEvaluation { OverloadableOperator op = OverloadableOperator.fromUnaryExpression(fOperator); if (op == null) return null; - + if (fArgument.isTypeDependent()) return null; - + IType type = fArgument.getTypeOrFunctionSet(point); type = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE); if (!CPPSemantics.isUserDefined(type)) @@ -132,20 +131,20 @@ public class EvalUnary implements ICPPEvaluation { } return CPPSemantics.findOverloadedOperator(point, args, type, op, LookupMode.LIMITED_GLOBALS); } - + @Override public IType getTypeOrFunctionSet(IASTNode point) { - if (fType == null) + if (fType == null) fType= computeType(point); return fType; } - + private IType computeType(IASTNode point) { - if (isTypeDependent()) + if (isTypeDependent()) return new TypeOfDependentExpression(this); - + ICPPFunction overload = getOverload(point); - if (overload != null) + if (overload != null) return ExpressionTypes.typeFromFunctionCall(overload); switch (fOperator) { @@ -163,7 +162,7 @@ public class EvalUnary implements ICPPEvaluation { type = prvalueTypeWithResolvedTypedefs(type); if (type instanceof IPointerType) { return glvalueType(((IPointerType) type).getType()); - } + } if (type instanceof ISemanticProblem) { return type; } @@ -212,7 +211,7 @@ public class EvalUnary implements ICPPEvaluation { buffer.putByte((byte) fOperator); buffer.marshalEvaluation(fArgument, includeValue); } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { int op= buffer.getByte(); ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java index 7c2ad77d1ad..c40d89f1011 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; @@ -31,7 +30,7 @@ public class EvalUnaryTypeID implements ICPPEvaluation { private final int fOperator; private final IType fOrigType; private IType fType; - + public EvalUnaryTypeID(int operator, IType type) { fOperator= operator; fOrigType= type; @@ -44,7 +43,7 @@ public class EvalUnaryTypeID implements ICPPEvaluation { public IType getArgument() { return fOrigType; } - + @Override public boolean isInitializerList() { return false; @@ -82,7 +81,7 @@ public class EvalUnaryTypeID implements ICPPEvaluation { case op_is_polymorphic: case op_is_union: return CPPTemplates.isDependentType(fOrigType); - + case op_typeid: case op_typeof: return false; @@ -92,11 +91,11 @@ public class EvalUnaryTypeID implements ICPPEvaluation { @Override public IType getTypeOrFunctionSet(IASTNode point) { - if (fType == null) + if (fType == null) fType= computeType(point); return fType; } - + private IType computeType(IASTNode point) { switch (fOperator) { case op_sizeof: @@ -120,7 +119,7 @@ public class EvalUnaryTypeID implements ICPPEvaluation { case op_is_union: return CPPBasicType.BOOLEAN; case op_typeof: - if (isTypeDependent()) + if (isTypeDependent()) return new TypeOfDependentExpression(this); return fOrigType; } @@ -143,7 +142,7 @@ public class EvalUnaryTypeID implements ICPPEvaluation { buffer.putByte((byte) fOperator); buffer.marshalType(fType); } - + public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException { int op= buffer.getByte(); IType arg= buffer.unmarshalType(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java index bd5e6a46b61..5c3b1646143 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.db; import org.eclipse.cdt.core.CCorePlugin; @@ -29,13 +29,13 @@ import org.eclipse.core.runtime.CoreException; * For marshalling types to byte arrays. */ public class TypeMarshalBuffer implements ITypeMarshalBuffer { - public final static byte[] EMPTY= { 0, 0, 0, 0, 0, 0 }; - public final static byte NULL_TYPE= 0; - public final static byte INDIRECT_TYPE= (byte) -1; - public final static byte BINDING_TYPE= (byte) -2; - public final static byte UNSTORABLE_TYPE= (byte) -3; - - public final static IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED); + public static final byte[] EMPTY= { 0, 0, 0, 0, 0, 0 }; + public static final byte NULL_TYPE= 0; + public static final byte INDIRECT_TYPE= (byte) -1; + public static final byte BINDING_TYPE= (byte) -2; + public static final byte UNSTORABLE_TYPE= (byte) -3; + + public static final IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED); static { assert EMPTY.length == Database.TYPE_SIZE; @@ -83,14 +83,14 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { putByte((byte) 0); putRecordPointer(pb.getRecord()); } - } + } } @Override public IBinding unmarshalBinding() throws CoreException { if (fPos >= fBuffer.length) throw unmarshallingError(); - + byte firstByte= fBuffer[fPos]; if (firstByte == BINDING_TYPE) { fPos+= 2; @@ -99,12 +99,12 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { } else if (firstByte == NULL_TYPE || firstByte == UNSTORABLE_TYPE) { fPos++; return null; - } - + } + IType type= fLinkage.unmarshalType(this); if (type == null || type instanceof IBinding) return (IBinding) type; - + throw unmarshallingError(); } @@ -126,10 +126,10 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { public IType unmarshalType() throws CoreException { if (fPos >= fBuffer.length) throw unmarshallingError(); - + byte firstByte= fBuffer[fPos]; if (firstByte == BINDING_TYPE) { - fPos+= 2; + fPos += 2; long rec= getRecordPointer(); return (IType) fLinkage.getNode(rec); } else if (firstByte == NULL_TYPE) { @@ -139,7 +139,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { fPos++; return UNSTORABLE_TYPE_PROBLEM; } - + return fLinkage.unmarshalType(this); } @@ -150,18 +150,18 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { } else { eval.marshal(this, includeValues); } - } - + } + @Override public ISerializableEvaluation unmarshalEvaluation() throws CoreException { if (fPos >= fBuffer.length) throw unmarshallingError(); - + byte firstByte= fBuffer[fPos]; if (firstByte == NULL_TYPE) { fPos++; return null; - } + } return fLinkage.unmarshalEvaluation(this); } @@ -171,14 +171,14 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { ((Value) value).marshall(this); } else { putByte(NULL_TYPE); - } + } } @Override public IValue unmarshalValue() throws CoreException { if (fPos >= fBuffer.length) throw unmarshallingError(); - + return Value.unmarshal(this); } @@ -209,7 +209,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { @Override public int getByte() throws CoreException { - if (fPos+1 > fBuffer.length) + if (fPos + 1 > fBuffer.length) throw unmarshallingError(); return 0xff & fBuffer[fPos++]; } @@ -218,6 +218,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { public CoreException unmarshallingError() { return new CoreException(CCorePlugin.createStatus("Unmarshalling error")); //$NON-NLS-1$ } + public CoreException marshallingError() { return new CoreException(CCorePlugin.createStatus("Marshalling error")); //$NON-NLS-1$ } @@ -225,31 +226,31 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { @Override public void putShort(short value) { request(2); - fBuffer[fPos++]= (byte)(value >> 8); - fBuffer[fPos++]= (byte)(value); + fBuffer[fPos++]= (byte) (value >> 8); + fBuffer[fPos++]= (byte) (value); } @Override public int getShort() throws CoreException { - if (fPos+2 > fBuffer.length) + if (fPos + 2 > fBuffer.length) throw unmarshallingError(); final int byte1 = 0xff & fBuffer[fPos++]; final int byte2 = 0xff & fBuffer[fPos++]; return (((byte1 << 8) | (byte2 & 0xff))); } - + public void putInt(int value) { request(4); fPos += 4; int p= fPos; - fBuffer[--p]= (byte)(value); value >>= 8; - fBuffer[--p]= (byte)(value); value >>= 8; - fBuffer[--p]= (byte)(value); value >>= 8; - fBuffer[--p]= (byte)(value); + fBuffer[--p]= (byte) (value); value >>= 8; + fBuffer[--p]= (byte) (value); value >>= 8; + fBuffer[--p]= (byte) (value); value >>= 8; + fBuffer[--p]= (byte) (value); } public int getInt() throws CoreException { - if (fPos+4 > fBuffer.length) + if (fPos + 4 > fBuffer.length) throw unmarshallingError(); int result= 0; result |= fBuffer[fPos++] & 0xff; result <<= 8; @@ -264,19 +265,19 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { request(8); fPos += 8; int p= fPos; - fBuffer[--p]= (byte)(value); value >>= 8; - fBuffer[--p]= (byte)(value); value >>= 8; - fBuffer[--p]= (byte)(value); value >>= 8; - fBuffer[--p]= (byte)(value); value >>= 8; - fBuffer[--p]= (byte)(value); value >>= 8; - fBuffer[--p]= (byte)(value); value >>= 8; - fBuffer[--p]= (byte)(value); value >>= 8; - fBuffer[--p]= (byte)(value); + fBuffer[--p]= (byte) (value); value >>= 8; + fBuffer[--p]= (byte) (value); value >>= 8; + fBuffer[--p]= (byte) (value); value >>= 8; + fBuffer[--p]= (byte) (value); value >>= 8; + fBuffer[--p]= (byte) (value); value >>= 8; + fBuffer[--p]= (byte) (value); value >>= 8; + fBuffer[--p]= (byte) (value); value >>= 8; + fBuffer[--p]= (byte) (value); } @Override public long getLong() throws CoreException { - if (fPos+8 > fBuffer.length) + if (fPos + 8 > fBuffer.length) throw unmarshallingError(); long result= 0; result |= fBuffer[fPos++] & 0xff; result <<= 8; @@ -293,7 +294,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { private void putRecordPointer(long record) { request(Database.PTR_SIZE); Chunk.putRecPtr(record, fBuffer, fPos); - fPos+= Database.PTR_SIZE; + fPos += Database.PTR_SIZE; } private long getRecordPointer() throws CoreException { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index d2e86cd34c4..decd3d170cb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -13,11 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; @@ -119,6 +114,11 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.core.runtime.CoreException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + /** * Container for c++-entities. */ @@ -127,15 +127,15 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { public final static int CACHE_BASES= 1; public final static int CACHE_INSTANCES= 2; public final static int CACHE_INSTANCE_SCOPE= 3; - + private final static int FIRST_NAMESPACE_CHILD_OFFSET= PDOMLinkage.RECORD_SIZE; - + @SuppressWarnings("hiding") private final static int RECORD_SIZE= FIRST_NAMESPACE_CHILD_OFFSET + Database.PTR_SIZE; // Only used when writing to database, which is single-threaded - private final LinkedList postProcesses = new LinkedList(); - + private final LinkedList postProcesses = new LinkedList(); + public PDOMCPPLinkage(PDOM pdom, long record) { super(pdom, record); } @@ -168,13 +168,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { class ConfigureTemplateParameters implements Runnable { private final IPDOMCPPTemplateParameter[] fPersisted; private final ICPPTemplateParameter[] fOriginal; - + public ConfigureTemplateParameters(ICPPTemplateParameter[] original, IPDOMCPPTemplateParameter[] params) { fOriginal= original; fPersisted= params; postProcesses.add(this); } - + @Override public void run() { for (int i = 0; i < fOriginal.length; i++) { @@ -184,18 +184,18 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } } } - + class ConfigurePartialSpecialization implements Runnable { IPDOMPartialSpecialization partial; ICPPClassTemplatePartialSpecialization binding; - + public ConfigurePartialSpecialization(IPDOMPartialSpecialization partial, ICPPClassTemplatePartialSpecialization binding) { this.partial = partial; this.binding = binding; postProcesses.add(this); } - + @Override public void run() { try { @@ -209,7 +209,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } } } - + class ConfigureFunctionTemplate implements Runnable { private final PDOMCPPFunctionTemplate fTemplate; private final IPDOMCPPTemplateParameter[] fTemplateParameters; @@ -217,7 +217,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { private final ICPPFunctionType fOriginalFunctionType; private final ICPPParameter[] fOriginalParameters; private final IType[] fOriginalExceptionSpec; - + public ConfigureFunctionTemplate(ICPPFunctionTemplate original, PDOMCPPFunctionTemplate template) throws DOMException { fTemplate = template; fTemplateParameters= template.getTemplateParameters(); @@ -227,7 +227,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { fOriginalExceptionSpec= template.extractExceptionSpec(original); postProcesses.add(this); } - + @Override public void run() { for (int i = 0; i < fOriginalTemplateParameters.length; i++) { @@ -238,7 +238,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { fTemplate.initData(fOriginalFunctionType, fOriginalParameters, fOriginalExceptionSpec); } } - + /** * Adds or returns existing binding for the given name. */ @@ -255,7 +255,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { addImplicitMethods(pdomBinding, (ICPPClassType) binding); } } - + handlePostProcesses(); return pdomBinding; } @@ -277,18 +277,18 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { if (cannotAdapt(inputBinding)) { return null; } - + PDOMBinding pdomBinding= attemptFastAdaptBinding(inputBinding); if (pdomBinding == null) { // assign names to anonymous types. IBinding binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(inputBinding); - if (binding == null) + if (binding == null) return null; final PDOMNode parent= adaptOrAddParent(true, binding); if (parent == null) return null; - + long fileLocalRec[]= {0}; pdomBinding = adaptBinding(parent, binding, fileLocalRec); if (pdomBinding != null) { @@ -349,9 +349,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { PDOMNode parent2= null; // template parameters are created directly by their owners. - if (binding instanceof ICPPTemplateParameter) + if (binding instanceof ICPPTemplateParameter) return null; - + if (binding instanceof ICPPSpecialization) { IBinding specialized = ((ICPPSpecialization) binding).getSpecializedBinding(); PDOMBinding pdomSpecialized= addBinding(specialized, null); @@ -427,7 +427,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { insertIntoNestedBindingsIndex(pdomBinding); } } - + return pdomBinding; } @@ -438,8 +438,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { ((PDOMCPPNamespace) node).addToList(record + FIRST_NAMESPACE_CHILD_OFFSET); } } - - private PDOMBinding createSpecialization(PDOMNode parent, PDOMBinding orig, IBinding special) + + private PDOMBinding createSpecialization(PDOMNode parent, PDOMBinding orig, IBinding special) throws CoreException, DOMException { PDOMBinding result= null; if (special instanceof ICPPDeferredClassInstance) { @@ -465,7 +465,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { result= new PDOMCPPFieldSpecialization(this, parent, (ICPPField) special, orig); } else if (special instanceof ICPPFunctionTemplate) { if (special instanceof ICPPConstructor) { - result= new PDOMCPPConstructorTemplateSpecialization( this, parent, (ICPPConstructor) special, orig); + result= new PDOMCPPConstructorTemplateSpecialization( this, parent, (ICPPConstructor) special, orig); } else if (special instanceof ICPPMethod) { result= new PDOMCPPMethodTemplateSpecialization( this, parent, (ICPPMethod) special, orig); } else if (special instanceof ICPPFunction) { @@ -486,10 +486,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } else if (special instanceof ICPPUsingDeclaration) { result= new PDOMCPPUsingDeclarationSpecialization(this, parent, (ICPPUsingDeclaration) special, orig); } - + return result; } - + private void addImplicitMethods(PDOMBinding type, ICPPClassType binding) throws CoreException { try { final long fileLocalRec= type.getLocalToFileRec(); @@ -537,7 +537,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } else if (binding instanceof ICPPFunction) { return CPP_FUNCTION_INSTANCE; } else if (binding instanceof ICPPClassType) { - return CPP_CLASS_INSTANCE; + return CPP_CLASS_INSTANCE; } } else if (binding instanceof ICPPClassTemplatePartialSpecialization) { if (binding instanceof ICPPClassTemplatePartialSpecializationSpecialization) @@ -619,7 +619,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } else if (binding instanceof ITypedef) { return CPPTYPEDEF; } - + return 0; } @@ -682,7 +682,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { if (fileLocalRecHolder == null) return glob; final long loc= getLocalToFileRec(parent, binding, glob); - if (loc == 0) + if (loc == 0) return glob; fileLocalRecHolder[0]= loc; return CPPFindBinding.findBinding(getIndex(), this, binding, loc); @@ -693,7 +693,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { if (fileLocalRecHolder == null) return glob; final long loc= getLocalToFileRec(parent, binding, glob); - if (loc == 0) + if (loc == 0) return glob; fileLocalRecHolder[0]= loc; return CPPFindBinding.findBinding(btree, this, binding, loc); @@ -705,7 +705,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { if (parent instanceof IPDOMMemberOwner) { PDOMBinding glob= CPPFindBinding.findBinding(parent, this, binding, 0); final long loc= getLocalToFileRec(parent, binding, glob); - if (loc == 0) + if (loc == 0) return glob; fileLocalRecHolder[0]= loc; return CPPFindBinding.findBinding(parent, this, binding, loc); @@ -714,7 +714,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } /** - * Adapts the parent of the given binding to an object contained in this linkage. May return + * Adapts the parent of the given binding to an object contained in this linkage. May return * null if the binding cannot be adapted or the binding does not exist and addParent * is set to false. * @param binding the binding to adapt @@ -747,7 +747,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { owner= owner.getOwner(); } } - + if (owner == null) return this; @@ -766,7 +766,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { postProcesses.removeFirst().run(); } } - + @Override public PDOMNode getNode(long record, int nodeType) throws CoreException { switch (nodeType) { @@ -863,7 +863,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { @Override public void onCreateName(PDOMFile file, IASTName name, PDOMName pdomName) throws CoreException { super.onCreateName(file, name, pdomName); - + IASTNode parentNode= name.getParent(); if (parentNode instanceof ICPPASTQualifiedName) { if (name != ((ICPPASTQualifiedName) parentNode).getLastName()) @@ -897,7 +897,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { IScope container= CPPVisitor.getContainingScope(name); boolean doit= false; PDOMCPPNamespace containerNS= null; - + IASTNode node= ASTInternal.getPhysicalNodeOfScope(container); if (node instanceof IASTTranslationUnit) { doit= true; @@ -931,7 +931,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } } } - } else if (parentNode instanceof ICPPASTFunctionDeclarator) { + } else if (parentNode instanceof ICPPASTFunctionDeclarator) { if (parentNode.getParent() instanceof IASTSimpleDeclaration) { IASTSimpleDeclaration grandparentNode = (IASTSimpleDeclaration) parentNode.getParent(); if (grandparentNode.getDeclSpecifier() instanceof ICPPASTDeclSpecifier) { @@ -974,7 +974,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { @Override public void onDeleteName(PDOMName pdomName) throws CoreException { super.onDeleteName(pdomName); - + if (pdomName.isBaseSpecifier()) { PDOMName derivedClassName= (PDOMName) pdomName.getEnclosingDefinition(); if (derivedClassName != null) { @@ -1031,22 +1031,22 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { if (file != null) { return file; } - } + } if (binding instanceof ICPPMember) { return null; } return super.getLocalToFile(binding, glob); } - - @Override + + @Override public PDOMBinding addTypeBinding(IBinding type) throws CoreException { return addBinding(type, null); } - + @Override public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException { int firstByte= buffer.getByte(); - switch((firstByte & ITypeMarshalBuffer.KIND_MASK)) { + switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) { case ITypeMarshalBuffer.ARRAY_TYPE: return CPPArrayType.unmarshal(firstByte, buffer); case ITypeMarshalBuffer.BASIC_TYPE: @@ -1068,14 +1068,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { case ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE: return TypeOfDependentExpression.unmarshal(firstByte, buffer); } - + throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$ } - + @Override public ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer buffer) throws CoreException { int firstByte= buffer.getByte(); - switch((firstByte & ITypeMarshalBuffer.KIND_MASK)) { + switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) { case ITypeMarshalBuffer.EVAL_BINARY: return EvalBinary.unmarshal(firstByte, buffer); case ITypeMarshalBuffer.EVAL_BINARY_TYPE_ID: From 9ab42da0771a5250dd42f04ac20781ec046b16e5 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 9 Jul 2012 12:09:25 -0700 Subject: [PATCH 03/14] Bug 299911. Signatures for evaluations. --- .../core/dom/parser/ITypeMarshalBuffer.java | 2 + .../cdt/internal/core/dom/parser/Value.java | 4 +- .../core/dom/parser/cpp/ICPPEvaluation.java | 37 ++- .../parser/cpp/semantics/CPPEvaluation.java | 228 ++++++++++++++++++ .../dom/parser/cpp/semantics/EvalBinary.java | 2 +- .../cpp/semantics/EvalBinaryTypeId.java | 3 +- .../dom/parser/cpp/semantics/EvalBinding.java | 3 +- .../dom/parser/cpp/semantics/EvalComma.java | 2 +- .../parser/cpp/semantics/EvalCompound.java | 2 +- .../parser/cpp/semantics/EvalConditional.java | 2 +- .../dom/parser/cpp/semantics/EvalFixed.java | 2 +- .../cpp/semantics/EvalFunctionCall.java | 2 +- .../parser/cpp/semantics/EvalFunctionSet.java | 3 +- .../core/dom/parser/cpp/semantics/EvalID.java | 2 +- .../parser/cpp/semantics/EvalInitList.java | 2 +- .../cpp/semantics/EvalMemberAccess.java | 2 +- .../dom/parser/cpp/semantics/EvalTypeId.java | 2 +- .../dom/parser/cpp/semantics/EvalUnary.java | 2 +- .../parser/cpp/semantics/EvalUnaryTypeID.java | 3 +- .../core/pdom/db/TypeMarshalBuffer.java | 4 +- 20 files changed, 283 insertions(+), 26 deletions(-) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java index f3dbae212dc..4b0ebf003e7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java @@ -63,6 +63,7 @@ public interface ITypeMarshalBuffer { ISerializableEvaluation unmarshalEvaluation() throws CoreException; int getByte() throws CoreException; int getShort() throws CoreException; + int getInt() throws CoreException; long getLong() throws CoreException; char[] getCharArray() throws CoreException; @@ -72,6 +73,7 @@ public interface ITypeMarshalBuffer { void marshalEvaluation(ISerializableEvaluation eval, boolean includeValue) throws CoreException; void putByte(byte data); void putShort(short data); + void putInt(int data); void putLong(long data); void putCharArray(char[] data); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index 808165c5c65..a731fd688ed 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -158,7 +158,7 @@ public class Value implements IValue { return parseLong(fExpression); } - public void marshall(TypeMarshalBuffer buf) throws CoreException { + public void marshall(ITypeMarshalBuffer buf) throws CoreException { if (UNKNOWN == this) { buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG1)); } else { @@ -183,7 +183,7 @@ public class Value implements IValue { } } - public static IValue unmarshal(TypeMarshalBuffer buf) throws CoreException { + public static IValue unmarshal(ITypeMarshalBuffer buf) throws CoreException { int firstByte= buf.getByte(); if (firstByte == TypeMarshalBuffer.NULL_TYPE) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java index c56f4d343ae..62e90c102f4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory; @@ -24,10 +23,40 @@ public interface ICPPEvaluation extends ISerializableEvaluation { boolean isInitializerList(); boolean isFunctionSet(); + /** + * Returns {@code true} if the type of the expression depends on template parameters. + */ boolean isTypeDependent(); + + /** + * Returns {@code true} if the value of the expression depends on template parameters. + */ boolean isValueDependent(); - + + /** + * TODO Add description + * + * @param point determines the scope for name lookups + */ IType getTypeOrFunctionSet(IASTNode point); + + /** + * TODO Add description + * + * @param point determines the scope for name lookups + */ IValue getValue(IASTNode point); + + /** + * TODO Add description + * + * @param point determines the scope for name lookups + */ ValueCategory getValueCategory(IASTNode point); + + /** + * Returns a signature uniquely identifying the evaluation. Two evaluations with identical + * signatures are guaranteed to produce the same results. + */ + char[] getSignature(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java new file mode 100644 index 00000000000..69460068b57 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java @@ -0,0 +1,228 @@ +/******************************************************************************* + * Copyright (c) 2012 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sergey Prigogin (Google) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; +import org.eclipse.cdt.internal.core.dom.parser.ISerializableType; +import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; +import org.eclipse.cdt.internal.core.dom.parser.Value; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; +import org.eclipse.core.runtime.CoreException; + +public abstract class CPPEvaluation implements ICPPEvaluation { + + private static class SignatureBuilder implements ITypeMarshalBuffer { + private static final byte NULL_TYPE= 0; + private static final byte UNSTORABLE_TYPE= (byte) -1; + private static final char[] HEX_DIGITS = + { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + + private final StringBuilder fBuffer; + private boolean hexMode; + + /** + * Constructor for input buffer. + */ + public SignatureBuilder() { + fBuffer= new StringBuilder(); + } + + @Override + public String toString() { + return fBuffer.toString(); + } + + @Override + public void marshalBinding(IBinding binding) throws CoreException { + if (binding instanceof ISerializableType) { + ((ISerializableType) binding).marshal(this); + } else if (binding == null) { + putByte(NULL_TYPE); + } else { + appendSeparator(); + IBinding owner= binding.getOwner(); + if (owner instanceof IType) { + ASTTypeUtil.appendType((IType) owner, true, fBuffer); + fBuffer.append("::"); //$NON-NLS-1$ + } + fBuffer.append(binding.getName()); + } + } + + @Override + public void marshalType(IType type) throws CoreException { + if (type instanceof ISerializableType) { + ((ISerializableType) type).marshal(this); + } else if (type == null) { + putByte(NULL_TYPE); + } else if (type instanceof IBinding) { + marshalBinding((IBinding) type); + } else { + assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + putByte(UNSTORABLE_TYPE); + } + } + + @Override + public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException { + if (eval == null) { + putByte(NULL_TYPE); + } else { + eval.marshal(this, includeValues); + } + } + + @Override + public void marshalValue(IValue value) throws CoreException { + if (value instanceof Value) { + ((Value) value).marshall(this); + } else { + putByte(NULL_TYPE); + } + } + + @Override + public void putByte(byte b) { + appendHexDigit(b >> 4); + appendHexDigit(b); + } + + @Override + public void putShort(short value) { + appendHexDigit(value >> 12); + appendHexDigit(value >> 8); + appendHexDigit(value >> 4); + appendHexDigit(value); + } + + @Override + public void putInt(int value) { + appendHexDigit(value >> 28); + appendHexDigit(value >> 24); + appendHexDigit(value >> 20); + appendHexDigit(value >> 16); + appendHexDigit(value >> 12); + appendHexDigit(value >> 8); + appendHexDigit(value >> 4); + appendHexDigit(value); + } + + @Override + public void putLong(long value) { + appendHexDigit((int) (value >> 60)); + appendHexDigit((int) (value >> 56)); + appendHexDigit((int) (value >> 52)); + appendHexDigit((int) (value >> 48)); + appendHexDigit((int) (value >> 44)); + appendHexDigit((int) (value >> 40)); + appendHexDigit((int) (value >> 36)); + appendHexDigit((int) (value >> 32)); + appendHexDigit((int) (value >> 28)); + appendHexDigit((int) (value >> 24)); + appendHexDigit((int) (value >> 20)); + appendHexDigit((int) (value >> 16)); + appendHexDigit((int) (value >> 12)); + appendHexDigit((int) (value >> 8)); + appendHexDigit((int) (value >> 4)); + appendHexDigit((int) value); + } + + @Override + public void putCharArray(char[] chars) { + appendSeparator(); + for (char c : chars) { + fBuffer.append(c); + } + } + + private void appendHexDigit(int val) { + if (hexMode) { + appendSeparator(); + fBuffer.append("0x"); //$NON-NLS-1$ + hexMode = true; + } + fBuffer.append(HEX_DIGITS[val & 0xF]); + } + + private void appendSeparator() { + if (fBuffer.length() != 0) + fBuffer.append(' '); + hexMode = false; + } + + @Override + public IBinding unmarshalBinding() throws CoreException { + throw new UnsupportedOperationException(); + } + + @Override + public IType unmarshalType() throws CoreException { + throw new UnsupportedOperationException(); + } + + @Override + public ISerializableEvaluation unmarshalEvaluation() throws CoreException { + throw new UnsupportedOperationException(); + } + + @Override + public IValue unmarshalValue() throws CoreException { + throw new UnsupportedOperationException(); + } + + @Override + public int getByte() throws CoreException { + throw new UnsupportedOperationException(); + } + + @Override + public CoreException unmarshallingError() { + throw new UnsupportedOperationException(); + } + + @Override + public int getShort() throws CoreException { + throw new UnsupportedOperationException(); + } + + @Override + public int getInt() throws CoreException { + throw new UnsupportedOperationException(); + } + + @Override + public long getLong() throws CoreException { + throw new UnsupportedOperationException(); + } + + @Override + public char[] getCharArray() throws CoreException { + throw new UnsupportedOperationException(); + } + } + + @Override + public char[] getSignature() { + SignatureBuilder buf = new SignatureBuilder(); + try { + marshal(buf, true); + } catch (CoreException e) { + CCorePlugin.log(e); + return new char[] { '?' }; + } + return buf.toString().toCharArray(); + } +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java index c762f12a9a7..0f119910e85 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java @@ -43,7 +43,7 @@ import org.eclipse.core.runtime.CoreException; /** * Performs evaluation of an expression. */ -public class EvalBinary implements ICPPEvaluation { +public class EvalBinary extends CPPEvaluation { public final static int op_arrayAccess= Byte.MAX_VALUE; private final int fOperator; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java index 7ef770b186a..ae2d6bd9878 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java @@ -23,13 +23,12 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.core.runtime.CoreException; /** * Performs evaluation of an expression. */ -public class EvalBinaryTypeId implements ICPPEvaluation { +public class EvalBinaryTypeId extends CPPEvaluation { private final Operator fOperator; private final IType fType1, fType2; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java index 8567ea3b666..2f75c840940 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java @@ -27,11 +27,10 @@ import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; import org.eclipse.cdt.internal.core.dom.parser.Value; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.core.runtime.CoreException; -public class EvalBinding implements ICPPEvaluation { +public class EvalBinding extends CPPEvaluation { private final IBinding fBinding; private final boolean fFixedType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java index 13a284e8c59..31e0f1f80fc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java @@ -25,7 +25,7 @@ import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.core.runtime.CoreException; -public class EvalComma implements ICPPEvaluation { +public class EvalComma extends CPPEvaluation { private static final ICPPFunction[] NO_FUNCTIONS = {}; private final ICPPEvaluation[] fArguments; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java index f4621924a41..8cae8cb319a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java @@ -25,7 +25,7 @@ import org.eclipse.core.runtime.CoreException; /** * Performs evaluation of an expression. */ -public class EvalCompound implements ICPPEvaluation { +public class EvalCompound extends CPPEvaluation { private final ICPPEvaluation fDelegate; public EvalCompound(ICPPEvaluation delegate) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java index 67bc4c3c1ee..d4caae8ea52 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java @@ -41,7 +41,7 @@ import org.eclipse.core.runtime.CoreException; /** * Performs evaluation of an expression. */ -public class EvalConditional implements ICPPEvaluation { +public class EvalConditional extends CPPEvaluation { private final ICPPEvaluation fCondition, fPositive, fNegative; private final boolean fPositiveThrows, fNegativeThrows; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java index fbd99448f59..c6985aed4c7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java @@ -28,7 +28,7 @@ import org.eclipse.core.runtime.CoreException; /** * Performs evaluation of an expression. */ -public class EvalFixed implements ICPPEvaluation { +public class EvalFixed extends CPPEvaluation { public static final ICPPEvaluation INCOMPLETE = new EvalFixed(ProblemType.UNKNOWN_FOR_EXPRESSION, PRVALUE, Value.UNKNOWN); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java index 2c2db81fb2e..38c741f9e38 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java @@ -36,7 +36,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode; import org.eclipse.core.runtime.CoreException; -public class EvalFunctionCall implements ICPPEvaluation { +public class EvalFunctionCall extends CPPEvaluation { private final ICPPEvaluation[] fArguments; private ICPPFunction fOverload= CPPFunction.UNINITIALIZED_FUNCTION; private IType fType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java index ce16b11a6b4..c2a98168cc7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java @@ -21,14 +21,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.Value; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.core.runtime.CoreException; /** * Performs evaluation of an expression. */ -public class EvalFunctionSet implements ICPPEvaluation { +public class EvalFunctionSet extends CPPEvaluation { private final CPPFunctionSet fFunctionSet; private final boolean fAddressOf; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java index 962def2afec..366e8f6e7a2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java @@ -43,7 +43,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.core.runtime.CoreException; -public class EvalID implements ICPPEvaluation { +public class EvalID extends CPPEvaluation { private final ICPPEvaluation fFieldOwner; private final char[] fName; private final IBinding fNameOwner; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java index 3b5e432cf2b..d54b0fb9bca 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java @@ -25,7 +25,7 @@ import org.eclipse.core.runtime.CoreException; /** * Performs evaluation of an expression. */ -public class EvalInitList implements ICPPEvaluation { +public class EvalInitList extends CPPEvaluation { private final ICPPEvaluation[] fClauses; public EvalInitList(ICPPEvaluation[] clauses) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java index e6eb6eb4437..84c8d69ea80 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java @@ -46,7 +46,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode; import org.eclipse.core.runtime.CoreException; -public class EvalMemberAccess implements ICPPEvaluation { +public class EvalMemberAccess extends CPPEvaluation { private final IType fOwnerType; private final IBinding fMember; private final ValueCategory fOwnerValueCategory; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java index 7ffadea8273..e2e41b728b1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java @@ -26,7 +26,7 @@ import org.eclipse.core.runtime.CoreException; /** * Performs evaluation of an expression. */ -public class EvalTypeId implements ICPPEvaluation { +public class EvalTypeId extends CPPEvaluation { private final IType fInputType; private final ICPPEvaluation[] fArguments; private IType fOutputType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java index 2058d62e861..ca5bef22dfc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java @@ -39,7 +39,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode; import org.eclipse.core.runtime.CoreException; -public class EvalUnary implements ICPPEvaluation { +public class EvalUnary extends CPPEvaluation { private static final ICPPEvaluation ZERO_EVAL = new EvalFixed(CPPSemantics.INT_TYPE, PRVALUE, Value.create(0)); private final int fOperator; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java index c40d89f1011..9caf7ec00f4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java @@ -23,10 +23,9 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.core.runtime.CoreException; -public class EvalUnaryTypeID implements ICPPEvaluation { +public class EvalUnaryTypeID extends CPPEvaluation { private final int fOperator; private final IType fOrigType; private IType fType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java index 5c3b1646143..7c3f483a70e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java @@ -117,7 +117,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { } else if (type instanceof IBinding) { marshalBinding((IBinding) type); } else { - assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + "(" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ putByte(UNSTORABLE_TYPE); } } @@ -239,6 +239,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { return (((byte1 << 8) | (byte2 & 0xff))); } + @Override public void putInt(int value) { request(4); fPos += 4; @@ -249,6 +250,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { fBuffer[--p]= (byte) (value); } + @Override public int getInt() throws CoreException { if (fPos + 4 > fBuffer.length) throw unmarshallingError(); From 8d580f3b986e951b9dbd0254341e6a43f1b7c01a Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 9 Jul 2012 15:56:34 -0700 Subject: [PATCH 04/14] Added a missing copyright header. --- .../dom/parser/cpp/semantics/CPPFunctionSet.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionSet.java index 3cbc6c97799..f92fcf3d165 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionSet.java @@ -1,10 +1,13 @@ -/* - * CPPFunctionSet.java - * Created on Sep 13, 2010 +/******************************************************************************* + * Copyright (c) 2010 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Copyright 2010 Wind River Systems, Inc. All rights reserved. - */ - + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import org.eclipse.cdt.core.dom.ILinkage; @@ -25,7 +28,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPTwoPhaseBinding; * The actual function can be resolved in certain contexts. */ public class CPPFunctionSet implements ICPPTwoPhaseBinding { - private final ICPPFunction[] fBindings; private final IASTName fName; private final ICPPTemplateArgument[] fTemplateArguments; From ee27356ecf18959a857fb0aeb3f964e8000a566d Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 9 Jul 2012 19:51:59 -0700 Subject: [PATCH 05/14] Cosmetics. --- .../cdt/core/dom/ast/DOMException.java | 19 ++++++++---------- .../ast/cpp/ICPPTemplateNonTypeParameter.java | 17 ++++++++-------- .../dom/parser/cpp/CPPASTFieldReference.java | 4 ++-- .../parser/cpp/CPPClassSpecialization.java | 12 ++++------- .../parser/cpp/semantics/CPPTemplates.java | 20 +++++++++---------- 5 files changed, 32 insertions(+), 40 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/DOMException.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/DOMException.java index 6b83daef583..d7503419071 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/DOMException.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/DOMException.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * Andrew Niefer (IBM Corporation) - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -18,22 +18,19 @@ package org.eclipse.cdt.core.dom.ast; * @noinstantiate This class is not intended to be instantiated by clients. */ public class DOMException extends Exception { - private static final long serialVersionUID = 0; IProblemBinding problemBinding; /** - * @param problem - * binding for throwing - * + * @param problem the binding for throwing */ public DOMException(IProblemBinding problem) { problemBinding = problem; } /** - * Get the problem associated w/this exception. + * Returns the problem associated w/this exception. * * @return problem */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateNonTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateNonTypeParameter.java index f04895b4f41..5861713590e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateNonTypeParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateNonTypeParameter.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Contributors: + * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression; * @noextend This interface is not intended to be extended by clients. */ public interface ICPPTemplateNonTypeParameter extends ICPPTemplateParameter, ICPPVariable { - /** * @deprecated, use {@link ICPPTemplateParameter#getDefaultValue()}. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java index 3f7f1473b53..8a2dff09a33 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java @@ -274,10 +274,10 @@ public class CPPASTFieldReference extends ASTNode IASTName[] ns= ((ICPPASTQualifiedName) n).getNames(); if (ns.length < 2) return EvalFixed.INCOMPLETE; - qualifier= ns[ns.length-2].resolveBinding(); + qualifier= ns[ns.length - 2].resolveBinding(); if (qualifier instanceof IProblemBinding) return EvalFixed.INCOMPLETE; - n= ns[ns.length-1]; + n= ns[ns.length - 1]; } if (n instanceof ICPPASTTemplateId) { args= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) n); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java index 4a1c7c34e7f..c1e5df4ee23 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java @@ -57,11 +57,11 @@ public class CPPClassSpecialization extends CPPSpecialization private ObjectMap specializationMap= ObjectMap.EMPTY_MAP; private final ThreadLocal> fInProgress= new ThreadLocal>(); - public CPPClassSpecialization(ICPPClassType specialized, IBinding owner, ICPPTemplateParameterMap argumentMap) { + public CPPClassSpecialization(ICPPClassType specialized, IBinding owner, + ICPPTemplateParameterMap argumentMap) { super(specialized, owner, argumentMap); } - @Override public ICPPClassType getSpecializedBinding() { return (ICPPClassType) super.getSpecializedBinding(); @@ -75,7 +75,7 @@ public class CPPClassSpecialization extends CPPSpecialization @Override public IBinding specializeMember(IBinding original, IASTNode point) { Set set; - synchronized(this) { + synchronized (this) { IBinding result= (IBinding) specializationMap.get(original); if (result != null) return result; @@ -91,7 +91,7 @@ public class CPPClassSpecialization extends CPPSpecialization IBinding result= CPPTemplates.createSpecialization(this, original, point); set.remove(original); - synchronized(this) { + synchronized (this) { IBinding concurrent= (IBinding) specializationMap.get(original); if (concurrent != null) return concurrent; @@ -233,9 +233,6 @@ public class CPPClassSpecialization extends CPPSpecialization return specScope; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType) - */ @Override public boolean isSameType(IType type) { if (type == this) @@ -251,7 +248,6 @@ public class CPPClassSpecialization extends CPPSpecialization @Override public Object clone() { - // TODO Auto-generated method stub return this; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index b42087adb35..bfd903dc69e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -844,7 +844,7 @@ public class CPPTemplates { return null; ICPPClassSpecialization within= (ICPPClassSpecialization) owner; ICPPClassType orig = within.getSpecializedBinding(); - for(;;) { + for (;;) { IBinding o1 = within.getOwner(); IBinding o2 = orig.getOwner(); if (!(o1 instanceof ICPPClassSpecialization && o2 instanceof ICPPClassType)) @@ -1027,7 +1027,7 @@ public class CPPTemplates { IType[] newResult= new IType[result.length+packSize-1]; System.arraycopy(result, 0, newResult, 0, j); result= newResult; - for(int k=0; k 0) { System.arraycopy(args, 0, result, 0, i); @@ -1145,7 +1145,7 @@ public class CPPTemplates { } /** - * Instantiates the given type with the provided map and packoffset. + * Instantiates the given type with the provided map and packОffset. * The context is used to replace templates with their specialization, where appropriate. * @param point */ From 040b82128a5e452bbfd52f707549a7eea1fa7324 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Mon, 9 Jul 2012 23:00:50 -0400 Subject: [PATCH 06/14] bug 380598: MinGW 64bit toolchain not detected. --- .../gnu/mingw/MingwEnvironmentVariableSupplier.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java index 79fb3eadc96..c5dcb3c01a0 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java @@ -127,6 +127,14 @@ public class MingwEnvironmentVariableSupplier implements IConfigurationEnvironme return mingwBinDir; } + // Check for MinGW-w64 on Windows 64 bit, see http://mingw-w64.sourceforge.net/ + if (Platform.ARCH_X86_64.equals(Platform.getOSArch())) { + IPath gcc64Loc = PathUtil.findProgramLocation("x86_64-w64-mingw32-gcc.exe", envPathValueCached); //$NON-NLS-1$ + if (gcc64Loc != null) { + return gcc64Loc.removeLastSegments(1); + } + } + // Look in PATH values. Look for mingw32-gcc.exe // TODO: Since this dir is already in the PATH, why are we adding it here? // This is really only to support isToolchainAvail. Must be a better way. From 5e5d6a0505d822cff45bcbd5fd97c549069613fd Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 10 Jul 2012 13:34:38 -0400 Subject: [PATCH 07/14] Bug 384756 - Projectless debugging: no error is reported if a directory is specified as the program path Change-Id: I4800d6851d3d086cc59963bd2bd44e4584a78d0b Reviewed-on: https://git.eclipse.org/r/6691 Reviewed-by: Marc Khouzam IP-Clean: Marc Khouzam Tested-by: Marc Khouzam Reviewed-by: Mikhail Khodjaiants IP-Clean: Mikhail Khodjaiants Tested-by: Mikhail Khodjaiants --- .../cdt/dsf/gdb/internal/ui/launching/CMainTab.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java index dcb0270820d..2ca26c25dcd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java @@ -470,10 +470,15 @@ public class CMainTab extends CAbstractMainTab { if (exePath.isAbsolute()) { // For absolute paths, we don't need a project, we can debug the binary directly // as long as it exists - if (!exePath.toFile().exists()) { + File executable = exePath.toFile(); + if (!executable.exists()) { setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$ return false; } + if (!executable.isFile()) { + setErrorMessage(LaunchMessages.getString("CMainTab.Selection_must_be_file")); //$NON-NLS-1$ + return false; + } } else { // For relative paths, we need a proper project String projectName = fProjText.getText().trim(); From 1c96bfa1b2a3fd8eb333a2e20b9998e095c2ffa7 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Tue, 10 Jul 2012 12:10:48 -0700 Subject: [PATCH 08/14] Cosmetics. --- .../cdt/core/dom/ast/cpp/ICPPMethod.java | 9 ++++----- .../cdt/core/dom/ast/cpp/ICPPNamespace.java | 4 ++-- .../core/dom/ast/cpp/ICPPNamespaceAlias.java | 4 +--- .../core/dom/ast/cpp/ICPPNamespaceScope.java | 2 -- .../cdt/core/dom/ast/cpp/ICPPParameter.java | 5 ++--- .../core/dom/ast/cpp/ICPPParameterPackType.java | 1 - .../cdt/core/dom/ast/cpp/ICPPReferenceType.java | 1 - .../eclipse/cdt/core/dom/ast/cpp/ICPPScope.java | 1 - .../core/dom/ast/cpp/ICPPSpecialization.java | 4 ++-- .../core/dom/ast/cpp/ICPPTemplateArgument.java | 2 +- .../dom/ast/cpp/ICPPTemplateDefinition.java | 6 ++---- .../core/dom/ast/cpp/ICPPTemplateInstance.java | 17 ++++++++--------- .../core/dom/ast/cpp/ICPPTemplateParameter.java | 6 +++--- .../dom/ast/cpp/ICPPTemplateParameterMap.java | 5 +---- .../cdt/core/dom/ast/cpp/ICPPTemplateScope.java | 4 ++-- .../ast/cpp/ICPPTemplateTemplateParameter.java | 1 - .../dom/ast/cpp/ICPPTemplateTypeParameter.java | 10 ++++------ .../core/dom/ast/cpp/ICPPUsingDeclaration.java | 3 +-- .../core/dom/ast/cpp/ICPPUsingDirective.java | 2 +- .../cdt/core/dom/ast/cpp/ICPPVariable.java | 1 - .../dom/parser/cpp/CPPASTLiteralExpression.java | 12 ++++-------- 21 files changed, 38 insertions(+), 62 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java index abbf0ad6cc2..5366f88f47c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPMethod.java @@ -6,11 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; - /** * Base interface for methods, also used for constructors. * @@ -18,7 +17,7 @@ package org.eclipse.cdt.core.dom.ast.cpp; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPMethod extends ICPPFunction, ICPPMember { - public static final ICPPMethod [] EMPTY_CPPMETHOD_ARRAY = new ICPPMethod[0]; + public static final ICPPMethod[] EMPTY_CPPMETHOD_ARRAY = {}; /** * Returns whether this method is declared to be virtual. Does not detect whether @@ -27,9 +26,9 @@ public interface ICPPMethod extends ICPPFunction, ICPPMember { public boolean isVirtual(); /** - * is this a destructor + * Is this a destructor? * - * returns true if its name starts with '~' + * Returns true if its name starts with '~' */ public boolean isDestructor(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespace.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespace.java index 275bddc4502..5e4de882ac9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespace.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespace.java @@ -21,12 +21,12 @@ import org.eclipse.cdt.core.dom.ast.IBinding; */ public interface ICPPNamespace extends ICPPBinding { /** - * get the scope object associated with this namespace + * Returns the scope object associated with this namespace */ public ICPPNamespaceScope getNamespaceScope(); /** - * get an array of the all the bindings declared in this namespace. + * Returns an array of the all the bindings declared in this namespace. */ public IBinding[] getMemberBindings(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespaceAlias.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespaceAlias.java index 8ca5e810bad..237ea89f333 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespaceAlias.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespaceAlias.java @@ -17,10 +17,8 @@ import org.eclipse.cdt.core.dom.ast.IBinding; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPNamespaceAlias extends ICPPNamespace { - /** - * get the binding of the original namespace. + * Returns the binding of the original namespace. */ public IBinding getBinding(); - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespaceScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespaceScope.java index 46146ae960f..f5b8ea79a7e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespaceScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNamespaceScope.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; - /** * A namespace scope is either a block-scope or a namespace-scope or global scope. * @@ -19,7 +18,6 @@ package org.eclipse.cdt.core.dom.ast.cpp; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPNamespaceScope extends ICPPScope { - /** * @since 5.3 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java index 12ae004074e..7ac37d22210 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Andrew Niefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IParameter; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPParameter extends IParameter, ICPPVariable { - /** * @since 5.2 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameterPackType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameterPackType.java index 04200c1d03d..62b72bf3639 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameterPackType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameterPackType.java @@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IType; * @since 5.2 */ public interface ICPPParameterPackType extends IType { - /** * Returns the pattern for the pack-expansion */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java index 5d4d7b4f06f..460194b209b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPReferenceType.java @@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IType; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPReferenceType extends IType { - /** * Returns the type that this is a reference of */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPScope.java index 22378e234cd..960c75db3d8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPScope.java @@ -17,5 +17,4 @@ import org.eclipse.cdt.core.dom.ast.IScope; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPScope extends IScope { - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPSpecialization.java index 3b14edcaa19..7f34606a020 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPSpecialization.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Andrew Niefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java index cda584b37a0..17e08457afa 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateDefinition.java index eb776231e3b..36f4f330fb7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateDefinition.java @@ -6,12 +6,11 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; - /** * Base interface for all template definitions including explicit (partial) specializations. * @@ -19,7 +18,6 @@ package org.eclipse.cdt.core.dom.ast.cpp; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPTemplateDefinition extends ICPPBinding { - /** * Returns an array of the template parameters. * In the case of a specialization, the array will be empty, diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java index 2ea5efd0cd4..fb71b0c5c30 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java @@ -1,15 +1,14 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2005, 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Contributors: + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.core.dom.ast.cpp; import org.eclipse.cdt.core.dom.ast.IType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java index d4d1eb12c29..9f9cf2c0459 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -18,7 +18,7 @@ package org.eclipse.cdt.core.dom.ast.cpp; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPTemplateParameter extends ICPPBinding { - public static final ICPPTemplateParameter[] EMPTY_TEMPLATE_PARAMETER_ARRAY = new ICPPTemplateParameter[0]; + public static final ICPPTemplateParameter[] EMPTY_TEMPLATE_PARAMETER_ARRAY = {}; /** * Returns the zero-based position of this parameter within the template parameter list it belongs to. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameterMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameterMap.java index a0ccd0e9aec..2a4b0a11e40 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameterMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameterMap.java @@ -6,11 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; - /** * Models the mapping of template parameters to values, or pack-expansions. * @@ -19,7 +18,6 @@ package org.eclipse.cdt.core.dom.ast.cpp; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPTemplateParameterMap { - /** * Returns the value for the template parameter with the given id. * @see ICPPTemplateParameter#getParameterID() @@ -32,7 +30,6 @@ public interface ICPPTemplateParameterMap { */ public ICPPTemplateArgument getArgument(ICPPTemplateParameter param); - /** * Returns the values for the template parameter pack with the given id in the map, * or null if the parameter is not mapped or is not a parameter pack. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateScope.java index e1b9e13a18c..ba8ed791e2b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateScope.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTemplateParameter.java index e86fa831fa2..c993e37327f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTemplateParameter.java @@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IType; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPTemplateTemplateParameter extends ICPPTemplateParameter, ICPPClassTemplate { - @Override public ICPPTemplateParameter[] getTemplateParameters(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTypeParameter.java index 0c494c5bc52..56acf7ec907 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTypeParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTypeParameter.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -18,17 +18,15 @@ import org.eclipse.cdt.core.dom.ast.IType; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPTemplateTypeParameter extends ICPPTemplateParameter, IType { - /** - * The default type for this parameter. May be null - * + * The default type for this parameter. May be {@code null}. */ public IType getDefault() throws DOMException; /** * Types containing template parameters need to be compared even before it is known to which - * binding the template parameter belongs to. Therefore {@link #isSameType(IType)} compares the - * kind and the parameter position of the template parameter, only. The name and the owner + * binding the template parameter belongs to. Therefore {@link #isSameType(IType)} compares + * the kind and the parameter position of the template parameter, only. The name and the owner * is ignored. * * @since 5.1 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPUsingDeclaration.java index da92e3e9154..ba37e652f46 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPUsingDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPUsingDeclaration.java @@ -22,8 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface ICPPUsingDeclaration extends ICPPBinding { - +public interface ICPPUsingDeclaration extends ICPPBinding { /** * Return an array of bindings that were declared by this using declaration. * Each of these bindings delegates to some previously declared binding to which it diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPUsingDirective.java index 5424102b9af..e5122a7c890 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPUsingDirective.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPUsingDirective.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPUsingDirective { - ICPPUsingDirective[] EMPTY_ARRAY = new ICPPUsingDirective[0]; + ICPPUsingDirective[] EMPTY_ARRAY = {}; /** * Returns the scope of the namespace that is nominated by this diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPVariable.java index c9144497a35..2961d919c83 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPVariable.java @@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IVariable; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPVariable extends IVariable, ICPPBinding { - /** * does this variable have the mutable storage class specifier */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java index a7a6fa62397..a80ff8b6cf0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java @@ -59,13 +59,9 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx @Override public CPPASTLiteralExpression copy(CopyStyle style) { - CPPASTLiteralExpression copy = new CPPASTLiteralExpression(kind, - value == null ? null : value.clone()); - copy.setOffsetAndLength(this); - if (style == CopyStyle.withLocations) { - copy.setCopyLocation(this); - } - return copy; + CPPASTLiteralExpression copy = + new CPPASTLiteralExpression(kind, value == null ? null : value.clone()); + return copy(copy, style); } @Override @@ -250,7 +246,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx case lk_float_constant: return new EvalFixed(classifyTypeOfFloatLiteral(), PRVALUE, Value.UNKNOWN); case lk_integer_constant: - return new EvalFixed(classifyTypeOfIntLiteral(),PRVALUE, createIntValue()); + return new EvalFixed(classifyTypeOfIntLiteral(), PRVALUE, createIntValue()); case lk_string_literal: IType type = new CPPBasicType(getCharType(), 0, this); type = new CPPQualifierType(type, true, false); From 0449ae3c417df7814949c1c8626f8e56cdc2aaf4 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 10 Jul 2012 15:38:21 -0400 Subject: [PATCH 09/14] Bug 381754: Group-expression support for Expressions view. A group-expression is a comma-separated list of expressions. Each expression can also use glob-pattern matching. Currently, the matching is only supported for registers and the single '*' expressions which will show all local variables. Change-Id: I09f505dcd453d9ce0301bbebb8d4c459316b9224 Reviewed-on: https://git.eclipse.org/r/6549 Reviewed-by: Marc Khouzam IP-Clean: Marc Khouzam Tested-by: Marc Khouzam --- .../GDBPatternMatchingExpressions.java | 848 ++++++++++++++++++ .../gdb/service/GdbDebugServicesFactory.java | 9 +- .../eclipse/cdt/dsf/gdb/service/Messages.java | 4 + .../cdt/dsf/gdb/service/Messages.properties | 6 +- .../IGDBPatternMatchingExpressions.java | 20 + .../cdt/dsf/mi/service/MIExpressions.java | 19 +- 6 files changed, 897 insertions(+), 9 deletions(-) create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBPatternMatchingExpressions.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IGDBPatternMatchingExpressions.java diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBPatternMatchingExpressions.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBPatternMatchingExpressions.java new file mode 100644 index 00000000000..fd3e5e03253 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBPatternMatchingExpressions.java @@ -0,0 +1,848 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.gdb.service; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.cdt.core.IAddress; +import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.datamodel.CompositeDMContext; +import org.eclipse.cdt.dsf.datamodel.DMContexts; +import org.eclipse.cdt.dsf.datamodel.IDMContext; +import org.eclipse.cdt.dsf.debug.service.ICachingService; +import org.eclipse.cdt.dsf.debug.service.IExpressions; +import org.eclipse.cdt.dsf.debug.service.IExpressions2; +import org.eclipse.cdt.dsf.debug.service.IExpressions3; +import org.eclipse.cdt.dsf.debug.service.IFormattedValues; +import org.eclipse.cdt.dsf.debug.service.IRegisters; +import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext; +import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterGroupDMContext; +import org.eclipse.cdt.dsf.debug.service.IStack; +import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; +import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMContext; +import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMData; +import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.dsf.mi.service.IGDBPatternMatchingExpressions; +import org.eclipse.cdt.dsf.mi.service.IMIExpressions; +import org.eclipse.cdt.dsf.mi.service.MIRegisters.MIRegisterDMC; +import org.eclipse.cdt.dsf.service.AbstractDsfService; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.osgi.framework.BundleContext; + +import com.ibm.icu.text.MessageFormat; + +/** + * Expressions service added as a layer above the standard Expressions service. + * This layer allows to support group-expressions and glob-pattern matching. + * Group-expressions give the user the ability to create a comma-separated + * list of expressions in a single entry. + * Glob-patterns are a way to specify a set of expressions that match the + * pattern. + * @since 4.2 + */ +public class GDBPatternMatchingExpressions extends AbstractDsfService implements IGDBPatternMatchingExpressions, ICachingService { + /** + * A regex representing each character that can be used to separate + * the different expressions contained in a group-expression. + * The [] are not part the characters, but are used in the regex format. + * Note that we don't allow a space separator because spaces are valid within + * an expression (e.g., i + 1) + */ + private final static String GROUP_EXPRESSION_SEPARATORS_REGEXP = "[,;]"; //$NON-NLS-1$ + + /** + * A group-expression is an expression that requires expansion into a (potentially empty) + * list of sub-expressions. Using a group-expression allows the user to create groups + * of expressions very quickly. + * + * We support two aspects for group-expressions: + * 1- The glob syntax (http://www.kernel.org/doc/man-pages/online/pages/man7/glob.7.html) + * This allows to user to specify glob-patterns to match different expressions. + * 2- Comma-separated expressions, each potentially using the glob-syntax + */ + protected static class GroupExpressionDMC implements IExpressionDMContext { + + /** + * The expression context, as created by the main Expression service. + * We delegate the handling of the expression to it. + */ + private IExpressionDMContext fExprDelegate; + + /** + * The set of expressions making up the group expression. + * This list is the result of splitting the original expression + * and then trimming each resulting expression. + */ + private List fExpressionsInGroup = null; + + public GroupExpressionDMC(IExpressionDMContext exprDmc) { + fExprDelegate = exprDmc; + } + + @Override + public String getExpression() { + return fExprDelegate.getExpression(); + } + + /** + * Returns an array representing the different expressions + * that make up this group-expression. + */ + public List getExpressionsInGroup() { + if (fExpressionsInGroup == null) { + // Split the list + String[] splitExpressions = getExpression().split(GROUP_EXPRESSION_SEPARATORS_REGEXP); + + // Remove any extra whitespace from each resulting expression, + // and ignore any empty expressions. + fExpressionsInGroup = new ArrayList(splitExpressions.length); + for (String expr : splitExpressions) { + expr = expr.trim(); + if (!expr.isEmpty()) { + fExpressionsInGroup.add(expr); + } + } + } + return fExpressionsInGroup; + } + + @Override + public String getSessionId() { + return fExprDelegate.getSessionId(); + } + + @Override + public IDMContext[] getParents() { + return fExprDelegate.getParents(); + }; + + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Class adapterType) { + return fExprDelegate.getAdapter(adapterType); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (!(obj instanceof GroupExpressionDMC)) return false; + + return ((GroupExpressionDMC)obj).fExprDelegate.equals(fExprDelegate); + } + + @Override + public int hashCode() { + return fExprDelegate.hashCode(); + } + } + + /** + * The model data interface for group-expressions + */ + protected static class GroupExpressionDMData implements IExpressionDMDataExtension { + private final String fRelativeExpression; + private final int fNumChildren; + + public GroupExpressionDMData(String expr, int numChildren) { + assert expr != null; + + fRelativeExpression = expr; + fNumChildren = numChildren; + } + + @Override + public String getName() { + return fRelativeExpression; + } + + @Override + public BasicType getBasicType() { + return IExpressionDMData.BasicType.array; + } + + @Override + public String getTypeName() { + return Messages.GroupPattern; + } + + @Override + public String getEncoding() { + return null; + } + + @Override + public String getTypeId() { + return null; + } + + @Override + public Map getEnumerations() { + return new HashMap(); + } + + @Override + public IRegisterDMContext getRegister() { + return null; + } + + @Override + public boolean hasChildren() { + return fNumChildren > 0; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof GroupExpressionDMData)) return false; + return fRelativeExpression.equals(((GroupExpressionDMData)other).fRelativeExpression); + } + + @Override + public int hashCode() { + return fRelativeExpression.hashCode(); + } + + @Override + public String toString() { + return "GroupExpr: " + fRelativeExpression; //$NON-NLS-1$ + } + } + + /** + * The base expression service to which we delegate all non-group-expression logic. + */ + private IMIExpressions fDelegate; + + public GDBPatternMatchingExpressions(DsfSession session, IExpressions delegate) { + super(session); + fDelegate = (IMIExpressions)delegate; + } + + @Override + public void initialize(final RequestMonitor requestMonitor) { + super.initialize( + new ImmediateRequestMonitor(requestMonitor) { + @Override + public void handleSuccess() { + doInitialize(requestMonitor); + }}); + } + + private void doInitialize(final RequestMonitor requestMonitor) { + // Our delegate should not be initialized yet, as we have no + // good way to unregister it. + assert !fDelegate.isRegistered(); + + // We must first register this service to let the original + // expression service know that it should not register itself. + register(new String[] { IExpressions.class.getName(), + IExpressions2.class.getName(), + IExpressions3.class.getName(), + IMIExpressions.class.getName() }, + new Hashtable()); + + // Second, we initialize the delegate so it can perform its duties + fDelegate.initialize(requestMonitor); + } + + @Override + public void shutdown(final RequestMonitor requestMonitor) { + fDelegate.shutdown(new RequestMonitor(getExecutor(), requestMonitor) { + @Override + protected void handleSuccess() { + unregister(); + GDBPatternMatchingExpressions.super.shutdown(requestMonitor); + } + }); + } + + @Override + protected BundleContext getBundleContext() { + return GdbPlugin.getBundleContext(); + } + + @Override + public IExpressionDMContext createExpression(IDMContext ctx, String expression) { + IExpressionDMContext expressionDmc = fDelegate.createExpression(ctx, expression); + + if (isGroupExpression(expression)) { + return new GroupExpressionDMC(expressionDmc); + } else { + return expressionDmc; + } + } + + @Override + public ICastedExpressionDMContext createCastedExpression(IExpressionDMContext context, CastInfo castInfo) { + // Cannot cast a GroupExpression + assert (!(context instanceof GroupExpressionDMC)); + + return fDelegate.createCastedExpression(context, castInfo); + } + + @Override + public void getExpressionDataExtension(final IExpressionDMContext dmc, final DataRequestMonitor rm) { + if (dmc instanceof GroupExpressionDMC) { + getSubExpressionCount(dmc, new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + rm.done(new GroupExpressionDMData(((GroupExpressionDMC)dmc).getExpression(), getData())); + } + }); + return; + } + + fDelegate.getExpressionDataExtension(dmc, rm); + } + + + @Override + public void getExpressionData(final IExpressionDMContext dmc, final DataRequestMonitor rm) { + if (dmc instanceof GroupExpressionDMC) { + getSubExpressionCount(dmc, new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + rm.done(new GroupExpressionDMData(((GroupExpressionDMC)dmc).getExpression(), getData())); + } + }); + return; + } + + fDelegate.getExpressionData(dmc, rm); + } + + @Override + public void getExpressionAddressData(IExpressionDMContext dmc, DataRequestMonitor rm) { + // A GroupExpression does not have an address + if (dmc instanceof GroupExpressionDMC) { + rm.done(new IExpressionDMLocation() { + @Override + public IAddress getAddress() { + return IExpressions.IExpressionDMLocation.INVALID_ADDRESS; + } + @Override + public int getSize() { + return 0; + } + @Override + public String getLocation() { + return ""; //$NON-NLS-1$ + } + }); + return; + } + + fDelegate.getExpressionAddressData(dmc, rm); + } + + @Override + public void getSubExpressions(IExpressionDMContext exprCtx, DataRequestMonitor rm) { + if (exprCtx instanceof GroupExpressionDMC) { + matchGroupExpression((GroupExpressionDMC)exprCtx, -1, -1, rm); + } else { + fDelegate.getSubExpressions(exprCtx, rm); + } + } + + @Override + public void getSubExpressions(IExpressionDMContext exprCtx, int startIndex, int length, DataRequestMonitor rm) { + if (exprCtx instanceof GroupExpressionDMC) { + matchGroupExpression((GroupExpressionDMC)exprCtx, startIndex, length, rm); + } else { + fDelegate.getSubExpressions(exprCtx, startIndex, length, rm); + } + } + + @Override + public void getSubExpressionCount(IExpressionDMContext dmc, final DataRequestMonitor rm) { + if (dmc instanceof GroupExpressionDMC) { + matchGroupExpression((GroupExpressionDMC)dmc, -1, -1, new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + rm.done(getData().length); + } + }); + } else { + fDelegate.getSubExpressionCount(dmc, rm); + } + } + + @Override + public void getSubExpressionCount(IExpressionDMContext dmc, int maxNumberOfChildren, final DataRequestMonitor rm) { + if (dmc instanceof GroupExpressionDMC) { + // No need to worry about maxNumberOfChildren for the case of a group-expression, since there won't be + // a very large amount of them. + matchGroupExpression((GroupExpressionDMC)dmc, -1, -1, new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + rm.done(getData().length); + } + }); + } else { + fDelegate.getSubExpressionCount(dmc, maxNumberOfChildren, rm); + } + } + + @Override + public void getBaseExpressions(IExpressionDMContext exprContext, DataRequestMonitor rm) { + rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ + } + + @Override + public void canWriteExpression(IExpressionDMContext dmc, DataRequestMonitor rm) { + // A GroupExpression's value cannot be modified + if (dmc instanceof GroupExpressionDMC) { + rm.done(false); + return; + } + + fDelegate.canWriteExpression(dmc, rm); + } + + @Override + public void writeExpression(IExpressionDMContext dmc, String expressionValue, String formatId, RequestMonitor rm) { + // A GroupExpression's value cannot be modified + assert !(dmc instanceof GroupExpressionDMC); + fDelegate.writeExpression(dmc, expressionValue, formatId, rm); + } + + @Override + public void getAvailableFormats(IFormattedDataDMContext dmc, DataRequestMonitor rm) { + //For a group expression, we only show the NATURAL format + if (dmc instanceof GroupExpressionDMC) { + rm.done(new String[] { IFormattedValues.NATURAL_FORMAT }); + return; + } + + fDelegate.getAvailableFormats(dmc, rm); + } + + @Override + public FormattedValueDMContext getFormattedValueContext(IFormattedDataDMContext dmc, String formatId) { + // No special handling for GroupExpressions + return fDelegate.getFormattedValueContext(dmc, formatId); + } + + @Override + public void getFormattedExpressionValue(FormattedValueDMContext dmc, final DataRequestMonitor rm) { + GroupExpressionDMC groupExpr = DMContexts.getAncestorOfType(dmc, GroupExpressionDMC.class); + if (groupExpr != null) { + getSubExpressionCount(groupExpr, new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + int numChildren = getData(); + String value; + if (numChildren == 0) { + value = Messages.NoMatches; + } else if (numChildren == 1) { + value = MessageFormat.format(Messages.UniqueMatch, numChildren); + } else { + value = MessageFormat.format(Messages.UniqueMatches, numChildren); + } + rm.done(new FormattedValueDMData(value)); + } + }); + return; + } + + fDelegate.getFormattedExpressionValue(dmc, rm); + } + + @Override + public void safeToAskForAllSubExpressions(IExpressionDMContext dmc, DataRequestMonitor rm) { + // Always safe to ask for all sub-expression of a group expression, since we don't expect large + // amounts of children + if (dmc instanceof GroupExpressionDMC) { + rm.done(true); + return; + } + + fDelegate.safeToAskForAllSubExpressions(dmc, rm); + } + + @Override + public void flushCache(IDMContext context) { + if (fDelegate instanceof ICachingService) { + ((ICachingService)fDelegate).flushCache(context); + } + } + + /** + * Verify if we are dealing with a group expression. + * @param expr The expression to verify + * @return True if expr is a group expression. A group + * expression is either a comma-separated list of + * expressions, or an expression using a glob-pattern + */ + protected boolean isGroupExpression(String expr) { + // First check for a comma separated list of expression + // We want to re-use the regex that defines our separators, and we need to check + // if the expression contains that regex. I didn't find a method that + // checks if a string contains a regex, so instead we all any character before + // and after the regex, which achieves what we want. + // Note that checking if expr.split(regex) is bigger than 1, will not notice + // an expression that has a separator only at the end. + if (expr.matches(".*" + GROUP_EXPRESSION_SEPARATORS_REGEXP +".*")) { //$NON-NLS-1$ //$NON-NLS-2$ + // We are dealing with a group expression. + // It may not be a valid one, but it is one nonetheless. + return true; + } + + // Not a comma-separated list. Check if we are dealing with a glob-pattern. + return isGlobPattern(expr); + } + + /** + * Verify if we are dealing with a glob-pattern. + * We support the expression * which will match all local variables. + * We support glob-patterns for registers (must start with $) + * @param expr The expression to verify + * @return True if expr is a glob-pattern we support. + */ + protected boolean isGlobPattern(String expr) { + // Get rid of useless whitespace + expr = expr.trim(); + + // We support the glob-pattern '*' to indicate all local variables + if (expr.equals("*")) { //$NON-NLS-1$ + return true; + } + + // We only support glob-expressions for registers at this time + if (expr.startsWith("$")) { //$NON-NLS-1$ + // see: 'man glob' + if (expr.indexOf('*') != -1 || expr.indexOf('?') != -1 || expr.indexOf('[') != -1) { + return true; + } + } + + return false; + } + + /** + * Find all expressions that match the specified group-expression. + * This method retains the order of the expressions in the group-expression, to show them + * in the same order as the one specified by the user. The match of each expression in the group + * is sorted alphabetically however. + * + * @param groupExprDmc The group-expression context for which we want the matches (sub-expressions) + * @param startIndex The beginning of the range of matches (-1 means all matches) + * @param length The length of the range of matches (-1 means all matches) + * @param rm RequestMonitor that will contain the range of found matches. + */ + protected void matchGroupExpression(final GroupExpressionDMC groupExprDmc, int startIndex, int length, + final DataRequestMonitor rm) { + // First separate the group into different expressions. + // We need to create a new list, as we will modify it during our processing. + final List exprList = new ArrayList(groupExprDmc.getExpressionsInGroup()); + + // List to store the final result, which is all the sub-expressions of this group + final ArrayList subExprList = new ArrayList(); + + final int startIndex1 = (startIndex < 0) ? 0 : startIndex; + final int length1 = (length < 0) ? Integer.MAX_VALUE : length; + + matchExpressionList(exprList, subExprList, groupExprDmc, new ImmediateRequestMonitor(rm) { + @Override + protected void handleSuccess() { + // It would be nice to allow identical elements, so that the user + // can control their positioning. For example, the pattern $eax, $*, would show + // the $eax first, followed by all other registers sorted alphabetically. In that case + // $eax will be shown again within $*, but that would be ok. + // However, the platform does not handle the same element being there twice. + // Not only does selecting the element jump back and forth between the duplicates, + // but children of duplicated elements are not always right. Because of this, we + // remove all duplicates here. + LinkedHashSet uniqueSubExprSet = new LinkedHashSet(subExprList); + subExprList.clear(); + subExprList.addAll(uniqueSubExprSet); + + // Extract the range of interest from the final list + int endIndex = Math.min(startIndex1 + length1, subExprList.size()); + List subExprRangeList = subExprList.subList(startIndex1, endIndex); + IExpressionDMContext[] subExprRange = subExprRangeList.toArray(new IExpressionDMContext[subExprRangeList.size()]); + rm.done(subExprRange); + } + }); + } + + /** + * We use this recursive method to serialize the request for matches. Once one request is done, + * we create a new one. This allows us to guarantee that the resulting matches will + * be ordered in the same way every time. + */ + private void matchExpressionList(final List exprList, final List subExprList, final IDMContext parentDmc, + final RequestMonitor rm) { + // We've finished parsing the list + if (exprList.isEmpty()) { + rm.done(); + return; + } + + // Remove the next element from the list and process it. We handle glob-pattern matching if needed + // and sort the result alphabetically in that case. + String expr = exprList.remove(0); + + if (isGlobPattern(expr)) { + IExpressionDMContext exprDmc = createExpression(parentDmc, expr); + matchGlobExpression(exprDmc, new ImmediateDataRequestMonitor>(rm) { + @Override + protected void handleSuccess() { + List matches = getData(); + // Sort the matches to be more user-friendly + Collections.sort(matches, new Comparator() { + @Override + public int compare(IExpressionDMContext o1, IExpressionDMContext o2) { + return o1.getExpression().compareTo(o2.getExpression()); + } + }); + + subExprList.addAll(matches); + // Match the next expression from the list + matchExpressionList(exprList, subExprList, parentDmc, rm); + } + }); + } else { + // Just a normal expression + subExprList.add(createExpression(parentDmc, expr)); + // Match the next expression from the list + matchExpressionList(exprList, subExprList, parentDmc, rm); + } + } + + /** + * Find all expressions that match the specified glob-pattern. + * + * @param exprDmc The expression context for which we want the matches (sub-expressions) + * @param rm RequestMonitor that will contain the matches. + */ + protected void matchGlobExpression(final IExpressionDMContext exprDmc, final DataRequestMonitor> rm) { + final String fullExpr = exprDmc.getExpression().trim(); + + if (fullExpr.equals("*")) { //$NON-NLS-1$ + matchLocals(exprDmc, rm); + return; + } + + // Currently, we only support glob-expressions for registers, so + // we only need to match the glob-expression with register names. + // We should not arrive here if we are not handling a register + assert fullExpr.startsWith("$"); //$NON-NLS-1$ + + final IRegisters registerService = getServicesTracker().getService(IRegisters.class); + if (registerService == null) { + rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Register service unavailable", null)); //$NON-NLS-1$ + return; + } + + registerService.getRegisterGroups(exprDmc, new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + registerService.getRegisters( + new CompositeDMContext(new IDMContext[] { getData()[0], exprDmc } ), + new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + assert getData() instanceof MIRegisterDMC[]; + ArrayList matches = new ArrayList(); + for (MIRegisterDMC register : (MIRegisterDMC[])getData()) { + String potentialMatch = "$"+register.getName(); //$NON-NLS-1$ + if (globMatches(fullExpr, potentialMatch)) { + matches.add(createExpression(exprDmc, potentialMatch)); + } + } + + rm.done(matches); + } + }); + } + }); + } + + + /** + * Find all local variables that match the specified glob-pattern. + * We currently only support matching all local variables using the '*' pattern. + * + * @param globDmc The glob-expression context for which we want the matches (sub-expressions) + * @param rm RequestMonitor that will contain the matches. + */ + + protected void matchLocals(final IExpressionDMContext globDmc, final DataRequestMonitor> rm) { + // We only support '*' for local variables at this time + assert globDmc.getExpression().equals("*"); //$NON-NLS-1$ + + final IStack stackService = getServicesTracker().getService(IStack.class); + if (stackService == null) { + rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Stack service unavailable", null)); //$NON-NLS-1$ + return; + } + + IFrameDMContext frameCtx = DMContexts.getAncestorOfType(globDmc, IFrameDMContext.class); + if (frameCtx == null) { + rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Stack frame unavailable", null)); //$NON-NLS-1$ + return; + } + + stackService.getLocals(frameCtx, new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + IVariableDMContext[] localsDMCs = getData(); + final IVariableDMData[] localsDMData = new IVariableDMData[localsDMCs.length]; + + final CountingRequestMonitor crm = new CountingRequestMonitor(getExecutor(), rm) { + @Override + public void handleSuccess() { + ArrayList expressionDMCs = new ArrayList(localsDMData.length); + + for (IVariableDMData localDMData : localsDMData) { + expressionDMCs.add(createExpression(globDmc, localDMData.getName())); + } + rm.done(expressionDMCs); + } + }; + int countRM = 0; + + for (int index=0; index < localsDMCs.length; index++) { + final int finalIndex = index; + stackService.getVariableData(localsDMCs[finalIndex], new ImmediateDataRequestMonitor(crm) { + @Override + public void handleSuccess() { + localsDMData[finalIndex] = getData(); + crm.done(); + } + }); + + countRM++; + } + crm.setDoneCount(countRM); + } + }); + } + + /** + * Verify if the potentialMatch variable matches the glob-pattern. + * + * @param globPattern The glob-pattern to match + * @param potentialMatch The string that must match globPattern. + * @return True of potentialMatch does match globPattern. + */ + protected boolean globMatches(String globPattern, String potentialMatch) { + // Convert the glob-pattern into java regex to do the matching + + boolean inBrackets = false; + char[] patternArray = globPattern.toCharArray(); + char[] resultArray = new char[patternArray.length * 2 + 2]; + int pos = 0; + + // Must match from the very beginning + resultArray[pos++] = '^'; + for (int i = 0; i < patternArray.length; i++) { + switch(patternArray[i]) { + case '?': + if (inBrackets) { + resultArray[pos++] = '?'; + } else { + resultArray[pos++] = '.'; + } + break; + + case '*': + if (!inBrackets) { + resultArray[pos++] = '.'; + } + resultArray[pos++] = '*'; + break; + + case '-': + if (!inBrackets) { + resultArray[pos++] = '\\'; + } + resultArray[pos++] = '-'; + break; + + case '[': + inBrackets = true; + resultArray[pos++] = '['; + + if (i < patternArray.length - 1) { + switch (patternArray[i+1]) { + case '!': + case '^': + resultArray[pos++] = '^'; + i++; + break; + + case ']': + resultArray[pos++] = ']'; + i++; + break; + } + } + break; + + case ']': + resultArray[pos++] = ']'; + inBrackets = false; + break; + + case '\\': + if (i == 0 && patternArray.length > 1 && patternArray[1] == '~') { + resultArray[pos++] = '~'; + ++i; + } else { + resultArray[pos++] = '\\'; + if (i < patternArray.length - 1 && "*?[]".indexOf(patternArray[i+1]) != -1) { //$NON-NLS-1$ + resultArray[pos++] = patternArray[++i]; + } else { + resultArray[pos++] = '\\'; + } + } + break; + + default: + // We must escape characters that are not digits or arrays + // specifically, "^$.{}()+|<>" + if (!Character.isLetterOrDigit(patternArray[i])) { + resultArray[pos++] = '\\'; + } + resultArray[pos++] = patternArray[i]; + break; + } + } + // Must match until the very end + resultArray[pos++] = '$'; + + try { + Pattern pattern = Pattern.compile(new String(resultArray, 0, pos), Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(potentialMatch); + return matcher.find(); + } catch(Exception e) { + // If the user put an invalid pattern, we just ignore it + return false; + } + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java index 848fbafe948..3d33d62131e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java @@ -102,7 +102,7 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory { return (V)createHardwareAndOSService(session, (ILaunchConfiguration)arg); } } - } + } return super.createService(clazz, session); } @@ -151,7 +151,12 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory { @Override protected IExpressions createExpressionService(DsfSession session) { - return new MIExpressions(session); + // Replace the standard Expressions service with a version that supports pattern matching. + // Pass in the original service which will be used as a delegate. + // This way of doing things allows to keep the pattern matching aspect isolated + // and easy to remove. + IExpressions originialExpressionService = new MIExpressions(session); + return new GDBPatternMatchingExpressions(session, originialExpressionService); } @Override diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/Messages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/Messages.java index a35539cb469..bc3be5a1abd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/Messages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/Messages.java @@ -20,6 +20,10 @@ class Messages extends NLS { public static String Tracing_not_supported_error; public static String Invalid_post_mortem_type_error; public static String Cannot_get_post_mortem_file_path_error; + public static String GroupPattern; + public static String NoMatches; + public static String UniqueMatch; + public static String UniqueMatches; static { // initialize resource bundle diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/Messages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/Messages.properties index ff882bec4ee..8f5360c82ad 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/Messages.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/Messages.properties @@ -11,4 +11,8 @@ Tracing_not_supported_error=Tracing not supported Invalid_post_mortem_type_error=Invalid post-mortem type -Cannot_get_post_mortem_file_path_error=Cannot get post mortem file path \ No newline at end of file +Cannot_get_post_mortem_file_path_error=Cannot get post mortem file path +GroupPattern=Group-pattern +NoMatches=No matches +UniqueMatch={0} unique match +UniqueMatches={0} unique matches diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IGDBPatternMatchingExpressions.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IGDBPatternMatchingExpressions.java new file mode 100644 index 00000000000..9dcd4fa745a --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/IGDBPatternMatchingExpressions.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.mi.service; + + +/** + * Interface that will indicate that the implementing service supports + * Glob-style expression pattern matching. + * @since 4.2 + */ +public interface IGDBPatternMatchingExpressions extends IMIExpressions { +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java index 4728a28ff5b..931e85728ce 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java @@ -30,6 +30,7 @@ import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.debug.service.ICachingService; import org.eclipse.cdt.dsf.debug.service.IExpressions; import org.eclipse.cdt.dsf.debug.service.IExpressions2; +import org.eclipse.cdt.dsf.debug.service.IExpressions3; import org.eclipse.cdt.dsf.debug.service.IFormattedValues; import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent; import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext; @@ -836,12 +837,18 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, // Register to receive service events for this session. getSession().addServiceEventListener(this, null); - // Register this service. - register(new String[] { IExpressions.class.getName(), - IExpressions2.class.getName(), - MIExpressions.class.getName() }, - new Hashtable()); - + // Register this service, but only if we don't already have an + // IExpression service present. This allows another expression + // service to be used, while delegating calls to this service. + if (getServicesTracker().getService(IExpressions.class) == null) { + register(new String[] { IExpressions.class.getName(), + IExpressions2.class.getName(), + IExpressions3.class.getName(), + IMIExpressions.class.getName(), + MIExpressions.class.getName() }, + new Hashtable()); + } + // Create the expressionService-specific CommandControl which is our // variable object manager. // It will deal with the meta-commands, before sending real MI commands From 9dbd7f7213be38eae81631be572bb9fc08c404e5 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 10 Jul 2012 15:36:04 -0400 Subject: [PATCH 10/14] Bug 381754: Group-expression support for Expressions view. JUnit tests. Change-Id: I5666d09a3abe71ef9c811fb94418c80da5b3a09e Reviewed-on: https://git.eclipse.org/r/6701 Reviewed-by: Marc Khouzam IP-Clean: Marc Khouzam Tested-by: Marc Khouzam --- .../src/PatternMatchingExpressionsTestApp.cc | 18 + .../GDBPatternMatchingExpressionsTest.java | 914 ++++++++++++++++++ ...GDBPatternMatchingExpressionsTest_6_6.java | 24 + .../dsf/gdb/tests/tests_6_6/Suite_6_6.java | 1 + .../gdb/tests/tests_6_6/Suite_Remote_6_6.java | 1 + ...GDBPatternMatchingExpressionsTest_6_7.java | 24 + .../dsf/gdb/tests/tests_6_7/Suite_6_7.java | 1 + .../gdb/tests/tests_6_7/Suite_Remote_6_7.java | 1 + ...GDBPatternMatchingExpressionsTest_6_8.java | 24 + .../dsf/gdb/tests/tests_6_8/Suite_6_8.java | 1 + .../gdb/tests/tests_6_8/Suite_Remote_6_8.java | 1 + ...GDBPatternMatchingExpressionsTest_7_0.java | 24 + .../dsf/gdb/tests/tests_7_0/Suite_7_0.java | 1 + .../gdb/tests/tests_7_0/Suite_Remote_7_0.java | 1 + ...GDBPatternMatchingExpressionsTest_7_1.java | 24 + .../dsf/gdb/tests/tests_7_1/Suite_7_1.java | 1 + .../gdb/tests/tests_7_1/Suite_Remote_7_1.java | 1 + ...GDBPatternMatchingExpressionsTest_7_2.java | 48 + .../dsf/gdb/tests/tests_7_2/Suite_7_2.java | 1 + .../gdb/tests/tests_7_2/Suite_Remote_7_2.java | 1 + ...GDBPatternMatchingExpressionsTest_7_3.java | 24 + .../dsf/gdb/tests/tests_7_3/Suite_7_3.java | 1 + .../gdb/tests/tests_7_3/Suite_Remote_7_3.java | 1 + ...GDBPatternMatchingExpressionsTest_7_4.java | 24 + .../dsf/gdb/tests/tests_7_4/Suite_7_4.java | 1 + .../gdb/tests/tests_7_4/Suite_Remote_7_4.java | 1 + ...GDBPatternMatchingExpressionsTest_7_5.java | 24 + .../dsf/gdb/tests/tests_7_5/Suite_7_5.java | 1 + .../gdb/tests/tests_7_5/Suite_Remote_7_5.java | 1 + 29 files changed, 1190 insertions(+) create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/PatternMatchingExpressionsTestApp.cc create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBPatternMatchingExpressionsTest.java create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/GDBPatternMatchingExpressionsTest_6_6.java create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/GDBPatternMatchingExpressionsTest_6_7.java create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/GDBPatternMatchingExpressionsTest_6_8.java create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBPatternMatchingExpressionsTest_7_0.java create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/GDBPatternMatchingExpressionsTest_7_1.java create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBPatternMatchingExpressionsTest_7_2.java create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/GDBPatternMatchingExpressionsTest_7_3.java create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/GDBPatternMatchingExpressionsTest_7_4.java create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/GDBPatternMatchingExpressionsTest_7_5.java diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/PatternMatchingExpressionsTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/PatternMatchingExpressionsTestApp.cc new file mode 100644 index 00000000000..a5720b1a77e --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/PatternMatchingExpressionsTestApp.cc @@ -0,0 +1,18 @@ + +int foo(int firstarg, bool secondarg) { + bool firstvar = true; + int secondvar = 18; + + return 0; +} + +int main (int argc, char *argv[]) +{ + int intvar = 80; + bool boolvar = true; + char chararray[201]; + + foo(15, true); + return 0; +} + diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBPatternMatchingExpressionsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBPatternMatchingExpressionsTest.java new file mode 100644 index 00000000000..bfb58add8c9 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBPatternMatchingExpressionsTest.java @@ -0,0 +1,914 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.Query; +import org.eclipse.cdt.dsf.datamodel.CompositeDMContext; +import org.eclipse.cdt.dsf.datamodel.DMContexts; +import org.eclipse.cdt.dsf.datamodel.IDMContext; +import org.eclipse.cdt.dsf.debug.service.IExpressions; +import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress; +import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; +import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData; +import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMLocation; +import org.eclipse.cdt.dsf.debug.service.IExpressions3.IExpressionDMDataExtension; +import org.eclipse.cdt.dsf.debug.service.IFormattedValues; +import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext; +import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData; +import org.eclipse.cdt.dsf.debug.service.IRegisters; +import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext; +import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterGroupDMContext; +import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType; +import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; +import org.eclipse.cdt.dsf.mi.service.ClassAccessor.MIExpressionDMCAccessor; +import org.eclipse.cdt.dsf.mi.service.IGDBPatternMatchingExpressions; +import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; +import org.eclipse.cdt.dsf.mi.service.IMIExpressions; +import org.eclipse.cdt.dsf.mi.service.MIRegisters.MIRegisterDMC; +import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent; +import org.eclipse.cdt.dsf.service.DsfServicesTracker; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; +import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; +import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; +import org.eclipse.core.runtime.Platform; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBPatternMatchingExpressionsTest extends BaseTestCase { + + private DsfSession fSession; + + private DsfServicesTracker fServicesTracker; + + protected IMIExpressions fExpService; + protected IRegisters fRegService; + + @Override + protected void setLaunchAttributes() { + super.setLaunchAttributes(); + + setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/PatternMatchingExpressionsTestApp.exe"); + } + + @Override + public void doBeforeTest() throws Exception { + super.doBeforeTest(); + + fSession = getGDBLaunch().getSession(); + Runnable runnable = new Runnable() { + @Override + public void run() { + fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId()); + + fExpService = fServicesTracker.getService(IMIExpressions.class); + assertTrue(fExpService instanceof IGDBPatternMatchingExpressions); + + fRegService = fServicesTracker.getService(IRegisters.class); + } + }; + fSession.getExecutor().submit(runnable).get(); + } + + @Override + public void doAfterTest() throws Exception { + super.doAfterTest(); + fExpService = null; + fServicesTracker.dispose(); + } + + //************************************************************************************** + // Utility methods + //************************************************************************************** + + protected List get_X86_REGS() { + // Because we are dealing with expressions for the registers, we must prefix them with '$' + List list = new LinkedList(Arrays.asList("$eax","$ecx","$edx","$ebx","$esp","$ebp","$esi","$edi","$eip","$eflags", + "$cs","$ss","$ds","$es","$fs","$gs","$st0","$st1","$st2","$st3", + "$st4","$st5","$st6","$st7","$fctrl","$fstat","$ftag","$fiseg","$fioff","$foseg", + "$fooff","$fop","$xmm0","$xmm1","$xmm2","$xmm3","$xmm4","$xmm5","$xmm6","$xmm7", + "$mxcsr","$orig_eax","$mm0","$mm1","$mm2","$mm3","$mm4","$mm5","$mm6","$mm7")); + // On Windows, gdb doesn't report "orig_eax" as a register. Apparently it does on Linux + if (Platform.getOS().equals(Platform.OS_WIN32)) { + list.remove("$orig_eax"); + } + return list; + } + + protected void checkChildrenCount(final IExpressionDMContext parentDmc, final int expectedCount) throws Throwable { + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + fExpService.getSubExpressionCount(parentDmc, rm); + } + }; + + fSession.getExecutor().execute(query); + int count = query.get(); + + assertTrue(String.format("Expected %d but got %d", expectedCount, count), count == expectedCount); + } + + protected String getRegisterValue(final String regName, final IMIExecutionDMContext threadDmc) throws Exception { + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + fRegService.getRegisterGroups(threadDmc, new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + fRegService.getRegisters( + new CompositeDMContext(new IDMContext[] { getData()[0], threadDmc } ), + new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + assert getData() instanceof MIRegisterDMC[]; + for (MIRegisterDMC register : (MIRegisterDMC[])getData()) { + if (register.getName().equals(regName)) { + final FormattedValueDMContext valueDmc = fRegService.getFormattedValueContext(register, IFormattedValues.HEX_FORMAT); + fRegService.getFormattedExpressionValue(valueDmc, new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + rm.done(getData().getFormattedValue()); + }; + }); + return; + } + } + // If we get here, we didn't find the register! + assertTrue("Invalid register: " + regName, false); + } + }); + } + }); + } + }; + + fSession.getExecutor().execute(query); + return query.get(); + } + + protected String getExpressionValue(final IExpressionDMContext exprDmc) throws Throwable + { + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + final FormattedValueDMContext valueDmc = + fExpService.getFormattedValueContext(exprDmc, IFormattedValues.HEX_FORMAT); + fExpService.getFormattedExpressionValue(valueDmc, + new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + rm.done(getData().getFormattedValue()); + } + }); + } + }; + + fSession.getExecutor().execute(query); + return query.get(); + } + + // This method tests IExpressions.getSubExpressions(IExpressionDMC, int, int, DRM); + protected IExpressionDMContext[] checkChildren(final IExpressionDMContext parentDmc, final int startIndex, final int length, + String[] expectedValues) throws Throwable { + + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + fExpService.getSubExpressions(parentDmc, startIndex, length, rm); + } + }; + + fSession.getExecutor().execute(query); + IExpressionDMContext[] childDmcs = query.get(); + + String[] childExpressions = new String[childDmcs.length]; + MIExpressionDMCAccessor[] childDmcsAccessor = new MIExpressionDMCAccessor[childDmcs.length]; + + // Convert to a MIExpressionDMCAccessor to be able to call getRelativeExpression + // Also convert to String[] to be able to use Arrays.toString() + for (int i = 0; i < childExpressions.length; i++) { + childDmcsAccessor[i] = new MIExpressionDMCAccessor(childDmcs[i]); + childExpressions[i] = childDmcsAccessor[i].getRelativeExpression(); + } + assertTrue("Expected " + Arrays.toString(expectedValues) + " but got " + Arrays.toString(childExpressions), + expectedValues.length == childExpressions.length); + + for (int i = 0; i < childDmcsAccessor.length; i++) { + assertEquals(childDmcsAccessor[i].getRelativeExpression(), expectedValues[i]); + } + + return childDmcs; + } + + //************************************************************************************** + // Tests methods + //************************************************************************************** + + /** + * Test that we can access a single register + */ + @Test + public void testMatchSingleReg() throws Throwable { + final String regName = "esp"; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + IMIExecutionDMContext threadDmc = DMContexts.getAncestorOfType(frameDmc, IMIExecutionDMContext.class); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, "$"+regName); + checkChildrenCount(exprDmc, 0); + + // get value of expression and compare with register + assertEquals(getRegisterValue(regName, threadDmc), getExpressionValue(exprDmc)); + } + + /** + * Test that we can access a single variable, without using groups or patterns + */ + @Test + public void testMatchSingleLocal() throws Throwable { + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, "secondvar"); + checkChildrenCount(exprDmc, 0); + + // get value of expression and compare with register + assertEquals(getExpressionValue(exprDmc), "0x12"); + } + + /** + * Test that we can create the all-register match + */ + @Test + public void testMatchAllRegs() throws Throwable { + final String exprString = "$*"; + List regList = get_X86_REGS(); + Collections.sort(regList); + final String[] children = regList.toArray(new String[0]); + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that we can create the all-locals match + */ + @Test + public void testMatchAllLocals() throws Throwable { + final String exprString = "*"; + final String[] children = new String[] { "firstarg", "firstvar", "secondarg", "secondvar" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that we can create the all-locals match for another frame + */ + @Test + public void testMatchAllLocalsOtherFrame() throws Throwable { + final String exprString = "*"; + final String[] children = new String[] { "argc", "argv", "boolvar", "chararray", "intvar" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 1); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that registers can be matched using '*' + */ + @Test + public void testMatchRegWithStar() throws Throwable { + final String exprString = "$e*"; + final String[] children = new String[] { "$eax","$ebp","$ebx","$ecx","$edi","$edx","$eflags","$eip","$es", "$esi","$esp" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that registers can be matched using '?' + */ + @Test + public void testMatchRegWithQuestionMark() throws Throwable { + final String exprString = "$e??"; + final String[] children = new String[] { "$eax","$ebp","$ebx","$ecx","$edi","$edx","$eip", "$esi","$esp" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that registers can be matched using [] with a single index + */ + @Test + public void testMatchRegWithBracketsOneDigit() throws Throwable { + final String exprString = "$st[4]"; + final String[] children = new String[] { "$st4" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that registers can be matched using '[]' using a range + */ + @Test + public void testMatchRegWithBracketsRange() throws Throwable { + final String exprString = "$st[2-5]"; + final String[] children = new String[] { "$st2","$st3", "$st4","$st5" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that all registers and all locals can be matched at the same time + */ + @Test + public void testGroupAllRegsAllLocals() throws Throwable { + final String exprString = "$*, *"; + List list = get_X86_REGS(); + Collections.sort(list); + list.addAll(Arrays.asList(new String[] { "firstarg", "firstvar", "secondarg", "secondvar" })); + final String[] children = list.toArray(new String[list.size()]); + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that all local and all registers can be matched at the same time. This + * is the reverse order than the previous test. + */ + @Test + public void testGroupAllLocalsAllRegs() throws Throwable { + final String exprString = "*, $*"; + List list = get_X86_REGS(); + Collections.sort(list); + list.addAll(0, Arrays.asList(new String[] { "firstarg", "firstvar", "secondarg", "secondvar" })); + final String[] children = list.toArray(new String[list.size()]); + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that we can match a range + */ + @Test + public void testGroupSubExprRange() throws Throwable { + final String exprString = "$eax, $es, *"; + final String[] children = new String[] { "$es", "firstarg", "firstvar", "secondarg" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + // Check four children starting at position 1 + checkChildren(exprDmc, 1, 4, children); + } + + /** + * Test that we can group a local with all registers + */ + @Test + public void testGroupOneLocalAllReg() throws Throwable { + final String exprString = "firstvar, $*"; + List list = get_X86_REGS(); + Collections.sort(list); + list.addAll(0, Arrays.asList(new String[] { "firstvar" })); + final String[] children = list.toArray(new String[list.size()]); + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that we only return a single instance of a duplicate + * register when using a pattern that matches the register + * more than once. + */ + @Test + public void testUniqueWhenOverlapReg() throws Throwable { + final String exprString = "$eax, $e?x, $eb?"; + final String[] children = new String[] { "$eax","$ebx","$ecx","$edx", "$ebp" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that we only return a single instance of a duplicate + * variable when using a pattern that matches the variable + * more than once. + */ + @Test + public void testUniqueWhenOverlapLocal() throws Throwable { + final String exprString = "firstvar,*,firstvar"; + final String[] children = new String[] { "firstvar", "firstarg", "secondarg", "secondvar" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that the all-register pattern is sorted alphabetically + */ + @Test + public void testSortedAllReg() throws Throwable { + final String exprString = "$*"; + List regList = get_X86_REGS(); + Collections.sort(regList); + final String[] children = regList.toArray(new String[0]); + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that the all-local pattern is sorted alphabetically + */ + @Test + public void testSortedAllLocals() throws Throwable { + final String exprString = "*"; + List list = Arrays.asList(new String[] { "firstarg", "firstvar", "secondarg", "secondvar" }); + Collections.sort(list); + final String[] children = list.toArray(new String[list.size()]); + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that individual expressions within a group-expression + * are not sorted between each other, but that each part of the + * group is kept in the user-specified order and sorted within + * itself. + */ + @Test + public void testSeparatlySorted() throws Throwable { + final String exprString = "$*, *"; + List list = get_X86_REGS(); + Collections.sort(list); + List localsList = Arrays.asList(new String[] { "firstarg", "firstvar", "secondarg", "secondvar" }); + Collections.sort(localsList); + list.addAll(localsList); + final String[] children = list.toArray(new String[list.size()]); + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that group-expression can use a comma as a separator + */ + @Test + public void testCommaSeparation() throws Throwable { + final String exprString = "firstvar,$eax"; + final String[] children = new String[] { "firstvar","$eax" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that group-expression can use a semi-colon as a separator + */ + @Test + public void testSemiColonSeparation() throws Throwable { + final String exprString = "firstvar;$eax"; + final String[] children = new String[] { "firstvar","$eax" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + + } + + /** + * Test that group-expression can use a comma and a semi-colon as a + * separator at the same time + */ + @Test + public void testCommaAndSemiColonSeparation() throws Throwable { + final String exprString = "firstvar,$eax;$es"; + final String[] children = new String[] { "firstvar","$eax","$es" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + + } + + /** + * Test that group-expression can have empty terms with commas. + */ + @Test + public void testGroupCommaEmptyTerm() throws Throwable { + final String exprString = ",,firstvar,,$eax,,"; + final String[] children = new String[] { "firstvar","$eax" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that group-expression can have empty terms with semi-colon. + */ + @Test + public void testGroupSemiColonEmptyTerm() throws Throwable { + final String exprString = ";;firstvar;;$eax;;"; + final String[] children = new String[] { "firstvar","$eax" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test that group-expression clean up extra spaces + */ + @Test + public void testExtraSpaces() throws Throwable { + final String exprString = " firstvar , $eax , , "; + final String[] children = new String[] { "firstvar","$eax" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + checkChildren(exprDmc, -1, -1, children); + checkChildrenCount(exprDmc, children.length); + } + + /** + * Test the expression data associated with group-expressions. + */ + @Test + public void testGroupExpressionData() throws Throwable { + final String exprString = "$eax,*"; +// final String[] children = new String[] { "$eax", "firstarg", "firstvar", "secondarg", "secondvar" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + fExpService.getExpressionData(exprDmc, rm); + } + }; + fSession.getExecutor().execute(query); + IExpressionDMData data = query.get(); + + Query query2 = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + fExpService.getExpressionDataExtension(exprDmc, rm); + } + }; + + fSession.getExecutor().execute(query2); + IExpressionDMDataExtension dataExt = query2.get(); + + // Make sure the two different ways to get the group-expression data return + // teh same thing, to make sure we didn't forget to update one of the two. + assertEquals(data, dataExt); + + assertEquals(exprString, dataExt.getName()); + assertEquals(IExpressionDMData.BasicType.array, dataExt.getBasicType()); + assertEquals("Group-pattern", dataExt.getTypeName()); + assertTrue("IExpressionDMDataExtension.HasChildren should have been true", dataExt.hasChildren()); + assertEquals("Group-pattern", dataExt.getTypeName()); + } + + /** + * Test the expression address data associated with group-expressions. + */ + @Test + public void testGroupExpressionAddressData() throws Throwable { + final String exprString = "$eax,*"; +// final String[] children = new String[] { "$eax", "firstarg", "firstvar", "secondarg", "secondvar" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + fExpService.getExpressionAddressData(exprDmc, rm); + } + }; + + fSession.getExecutor().execute(query); + IExpressionDMAddress data = query.get(); + + assertTrue("The address data shoudl be of type IExpressionDMLocation", data instanceof IExpressionDMLocation); + assertEquals(IExpressions.IExpressionDMLocation.INVALID_ADDRESS, data.getAddress()); + assertEquals(0, data.getSize()); + assertEquals("", ((IExpressionDMLocation)data).getLocation()); + } + + /** + * Test the call to IExpressions.getSubExpressions(IExpressionDMC, DRM); + * which is not tested by the method checkChildren() used by our other tests + */ + @Test + public void testGroupGetSubExpressions() throws Throwable { + final String exprString = "$eax,*"; + final String[] children = new String[] { "$eax", "firstarg", "firstvar", "secondarg", "secondvar" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + fExpService.getSubExpressions(exprDmc, rm); + } + }; + + fSession.getExecutor().execute(query); + IExpressionDMContext[] childDmcs = query.get(); + + String[] childExpressions = new String[childDmcs.length]; + MIExpressionDMCAccessor[] childDmcsAccessor = new MIExpressionDMCAccessor[childDmcs.length]; + + // Convert to a MIExpressionDMCAccessor to be able to call getRelativeExpression + // Also convert to String[] to be able to use Arrays.toString() + for (int i = 0; i < childExpressions.length; i++) { + childDmcsAccessor[i] = new MIExpressionDMCAccessor(childDmcs[i]); + childExpressions[i] = childDmcsAccessor[i].getRelativeExpression(); + } + assertTrue("Expected " + Arrays.toString(children) + " but got " + Arrays.toString(childExpressions), + children.length == childExpressions.length); + + for (int i = 0; i < childDmcsAccessor.length; i++) { + assertEquals(childDmcsAccessor[i].getRelativeExpression(), children[i]); + } + } + + /** + * Test we cannot modify the value of a group-expression + */ + @Test + public void testGroupExpressionNotModifiable() throws Throwable { + final String exprString = "$eax,*"; +// final String[] children = new String[] { "$eax", "firstarg", "firstvar", "secondarg", "secondvar" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + fExpService.canWriteExpression(exprDmc, rm); + } + }; + + fSession.getExecutor().execute(query); + boolean canWrite = query.get(); + + assertFalse("Should not be able to modify the value of a group-expression", canWrite); + } + + /** + * Test the only available format for the value of a group-expression is NATURAL + */ + @Test + public void testGroupExpressionAvailableFormats() throws Throwable { + final String exprString = "$eax,*"; +// final String[] children = new String[] { "$eax", "firstarg", "firstvar", "secondarg", "secondvar" }; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, exprString); + + Query query = new Query() { + @Override + protected void execute(final DataRequestMonitor rm) { + fExpService.getAvailableFormats(exprDmc, rm); + } + }; + + fSession.getExecutor().execute(query); + String[] formats = query.get(); + + assertEquals(1, formats.length); + assertEquals(IFormattedValues.NATURAL_FORMAT, formats[0]); + } + + /** + * Test the different values returned by a group-expression + */ + @Test + public void testGroupExpressionValue() throws Throwable { + final String noMatchExpr = "$zzz*"; + final String singleMatchExpr = "$eax,"; + final String doubleMatchExpr = "$eax,$ebx"; + + SyncUtil.runToLocation("foo"); + MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + + IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); + + final IExpressionDMContext noMatchExprDmc = SyncUtil.createExpression(frameDmc, noMatchExpr); + final IExpressionDMContext singleMatchExprDmc = SyncUtil.createExpression(frameDmc, singleMatchExpr); + final IExpressionDMContext doubleMatchExprDmc = SyncUtil.createExpression(frameDmc, doubleMatchExpr); + + assertEquals("No matches", getExpressionValue(noMatchExprDmc)); + assertEquals("1 unique match", getExpressionValue(singleMatchExprDmc)); + assertEquals("2 unique matches", getExpressionValue(doubleMatchExprDmc)); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/GDBPatternMatchingExpressionsTest_6_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/GDBPatternMatchingExpressionsTest_6_6.java new file mode 100644 index 00000000000..15193508e0b --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/GDBPatternMatchingExpressionsTest_6_6.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.GDBPatternMatchingExpressionsTest; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBPatternMatchingExpressionsTest_6_6 extends GDBPatternMatchingExpressionsTest { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_6_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_6_6.java index e4f7358bc39..98f6f23a229 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_6_6.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_6_6.java @@ -33,6 +33,7 @@ import org.junit.runners.Suite; MIRunControlTest_6_6.class, MIRunControlTargetAvailableTest_6_6.class, MIExpressionsTest_6_6.class, + GDBPatternMatchingExpressionsTest_6_6.class, MIMemoryTest_6_6.class, MIBreakpointsTest_6_6.class, MICatchpointsTest_6_6.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java index ba0be9b3642..e49d4e3c2df 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java @@ -34,6 +34,7 @@ import org.junit.runners.Suite; MIRunControlTest_6_6.class, MIRunControlTargetAvailableTest_6_6.class, MIExpressionsTest_6_6.class, + GDBPatternMatchingExpressionsTest_6_6.class, MIMemoryTest_6_6.class, MIBreakpointsTest_6_6.class, MICatchpointsTest_6_6.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/GDBPatternMatchingExpressionsTest_6_7.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/GDBPatternMatchingExpressionsTest_6_7.java new file mode 100644 index 00000000000..0f53b98abe9 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/GDBPatternMatchingExpressionsTest_6_7.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_7; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6.GDBPatternMatchingExpressionsTest_6_6; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBPatternMatchingExpressionsTest_6_7 extends GDBPatternMatchingExpressionsTest_6_6 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_7); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_6_7.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_6_7.java index 928a49eafd8..faa5fb999f0 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_6_7.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_6_7.java @@ -33,6 +33,7 @@ import org.junit.runners.Suite; MIRunControlTest_6_7.class, MIRunControlTargetAvailableTest_6_7.class, MIExpressionsTest_6_7.class, + GDBPatternMatchingExpressionsTest_6_7.class, MIMemoryTest_6_7.class, MIBreakpointsTest_6_7.class, MICatchpointsTest_6_7.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java index a3e9277200b..91dd44f7c92 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java @@ -34,6 +34,7 @@ import org.junit.runners.Suite; MIRunControlTest_6_7.class, MIRunControlTargetAvailableTest_6_7.class, MIExpressionsTest_6_7.class, + GDBPatternMatchingExpressionsTest_6_7.class, MIMemoryTest_6_7.class, MIBreakpointsTest_6_7.class, MICatchpointsTest_6_7.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/GDBPatternMatchingExpressionsTest_6_8.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/GDBPatternMatchingExpressionsTest_6_8.java new file mode 100644 index 00000000000..55f0059ba12 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/GDBPatternMatchingExpressionsTest_6_8.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_7.GDBPatternMatchingExpressionsTest_6_7; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBPatternMatchingExpressionsTest_6_8 extends GDBPatternMatchingExpressionsTest_6_7 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_8); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_6_8.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_6_8.java index 2b975e1e114..a5b180b6d80 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_6_8.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_6_8.java @@ -33,6 +33,7 @@ import org.junit.runners.Suite; MIRunControlTest_6_8.class, MIRunControlTargetAvailableTest_6_8.class, MIExpressionsTest_6_8.class, + GDBPatternMatchingExpressionsTest_6_8.class, MIMemoryTest_6_8.class, MIBreakpointsTest_6_8.class, MICatchpointsTest_6_8.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java index 1cbc297d442..ca7e8503d7f 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java @@ -34,6 +34,7 @@ import org.junit.runners.Suite; MIRunControlTest_6_8.class, MIRunControlTargetAvailableTest_6_8.class, MIExpressionsTest_6_8.class, + GDBPatternMatchingExpressionsTest_6_8.class, MIMemoryTest_6_8.class, MIBreakpointsTest_6_8.class, MICatchpointsTest_6_8.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBPatternMatchingExpressionsTest_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBPatternMatchingExpressionsTest_7_0.java new file mode 100644 index 00000000000..38109caa82b --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBPatternMatchingExpressionsTest_7_0.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8.GDBPatternMatchingExpressionsTest_6_8; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBPatternMatchingExpressionsTest_7_0 extends GDBPatternMatchingExpressionsTest_6_8 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_0); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_7_0.java index 597c13a0aff..7b332907ccb 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_7_0.java @@ -34,6 +34,7 @@ import org.junit.runners.Suite; MIRunControlTargetAvailableTest_7_0.class, MIRunControlNonStopTargetAvailableTest_7_0.class, MIExpressionsTest_7_0.class, + GDBPatternMatchingExpressionsTest_7_0.class, MIMemoryTest_7_0.class, MIBreakpointsTest_7_0.class, MICatchpointsTest_7_0.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java index c5ed44539bb..0d2c2685df0 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java @@ -36,6 +36,7 @@ import org.junit.runners.Suite; MIRunControlNonStopTargetAvailableTest_7_0.class, MIRunControlTest_7_0.class, MIExpressionsTest_7_0.class, + GDBPatternMatchingExpressionsTest_7_0.class, MIMemoryTest_7_0.class, MIBreakpointsTest_7_0.class, MICatchpointsTest_7_0.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/GDBPatternMatchingExpressionsTest_7_1.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/GDBPatternMatchingExpressionsTest_7_1.java new file mode 100644 index 00000000000..1e0a5189daa --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/GDBPatternMatchingExpressionsTest_7_1.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0.GDBPatternMatchingExpressionsTest_7_0; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBPatternMatchingExpressionsTest_7_1 extends GDBPatternMatchingExpressionsTest_7_0 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_1); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_7_1.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_7_1.java index dead4063e58..a32d08b620a 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_7_1.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_7_1.java @@ -34,6 +34,7 @@ import org.junit.runners.Suite; MIRunControlTargetAvailableTest_7_1.class, MIRunControlNonStopTargetAvailableTest_7_1.class, MIExpressionsTest_7_1.class, + GDBPatternMatchingExpressionsTest_7_1.class, MIMemoryTest_7_1.class, MIBreakpointsTest_7_1.class, MICatchpointsTest_7_1.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java index 45ae7f21188..c1009e1ac81 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java @@ -36,6 +36,7 @@ import org.junit.runners.Suite; MIRunControlNonStopTargetAvailableTest_7_1.class, MIRunControlTest_7_1.class, MIExpressionsTest_7_1.class, + GDBPatternMatchingExpressionsTest_7_1.class, MIMemoryTest_7_1.class, MIBreakpointsTest_7_1.class, MICatchpointsTest_7_1.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBPatternMatchingExpressionsTest_7_2.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBPatternMatchingExpressionsTest_7_2.java new file mode 100644 index 00000000000..b4fafad52f3 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBPatternMatchingExpressionsTest_7_2.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1.GDBPatternMatchingExpressionsTest_7_1; +import org.eclipse.core.runtime.Platform; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBPatternMatchingExpressionsTest_7_2 extends GDBPatternMatchingExpressionsTest_7_1 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2); + } + + // GDB's list of registers is different with GDB 7.2 + @Override + protected List get_X86_REGS() { + // Because we are dealing with expressions for the registers, we must prefix them with '$' + List list = new LinkedList(Arrays.asList("$eax","$ecx","$edx","$ebx","$esp","$ebp","$esi","$edi","$eip","$eflags", + "$cs","$ss","$ds","$es","$fs","$gs","$st0","$st1","$st2","$st3", + "$st4","$st5","$st6","$st7","$fctrl","$fstat","$ftag","$fiseg","$fioff","$foseg", + "$fooff","$fop","$xmm0","$xmm1","$xmm2","$xmm3","$xmm4","$xmm5","$xmm6","$xmm7", + "$mxcsr",/*"","","","","","","","",*/"$orig_eax", + "$al","$cl","$dl","$bl","$ah","$ch","$dh","$bh","$ax","$cx", + "$dx","$bx",/*"",*/"$bp","$si","$di","$mm0","$mm1","$mm2","$mm3", + "$mm4","$mm5","$mm6","$mm7")); + // On Windows, gdb doesn't report "orig_eax" as a register. Apparently it does on Linux + if (Platform.getOS().equals(Platform.OS_WIN32)) { + list.remove("$orig_eax"); + } + return list; + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_7_2.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_7_2.java index 6ba8cc61448..adc8589e8d7 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_7_2.java @@ -34,6 +34,7 @@ import org.junit.runners.Suite; MIRunControlTargetAvailableTest_7_2.class, MIRunControlNonStopTargetAvailableTest_7_2.class, MIExpressionsTest_7_2.class, + GDBPatternMatchingExpressionsTest_7_2.class, MIMemoryTest_7_2.class, MIBreakpointsTest_7_2.class, MICatchpointsTest_7_2.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java index bc3a8c80258..c3e6be320ce 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java @@ -36,6 +36,7 @@ import org.junit.runners.Suite; MIRunControlTargetAvailableTest_7_2.class, MIRunControlNonStopTargetAvailableTest_7_2.class, MIExpressionsTest_7_2.class, + GDBPatternMatchingExpressionsTest_7_2.class, MIMemoryTest_7_2.class, MIBreakpointsTest_7_2.class, MICatchpointsTest_7_2.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/GDBPatternMatchingExpressionsTest_7_3.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/GDBPatternMatchingExpressionsTest_7_3.java new file mode 100644 index 00000000000..0b3ef26299f --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/GDBPatternMatchingExpressionsTest_7_3.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2.GDBPatternMatchingExpressionsTest_7_2; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBPatternMatchingExpressionsTest_7_3 extends GDBPatternMatchingExpressionsTest_7_2 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_3); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_7_3.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_7_3.java index 930010a9cf2..0e337aca913 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_7_3.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_7_3.java @@ -34,6 +34,7 @@ import org.junit.runners.Suite; MIRunControlTargetAvailableTest_7_3.class, MIRunControlNonStopTargetAvailableTest_7_3.class, MIExpressionsTest_7_3.class, + GDBPatternMatchingExpressionsTest_7_3.class, MIMemoryTest_7_3.class, MIBreakpointsTest_7_3.class, MICatchpointsTest_7_3.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java index 5f47adad789..2237dc03cdf 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java @@ -36,6 +36,7 @@ import org.junit.runners.Suite; MIRunControlTargetAvailableTest_7_3.class, MIRunControlNonStopTargetAvailableTest_7_3.class, MIExpressionsTest_7_3.class, + GDBPatternMatchingExpressionsTest_7_3.class, MIMemoryTest_7_3.class, MIBreakpointsTest_7_3.class, MICatchpointsTest_7_3.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/GDBPatternMatchingExpressionsTest_7_4.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/GDBPatternMatchingExpressionsTest_7_4.java new file mode 100644 index 00000000000..4852c5f2831 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/GDBPatternMatchingExpressionsTest_7_4.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3.GDBPatternMatchingExpressionsTest_7_3; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBPatternMatchingExpressionsTest_7_4 extends GDBPatternMatchingExpressionsTest_7_3 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_4); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_7_4.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_7_4.java index 213aea1f852..2107bddf8f2 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_7_4.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_7_4.java @@ -34,6 +34,7 @@ import org.junit.runners.Suite; MIRunControlTargetAvailableTest_7_4.class, MIRunControlNonStopTargetAvailableTest_7_4.class, MIExpressionsTest_7_4.class, + GDBPatternMatchingExpressionsTest_7_4.class, MIMemoryTest_7_4.class, MIBreakpointsTest_7_4.class, MICatchpointsTest_7_4.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_Remote_7_4.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_Remote_7_4.java index 9c7a5aca437..094816a56cd 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_Remote_7_4.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_4/Suite_Remote_7_4.java @@ -36,6 +36,7 @@ import org.junit.runners.Suite; MIRunControlTargetAvailableTest_7_4.class, MIRunControlNonStopTargetAvailableTest_7_4.class, MIExpressionsTest_7_4.class, + GDBPatternMatchingExpressionsTest_7_4.class, MIMemoryTest_7_4.class, MIBreakpointsTest_7_4.class, MICatchpointsTest_7_4.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/GDBPatternMatchingExpressionsTest_7_5.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/GDBPatternMatchingExpressionsTest_7_5.java new file mode 100644 index 00000000000..0c47453ffc9 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/GDBPatternMatchingExpressionsTest_7_5.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5; + +import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; +import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; +import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4.GDBPatternMatchingExpressionsTest_7_4; +import org.junit.runner.RunWith; + +@RunWith(BackgroundRunner.class) +public class GDBPatternMatchingExpressionsTest_7_5 extends GDBPatternMatchingExpressionsTest_7_4 { + @Override + protected void setGdbVersion() { + setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_5); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_7_5.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_7_5.java index b0b9997b00f..913eb137fe4 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_7_5.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_7_5.java @@ -34,6 +34,7 @@ import org.junit.runners.Suite; MIRunControlTargetAvailableTest_7_5.class, MIRunControlNonStopTargetAvailableTest_7_5.class, MIExpressionsTest_7_5.class, + GDBPatternMatchingExpressionsTest_7_5.class, MIMemoryTest_7_5.class, MIBreakpointsTest_7_5.class, MICatchpointsTest_7_5.class, diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_Remote_7_5.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_Remote_7_5.java index 29d3a85b660..013a5c821cc 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_Remote_7_5.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_5/Suite_Remote_7_5.java @@ -36,6 +36,7 @@ import org.junit.runners.Suite; MIRunControlTargetAvailableTest_7_5.class, MIRunControlNonStopTargetAvailableTest_7_5.class, MIExpressionsTest_7_5.class, + GDBPatternMatchingExpressionsTest_7_5.class, MIMemoryTest_7_5.class, MIBreakpointsTest_7_5.class, MICatchpointsTest_7_5.class, From e19147b55497bae506455f597a319821e0cc9a08 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 10 Jul 2012 16:16:03 -0400 Subject: [PATCH 11/14] Bug 384780 - No error is reported if a directory is specified as program path. --- .../src/org/eclipse/cdt/launch/ui/CMainTab.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java index 24c5a96682a..ddf8c39f60c 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java @@ -498,6 +498,11 @@ public class CMainTab extends CAbstractMainTab { // Notice that we don't check if exePath points to a valid executable since such // check is too expensive to be done on the UI thread. // See "https://bugs.eclipse.org/bugs/show_bug.cgi?id=328012". + // We only verify that the program path represents a file. + if (!exePath.toFile().isFile()) { + setErrorMessage(fPreviouslyCheckedProgramErrorMsg = LaunchMessages.CMainTab_Selection_must_be_file); + return (fPreviouslyCheckedProgramIsValid = false); + } } } From c260ca640d99e23d705820e5c37cd438beba4db2 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Tue, 10 Jul 2012 18:08:11 -0700 Subject: [PATCH 12/14] Cosmetics. --- .../dom/parser/IASTInternalNameOwner.java | 3 +- .../core/dom/parser/IASTInternalScope.java | 2 +- .../core/dom/parser/IInternalVariable.java | 3 +- .../dom/parser/ISerializableEvaluation.java | 3 +- .../core/dom/parser/ISerializableType.java | 3 +- .../core/dom/parser/ITypeContainer.java | 4 +-- .../dom/parser/ParserLogServiceWrapper.java | 4 +-- .../core/dom/parser/ProblemFunctionType.java | 1 - .../cdt/internal/core/dom/parser/Value.java | 18 ++++++------ .../parser/cpp/semantics/FunctionCost.java | 7 +++-- .../parser/cpp/semantics/FunctionSetType.java | 16 ++++++----- .../cpp/semantics/InitializerListType.java | 2 +- .../dom/parser/cpp/semantics/LookupData.java | 10 +++---- .../cpp/semantics/NamespaceTypeCollector.java | 5 ++-- .../semantics/TemplateArgumentDeduction.java | 28 +++++++++++-------- .../semantics/TypeOfDependentExpression.java | 5 ++-- .../dom/parser/cpp/semantics/UniqueType.java | 16 ++++++----- 17 files changed, 67 insertions(+), 63 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalNameOwner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalNameOwner.java index 3296032b76c..fcc2228024a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalNameOwner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalNameOwner.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; * Provides additional methods for internal use by the name resolution. */ public interface IASTInternalNameOwner extends IASTNameOwner { - /** * Get the role for the name. If the name needs to be resolved to determine that and * allowResolution is set to false, then {@link IASTNameOwner#r_unclear} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java index e347d0c22bc..a012615ae1a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalScope.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IInternalVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IInternalVariable.java index cb3271c634a..ac2fdb627ea 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IInternalVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IInternalVariable.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.IVariable; * Internal interface for bindings in the ast that have values. */ public interface IInternalVariable extends IVariable { - /** * Returns the value of the variable, or null. * If the recursion depth is reached {@link Value#UNKNOWN} will be returned. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ISerializableEvaluation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ISerializableEvaluation.java index 9f3f00f1245..2bcc0e52a97 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ISerializableEvaluation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ISerializableEvaluation.java @@ -6,13 +6,12 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; import org.eclipse.core.runtime.CoreException; - /** * Interface for marshalling types for storage in the index. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ISerializableType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ISerializableType.java index 017bbb5ac85..5e37bfe836e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ISerializableType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ISerializableType.java @@ -6,13 +6,12 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; import org.eclipse.core.runtime.CoreException; - /** * Interface for marshalling types for storage in the index. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeContainer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeContainer.java index d27d4de23e6..d90622af91e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeContainer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeContainer.java @@ -18,12 +18,12 @@ import org.eclipse.cdt.core.dom.ast.IType; */ public interface ITypeContainer extends IType { /** - * get the type this contains + * Returns the type this container contains. */ IType getType(); /** - * set the type this contains + * Sets the type this container contains. */ void setType(IType type); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ParserLogServiceWrapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ParserLogServiceWrapper.java index 3598b66d7c6..cd71e91c40d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ParserLogServiceWrapper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ParserLogServiceWrapper.java @@ -6,16 +6,14 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.core.dom.parser; import org.eclipse.cdt.core.parser.AbstractParserLogService; import org.eclipse.cdt.core.parser.IParserLogService; public class ParserLogServiceWrapper extends AbstractParserLogService { - private IParserLogService fDelegate; public ParserLogServiceWrapper(IParserLogService log) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java index 590220e76c1..5c11ff95c55 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java @@ -16,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType; import org.eclipse.core.runtime.CoreException; - /** * Implementation of problem types. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index a731fd688ed..41c7f5bb0b2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -78,7 +78,7 @@ public class Value implements IValue { private static class Reevaluation { public final char[] fExpression; private final int fPackOffset; - public int pos=0; + public int pos= 0; public final Map fUnknownSigs; public final List fUnknowns; public final IBinding[] fResolvedUnknown; @@ -94,7 +94,7 @@ public class Value implements IValue { fMap= map; } - public void nextSeperator() throws UnknownValueException { + public void nextSeparator() throws UnknownValueException { final char[] expression = fExpression; final int len = expression.length; int idx = pos; @@ -783,17 +783,17 @@ public class Value implements IValue { switch (c) { case BINARY_OP_CHAR: int op= parseNonNegative(buf, idx + 1); - reeval.nextSeperator(); + reeval.nextSeparator(); Object o1= reevaluate(reeval, maxdepth); Object o2= reevaluate(reeval, maxdepth); return combineBinary(op, o1, o2); case UNARY_OP_CHAR: op= parseNonNegative(buf, idx + 1); - reeval.nextSeperator(); + reeval.nextSeparator(); o1= reevaluate(reeval, maxdepth); return combineUnary(op, o1); case CONDITIONAL_CHAR: - reeval.nextSeperator(); + reeval.nextSeparator(); Object cond= reevaluate(reeval, maxdepth); Object po= reevaluate(reeval, maxdepth); Object neg= reevaluate(reeval, maxdepth); @@ -811,12 +811,12 @@ public class Value implements IValue { final IBinding[] resolvedUnknowns= reeval.fResolvedUnknown; if (num >= resolvedUnknowns.length) throw UNKNOWN_EX; - reeval.nextSeperator(); + reeval.nextSeparator(); return evaluateBinding(resolvedUnknowns[num], reeval.fUnknownSigs, reeval.fUnknowns, maxdepth); case TEMPLATE_PARAM_CHAR: num= parseHex(buf, idx + 1); - reeval.nextSeperator(); + reeval.nextSeparator(); ICPPTemplateArgument arg = reeval.fMap.getArgument(num); if (arg != null) { IValue val= arg.getNonTypeValue(); @@ -828,7 +828,7 @@ public class Value implements IValue { case TEMPLATE_PARAM_PACK_CHAR: num= parseHex(buf, idx + 1); - reeval.nextSeperator(); + reeval.nextSeparator(); arg= null; if (reeval.fPackOffset >= 0) { ICPPTemplateArgument[] args= reeval.fMap.getPackExpansion(num); @@ -845,7 +845,7 @@ public class Value implements IValue { return createTemplateParamExpression(num, true); default: - reeval.nextSeperator(); + reeval.nextSeparator(); return parseLong(buf, idx); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionCost.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionCost.java index 4c95cf732cd..ef6dd69e55a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionCost.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionCost.java @@ -6,13 +6,16 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.TypeSelection.PARAMETERS; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.TypeSelection.RETURN_TYPE; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionSetType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionSetType.java index 91a406cd7b7..21b92e87b7d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionSetType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/FunctionSetType.java @@ -1,10 +1,13 @@ -/* - * FunctionSetType.java - * Created on Sep 14, 2010 +/******************************************************************************* + * Copyright (c) 2010 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Copyright 2010 Wind River Systems, Inc. All rights reserved. - */ - + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; @@ -22,7 +25,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Cost.Rank; * Used during overload resolution as a place-holder for function sets. */ public class FunctionSetType implements IType { - private final CPPFunctionSet fFunctionSet; private final boolean fPointerType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/InitializerListType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/InitializerListType.java index 74850ce7280..626460e0308 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/InitializerListType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/InitializerListType.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java index 88ce838a268..fd7005e882b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java @@ -6,11 +6,11 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Bryan Wilkinson (QNX) - * Andrew Ferguson (Symbian) - * Sergey Prigogin (Google) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Bryan Wilkinson (QNX) + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/NamespaceTypeCollector.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/NamespaceTypeCollector.java index d020bca11b0..04eb1a97c47 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/NamespaceTypeCollector.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/NamespaceTypeCollector.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * Sergey Prigogin (Google) + * Markus Schorn - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; @@ -33,7 +33,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalScope; * Utility class to populate scope with friend declarations hidden in nested classes */ class NamespaceTypeCollector extends ASTVisitor { - private final ICPPASTInternalScope fScope; public NamespaceTypeCollector(ICPPASTInternalScope scope) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java index 11fa5ddacea..cdc2cdfa66a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java @@ -6,12 +6,18 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getCVQualifier; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getSimplifiedType; import java.util.ArrayList; import java.util.Arrays; @@ -69,9 +75,8 @@ public class TemplateArgumentDeduction { * @param point */ static ICPPTemplateArgument[] deduceForFunctionCall(ICPPFunctionTemplate template, - ICPPTemplateArgument[] tmplArgs, List fnArgs, List argIsLValue, CPPTemplateParameterMap map, IASTNode point) - throws DOMException { - + ICPPTemplateArgument[] tmplArgs, List fnArgs, List argIsLValue, + CPPTemplateParameterMap map, IASTNode point) throws DOMException { final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters(); if (tmplArgs != null && !addExplicitArguments(tmplParams, tmplArgs, map, point)) @@ -87,13 +92,14 @@ public class TemplateArgumentDeduction { * Deduces the mapping for the template parameters from the function parameters, * returns false if there is no mapping. */ - static boolean deduceFromFunctionArgs(ICPPFunctionTemplate template, List fnArgs, List argCats, - CPPTemplateParameterMap map, IASTNode point) { + static boolean deduceFromFunctionArgs(ICPPFunctionTemplate template, List fnArgs, + List argCats, CPPTemplateParameterMap map, IASTNode point) { try { IType[] fnPars = template.getType().getParameterTypes(); final int fnParCount = fnPars.length; final ICPPTemplateParameter[] tmplPars = template.getTemplateParameters(); - TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplPars, map, new CPPTemplateParameterMap(fnParCount), 0); + TemplateArgumentDeduction deduct= + new TemplateArgumentDeduction(tmplPars, map, new CPPTemplateParameterMap(fnParCount), 0); IType fnParPack= null; argLoop: for (int j= 0; j < fnArgs.size(); j++) { IType par; @@ -474,7 +480,6 @@ public class TemplateArgumentDeduction { return result.toArray(new ICPPTemplateArgument[result.size()]); } - /** * 14.8.2.1.3 If P is a class and has the form template-id, then A can be a derived class of the deduced A. */ @@ -543,7 +548,9 @@ public class TemplateArgumentDeduction { * Deduces the template parameter mapping from pairs of template arguments. * @param point */ - public static boolean fromTemplateArguments(final ICPPTemplateParameter[] pars, final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map, IASTNode point) throws DOMException { + public static boolean fromTemplateArguments(final ICPPTemplateParameter[] pars, + final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map, + IASTNode point) throws DOMException { TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(pars, null, map, 0); final int len= a.length; if (p == null || p.length != len) { @@ -663,7 +670,6 @@ public class TemplateArgumentDeduction { return fromType(p.getTypeValue(), a.getTypeValue(), false, point); } - private boolean fromType(IType p, IType a, boolean allowCVQConversion, IASTNode point) throws DOMException { while (p != null) { while (a instanceof ITypedef) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java index c9014ba8a0d..6fdd5259adc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import org.eclipse.cdt.core.dom.ast.IType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/UniqueType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/UniqueType.java index eca0003abaa..82b2e6cd40e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/UniqueType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/UniqueType.java @@ -1,10 +1,13 @@ -/* - * UniqueType.java - * Created on 04.10.2010 +/******************************************************************************* + * Copyright (c) 2010 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Copyright 2010 Wind River Systems, Inc. All rights reserved. - */ - + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import org.eclipse.cdt.core.dom.ast.IType; @@ -13,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.IType; * Used for computing the partial ordering of function templates. */ class UniqueType implements IType { - private boolean fForParameterPack; public UniqueType(boolean forParameterPack) { From b3d33570ed033f24cbedc6dda2879ba432460740 Mon Sep 17 00:00:00 2001 From: mhussein Date: Wed, 11 Jul 2012 14:06:26 +0300 Subject: [PATCH 13/14] Bug 384819: Initialize selection in tree option editor with current value Change-Id: I5df6f9bb2e5789e980bfefc1d303d691f139211b Reviewed-on: https://git.eclipse.org/r/6715 Reviewed-by: Doug Schaefer IP-Clean: Doug Schaefer Tested-by: Doug Schaefer --- .../ui/properties/BuildOptionSettingsUI.java | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java index 42e1a7dcab4..80f927fc86e 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java @@ -68,6 +68,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.window.Window; @@ -132,6 +133,17 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { try { treeRoot = option.getTreeRoot(); TreeSelectionDialog dlg = new TreeSelectionDialog(getShell(), treeRoot, nameStr, contextId); + String name = getStringValue(); + if (name != null) { + String treeId = option.getId(name); + if (treeId != null) { + ITreeOption node = treeRoot.findNode(treeId); + if (node != null) { + dlg.setSelection(node); + } + } + } + if (dlg.open() == Window.OK) { ITreeOption selected = dlg.getSelection(); return selected.getName(); @@ -1073,7 +1085,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { } /** - * @since 8.1 + * @since 8.2 */ public static class TreeSelectionDialog extends TitleAreaDialog { private final ITreeRoot treeRoot; @@ -1081,6 +1093,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { private final String name; private String contextId; private String baseMessage = ""; //$NON-NLS-1$ + private TreeViewer viewer; public TreeSelectionDialog(Shell parentShell, ITreeRoot root, String name, String contextId) { super(parentShell); @@ -1117,7 +1130,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { FilteredTree tree = new FilteredTree(control, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filter, true); - final TreeViewer viewer = tree.getViewer(); + viewer = tree.getViewer(); viewer.setContentProvider(new ITreeContentProvider() { @Override @@ -1275,10 +1288,42 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { return control; } + + @Override + public void create() { + super.create(); + // Need to update selection after the dialog has been created + // so that we trigger the listener and correctly update the label + // and buttons + setUISelection(); + } public ITreeOption getSelection() { return selected; } + + public void setSelection(ITreeOption option) { + if (treeRoot == getRoot(option)) { // only work in the same tree + selected = option; + setUISelection(); + } + } + + private void setUISelection() { + if (viewer != null && selected != null) viewer.setSelection(new StructuredSelection(selected), true); + } + + private static ITreeRoot getRoot(ITreeOption option) { + if (option != null) { + ITreeOption parent = option.getParent(); + while (parent != null) { + option = parent; + parent = option.getParent(); + } + return option instanceof ITreeRoot? (ITreeRoot) option : null; + } + return null; + } private Image createImage(String icon) { if (icon != null) { From c6e1d1e6ab8fd7ebb285143f1da12defe6ffea15 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Wed, 11 Jul 2012 11:02:13 -0400 Subject: [PATCH 14/14] bug 378590: [sd90] Sometimes, includes won't appear in project explorer after project creation --- .../internal/core/model/CModelManager.java | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java index 278a16667f1..21cbf20cf06 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java @@ -34,6 +34,9 @@ import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive; import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsChangeEvent; +import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsChangeListener; +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ElementChangedEvent; @@ -87,7 +90,9 @@ import org.eclipse.core.runtime.content.IContentTypeManager; import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent; import org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeChangeListener; -public class CModelManager implements IResourceChangeListener, IContentTypeChangeListener, ICProjectDescriptionListener { +public class CModelManager implements IResourceChangeListener, IContentTypeChangeListener, + ICProjectDescriptionListener, ILanguageSettingsChangeListener { + public static boolean VERBOSE = false; /** @@ -197,6 +202,9 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang // Register the Core Model on the ContentTypeManager // it needs to know about changes. Platform.getContentTypeManager().addContentTypeChangeListener(factory); + + // Register to listen on language settings changes from LSP providers + LanguageSettingsManager.registerLanguageSettingsChangeListener(factory); } } return factory; @@ -837,7 +845,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang /** * Registers the given delta with this manager. This API is to be - * used to registerd deltas that are created explicitly by the C + * used to register deltas that are created explicitly by the C * Model. Deltas created as translations of IResourceDeltas * are to be registered with #registerResourceDelta. */ @@ -969,6 +977,31 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang ContentTypeProcessor.processContentTypeChanges(events); } + @Override + public void handleEvent(ILanguageSettingsChangeEvent event) { + try { + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(event.getProjectName()); + + // Recalculate cached settings + CoreModel.getDefault().updateProjectDescriptions(new IProject[] {project}, null); + + // Notify listeners + ICProject cproject = CModelManager.getDefault().getCModel().getCProject(project); + CElementDelta delta = new CElementDelta(cproject); + // just add all possible flags, listeners tend to recalculate themselves anyway + int flag = ICElementDelta.F_CHANGED_PATHENTRY_PROJECT + | ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE + | ICElementDelta.F_CHANGED_PATHENTRY_MACRO + | ICElementDelta.F_ADDED_PATHENTRY_LIBRARY + | ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY + | ICElementDelta.F_PATHENTRY_REORDER; + delta.changed(cproject, flag); + fire(delta, ElementChangedEvent.POST_CHANGE); + } catch (CoreException e) { + CCorePlugin.log(e); + } + } + public void fire(int eventType) { fire(null, eventType); } @@ -1277,9 +1310,13 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang } public void shutdown() { + // Unregister from language settings changes + LanguageSettingsManager.unregisterLanguageSettingsChangeListener(factory); + // Remove ourself from the DescriptorManager. CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this); // CCorePlugin.getDefault().getCDescriptorManager().removeDescriptorListener(factory); + // Remove ourself from the ContentTypeManager Platform.getContentTypeManager().removeContentTypeChangeListener(factory);