mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 11:55:40 +02:00
Bug 327878: Identifying unknown instances in index.
This commit is contained in:
parent
a56f1006bd
commit
9d1a38c5e3
26 changed files with 461 additions and 368 deletions
|
@ -327,7 +327,7 @@ org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
|
|||
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
|
||||
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
|
||||
org.eclipse.jdt.core.formatter.lineSplit=110
|
||||
org.eclipse.jdt.core.formatter.lineSplit=100
|
||||
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||
|
@ -21,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
|
|||
import org.eclipse.cdt.core.dom.ast.c.ICQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
||||
|
@ -42,6 +40,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
|
||||
|
@ -65,25 +64,28 @@ public class ASTTypeUtil {
|
|||
*/
|
||||
public static String getParameterTypeString(IFunctionType type) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
String[] parms = getParameterTypeStringArray(type);
|
||||
|
||||
appendParameterTypeString(type, result);
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private static void appendParameterTypeString(IFunctionType ft, StringBuilder result) {
|
||||
IType[] types = ft.getParameterTypes();
|
||||
result.append(Keywords.cpLPAREN);
|
||||
boolean needComma= false;
|
||||
for (String parm : parms) {
|
||||
if (parm != null) {
|
||||
for (IType type : types) {
|
||||
if (type != null) {
|
||||
if (needComma)
|
||||
result.append(COMMA_SPACE);
|
||||
result.append(parm);
|
||||
appendType(type, true, result);
|
||||
needComma= true;
|
||||
}
|
||||
}
|
||||
if (type instanceof ICPPFunctionType && ((ICPPFunctionType) type).takesVarArgs()) {
|
||||
if (ft instanceof ICPPFunctionType && ((ICPPFunctionType) ft).takesVarArgs()) {
|
||||
if (needComma)
|
||||
result.append(COMMA_SPACE);
|
||||
result.append(Keywords.cpELLIPSIS);
|
||||
}
|
||||
result.append(Keywords.cpRPAREN);
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,7 +127,7 @@ public class ASTTypeUtil {
|
|||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (types[i] != null) {
|
||||
result.append(getType(types[i], normalize));
|
||||
appendType(types[i], normalize, result);
|
||||
if (i < types.length - 1)
|
||||
result.append(COMMA_SPACE);
|
||||
}
|
||||
|
@ -144,6 +146,11 @@ public class ASTTypeUtil {
|
|||
*/
|
||||
public static String getArgumentListString(ICPPTemplateArgument[] args, boolean normalize) {
|
||||
StringBuilder result= new StringBuilder();
|
||||
appendArgumentList(args, normalize, result);
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private static void appendArgumentList(ICPPTemplateArgument[] args, boolean normalize, StringBuilder result) {
|
||||
boolean first= true;
|
||||
result.append('<');
|
||||
for (ICPPTemplateArgument arg : args) {
|
||||
|
@ -151,10 +158,9 @@ public class ASTTypeUtil {
|
|||
result.append(',');
|
||||
}
|
||||
first= false;
|
||||
result.append(getArgumentString(arg, normalize));
|
||||
appendArgument(arg, normalize, result);
|
||||
}
|
||||
result.append('>');
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,11 +172,18 @@ public class ASTTypeUtil {
|
|||
* @since 5.1
|
||||
*/
|
||||
public static String getArgumentString(ICPPTemplateArgument arg, boolean normalize) {
|
||||
StringBuilder buf= new StringBuilder();
|
||||
appendArgument(arg, normalize, buf);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private static void appendArgument(ICPPTemplateArgument arg, boolean normalize, StringBuilder buf) {
|
||||
IValue val= arg.getNonTypeValue();
|
||||
if (val != null)
|
||||
return new String(val.getSignature());
|
||||
|
||||
return getType(arg.getTypeValue(), normalize);
|
||||
if (val != null) {
|
||||
buf.append(val.getSignature());
|
||||
} else {
|
||||
appendType(arg.getTypeValue(), normalize, buf);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -191,8 +204,7 @@ public class ASTTypeUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static String getTypeString(IType type, boolean normalize) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
private static void appendTypeString(IType type, boolean normalize, StringBuilder result) {
|
||||
boolean needSpace = false;
|
||||
|
||||
if (type instanceof IArrayType) {
|
||||
|
@ -328,25 +340,18 @@ public class ASTTypeUtil {
|
|||
break;
|
||||
}
|
||||
} else if (type instanceof ICPPTemplateParameter) {
|
||||
final ICPPTemplateParameter tpar = (ICPPTemplateParameter) type;
|
||||
if (normalize) {
|
||||
result.append('#');
|
||||
result.append(Integer.toString(tpar.getParameterID(), 16));
|
||||
} else {
|
||||
result.append(tpar.getName());
|
||||
appendCppName((ICPPTemplateParameter) type, normalize, true, result);
|
||||
} else if (type instanceof ICPPBinding) {
|
||||
if (type instanceof IEnumeration) {
|
||||
result.append(Keywords.ENUM);
|
||||
result.append(SPACE);
|
||||
}
|
||||
appendCppName((ICPPBinding) type, normalize, true, result);
|
||||
} else if (type instanceof ICompositeType) {
|
||||
// 101114 fix, do not display class, and for consistency don't display struct/union as well
|
||||
if (type instanceof ICPPClassType) {
|
||||
String qn = CPPVisitor.renderQualifiedName(getQualifiedNameForAnonymous((ICPPClassType) type, normalize));
|
||||
result.append(qn);
|
||||
} else {
|
||||
result.append(getNameForAnonymous((ICompositeType) type));
|
||||
}
|
||||
if (type instanceof ICPPTemplateInstance) {
|
||||
ICPPTemplateInstance inst = (ICPPTemplateInstance) type;
|
||||
result.append(getArgumentListString(inst.getTemplateArguments(), normalize));
|
||||
}
|
||||
appendNameCheckAnonymous((ICompositeType) type, result);
|
||||
} else if (type instanceof ITypedef) {
|
||||
result.append(((ITypedef) type).getNameCharArray());
|
||||
} else if (type instanceof ICPPReferenceType) {
|
||||
if (((ICPPReferenceType) type).isRValueReference()) {
|
||||
result.append(Keywords.cpAND);
|
||||
|
@ -358,19 +363,17 @@ public class ASTTypeUtil {
|
|||
} else if (type instanceof IEnumeration) {
|
||||
result.append(Keywords.ENUM);
|
||||
result.append(SPACE);
|
||||
result.append(getNameForAnonymous((IEnumeration) type));
|
||||
appendNameCheckAnonymous((IEnumeration) type, result);
|
||||
} else if (type instanceof IFunctionType) {
|
||||
String temp = getParameterTypeString((IFunctionType) type);
|
||||
if (temp != null && !temp.equals(EMPTY_STRING)) {
|
||||
result.append(temp); needSpace = false;
|
||||
}
|
||||
appendParameterTypeString((IFunctionType) type, result);
|
||||
needSpace = false;
|
||||
if (type instanceof ICPPFunctionType) {
|
||||
ICPPFunctionType ft= (ICPPFunctionType) type;
|
||||
needSpace= appendCVQ(result, needSpace, ft.isConst(), ft.isVolatile(), false);
|
||||
}
|
||||
} else if (type instanceof IPointerType) {
|
||||
if (type instanceof ICPPPointerToMemberType) {
|
||||
result.append(getTypeString(((ICPPPointerToMemberType) type).getMemberOfClass(), normalize));
|
||||
appendTypeString(((ICPPPointerToMemberType) type).getMemberOfClass(), normalize, result);
|
||||
result.append(Keywords.cpCOLONCOLON);
|
||||
}
|
||||
result.append(Keywords.cpSTAR); needSpace = true;
|
||||
|
@ -389,15 +392,20 @@ public class ASTTypeUtil {
|
|||
|
||||
IQualifierType qt= (IQualifierType) type;
|
||||
needSpace= appendCVQ(result, needSpace, qt.isConst(), qt.isVolatile(), false);
|
||||
} else if (type instanceof ITypedef) {
|
||||
result.append(((ITypedef) type).getNameCharArray());
|
||||
} else if (type instanceof ISemanticProblem) {
|
||||
result.append('?');
|
||||
} else if (type != null) {
|
||||
result.append('@').append(type.hashCode());
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private static void appendTemplateParameter(ICPPTemplateParameter type, boolean normalize, StringBuilder result) {
|
||||
if (normalize) {
|
||||
result.append('#');
|
||||
result.append(Integer.toString(type.getParameterID(), 16));
|
||||
} else {
|
||||
result.append(type.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean appendCVQ(StringBuilder target, boolean needSpace, final boolean isConst,
|
||||
|
@ -446,6 +454,15 @@ public class ASTTypeUtil {
|
|||
*/
|
||||
public static String getType(IType type, boolean normalize) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
appendType(type, normalize, result);
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the the result of {@link #getType(IType, boolean)} to the given buffer.
|
||||
* @since 5.3
|
||||
*/
|
||||
public static void appendType(IType type, boolean normalize, StringBuilder result) {
|
||||
IType[] types = new IType[DEAULT_ITYPE_SIZE];
|
||||
|
||||
// push all of the types onto the stack
|
||||
|
@ -516,23 +533,26 @@ public class ASTTypeUtil {
|
|||
List<IType> postfix= null;
|
||||
BitSet parenthesis= null;
|
||||
boolean needParenthesis= false;
|
||||
boolean needSpace= false;
|
||||
for (int j = types.length - 1; j >= 0; j--) {
|
||||
IType tj = types[j];
|
||||
if (tj != null) {
|
||||
if (j > 0 && types[j - 1] instanceof IQualifierType) {
|
||||
if (result.length() > 0)
|
||||
result.append(SPACE); // only add a space if this is not the first type being added
|
||||
result.append(getTypeString(types[j - 1], normalize));
|
||||
if (needSpace)
|
||||
result.append(SPACE);
|
||||
appendTypeString(types[j - 1], normalize, result);
|
||||
result.append(SPACE);
|
||||
result.append(getTypeString(tj, normalize));
|
||||
appendTypeString(tj, normalize, result);
|
||||
needSpace= true;
|
||||
--j;
|
||||
} else {
|
||||
// handle post-fix
|
||||
if (tj instanceof IFunctionType || tj instanceof IArrayType) {
|
||||
if (j == 0) {
|
||||
if (result.length() > 0)
|
||||
result.append(SPACE); // only add a space if this is not the first type being added
|
||||
result.append(getTypeString(tj, normalize));
|
||||
if (needSpace)
|
||||
result.append(SPACE);
|
||||
appendTypeString(tj, normalize, result);
|
||||
needSpace= true;
|
||||
} else {
|
||||
if (postfix == null) {
|
||||
postfix= new ArrayList<IType>();
|
||||
|
@ -541,8 +561,8 @@ public class ASTTypeUtil {
|
|||
needParenthesis= true;
|
||||
}
|
||||
} else {
|
||||
if (result.length() > 0)
|
||||
result.append(SPACE); // only add a space if this is not the first type being added
|
||||
if (needSpace)
|
||||
result.append(SPACE);
|
||||
if (needParenthesis && postfix != null) {
|
||||
result.append('(');
|
||||
if (parenthesis == null) {
|
||||
|
@ -550,8 +570,9 @@ public class ASTTypeUtil {
|
|||
}
|
||||
parenthesis.set(postfix.size()-1);
|
||||
}
|
||||
result.append(getTypeString(tj, normalize));
|
||||
appendTypeString(tj, normalize, result);
|
||||
needParenthesis= false;
|
||||
needSpace= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -563,11 +584,9 @@ public class ASTTypeUtil {
|
|||
result.append(')');
|
||||
}
|
||||
IType tj = postfix.get(j);
|
||||
result.append(getTypeString(tj, normalize));
|
||||
appendTypeString(tj, normalize, result);
|
||||
}
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -675,55 +694,66 @@ public class ASTTypeUtil {
|
|||
}
|
||||
}
|
||||
|
||||
private static String[] getQualifiedNameForAnonymous(ICPPBinding binding, boolean normalize) {
|
||||
LinkedList<String> result= new LinkedList<String>();
|
||||
result.addFirst(getNameForAnonymous(binding));
|
||||
|
||||
IBinding owner= binding;
|
||||
for (;;) {
|
||||
if (owner instanceof ICPPTemplateParameter)
|
||||
break;
|
||||
if (owner instanceof ICPPDeferredClassInstance) {
|
||||
ICPPDeferredClassInstance deferredInst = (ICPPDeferredClassInstance) owner;
|
||||
if (deferredInst.getTemplateDefinition() instanceof ICPPTemplateParameter)
|
||||
break;
|
||||
}
|
||||
|
||||
owner = owner.getOwner();
|
||||
if (!(owner instanceof ICPPNamespace || owner instanceof IType))
|
||||
break;
|
||||
|
||||
char[] name = owner.getNameCharArray();
|
||||
if (name == null || name.length == 0) {
|
||||
if (!(owner instanceof ICPPNamespace)) {
|
||||
char[] altname = createNameForAnonymous(owner);
|
||||
if (altname != null) {
|
||||
result.addFirst(new String(altname));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (normalize && owner instanceof IType) {
|
||||
result.addFirst(getType((IType) owner, normalize));
|
||||
} else {
|
||||
result.addFirst(new String(name));
|
||||
private static void appendCppName(IBinding binding, boolean normalize, boolean addTemplateArgs, StringBuilder result) {
|
||||
ICPPTemplateParameter tpar= getTemplateParameter(binding);
|
||||
if (tpar != null) {
|
||||
appendTemplateParameter(tpar, normalize, result);
|
||||
} else {
|
||||
if (normalize) {
|
||||
IBinding owner= binding.getOwner();
|
||||
if (owner instanceof ICPPNamespace || owner instanceof IType) {
|
||||
int pos= result.length();
|
||||
appendCppName(owner, normalize, normalize, result);
|
||||
if (result.length() > pos)
|
||||
result.append("::"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
appendNameCheckAnonymous(binding, result);
|
||||
}
|
||||
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
appendArgumentList(((ICPPTemplateInstance) binding).getTemplateArguments(), normalize, result);
|
||||
} else if (binding instanceof ICPPUnknownClassInstance) {
|
||||
appendArgumentList(((ICPPUnknownClassInstance) binding).getArguments(), normalize, result);
|
||||
}
|
||||
return result.toArray(new String[result.size()]);
|
||||
}
|
||||
|
||||
private static String getNameForAnonymous(IBinding binding) {
|
||||
private static ICPPTemplateParameter getTemplateParameter(IBinding binding) {
|
||||
if (binding instanceof ICPPTemplateParameter)
|
||||
return (ICPPTemplateParameter) binding;
|
||||
|
||||
if (binding instanceof ICPPDeferredClassInstance)
|
||||
return getTemplateParameter(((ICPPDeferredClassInstance) binding).getTemplateDefinition());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void appendNameCheckAnonymous(IBinding binding, StringBuilder result) {
|
||||
char[] name= binding.getNameCharArray();
|
||||
if (name == null || name.length == 0) {
|
||||
char[] altname= createNameForAnonymous(binding);
|
||||
if (altname != null) {
|
||||
return new String(altname);
|
||||
}
|
||||
if (name != null && name.length > 0) {
|
||||
result.append(name);
|
||||
} else if (!(binding instanceof ICPPNamespace)) {
|
||||
appendNameForAnonymous(binding, result);
|
||||
}
|
||||
return new String(name);
|
||||
}
|
||||
|
||||
public static char[] createNameForAnonymous(IBinding binding) {
|
||||
StringBuilder result= new StringBuilder();
|
||||
appendNameForAnonymous(binding, result);
|
||||
if (result.length() == 0)
|
||||
return null;
|
||||
|
||||
return extractChars(result);
|
||||
}
|
||||
|
||||
private static char[] extractChars(StringBuilder buf) {
|
||||
final int length = buf.length();
|
||||
char[] result= new char[length];
|
||||
buf.getChars(0, length, result, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void appendNameForAnonymous(IBinding binding, StringBuilder buf) {
|
||||
IASTNode node= null;
|
||||
if (binding instanceof ICInternalBinding) {
|
||||
node= ((ICInternalBinding) binding).getPhysicalNode();
|
||||
|
@ -741,16 +771,13 @@ public class ASTTypeUtil {
|
|||
if (loc != null) {
|
||||
char[] fname= loc.getFileName().toCharArray();
|
||||
int fnamestart= findFileNameStart(fname);
|
||||
StringBuilder buf= new StringBuilder();
|
||||
buf.append('{');
|
||||
buf.append(fname, fnamestart, fname.length-fnamestart);
|
||||
buf.append(':');
|
||||
buf.append(loc.getNodeOffset());
|
||||
buf.append('}');
|
||||
return buf.toString().toCharArray();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int findFileNameStart(char[] fname) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
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.core.runtime.CoreException;
|
||||
|
@ -27,6 +28,7 @@ public interface ITypeMarshalBuffer {
|
|||
final static byte POINTER_TO_MEMBER= 7;
|
||||
final static byte PACK_EXPANSION= 8;
|
||||
final static byte PROBLEM_TYPE= 9;
|
||||
final static byte VALUE= 10;
|
||||
static final byte KIND_MASK = 0xf;
|
||||
|
||||
final static int FLAG1 = 0x10;
|
||||
|
@ -37,12 +39,18 @@ public interface ITypeMarshalBuffer {
|
|||
CoreException unmarshallingError();
|
||||
|
||||
IType unmarshalType() throws CoreException;
|
||||
IValue unmarshalValue() throws CoreException;
|
||||
IBinding unmarshalBinding() throws CoreException;
|
||||
int getByte() throws CoreException;
|
||||
int getShort() throws CoreException;
|
||||
IValue getValue() throws CoreException;
|
||||
long getLong() throws CoreException;
|
||||
char[] getCharArray() throws CoreException;
|
||||
|
||||
void marshalType(IType type) throws CoreException;
|
||||
void marshalValue(IValue value) throws CoreException;
|
||||
void marshalBinding(IBinding binding) throws CoreException;
|
||||
void putByte(byte data);
|
||||
void putShort(short data);
|
||||
void putValue(IValue val) throws CoreException;
|
||||
void putLong(long data);
|
||||
void putCharArray(char[] data);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
|
||||
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
|
||||
|
@ -145,6 +147,59 @@ public class Value implements IValue {
|
|||
return parseLong(fExpression);
|
||||
}
|
||||
|
||||
public void marshall(TypeMarshalBuffer buf) throws CoreException {
|
||||
if (UNKNOWN == this) {
|
||||
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG1));
|
||||
} else {
|
||||
Long num= numericalValue();
|
||||
if (num != null) {
|
||||
long lv= num;
|
||||
if (lv >= Integer.MIN_VALUE && lv <= Integer.MAX_VALUE) {
|
||||
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG2));
|
||||
buf.putInt((int) lv);
|
||||
} else {
|
||||
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG3));
|
||||
buf.putLong(lv);
|
||||
}
|
||||
} else {
|
||||
buf.putByte((ITypeMarshalBuffer.VALUE));
|
||||
buf.putCharArray(fExpression);
|
||||
buf.putShort((short) fUnknownBindings.length);
|
||||
for (ICPPUnknownBinding b : fUnknownBindings) {
|
||||
buf.marshalBinding(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IValue unmarshal(TypeMarshalBuffer buf) throws CoreException {
|
||||
int firstByte= buf.getByte();
|
||||
if (firstByte == TypeMarshalBuffer.NULL_TYPE)
|
||||
return null;
|
||||
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0)
|
||||
return Value.UNKNOWN;
|
||||
if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
|
||||
int val= buf.getInt();
|
||||
return Value.create(val);
|
||||
}
|
||||
if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0) {
|
||||
long val= buf.getLong();
|
||||
return Value.create(val);
|
||||
}
|
||||
|
||||
char[] expr = buf.getCharArray();
|
||||
final int len= buf.getShort();
|
||||
ICPPUnknownBinding[] unknowns= new ICPPUnknownBinding[len];
|
||||
for (int i = 0; i < unknowns.length; i++) {
|
||||
final ICPPUnknownBinding unknown = (ICPPUnknownBinding) buf.unmarshalBinding();
|
||||
if (unknown == null) {
|
||||
return Value.UNKNOWN;
|
||||
}
|
||||
unknowns[i]= unknown;
|
||||
}
|
||||
return new Value(expr, unknowns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return CharArrayUtils.hash(fExpression);
|
||||
|
@ -863,7 +918,9 @@ public class Value implements IValue {
|
|||
private static String getSignatureForUnknown(ICPPUnknownBinding binding) {
|
||||
IBinding owner= binding.getOwner();
|
||||
if (owner instanceof IType) {
|
||||
return ASTTypeUtil.getType((IType) owner, true) + SCOPE_OP + binding.getName();
|
||||
StringBuilder buf= new StringBuilder();
|
||||
ASTTypeUtil.appendType((IType) owner, true, buf);
|
||||
return buf.append(SCOPE_OP).append(binding.getName()).toString();
|
||||
}
|
||||
return binding.getName();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 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
|
||||
|
@ -184,7 +184,7 @@ public class CArrayType implements ICArrayType, ITypeContainer, ISerializableTyp
|
|||
if (nval >= 0) {
|
||||
buffer.putShort(nval);
|
||||
} else if (val != null) {
|
||||
buffer.putValue(val);
|
||||
buffer.marshalValue(val);
|
||||
}
|
||||
buffer.marshalType(getType());
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public class CArrayType implements ICArrayType, ITypeContainer, ISerializableTyp
|
|||
if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0) {
|
||||
value = Value.create(buffer.getShort());
|
||||
} else if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
|
||||
value = buffer.getValue();
|
||||
value = buffer.unmarshalValue();
|
||||
}
|
||||
IType nested= buffer.unmarshalType();
|
||||
CArrayType result= new CArrayType(nested, (flags & 0x01) != 0, (flags & 0x02) != 0, (flags & 0x04) != 0, value);
|
||||
|
|
|
@ -106,7 +106,7 @@ public class CPPASTConversionName extends CPPASTNameBase implements ICPPASTConve
|
|||
buf.append(Keywords.cOPERATOR);
|
||||
buf.append(' ');
|
||||
if (t != null) {
|
||||
buf.append(ASTTypeUtil.getType(t, true));
|
||||
ASTTypeUtil.appendType(t, true, buf);
|
||||
} else {
|
||||
buf.append(typeId.getRawSignature());
|
||||
WHITESPACE_SEQ.matcher(buf).replaceAll(" "); //$NON-NLS-1$
|
||||
|
|
|
@ -133,7 +133,7 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
|
|||
if (type instanceof ISemanticProblem) {
|
||||
buf.append(arg.getRawSignature());
|
||||
} else {
|
||||
buf.append(ASTTypeUtil.getType(type, false));
|
||||
ASTTypeUtil.appendType(type, false, buf);
|
||||
}
|
||||
}
|
||||
if (cleanupWhitespace)
|
||||
|
|
|
@ -124,7 +124,7 @@ public class CPPArrayType implements IArrayType, ITypeContainer, ISerializableTy
|
|||
}
|
||||
}
|
||||
buffer.putByte((byte) (firstByte | ITypeMarshalBuffer.FLAG2));
|
||||
buffer.putValue(val);
|
||||
buffer.marshalValue(val);
|
||||
buffer.marshalType(getType());
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class CPPArrayType implements IArrayType, ITypeContainer, ISerializableTy
|
|||
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) {
|
||||
value = Value.create(buffer.getShort());
|
||||
} else if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
|
||||
value = buffer.getValue();
|
||||
value = buffer.unmarshalValue();
|
||||
}
|
||||
IType nested= buffer.unmarshalType();
|
||||
return new CPPArrayType(nested, value);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
@ -109,4 +110,9 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPUnknownCla
|
|||
public boolean isAnonymous() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ASTTypeUtil.getType(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3610,8 +3610,10 @@ public class CPPSemantics {
|
|||
} catch (DOMException e) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
// 4: post processing
|
||||
binding = postResolution(binding, data);
|
||||
// 4: Normal post processing is not possible, because the name is not rooted in AST
|
||||
if (binding == null)
|
||||
binding = new ProblemBinding(unknownName, IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
||||
|
||||
return binding;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2009 QNX Software Systems and others.
|
||||
* Copyright (c) 2007, 2010 QNX Software Systems 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
|
||||
|
@ -98,7 +98,7 @@ public class IndexCPPSignatureUtil {
|
|||
if (i > 0) {
|
||||
result.append(',');
|
||||
}
|
||||
result.append(ASTTypeUtil.getType(types[i]));
|
||||
ASTTypeUtil.appendType(types[i], true, result);
|
||||
}
|
||||
if (functionType instanceof ICPPFunctionType && ((ICPPFunctionType) functionType).takesVarArgs()) {
|
||||
if (types.length != 0) {
|
||||
|
|
|
@ -201,10 +201,11 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
* 111.0 - correct marshalling of basic types, bug 319186.
|
||||
* 111.1 - defaulted and deleted functions, bug 305978
|
||||
* 112.0 - inline namespaces, bug 305980
|
||||
* 113.0 - Changed marshaling of values, bug 327878
|
||||
*/
|
||||
private static final int MIN_SUPPORTED_VERSION= version(112, 0);
|
||||
private static final int MAX_SUPPORTED_VERSION= version(112, Short.MAX_VALUE);
|
||||
private static final int DEFAULT_VERSION = version(112, 0);
|
||||
private static final int MIN_SUPPORTED_VERSION= version(113, 0);
|
||||
private static final int MAX_SUPPORTED_VERSION= version(113, Short.MAX_VALUE);
|
||||
private static final int DEFAULT_VERSION = version(113, 0);
|
||||
|
||||
private static int version(int major, int minor) {
|
||||
return (major << 16) + minor;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2009 QNX Software Systems and others.
|
||||
* Copyright (c) 2005, 2010 QNX Software Systems 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
|
||||
|
@ -75,6 +75,7 @@ public class Database {
|
|||
public static final int MAX_MALLOC_SIZE = MAX_BLOCK_DELTAS*BLOCK_SIZE_DELTA - BLOCK_HEADER_SIZE;
|
||||
public static final int PTR_SIZE = 4; // size of a pointer in the database in bytes
|
||||
public static final int TYPE_SIZE = 2+PTR_SIZE; // size of a type in the database in bytes
|
||||
public static final int VALUE_SIZE = TYPE_SIZE; // size of a value in the database in bytes
|
||||
public static final long MAX_DB_SIZE= ((long) 1 << (Integer.SIZE + BLOCK_SIZE_DELTA_BITS));
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IValue;
|
|||
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.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -31,7 +30,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
public final static byte NULL_TYPE= 0;
|
||||
public final static byte INDIRECT_TYPE= (byte) -1;
|
||||
public final static byte BINDING_TYPE= (byte) -2;
|
||||
|
||||
|
||||
static {
|
||||
assert EMPTY.length == Database.TYPE_SIZE;
|
||||
}
|
||||
|
@ -63,9 +62,11 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
return fBuffer;
|
||||
}
|
||||
|
||||
public void marshalType(IType type) throws CoreException {
|
||||
if (type instanceof IBinding) {
|
||||
PDOMBinding pb= fLinkage.addTypeBinding((IBinding) type);
|
||||
public void marshalBinding(IBinding binding) throws CoreException {
|
||||
if (binding instanceof ISerializableType) {
|
||||
((ISerializableType) binding).marshal(this);
|
||||
} else {
|
||||
PDOMBinding pb= fLinkage.addTypeBinding(binding);
|
||||
if (pb == null) {
|
||||
putByte(NULL_TYPE);
|
||||
} else {
|
||||
|
@ -73,6 +74,33 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
putByte((byte) 0);
|
||||
putRecordPointer(pb.getRecord());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IBinding unmarshalBinding() throws CoreException {
|
||||
if (fPos >= fBuffer.length)
|
||||
throw unmarshallingError();
|
||||
|
||||
byte firstByte= fBuffer[fPos];
|
||||
if (firstByte == BINDING_TYPE) {
|
||||
fPos+= 2;
|
||||
long rec= getRecordPointer();
|
||||
return (IBinding) fLinkage.getNode(rec);
|
||||
} else if (firstByte == 0) {
|
||||
fPos++;
|
||||
return null;
|
||||
}
|
||||
|
||||
IType type= fLinkage.unmarshalType(this);
|
||||
if (type == null || type instanceof IBinding)
|
||||
return (IBinding) type;
|
||||
|
||||
throw unmarshallingError();
|
||||
}
|
||||
|
||||
public void marshalType(IType type) throws CoreException {
|
||||
if (type instanceof IBinding) {
|
||||
marshalBinding((IBinding) type);
|
||||
} else if (type instanceof ISerializableType) {
|
||||
((ISerializableType) type).marshal(this);
|
||||
} else {
|
||||
|
@ -81,6 +109,38 @@ 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;
|
||||
long rec= getRecordPointer();
|
||||
return (IType) fLinkage.getNode(rec);
|
||||
} else if (firstByte == 0) {
|
||||
fPos++;
|
||||
return null;
|
||||
}
|
||||
|
||||
return fLinkage.unmarshalType(this);
|
||||
}
|
||||
|
||||
public void marshalValue(IValue value) throws CoreException {
|
||||
if (value instanceof Value) {
|
||||
((Value) value).marshall(this);
|
||||
} else {
|
||||
putByte(NULL_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
public IValue unmarshalValue() throws CoreException {
|
||||
if (fPos >= fBuffer.length)
|
||||
throw unmarshallingError();
|
||||
|
||||
return Value.unmarshal(this);
|
||||
}
|
||||
|
||||
private void request(int i) {
|
||||
if (fBuffer == null) {
|
||||
if (i <= Database.TYPE_SIZE) {
|
||||
|
@ -131,6 +191,56 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
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);
|
||||
}
|
||||
|
||||
public int getInt() throws CoreException {
|
||||
if (fPos+4 > fBuffer.length)
|
||||
throw unmarshallingError();
|
||||
int result= 0;
|
||||
result |= fBuffer[fPos++] & 0xff; result <<= 8;
|
||||
result |= fBuffer[fPos++] & 0xff; result <<= 8;
|
||||
result |= fBuffer[fPos++] & 0xff; result <<= 8;
|
||||
result |= fBuffer[fPos++] & 0xff;
|
||||
return result;
|
||||
}
|
||||
|
||||
public void putLong(long value) {
|
||||
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);
|
||||
}
|
||||
|
||||
public long getLong() throws CoreException {
|
||||
if (fPos+8 > fBuffer.length)
|
||||
throw unmarshallingError();
|
||||
long result= 0;
|
||||
result |= fBuffer[fPos++] & 0xff; result <<= 8;
|
||||
result |= fBuffer[fPos++] & 0xff; result <<= 8;
|
||||
result |= fBuffer[fPos++] & 0xff; result <<= 8;
|
||||
result |= fBuffer[fPos++] & 0xff; result <<= 8;
|
||||
result |= fBuffer[fPos++] & 0xff; result <<= 8;
|
||||
result |= fBuffer[fPos++] & 0xff; result <<= 8;
|
||||
result |= fBuffer[fPos++] & 0xff; result <<= 8;
|
||||
result |= fBuffer[fPos++] & 0xff;
|
||||
return result;
|
||||
}
|
||||
|
||||
private void putRecordPointer(long record) {
|
||||
request(Database.PTR_SIZE);
|
||||
|
@ -148,56 +258,19 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
return Chunk.getRecPtr(fBuffer, pos);
|
||||
}
|
||||
|
||||
public IValue getValue() throws CoreException {
|
||||
int replen= getShort();
|
||||
int unknwonLen= getShort();
|
||||
|
||||
char[] rep= new char[replen];
|
||||
for (int i = 0; i < replen; i++) {
|
||||
rep[i]= (char) getShort();
|
||||
}
|
||||
ICPPUnknownBinding[] unknown= new ICPPUnknownBinding[unknwonLen];
|
||||
for (int i = 0; i < unknwonLen; i++) {
|
||||
long ptr= getRecordPointer();
|
||||
IBinding b= fLinkage.getBinding(ptr);
|
||||
if (b instanceof ICPPUnknownBinding) {
|
||||
unknown[i]= (ICPPUnknownBinding) b;
|
||||
}
|
||||
}
|
||||
return Value.fromInternalRepresentation(rep, unknown);
|
||||
}
|
||||
|
||||
public void putValue(IValue value) throws CoreException {
|
||||
char[] rep= value.getInternalExpression();
|
||||
IBinding[] unknown= value.getUnknownBindings();
|
||||
putShort((short) rep.length);
|
||||
putShort((short) unknown.length);
|
||||
|
||||
int len= rep.length & 0xffff;
|
||||
for (int i = 0; i < len; i++) {
|
||||
putShort((short) rep[i]);
|
||||
}
|
||||
len= unknown.length & 0xffff;
|
||||
for (int i = 0; i < len; i++) {
|
||||
PDOMBinding uv = fLinkage.addUnknownValue(unknown[i]);
|
||||
putRecordPointer(uv != null ? uv.getRecord() : 0);
|
||||
public void putCharArray(char[] chars) {
|
||||
putShort((short) chars.length);
|
||||
for (char c : chars) {
|
||||
putShort((short) c);
|
||||
}
|
||||
}
|
||||
|
||||
public IType unmarshalType() throws CoreException {
|
||||
if (fPos >= fBuffer.length)
|
||||
throw unmarshallingError();
|
||||
|
||||
byte firstByte= fBuffer[fPos];
|
||||
if (firstByte == BINDING_TYPE) {
|
||||
fPos+= 2;
|
||||
long rec= getRecordPointer();
|
||||
return (IType) fLinkage.getNode(rec);
|
||||
} else if (firstByte == 0) {
|
||||
fPos++;
|
||||
return null;
|
||||
public char[] getCharArray() throws CoreException {
|
||||
int len= getShort();
|
||||
char[] expr= new char[len];
|
||||
for (int i = 0; i < expr.length; i++) {
|
||||
expr[i]= (char) getShort();
|
||||
}
|
||||
|
||||
return fLinkage.unmarshalType(this);
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
|
||||
import org.eclipse.cdt.core.index.IIndexLinkage;
|
||||
|
@ -476,19 +477,65 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
|||
db.getBytes(ptr+2, data);
|
||||
break;
|
||||
case TypeMarshalBuffer.NULL_TYPE:
|
||||
break;
|
||||
return null;
|
||||
default:
|
||||
data= new byte[Database.TYPE_SIZE];
|
||||
db.getBytes(offset, data);
|
||||
break;
|
||||
}
|
||||
|
||||
if (data != null) {
|
||||
return new TypeMarshalBuffer(this, data).unmarshalType();
|
||||
}
|
||||
return null;
|
||||
return new TypeMarshalBuffer(this, data).unmarshalType();
|
||||
}
|
||||
|
||||
public void storeValue(long offset, IValue type) throws CoreException {
|
||||
final Database db= getDB();
|
||||
deleteValue(db, offset);
|
||||
storeValue(db, offset, type);
|
||||
}
|
||||
|
||||
private void storeValue(Database db, long offset, IValue value) throws CoreException {
|
||||
if (value != null) {
|
||||
TypeMarshalBuffer bc= new TypeMarshalBuffer(this);
|
||||
bc.marshalValue(value);
|
||||
int len= bc.getPosition();
|
||||
if (len > 0) {
|
||||
if (len <= Database.TYPE_SIZE) {
|
||||
db.putBytes(offset, bc.getBuffer(), len);
|
||||
} else if (len <= Database.MAX_MALLOC_SIZE-2){
|
||||
long ptr= db.malloc(len+2);
|
||||
db.putShort(ptr, (short) len);
|
||||
db.putBytes(ptr+2, bc.getBuffer(), len);
|
||||
db.putByte(offset, TypeMarshalBuffer.INDIRECT_TYPE);
|
||||
db.putRecPtr(offset+2, ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteValue(Database db, long offset) throws CoreException {
|
||||
deleteType(db, offset);
|
||||
}
|
||||
|
||||
public IValue loadValue(long offset) throws CoreException {
|
||||
final Database db= getDB();
|
||||
final byte firstByte= db.getByte(offset);
|
||||
byte[] data= null;
|
||||
switch(firstByte) {
|
||||
case TypeMarshalBuffer.INDIRECT_TYPE:
|
||||
long ptr= db.getRecPtr(offset+2);
|
||||
int len= db.getShort(ptr) & 0xffff;
|
||||
data= new byte[len];
|
||||
db.getBytes(ptr+2, data);
|
||||
break;
|
||||
case TypeMarshalBuffer.NULL_TYPE:
|
||||
return null;
|
||||
default:
|
||||
data= new byte[Database.TYPE_SIZE];
|
||||
db.getBytes(offset, data);
|
||||
break;
|
||||
}
|
||||
return new TypeMarshalBuffer(this, data).unmarshalValue();
|
||||
}
|
||||
|
||||
public IIndexScope[] getInlineNamespaces() {
|
||||
return IIndexScope.EMPTY_INDEX_SCOPE_ARRAY;
|
||||
}
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 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
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Helper class for storing values in the index.
|
||||
*/
|
||||
public class PDOMValue {
|
||||
|
||||
/**
|
||||
* Stores a value and returns the offset of where it was stored.
|
||||
* @throws CoreException
|
||||
*/
|
||||
public static long store(Database db, PDOMLinkage linkage, IValue val) throws CoreException {
|
||||
if (val == null)
|
||||
return 0;
|
||||
|
||||
final IBinding[] unknown= val.getUnknownBindings();
|
||||
long[] unknownRecs= {};
|
||||
if (unknown.length != 0) {
|
||||
unknownRecs= new long[unknown.length];
|
||||
for (int i = 0; i < unknown.length; i++) {
|
||||
PDOMNode node= linkage.addUnknownValue(unknown[i]);
|
||||
if (node == null) {
|
||||
return store(db, linkage, Value.UNKNOWN);
|
||||
}
|
||||
unknownRecs[i]= node.getRecord();
|
||||
}
|
||||
}
|
||||
|
||||
final short len= (short) Math.min(unknown.length, (Database.MAX_MALLOC_SIZE-6)/4);
|
||||
final long block= db.malloc(6+4*len);
|
||||
final long repRec= db.newString(val.getInternalExpression()).getRecord();
|
||||
|
||||
db.putShort(block, len);
|
||||
db.putRecPtr(block+2, repRec);
|
||||
|
||||
long p= block+6;
|
||||
for (int i = 0; i < len; i++) {
|
||||
db.putRecPtr(p, unknownRecs[i]);
|
||||
p+= 4;
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores a value from the given record
|
||||
* @throws CoreException
|
||||
*/
|
||||
public static IValue restore(Database db, PDOMLinkage linkage, long valRec) throws CoreException {
|
||||
if (valRec == 0)
|
||||
return null;
|
||||
|
||||
final int len= db.getShort(valRec);
|
||||
final long repRec = db.getRecPtr(valRec+2);
|
||||
final char[] rep= db.getString(repRec).getChars();
|
||||
|
||||
if (len == 0)
|
||||
return Value.fromInternalRepresentation(rep, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY);
|
||||
|
||||
ICPPUnknownBinding[] unknown= new ICPPUnknownBinding[len];
|
||||
long p= valRec+6;
|
||||
for (int i = 0; i < unknown.length; i++) {
|
||||
long rec= db.getRecPtr(p);
|
||||
PDOMNode node= linkage.getNode(rec);
|
||||
if (node instanceof ICPPUnknownBinding) {
|
||||
unknown[i]= (ICPPUnknownBinding) node;
|
||||
} else {
|
||||
return Value.UNKNOWN;
|
||||
}
|
||||
p+= 4;
|
||||
}
|
||||
return Value.fromInternalRepresentation(rep, unknown);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a value stored at the given record.
|
||||
*/
|
||||
public static void delete(Database db, long valueRec) throws CoreException {
|
||||
if (valueRec == 0)
|
||||
return;
|
||||
final long repRec = db.getRecPtr(valueRec+2);
|
||||
db.getString(repRec).delete();
|
||||
db.free(valueRec);
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMValue;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +48,7 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
|
|||
* Offset of annotation information (relative to the beginning of the
|
||||
* record).
|
||||
*/
|
||||
private static final int ANNOTATIONS = VALUE_OFFSET + Database.PTR_SIZE;
|
||||
private static final int ANNOTATIONS = VALUE_OFFSET + Database.VALUE_SIZE;
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCVariable record in the database.
|
||||
|
@ -61,37 +60,22 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
|
|||
super(linkage, parent, variable.getNameCharArray());
|
||||
|
||||
final Database db = getDB();
|
||||
setType(parent.getLinkage(), variable.getType());
|
||||
linkage.storeType(record + TYPE_OFFSET, variable.getType());
|
||||
linkage.storeValue(record + VALUE_OFFSET, variable.getInitialValue());
|
||||
db.putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(variable));
|
||||
|
||||
setValue(db, variable);
|
||||
}
|
||||
|
||||
private void setValue(final Database db, IVariable variable) throws CoreException {
|
||||
IValue val= variable.getInitialValue();
|
||||
long valrec= PDOMValue.store(db, getLinkage(), val);
|
||||
db.putRecPtr(record + VALUE_OFFSET, valrec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
||||
if (newBinding instanceof IVariable) {
|
||||
final Database db = getDB();
|
||||
IVariable var= (IVariable) newBinding;
|
||||
long valueRec= db.getRecPtr(record + VALUE_OFFSET);
|
||||
IType newType= var.getType();
|
||||
setType(linkage, newType);
|
||||
linkage.storeType(record + TYPE_OFFSET, var.getType());
|
||||
linkage.storeValue(record + VALUE_OFFSET, var.getInitialValue());
|
||||
db.putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(var));
|
||||
setValue(db, var);
|
||||
|
||||
PDOMValue.delete(db, valueRec);
|
||||
}
|
||||
}
|
||||
|
||||
private void setType(final PDOMLinkage linkage, final IType type) throws CoreException {
|
||||
linkage.storeType(record + TYPE_OFFSET, type);
|
||||
}
|
||||
|
||||
public PDOMCVariable(PDOMLinkage linkage, long record) {
|
||||
super(linkage, record);
|
||||
}
|
||||
|
@ -117,9 +101,7 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
|
|||
|
||||
public IValue getInitialValue() {
|
||||
try {
|
||||
final Database db = getDB();
|
||||
long valRec = db.getRecPtr(record + VALUE_OFFSET);
|
||||
return PDOMValue.restore(db, getLinkage(), valRec);
|
||||
return getLinkage().loadValue(record + VALUE_OFFSET);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2008, 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
|
||||
|
@ -19,7 +19,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
|||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMValue;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -28,7 +27,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public class PDOMCPPArgumentList {
|
||||
private static final int VALUE_OFFSET= Database.TYPE_SIZE;
|
||||
private static final int NODE_SIZE = VALUE_OFFSET + Database.PTR_SIZE;
|
||||
private static final int NODE_SIZE = VALUE_OFFSET + Database.VALUE_SIZE;
|
||||
|
||||
/**
|
||||
* Stores the given template arguments in the database.
|
||||
|
@ -47,8 +46,7 @@ public class PDOMCPPArgumentList {
|
|||
final boolean isNonType= arg.isNonTypeValue();
|
||||
if (isNonType) {
|
||||
linkage.storeType(p, arg.getTypeOfNonTypeValue());
|
||||
long valueRec= PDOMValue.store(db, linkage, arg.getNonTypeValue());
|
||||
db.putRecPtr(p+VALUE_OFFSET, valueRec);
|
||||
linkage.storeValue(p+VALUE_OFFSET, arg.getNonTypeValue());
|
||||
} else {
|
||||
linkage.storeType(p, arg.getTypeValue());
|
||||
}
|
||||
|
@ -69,8 +67,7 @@ public class PDOMCPPArgumentList {
|
|||
long p= record+2;
|
||||
for (int i=0; i<len; i++) {
|
||||
linkage.storeType(p, null);
|
||||
final long nonTypeValueRec= db.getRecPtr(p+VALUE_OFFSET);
|
||||
PDOMValue.delete(db, nonTypeValueRec);
|
||||
linkage.storeValue(p+VALUE_OFFSET, null);
|
||||
p+= NODE_SIZE;
|
||||
}
|
||||
db.free(record);
|
||||
|
@ -96,9 +93,8 @@ public class PDOMCPPArgumentList {
|
|||
if (type == null) {
|
||||
type= new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||
}
|
||||
final long nonTypeValRec= db.getRecPtr(rec+VALUE_OFFSET);
|
||||
if (nonTypeValRec != 0) {
|
||||
final IValue val= PDOMValue.restore(db, linkage, nonTypeValRec);
|
||||
IValue val= linkage.loadValue(rec+VALUE_OFFSET);
|
||||
if (val != null) {
|
||||
result[i]= new CPPTemplateArgument(val, type);
|
||||
} else {
|
||||
result[i]= new CPPTemplateArgument(type);
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
|
@ -63,7 +64,8 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
|
|||
throws CoreException {
|
||||
super(linkage, parent, classType, instantiated);
|
||||
|
||||
final long argListRec= PDOMCPPArgumentList.putArguments(this, classType.getTemplateArguments());
|
||||
final ICPPTemplateArgument[] args= SemanticUtil.getSimplifiedArguments(classType.getTemplateArguments());
|
||||
final long argListRec= PDOMCPPArgumentList.putArguments(this, args);
|
||||
getDB().putRecPtr(record+ARGUMENTS, argListRec);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMValue;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -36,17 +35,15 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements ICPPFi
|
|||
private static final int TYPE_OFFSET = PDOMCPPSpecialization.RECORD_SIZE + 0;
|
||||
private static final int VALUE_OFFSET = TYPE_OFFSET + Database.TYPE_SIZE;
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = VALUE_OFFSET + Database.PTR_SIZE;
|
||||
protected static final int RECORD_SIZE = VALUE_OFFSET + Database.VALUE_SIZE;
|
||||
|
||||
public PDOMCPPFieldSpecialization(PDOMLinkage linkage, PDOMNode parent,
|
||||
ICPPField field, PDOMBinding specialized)
|
||||
throws CoreException {
|
||||
super(linkage, parent, (ICPPSpecialization) field, specialized);
|
||||
|
||||
final Database db = getDB();
|
||||
linkage.storeType(record + TYPE_OFFSET, field.getType());
|
||||
long rec= PDOMValue.store(db, linkage, field.getInitialValue());
|
||||
db.putRecPtr(record + VALUE_OFFSET, rec);
|
||||
linkage.storeValue(record + VALUE_OFFSET, field.getInitialValue());
|
||||
}
|
||||
|
||||
public PDOMCPPFieldSpecialization(PDOMLinkage linkage, long bindingRecord) {
|
||||
|
@ -82,9 +79,7 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements ICPPFi
|
|||
|
||||
public IValue getInitialValue() {
|
||||
try {
|
||||
final Database db = getDB();
|
||||
long valRec = db.getRecPtr(record + VALUE_OFFSET);
|
||||
return PDOMValue.restore(db, getLinkage(), valRec);
|
||||
return getLinkage().loadValue(record + VALUE_OFFSET);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2009 QNX Software Systems and others.
|
||||
* Copyright (c) 2007, 2010 QNX Software Systems 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
|
||||
|
@ -30,7 +30,6 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMValue;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +40,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
|
|||
|
||||
private static final int TYPE_OFFSET= PDOMCPPBinding.RECORD_SIZE;
|
||||
private static final int PARAMETERID= TYPE_OFFSET + Database.TYPE_SIZE;
|
||||
private static final int DEFAULTVAL= PARAMETERID + 4;
|
||||
private static final int DEFAULTVAL= PARAMETERID + Database.VALUE_SIZE;
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = DEFAULTVAL + Database.PTR_SIZE;
|
||||
|
||||
|
@ -71,9 +70,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
|
|||
|
||||
public ICPPTemplateArgument getDefaultValue() {
|
||||
try {
|
||||
final Database db = getDB();
|
||||
long rec= db.getRecPtr(record + DEFAULTVAL);
|
||||
IValue val= PDOMValue.restore(db, getLinkage(), rec);
|
||||
IValue val= getLinkage().loadValue(record + DEFAULTVAL);
|
||||
if (val == null)
|
||||
return null;
|
||||
return new CPPTemplateArgument(val, getType());
|
||||
|
@ -89,13 +86,10 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
|
|||
ICPPTemplateNonTypeParameter ntp= (ICPPTemplateNonTypeParameter) newBinding;
|
||||
updateName(newBinding.getNameCharArray());
|
||||
final Database db = getDB();
|
||||
long valueRec= db.getRecPtr(record + DEFAULTVAL);
|
||||
try {
|
||||
IType newType= ntp.getType();
|
||||
setType(linkage, newType);
|
||||
if (setDefaultValue(db, ntp)) {
|
||||
PDOMValue.delete(db, valueRec);
|
||||
}
|
||||
setDefaultValue(db, ntp);
|
||||
} catch (DOMException e) {
|
||||
throw new CoreException(Util.createStatus(e));
|
||||
}
|
||||
|
@ -105,9 +99,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
|
|||
public void forceDelete(PDOMLinkage linkage) throws CoreException {
|
||||
getDBName().delete();
|
||||
linkage.storeType(record+TYPE_OFFSET, null);
|
||||
final Database db= getDB();
|
||||
final long valueRec= db.getRecPtr(record + DEFAULTVAL);
|
||||
PDOMValue.delete(db, valueRec);
|
||||
linkage.storeValue(record+DEFAULTVAL, null);
|
||||
}
|
||||
|
||||
public short getParameterPosition() {
|
||||
|
@ -159,17 +151,14 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
|
|||
}
|
||||
}
|
||||
|
||||
private boolean setDefaultValue(Database db, ICPPTemplateNonTypeParameter nonTypeParm) throws CoreException {
|
||||
private void setDefaultValue(Database db, ICPPTemplateNonTypeParameter nonTypeParm) throws CoreException {
|
||||
ICPPTemplateArgument val= nonTypeParm.getDefaultValue();
|
||||
if (val != null) {
|
||||
IValue sval= val.getNonTypeValue();
|
||||
if (sval != null) {
|
||||
long valueRec= PDOMValue.store(db, getLinkage(), sval);
|
||||
db.putRecPtr(record + DEFAULTVAL, valueRec);
|
||||
return true;
|
||||
getLinkage().storeValue(record + DEFAULTVAL, sval);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public IType getType() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2008, 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
|
||||
|
@ -21,7 +21,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
|||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMValue;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +29,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
public class PDOMCPPTemplateParameterMap {
|
||||
private static final int TYPE_OFFSET= 0;
|
||||
private static final int VALUE_OFFSET= TYPE_OFFSET + Database.TYPE_SIZE;
|
||||
private static final int NODE_SIZE = VALUE_OFFSET + Database.PTR_SIZE;
|
||||
private static final int NODE_SIZE = VALUE_OFFSET + Database.VALUE_SIZE;
|
||||
|
||||
/**
|
||||
* Stores the given template parameter map in the database.
|
||||
|
@ -80,7 +79,7 @@ public class PDOMCPPTemplateParameterMap {
|
|||
final ICPPTemplateArgument arg) throws CoreException {
|
||||
if (arg.isNonTypeValue()) {
|
||||
linkage.storeType(p + TYPE_OFFSET, arg.getTypeOfNonTypeValue());
|
||||
db.putRecPtr(p+VALUE_OFFSET, PDOMValue.store(db, linkage, arg.getNonTypeValue()));
|
||||
linkage.storeValue(p + VALUE_OFFSET, arg.getNonTypeValue());
|
||||
} else {
|
||||
linkage.storeType(p + TYPE_OFFSET, arg.getTypeValue());
|
||||
}
|
||||
|
@ -103,7 +102,7 @@ public class PDOMCPPTemplateParameterMap {
|
|||
packSize= 1;
|
||||
for (int j = 0; j < packSize; j++) {
|
||||
linkage.storeType(p+TYPE_OFFSET, null);
|
||||
PDOMValue.delete(db, db.getRecPtr(p+VALUE_OFFSET));
|
||||
linkage.storeValue(p+VALUE_OFFSET, null);
|
||||
p+= NODE_SIZE;
|
||||
}
|
||||
}
|
||||
|
@ -148,10 +147,9 @@ public class PDOMCPPTemplateParameterMap {
|
|||
if (type == null) {
|
||||
type= new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||
}
|
||||
final long nonTypeValRec= db.getRecPtr(rec+VALUE_OFFSET);
|
||||
IValue val= linkage.loadValue(rec + VALUE_OFFSET);
|
||||
ICPPTemplateArgument arg;
|
||||
if (nonTypeValRec != 0) {
|
||||
IValue val= PDOMValue.restore(db, linkage, nonTypeValRec);
|
||||
if (val != null) {
|
||||
arg= new CPPTemplateArgument(val, type);
|
||||
} else {
|
||||
arg= new CPPTemplateArgument(type);
|
||||
|
|
|
@ -12,13 +12,18 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -26,12 +31,13 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* @author Sergey Prigogin
|
||||
*/
|
||||
class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICPPUnknownClassInstance {
|
||||
class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICPPUnknownClassInstance, IPDOMOverloader {
|
||||
|
||||
private static final int ARGUMENTS = PDOMCPPUnknownClassType.RECORD_SIZE + 0;
|
||||
private static final int SIGNATURE_HASH = ARGUMENTS + 4;
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPUnknownClassType.RECORD_SIZE + 4;
|
||||
protected static final int RECORD_SIZE = SIGNATURE_HASH + 4;
|
||||
|
||||
// Cached values.
|
||||
ICPPTemplateArgument[] arguments;
|
||||
|
@ -40,8 +46,16 @@ class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICP
|
|||
throws CoreException {
|
||||
super(linkage, parent, classInstance);
|
||||
|
||||
long rec= PDOMCPPArgumentList.putArguments(this, classInstance.getArguments());
|
||||
getDB().putRecPtr(record + ARGUMENTS, rec);
|
||||
final ICPPTemplateArgument[] args= SemanticUtil.getSimplifiedArguments(classInstance.getArguments());
|
||||
long rec= PDOMCPPArgumentList.putArguments(this, args);
|
||||
final Database db = getDB();
|
||||
db.putRecPtr(record + ARGUMENTS, rec);
|
||||
try {
|
||||
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(classInstance);
|
||||
db.putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public PDOMCPPUnknownClassInstance(PDOMLinkage linkage, long bindingRecord) {
|
||||
|
@ -58,6 +72,10 @@ class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICP
|
|||
return IIndexCPPBindingConstants.CPP_UNKNOWN_CLASS_INSTANCE;
|
||||
}
|
||||
|
||||
public int getSignatureHash() throws CoreException {
|
||||
return getDB().getInt(record + SIGNATURE_HASH);
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] getArguments() {
|
||||
if (arguments == null) {
|
||||
try {
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMValue;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -36,7 +35,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
|||
|
||||
private static final int TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE;
|
||||
private static final int VALUE_OFFSET = TYPE_OFFSET + Database.TYPE_SIZE;
|
||||
protected static final int ANNOTATIONS = VALUE_OFFSET + Database.PTR_SIZE; // byte
|
||||
protected static final int ANNOTATIONS = VALUE_OFFSET + Database.VALUE_SIZE; // byte
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = ANNOTATIONS + 1;
|
||||
|
||||
|
@ -52,8 +51,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
|||
|
||||
private void setValue(Database db, IVariable variable) throws CoreException {
|
||||
IValue val= variable.getInitialValue();
|
||||
long valueRec= PDOMValue.store(db, getLinkage(), val);
|
||||
db.putRecPtr(record + VALUE_OFFSET, valueRec);
|
||||
getLinkage().storeValue(record + VALUE_OFFSET, val);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,12 +59,10 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
|||
if (newBinding instanceof IVariable) {
|
||||
final Database db = getDB();
|
||||
IVariable var= (IVariable) newBinding;
|
||||
long valueRec= db.getRecPtr(record + VALUE_OFFSET);
|
||||
IType newType= var.getType();
|
||||
setType(linkage, newType);
|
||||
db.putByte(record + ANNOTATIONS, encodeFlags(var));
|
||||
setValue(db, var);
|
||||
PDOMValue.delete(db, valueRec);
|
||||
db.putByte(record + ANNOTATIONS, encodeFlags(var));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,9 +105,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
|||
|
||||
public IValue getInitialValue() {
|
||||
try {
|
||||
final Database db = getDB();
|
||||
long valRec = db.getRecPtr(record + VALUE_OFFSET);
|
||||
return PDOMValue.restore(db, getLinkage(), valRec);
|
||||
return getLinkage().loadValue(record + VALUE_OFFSET);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 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
|
||||
|
@ -279,7 +279,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
|
||||
editor.selectAndReveal(content.indexOf("mem4"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "s4::mem4 : s4::{struct_member.cpp:129}");
|
||||
checkTreeNode(tree, 0, "s4::mem4 : {struct_member.cpp:129}");
|
||||
checkTreeNode(tree, 0, 0, "main() : void");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
||||
|
@ -298,7 +298,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
|
||||
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "s4::mem4 : s4::{struct_member.cpp:129}");
|
||||
checkTreeNode(tree, 0, "s4::mem4 : {struct_member.cpp:129}");
|
||||
checkTreeNode(tree, 0, 0, "main() : void");
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
|
||||
editor.selectAndReveal(content.indexOf("mem4"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "u4::mem4 : u4::{union_member.cpp:161}");
|
||||
checkTreeNode(tree, 0, "u4::mem4 : {union_member.cpp:161}");
|
||||
checkTreeNode(tree, 0, 0, "main() : void");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
||||
|
@ -480,7 +480,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
|
||||
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "u4::mem4 : u4::{union_member.cpp:161}");
|
||||
checkTreeNode(tree, 0, "u4::mem4 : {union_member.cpp:161}");
|
||||
checkTreeNode(tree, 0, 0, "main() : void");
|
||||
}
|
||||
|
||||
|
|
|
@ -1232,7 +1232,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
//};
|
||||
public void testConstructorInitializerList_EmptyInput_Bug266586() throws Exception {
|
||||
final String[] expected= {"mOne", "Base",
|
||||
"Base(int)", "Base(const ns::Base<Helper> &)", "Helper",
|
||||
"Base(int)", "Base(const Base<Helper> &)", "Helper",
|
||||
"Helper(void)", "Helper(const Helper &)",
|
||||
// Namespaces must be offered as well. In order for this code
|
||||
// to compile with gcc (e.g. 4.1.2), you need to write
|
||||
|
|
Loading…
Add table
Reference in a new issue