mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
API and data-structures for proper support of template non-type arguments, bug 242668.
This commit is contained in:
parent
cade3e70c6
commit
6724c62308
64 changed files with 1575 additions and 748 deletions
|
@ -170,7 +170,7 @@ public class IndexModelUtil {
|
|||
String[] parameterTypes= new String[params.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
IParameter param = params[i];
|
||||
parameterTypes[i]= ASTTypeUtil.getType(param.getType());
|
||||
parameterTypes[i]= ASTTypeUtil.getType(param.getType(), false);
|
||||
}
|
||||
if (parameterTypes.length == 1 && parameterTypes[0].equals("void")) { //$NON-NLS-1$
|
||||
return EMPTY_STRING_ARRAY;
|
||||
|
@ -185,6 +185,6 @@ public class IndexModelUtil {
|
|||
* @throws DOMException
|
||||
*/
|
||||
public static String extractReturnType(IFunction function) throws DOMException {
|
||||
return ASTTypeUtil.getType(function.getType().getReturnType());
|
||||
return ASTTypeUtil.getType(function.getType().getReturnType(), false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* Markus Schorn - initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.model.ext;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -271,7 +270,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
String[] parameterTypes= new String[params.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
IParameter param = params[i];
|
||||
parameterTypes[i]= ASTTypeUtil.getType(param.getType());
|
||||
parameterTypes[i]= ASTTypeUtil.getType(param.getType(), false);
|
||||
}
|
||||
if (parameterTypes.length == 1 && parameterTypes[0].equals("void")) { //$NON-NLS-1$
|
||||
return EMPTY_STRING_ARRAY;
|
||||
|
|
|
@ -27,9 +27,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPQualifierType;
|
||||
|
@ -56,13 +56,9 @@ public class ASTTypeUtil {
|
|||
private static final int DEAULT_ITYPE_SIZE = 2;
|
||||
|
||||
/**
|
||||
* Returns a String representation of the parameter type of an IFunctionType.
|
||||
*
|
||||
* This function calls ASTTypeUtil#getParameterTypeStringArray(IFunctionType) and wraps the
|
||||
* results in "()" with a comma separated list.
|
||||
*
|
||||
* @param type
|
||||
* @return the representation of the parameter type of an IFunctionType
|
||||
* Returns a string representation for the parameters of the given function type. The
|
||||
* representation contains the comma-separated list of the normalized parameter type
|
||||
* representations wrapped in parenthesis.
|
||||
*/
|
||||
public static String getParameterTypeString(IFunctionType type) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
@ -80,29 +76,75 @@ public class ASTTypeUtil {
|
|||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation for the type array. The representation is
|
||||
* a comma-separated list of the normalized string representations of the
|
||||
* provided types.
|
||||
* @see #getTypeListString(IType[], boolean)
|
||||
*/
|
||||
public static String getTypeListString(IType[] types) {
|
||||
return getTypeListString(types, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String representation of the type array as a
|
||||
* comma-separated list.
|
||||
* @param types
|
||||
* @return representation of the type array as a comma-separated list
|
||||
* @since 5.1
|
||||
*/
|
||||
public static String getTypeListString(IType[] types) {
|
||||
public static String getTypeListString(IType[] types, boolean normalize) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (types[i] != null) {
|
||||
result.append(getTypeString(types[i]));
|
||||
result.append(getType(types[i], normalize));
|
||||
if (i < types.length - 1)
|
||||
result.append(COMMA_SPACE);
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a comma-separated list of the string representations of the arguments.
|
||||
* Optionally normalization is performed:
|
||||
* <br> template parameter names are represented by their parameter position,
|
||||
* <br> further normalization may be performed in future versions.
|
||||
* @param normalize indicates whether normalization shall be performed
|
||||
* @since 5.1
|
||||
*/
|
||||
public static String getArgumentListString(ICPPTemplateArgument[] args, boolean normalize) {
|
||||
StringBuilder result= new StringBuilder();
|
||||
boolean first= true;
|
||||
for (ICPPTemplateArgument arg : args) {
|
||||
if (!first) {
|
||||
result.append(',');
|
||||
}
|
||||
first= false;
|
||||
result.append(getArgumentString(arg, normalize));
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns String[] corresponding to the types of the parameters for the IFunctionType.
|
||||
*
|
||||
* @param type
|
||||
* @return the types of the parameters for the IFunctionType
|
||||
* Returns a string representation for an template argument. Optionally
|
||||
* normalization is performed:
|
||||
* <br> template parameter names are represented by their parameter position,
|
||||
* <br> further normalization may be performed in future versions.
|
||||
* @param normalize indicates whether normalization shall be performed
|
||||
* @since 5.1
|
||||
*/
|
||||
public static String getArgumentString(ICPPTemplateArgument arg, boolean normalize) {
|
||||
if (arg.isNonTypeValue())
|
||||
return arg.getNonTypeValue().getCanonicalRepresentation();
|
||||
|
||||
return getTypeString(arg.getTypeValue(), normalize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of normalized string representations for the parameter types of the
|
||||
* given function type.
|
||||
* @see #getType(IType, boolean)
|
||||
*/
|
||||
public static String[] getParameterTypeStringArray(IFunctionType type) {
|
||||
IType[] parms = null;
|
||||
|
@ -123,7 +165,7 @@ public class ASTTypeUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static String getTypeString(IType type) {
|
||||
private static String getTypeString(IType type, boolean normalize) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
boolean needSpace = false;
|
||||
|
||||
|
@ -269,29 +311,16 @@ public class ASTTypeUtil {
|
|||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
} else if (type instanceof ICPPTemplateParameter) {
|
||||
final ICPPTemplateParameter tpar = (ICPPTemplateParameter) type;
|
||||
if (normalize) {
|
||||
result.append('#');
|
||||
result.append(Integer.toString(tpar.getParameterPosition(), 16));
|
||||
} else {
|
||||
result.append(tpar.getName());
|
||||
}
|
||||
} 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) {
|
||||
// try {
|
||||
// switch(((ICPPClassType) type).getKey()) {
|
||||
// case ICPPClassType.k_class:
|
||||
// result.append(Keywords.CLASS);
|
||||
// break;
|
||||
// }
|
||||
// } catch (DOMException e) {}
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// switch(((ICompositeType) type).getKey()) {
|
||||
// case ICompositeType.k_struct:
|
||||
// result.append(Keywords.STRUCT);
|
||||
// break;
|
||||
// case ICompositeType.k_union:
|
||||
// result.append(Keywords.UNION);
|
||||
// break;
|
||||
// }
|
||||
// } catch (DOMException e) {}
|
||||
// result.append(SPACE);
|
||||
if (type instanceof ICPPClassType) {
|
||||
try {
|
||||
String qn = CPPVisitor.renderQualifiedName(getQualifiedNameForAnonymous((ICPPClassType) type));
|
||||
|
@ -304,17 +333,13 @@ public class ASTTypeUtil {
|
|||
}
|
||||
} else if (type instanceof ICPPReferenceType) {
|
||||
result.append(Keywords.cpAMPER);
|
||||
} else if (type instanceof ICPPTemplateTypeParameter) {
|
||||
result.append(((ICPPTemplateTypeParameter) type).getName());
|
||||
} else if (type instanceof ICPPTemplateTemplateParameter) {
|
||||
result.append(((ICPPTemplateTemplateParameter) type).getName());
|
||||
} else if (type instanceof IEnumeration) {
|
||||
result.append(Keywords.ENUM);
|
||||
result.append(SPACE);
|
||||
result.append(getNameForAnonymous((IEnumeration) type));
|
||||
} else if (type instanceof IFunctionType) {
|
||||
try {
|
||||
String temp = getType(((IFunctionType) type).getReturnType());
|
||||
String temp = getType(((IFunctionType) type).getReturnType(), normalize);
|
||||
if (temp != null && !temp.equals(EMPTY_STRING)) {
|
||||
result.append(temp); needSpace = true;
|
||||
}
|
||||
|
@ -389,23 +414,24 @@ public class ASTTypeUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the type representation of the IType as a String. This function uses the IType interfaces to build the
|
||||
* String representation of the IType. Resolves typedefs.
|
||||
* @param type
|
||||
* @return the type representation of the IType
|
||||
* Returns the normalized string representation of the type.
|
||||
* @see #getType(IType, boolean)
|
||||
*/
|
||||
public static String getType(IType type) {
|
||||
return getType(type, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type representation of the IType as a String. This function uses the IType interfaces to build the
|
||||
* String representation of the IType.
|
||||
* @param type
|
||||
* @param resolveTypedefs whether or not typedefs shall be resolved to their real types
|
||||
* Returns a string representation of a type.
|
||||
* Optionally the representation is normalized:
|
||||
* <br> typedefs are resolved
|
||||
* <br> template parameter names are represented by their parameter position
|
||||
* <br> further normalization may be performed in the future.
|
||||
* @param type a type to compute the string representation for.
|
||||
* @param normalize whether or not normalization should be performed.
|
||||
* @return the type representation of the IType
|
||||
*/
|
||||
public static String getType(IType type, boolean resolveTypedefs) {
|
||||
public static String getType(IType type, boolean normalize) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
IType[] types = new IType[DEAULT_ITYPE_SIZE];
|
||||
|
||||
|
@ -413,10 +439,10 @@ public class ASTTypeUtil {
|
|||
int i = 0;
|
||||
while (type != null && ++i < 100) {
|
||||
final boolean isTypedef= type instanceof ITypedef;
|
||||
if (!resolveTypedefs || !isTypedef) {
|
||||
if (!normalize || !isTypedef) {
|
||||
types = (IType[]) ArrayUtil.append(IType.class, types, type);
|
||||
}
|
||||
if (!resolveTypedefs && isTypedef) {
|
||||
if (!normalize && isTypedef) {
|
||||
type= null; // stop here
|
||||
} else if (type instanceof ITypeContainer) {
|
||||
try {
|
||||
|
@ -436,12 +462,12 @@ public class ASTTypeUtil {
|
|||
|
||||
if (types[j] != null) {
|
||||
if (j > 0 && types[j - 1] instanceof IQualifierType) {
|
||||
result.append(getTypeString(types[j - 1]));
|
||||
result.append(getTypeString(types[j - 1], normalize));
|
||||
result.append(SPACE);
|
||||
result.append(getTypeString(types[j]));
|
||||
result.append(getTypeString(types[j], normalize));
|
||||
--j;
|
||||
} else {
|
||||
result.append(getTypeString(types[j]));
|
||||
result.append(getTypeString(types[j], normalize));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -450,10 +476,10 @@ public class ASTTypeUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the type representation of the declarator (including parameters) as a String.
|
||||
*
|
||||
* @param decltor
|
||||
* @return the type representation of the IASTDeclarator (including parameters)
|
||||
* For testing purposes, only.
|
||||
* Returns the normalized string representation of the type defined by the given declarator.
|
||||
*
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public static String getType(IASTDeclarator decltor) {
|
||||
// get the most nested declarator
|
||||
|
@ -485,13 +511,10 @@ public class ASTTypeUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return's the String representation of a node's type (if available). This is
|
||||
* currently only being used for testing.
|
||||
* For testing purposes, only.
|
||||
* Return's the String representation of a node's type (if available).
|
||||
*
|
||||
* TODO Remove this function when done testing if it is no longer needed
|
||||
*
|
||||
* @param node
|
||||
* @return the String representation of a node's type (if available)
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public static String getNodeType(IASTNode node) {
|
||||
try {
|
||||
|
@ -511,7 +534,7 @@ public class ASTTypeUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retuns the type representation of the IASTTypeId as a String.
|
||||
* Returns the type representation of the IASTTypeId as a String.
|
||||
*
|
||||
* @param typeId
|
||||
* @return the type representation of the IASTTypeId as a String
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
||||
/**
|
||||
* Maps template parameters to values.
|
||||
* @since 5.1
|
||||
*/
|
||||
public class CPPTemplateParameterMap implements ICPPTemplateParameterMap {
|
||||
public static final CPPTemplateParameterMap EMPTY = new CPPTemplateParameterMap();
|
||||
|
||||
private ObjectMap fMap= new ObjectMap(2);
|
||||
|
||||
/**
|
||||
* Returns whether the map contains the given parameter
|
||||
*/
|
||||
public boolean contains(ICPPTemplateParameter templateParameter) {
|
||||
return fMap.containsKey(templateParameter.getParameterPosition());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the mapping to the map.
|
||||
*/
|
||||
public void put(ICPPTemplateParameter param, ICPPTemplateArgument value) {
|
||||
fMap.put(param.getParameterPosition(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the mapping to the map.
|
||||
*/
|
||||
public void put(int parameterPos, ICPPTemplateArgument value) {
|
||||
fMap.put(parameterPos, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value for the given parameter.
|
||||
*/
|
||||
public ICPPTemplateArgument getArgument(ICPPTemplateParameter param) {
|
||||
return (ICPPTemplateArgument) fMap.get(param.getParameterPosition());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value for the template parameter at the given position.
|
||||
* @see ICPPTemplateParameter#getParameterPosition()
|
||||
*/
|
||||
public ICPPTemplateArgument getArgument(int paramPosition) {
|
||||
return (ICPPTemplateArgument) fMap.get(paramPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts all mappings from the supplied map into this map.
|
||||
*/
|
||||
public void putAll(CPPTemplateParameterMap map) {
|
||||
final ObjectMap omap= map.fMap;
|
||||
for (int i = 0; i < omap.size(); i++) {
|
||||
fMap.put(omap.keyAt(i), omap.getAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of template parameter positions, for which a mapping exists.
|
||||
*/
|
||||
public Integer[] getAllParameterPositions() {
|
||||
return fMap.keyArray(Integer.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* For debugging purposes, only.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("{"); //$NON-NLS-1$
|
||||
for (int i = 0; i < fMap.size(); i++) {
|
||||
Integer key = (Integer) fMap.keyAt(i);
|
||||
if (key != null) {
|
||||
if (sb.length() > 1) {
|
||||
sb.append(", "); //$NON-NLS-1$
|
||||
}
|
||||
ICPPTemplateArgument value = (ICPPTemplateArgument) fMap.getAt(i);
|
||||
sb.append('#');
|
||||
sb.append(key >> 16);
|
||||
sb.append(',');
|
||||
sb.append(key & 0xffff);
|
||||
sb.append(": "); //$NON-NLS-1$
|
||||
sb.append(ASTTypeUtil.getArgumentString(value, true));
|
||||
}
|
||||
}
|
||||
sb.append("}"); //$NON-NLS-1$
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -6,29 +6,23 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
/*
|
||||
* Created on Mar 23, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
|
||||
/**
|
||||
* This interface represents a class template partial specialization. A partial specialization is
|
||||
* a class template in its own right.
|
||||
*
|
||||
* eg:
|
||||
* e.g.:
|
||||
* template <class T> class A {}; //the primary class template
|
||||
* template <class T> class A<T*> {}; //a partial specialization of the primary class template
|
||||
*
|
||||
* @author aniefer
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPClassTemplatePartialSpecialization extends ICPPClassTemplate {
|
||||
public static final ICPPClassTemplatePartialSpecialization[] EMPTY_PARTIAL_SPECIALIZATION_ARRAY = new ICPPClassTemplatePartialSpecialization[0];
|
||||
|
@ -43,4 +37,11 @@ public interface ICPPClassTemplatePartialSpecialization extends ICPPClassTemplat
|
|||
* get the ICPPTemplateDefinition which this is a specialization of
|
||||
*/
|
||||
public ICPPClassTemplate getPrimaryClassTemplate() throws DOMException;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the arguments of this partial specialization.
|
||||
* @since 5.1
|
||||
*/
|
||||
public ICPPTemplateArgument[] getTemplateArguments();
|
||||
}
|
||||
|
|
|
@ -1,17 +1,26 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 QNX Software Systems and others.
|
||||
* Copyright (c) 2007, 2008 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
* Interface for deferred instances. A deferred instance is not actually instantiated yet,
|
||||
* because the correct template cannot be selected until all information is available.
|
||||
*/
|
||||
public interface ICPPDeferredTemplateInstance extends ICPPTemplateInstance {
|
||||
|
||||
/**
|
||||
* Returns an empty map, because template parameters cannot be mapped until
|
||||
* all of the arguments are resolved.
|
||||
* @since 5.1
|
||||
*/
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap();
|
||||
}
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2008 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
|
||||
* /
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
/*
|
||||
* Created on Apr 29, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -22,11 +19,9 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
|||
* specializations of the members of the original class template.
|
||||
* For an instantiation of a function template, the parameters will be specializations
|
||||
* of the parameters of the original function template.
|
||||
* Specializations can also be explicitly defined.
|
||||
*
|
||||
* Specializations can also be explicitly defined
|
||||
*
|
||||
* @author aniefer
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPSpecialization extends ICPPBinding {
|
||||
/**
|
||||
|
@ -36,10 +31,14 @@ public interface ICPPSpecialization extends ICPPBinding {
|
|||
public IBinding getSpecializedBinding();
|
||||
|
||||
/**
|
||||
* Returns the argument map for this specialization. For partial specializations, only
|
||||
* those arguments which have been specialized will appear.
|
||||
* @return a map which maps from template parameter to the corresponding
|
||||
* template argument
|
||||
* Returns the mapping of template parameters to values.
|
||||
* @since 5.1
|
||||
*/
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap();
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getTemplateParameterMap()}, instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
|
||||
/**
|
||||
* Models the value of a template parameter or for the argument of a template-id.
|
||||
* Such a value can either be a type-value, or an integral value.
|
||||
*
|
||||
* @since 5.1
|
||||
*/
|
||||
public interface ICPPTemplateArgument {
|
||||
ICPPTemplateArgument[] EMPTY_ARGUMENTS = {};
|
||||
|
||||
/**
|
||||
* Returns whether this is an integral value, suitable for a template non-type parameter.
|
||||
*/
|
||||
boolean isNonTypeValue();
|
||||
|
||||
/**
|
||||
* If this is a type value (suitable for a template type and template template parameters),
|
||||
* the type used as a value is returned.
|
||||
* For non-type values, <code>null</code> is returned.
|
||||
*/
|
||||
IType getTypeValue();
|
||||
|
||||
/**
|
||||
* If this is a non-type value (suitable for a template non-type parameters),
|
||||
* the value is returned.
|
||||
* For type values, <code>null</code> is returned.
|
||||
*/
|
||||
IValue getNonTypeValue();
|
||||
|
||||
/**
|
||||
* If this is a non-type value (suitable for a template non-type parameter),
|
||||
* the type of the value is returned.
|
||||
* For type values, <code>null</code> is returned.
|
||||
*/
|
||||
IType getTypeOfNonTypeValue();
|
||||
|
||||
/**
|
||||
* Checks whether two arguments denote the same value.
|
||||
*/
|
||||
boolean isSameValue(ICPPTemplateArgument arg);
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
* 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;
|
||||
|
@ -35,7 +35,14 @@ public interface ICPPTemplateInstance extends ICPPSpecialization {
|
|||
public ICPPTemplateDefinition getTemplateDefinition();
|
||||
|
||||
/**
|
||||
* get the types of the arguments the template was instantiated with.
|
||||
* Returns the template arguments of this instance.
|
||||
* @since 5.1
|
||||
*/
|
||||
public ICPPTemplateArgument[] getTemplateArguments();
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getTemplateArguments()}, instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public IType[] getArguments();
|
||||
}
|
||||
|
|
|
@ -1,19 +1,32 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2008 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
|
||||
* Doug Schaefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
* Base interface for all template parameters (non-type, type and template).
|
||||
*
|
||||
* @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];
|
||||
|
||||
/**
|
||||
* The position of the template parameter is determined by the nesting level of the template
|
||||
* declaration and the position within the template parameter list. In every context where a
|
||||
* template parameter can be referenced (i.e. within a template declaration) the parameter
|
||||
* position is unique.
|
||||
* <par>
|
||||
* The position is computed by <code>(nesting-level << 16) + position-in-parameter-list</code>
|
||||
* @since 5.1
|
||||
*/
|
||||
int getParameterPosition();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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.core.dom.ast.cpp;
|
||||
|
||||
/**
|
||||
* Models the mapping of template parameters to values.
|
||||
* @since 5.1
|
||||
*/
|
||||
public interface ICPPTemplateParameterMap {
|
||||
|
||||
/**
|
||||
* Returns the value for the template parameter at the given position.
|
||||
* @see ICPPTemplateParameter#getParameterPosition()
|
||||
*/
|
||||
public ICPPTemplateArgument getArgument(int paramPosition);
|
||||
|
||||
/**
|
||||
* Returns the array of template parameter positions, for which a mapping exists.
|
||||
*/
|
||||
Integer[] getAllParameterPositions();
|
||||
}
|
|
@ -49,6 +49,7 @@ public class Value implements IValue {
|
|||
|
||||
private final String fValue;
|
||||
private Value(String rep) {
|
||||
assert rep != null;
|
||||
fValue= rep;
|
||||
}
|
||||
public String getCanonicalRepresentation() {
|
||||
|
@ -62,6 +63,18 @@ public class Value implements IValue {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return fValue.hashCode();
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof IValue)) {
|
||||
return false;
|
||||
}
|
||||
return fValue.equals(((IValue) obj).getCanonicalRepresentation());
|
||||
}
|
||||
|
||||
public static IValue create(long value) {
|
||||
if (value >=0 && value < TYPICAL.length)
|
||||
|
@ -185,8 +198,7 @@ public class Value implements IValue {
|
|||
|
||||
@SuppressWarnings("nls")
|
||||
private static String evaluate(ICPPTemplateParameter param) {
|
||||
// mstodo add support for parameter positions first.
|
||||
return "#" ;//+Integer.toHexString(param.getParameterPosition());
|
||||
return "#" + Integer.toHexString(param.getParameterPosition());
|
||||
}
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
|
|
|
@ -148,9 +148,7 @@ public class CBasicType implements ICBasicType {
|
|||
return t;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBasicType#getValue()
|
||||
*/
|
||||
@Deprecated
|
||||
public IASTExpression getValue() {
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -6,28 +6,31 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
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.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
* The result of instantiating a class template.
|
||||
*/
|
||||
public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemplateInstance {
|
||||
private IType[] arguments;
|
||||
private ICPPTemplateArgument[] arguments;
|
||||
|
||||
public CPPClassInstance(IBinding owner, ICPPClassType orig, ObjectMap argMap, IType[] args) {
|
||||
public CPPClassInstance(IBinding owner, ICPPClassType orig, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args) {
|
||||
super(orig, owner, argMap);
|
||||
this.arguments= args;
|
||||
}
|
||||
|
@ -35,17 +38,22 @@ public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemp
|
|||
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||
return (ICPPTemplateDefinition) getSpecializedBinding();
|
||||
}
|
||||
|
||||
public IType[] getArguments() {
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* For debug purposes only
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + " <" + ASTTypeUtil.getTypeListString(arguments) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return getName() + " <" + ASTTypeUtil.getArgumentListString(arguments, true) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
|
@ -53,7 +54,7 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
private ObjectMap specializationMap= ObjectMap.EMPTY_MAP;
|
||||
private boolean checked;
|
||||
|
||||
public CPPClassSpecialization(ICPPClassType specialized, IBinding owner, ObjectMap argumentMap) {
|
||||
public CPPClassSpecialization(ICPPClassType specialized, IBinding owner, CPPTemplateParameterMap argumentMap) {
|
||||
super(specialized, owner, argumentMap);
|
||||
}
|
||||
|
||||
|
@ -70,7 +71,7 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
return result;
|
||||
}
|
||||
|
||||
IBinding result= CPPTemplates.createSpecialization(this, original, argumentMap);
|
||||
IBinding result= CPPTemplates.createSpecialization(this, original, getArgumentMap());
|
||||
synchronized(this) {
|
||||
IBinding concurrent= (IBinding) specializationMap.get(original);
|
||||
if (concurrent != null)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
@ -14,39 +14,45 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
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.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
* A partial class template specialization.
|
||||
*/
|
||||
public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate implements
|
||||
ICPPClassTemplatePartialSpecialization, ICPPSpecialization {
|
||||
public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate
|
||||
implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization {
|
||||
|
||||
private ICPPTemplateArgument[] arguments;
|
||||
|
||||
private IType [] arguments;
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CPPClassTemplatePartialSpecialization(ICPPASTTemplateId name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateSpecialization#getArguments()
|
||||
*/
|
||||
public IType[] getArguments() {
|
||||
if( arguments == null ){
|
||||
ICPPASTTemplateId id= (ICPPASTTemplateId) getTemplateName();
|
||||
arguments = CPPTemplates.createTemplateArgumentArray(id);
|
||||
}
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
createArguments();
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private void createArguments() {
|
||||
if (arguments == null) {
|
||||
arguments= CPPTemplates.convert(
|
||||
CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) getTemplateName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization#getPrimaryClassTemplate()
|
||||
*/
|
||||
|
@ -59,25 +65,22 @@ public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate impl
|
|||
return getPrimaryClassTemplate();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization#getArgumentMap()
|
||||
*/
|
||||
public ObjectMap getArgumentMap() {
|
||||
IType[] arg= getArguments();
|
||||
ICPPTemplateParameter[] params;
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
CPPTemplateParameterMap result= new CPPTemplateParameterMap();
|
||||
try {
|
||||
params = getPrimaryClassTemplate().getTemplateParameters();
|
||||
ICPPTemplateParameter[] params = getPrimaryClassTemplate().getTemplateParameters();
|
||||
ICPPTemplateArgument[] args= getTemplateArguments();
|
||||
int len= Math.min(params.length, args.length);
|
||||
for (int i = 0; i < len; i++) {
|
||||
result.put(params[i], args[i]);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
return ObjectMap.EMPTY_MAP;
|
||||
}
|
||||
// lengths should be equal, be defensive
|
||||
final int len= Math.min(params.length, arg.length);
|
||||
ObjectMap map = new ObjectMap(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
map.put(params[i], arg[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return map;
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return CPPTemplates.getArgumentMap(getPrimaryClassTemplate(), getTemplateParameterMap());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
|
@ -30,7 +31,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
|||
|
||||
private ObjectMap instances = null;
|
||||
|
||||
public CPPClassTemplateSpecialization(ICPPClassTemplate orig, ICPPClassType owner, ObjectMap argumentMap) {
|
||||
public CPPClassTemplateSpecialization(ICPPClassTemplate orig, ICPPClassType owner, CPPTemplateParameterMap argumentMap) {
|
||||
super(orig, owner, argumentMap);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,26 +6,25 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*
|
||||
* Instantiation of a constructor template
|
||||
*/
|
||||
public class CPPConstructorInstance extends CPPMethodInstance implements
|
||||
ICPPConstructor {
|
||||
public class CPPConstructorInstance extends CPPMethodInstance implements ICPPConstructor {
|
||||
|
||||
public CPPConstructorInstance(ICPPClassType owner, ICPPConstructor orig, ObjectMap argMap, IType[] args) {
|
||||
super(owner, orig, argMap, args);
|
||||
public CPPConstructorInstance(ICPPClassType owner, ICPPConstructor orig,
|
||||
CPPTemplateParameterMap tpmap, ICPPTemplateArgument[] args) {
|
||||
super(owner, orig, tpmap, args);
|
||||
}
|
||||
|
||||
public boolean isExplicit() throws DOMException {
|
||||
|
|
|
@ -13,9 +13,9 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
||||
/**
|
||||
* Specialization of a constructor for a class-template or class-template specialization
|
||||
|
@ -23,7 +23,8 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
|||
public class CPPConstructorSpecialization extends CPPMethodSpecialization
|
||||
implements ICPPConstructor {
|
||||
|
||||
public CPPConstructorSpecialization(IBinding orig, ICPPClassType owner, ObjectMap argMap) {
|
||||
public CPPConstructorSpecialization(IBinding orig, ICPPClassType owner,
|
||||
CPPTemplateParameterMap argMap) {
|
||||
super(orig, owner, argMap);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,18 +13,19 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
||||
/**
|
||||
* Specialization of a constructor template
|
||||
*/
|
||||
public class CPPConstructorTemplateSpecialization extends CPPMethodTemplateSpecialization implements ICPPConstructor {
|
||||
|
||||
public class CPPConstructorTemplateSpecialization extends CPPMethodTemplateSpecialization
|
||||
implements ICPPConstructor {
|
||||
|
||||
public CPPConstructorTemplateSpecialization(IBinding specialized,
|
||||
ICPPClassType owner, ObjectMap argumentMap) {
|
||||
super(specialized, owner, argumentMap);
|
||||
ICPPClassType owner, CPPTemplateParameterMap tpmap) {
|
||||
super(specialized, owner, tpmap);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -17,7 +17,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
@ -27,10 +29,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
|||
*/
|
||||
public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDeferredClassInstance {
|
||||
|
||||
private final IType[] fArguments;
|
||||
private final ICPPTemplateArgument[] fArguments;
|
||||
private final ICPPClassTemplate fClassTemplate;
|
||||
|
||||
public CPPDeferredClassInstance(ICPPClassTemplate template, IType[] arguments) throws DOMException {
|
||||
public CPPDeferredClassInstance(ICPPClassTemplate template, ICPPTemplateArgument[] arguments) throws DOMException {
|
||||
super(template.getOwner(), new CPPASTName(template.getNameCharArray()));
|
||||
|
||||
fArguments= arguments;
|
||||
|
@ -62,21 +64,7 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef
|
|||
if (!classTemplate.isSameType((IType) rhs.getSpecializedBinding()))
|
||||
return false;
|
||||
|
||||
IType[] lhsArgs= getArguments();
|
||||
IType[] rhsArgs= rhs.getArguments();
|
||||
if (lhsArgs != rhsArgs) {
|
||||
if (lhsArgs == null || rhsArgs == null)
|
||||
return false;
|
||||
|
||||
if (lhsArgs.length != rhsArgs.length)
|
||||
return false;
|
||||
|
||||
for (int i= 0; i < lhsArgs.length; i++) {
|
||||
if (!CPPTemplates.isSameTemplateArgument(lhsArgs[i],rhsArgs[i]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return CPPTemplates.haveSameArguments(this, rhs);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -85,8 +73,13 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef
|
|||
public int getKey() throws DOMException {
|
||||
return getClassTemplate().getKey();
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return fArguments;
|
||||
}
|
||||
|
||||
|
@ -95,8 +88,11 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef
|
|||
}
|
||||
|
||||
public ObjectMap getArgumentMap() {
|
||||
// mstodo- compute argmap
|
||||
return null;
|
||||
return ObjectMap.EMPTY_MAP;
|
||||
}
|
||||
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return CPPTemplateParameterMap.EMPTY;
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
@ -19,10 +19,12 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
@ -31,17 +33,18 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
* The deferred function instance collects information about the instantiation until it can
|
||||
* be carried out.
|
||||
*/
|
||||
public class CPPDeferredFunctionInstance extends CPPUnknownBinding implements ICPPFunction, ICPPInternalFunction, ICPPDeferredTemplateInstance {
|
||||
private IType[] fArguments;
|
||||
private ICPPTemplateArgument[] fArguments;
|
||||
private ICPPFunctionTemplate fFunctionTemplate;
|
||||
|
||||
private ObjectMap fArgmap;
|
||||
private CPPTemplateParameterMap fArgmap;
|
||||
private IParameter [] fParameters;
|
||||
private IFunctionType fFunctionType;
|
||||
|
||||
public CPPDeferredFunctionInstance( ICPPFunctionTemplate template, IType[] arguments ) throws DOMException {
|
||||
public CPPDeferredFunctionInstance(ICPPFunctionTemplate template, ICPPTemplateArgument[] arguments) throws DOMException {
|
||||
super(template.getOwner(), new CPPASTName(template.getNameCharArray()));
|
||||
fArguments= arguments;
|
||||
fFunctionTemplate= template;
|
||||
|
@ -55,38 +58,45 @@ public class CPPDeferredFunctionInstance extends CPPUnknownBinding implements IC
|
|||
return fFunctionTemplate;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return CPPTemplates.getArgumentMap(fFunctionTemplate, getTemplateParameterMap());
|
||||
}
|
||||
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
// mstodo- deferred function instance and tpmap
|
||||
if (fArgmap == null) {
|
||||
fArgmap= ObjectMap.EMPTY_MAP;
|
||||
CPPTemplateParameterMap argmap= new CPPTemplateParameterMap();
|
||||
try {
|
||||
ICPPTemplateParameter[] params= fFunctionTemplate.getTemplateParameters();
|
||||
ObjectMap result= new ObjectMap(params.length);
|
||||
for (int i=0; i < params.length; i++) {
|
||||
if (i < fArguments.length) {
|
||||
result.put(params[i], fArguments[i]);
|
||||
}
|
||||
ICPPTemplateArgument[] args= fArguments;
|
||||
int len= Math.min(params.length, args.length);
|
||||
for (int i = 0; i < len; i++) {
|
||||
argmap.put(params[i], args[i]);
|
||||
}
|
||||
fArgmap= result;
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
fArgmap= argmap;
|
||||
}
|
||||
return fArgmap;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return fArguments;
|
||||
}
|
||||
|
||||
public IParameter[] getParameters() throws DOMException {
|
||||
ObjectMap map= getArgumentMap();
|
||||
if (map == null || map.isEmpty()) {
|
||||
return ((ICPPFunction)getTemplateDefinition()).getParameters();
|
||||
}
|
||||
// mstodo- deferred function instance and tpmap
|
||||
if( fParameters == null ){
|
||||
IParameter [] params = ((ICPPFunction)getTemplateDefinition()).getParameters();
|
||||
fParameters = new IParameter[ params.length ];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
fParameters[i] = new CPPParameterSpecialization( (ICPPParameter)params[i], null, getArgumentMap() );
|
||||
fParameters[i] = new CPPParameterSpecialization( (ICPPParameter)params[i], null, CPPTemplateParameterMap.EMPTY);
|
||||
}
|
||||
}
|
||||
return fParameters;
|
||||
|
@ -100,11 +110,9 @@ public class CPPDeferredFunctionInstance extends CPPUnknownBinding implements IC
|
|||
if( fFunctionType == null ){
|
||||
IFunctionType ft = ((ICPPFunction)getTemplateDefinition()).getType();
|
||||
IType returnType = ft.getReturnType();
|
||||
// mstodo- is that necessary?
|
||||
returnType = CPPTemplates.instantiateType( returnType, getArgumentMap(), null);
|
||||
returnType = CPPTemplates.instantiateType(returnType, getArgumentMap(), null);
|
||||
fFunctionType = CPPVisitor.createImplicitFunctionType( returnType, getParameters(), null);
|
||||
}
|
||||
|
||||
return fFunctionType;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IInternalVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
|
||||
|
@ -29,8 +29,8 @@ public class CPPFieldSpecialization extends CPPSpecialization implements ICPPFie
|
|||
private IType type = null;
|
||||
private IValue value= null;
|
||||
|
||||
public CPPFieldSpecialization( IBinding orig, ICPPClassType owner, ObjectMap argMap ) {
|
||||
super(orig, owner, argMap);
|
||||
public CPPFieldSpecialization( IBinding orig, ICPPClassType owner, CPPTemplateParameterMap tpmap) {
|
||||
super(orig, owner, tpmap);
|
||||
}
|
||||
|
||||
private ICPPField getField() {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
@ -16,30 +16,36 @@ import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
|||
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.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
* The instantiation of a function template.
|
||||
*/
|
||||
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPTemplateInstance {
|
||||
private IType[] arguments;
|
||||
private ICPPTemplateArgument[] fArguments;
|
||||
|
||||
public CPPFunctionInstance(IBinding owner, ICPPFunction orig, ObjectMap argMap, IType[] args) {
|
||||
public CPPFunctionInstance(IBinding owner, ICPPFunction orig, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args) {
|
||||
super(orig, owner, argMap);
|
||||
this.arguments = args;
|
||||
fArguments = args;
|
||||
}
|
||||
|
||||
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||
return (ICPPTemplateDefinition) getSpecializedBinding();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return arguments;
|
||||
return CPPTemplates.getArguments(fArguments);
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return fArguments;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -47,28 +53,20 @@ public class CPPFunctionInstance extends CPPFunctionSpecialization implements IC
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + " <" + ASTTypeUtil.getTypeListString(arguments) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return getName() + " <" + ASTTypeUtil.getArgumentListString(fArguments, true) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if( (obj instanceof ICPPTemplateInstance) && (obj instanceof ICPPFunction)){
|
||||
try {
|
||||
final ICPPTemplateInstance inst = (ICPPTemplateInstance)obj;
|
||||
ICPPFunctionType ct1= (ICPPFunctionType) ((ICPPFunction)getSpecializedBinding()).getType();
|
||||
ICPPFunctionType ct2= (ICPPFunctionType) ((ICPPFunction)((ICPPTemplateInstance)obj).getTemplateDefinition()).getType();
|
||||
ICPPFunctionType ct2= (ICPPFunctionType) ((ICPPFunction)inst.getTemplateDefinition()).getType();
|
||||
if(!ct1.isSameType(ct2))
|
||||
return false;
|
||||
|
||||
ObjectMap m1 = getArgumentMap(), m2 = ((ICPPTemplateInstance)obj).getArgumentMap();
|
||||
if( m1 == null || m2 == null || m1.size() != m2.size())
|
||||
return false;
|
||||
for( int i = 0; i < m1.size(); i++ ){
|
||||
IType t1 = (IType) m1.getAt( i );
|
||||
IType t2 = (IType) m2.getAt( i );
|
||||
if(!CPPTemplates.isSameTemplateArgument(t1, t2))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return CPPTemplates.haveSameArguments(this, inst);
|
||||
} catch(DOMException de) {
|
||||
CCorePlugin.log(de);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
@ -24,21 +24,22 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
* The specialization of a friend function in the context of a class specialization,
|
||||
* also used as base class for function instances.
|
||||
*/
|
||||
public class CPPFunctionSpecialization extends CPPSpecialization implements ICPPFunction, ICPPInternalFunction {
|
||||
private IFunctionType type = null;
|
||||
private IParameter[] specializedParams = null;
|
||||
|
||||
public CPPFunctionSpecialization(IBinding orig, IBinding owner, ObjectMap argMap) {
|
||||
public CPPFunctionSpecialization(IBinding orig, IBinding owner, CPPTemplateParameterMap argMap) {
|
||||
super(orig, owner, argMap);
|
||||
}
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
specializedParams = new IParameter[params.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
specializedParams[i] = new CPPParameterSpecialization((ICPPParameter)params[i],
|
||||
this, argumentMap);
|
||||
this, getTemplateParameterMap());
|
||||
}
|
||||
}
|
||||
return specializedParams;
|
||||
|
@ -241,9 +242,10 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
} catch (DOMException e) {
|
||||
}
|
||||
result.append(t != null ? ASTTypeUtil.getParameterTypeString(t) : "()"); //$NON-NLS-1$
|
||||
if (argumentMap != null) {
|
||||
CPPTemplateParameterMap tpmap= getTemplateParameterMap();
|
||||
if (tpmap != null) {
|
||||
result.append(" "); //$NON-NLS-1$
|
||||
result.append(argumentMap.toString());
|
||||
result.append(tpmap.toString());
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
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.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
|
@ -22,15 +23,14 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
* The specialization of a friend function template in the context of a class specialization.
|
||||
*/
|
||||
public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
|
||||
implements ICPPFunctionTemplate, ICPPInternalTemplate {
|
||||
|
||||
private ObjectMap instances = null;
|
||||
|
||||
public CPPFunctionTemplateSpecialization(IBinding specialized, ICPPClassType owner, ObjectMap argumentMap) {
|
||||
public CPPFunctionTemplateSpecialization(IBinding specialized, ICPPClassType owner, CPPTemplateParameterMap argumentMap) {
|
||||
super(specialized, owner, argumentMap);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,24 +6,24 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
* The result of instantiating a method template.
|
||||
*/
|
||||
public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod {
|
||||
|
||||
public CPPMethodInstance(ICPPClassType owner, ICPPMethod orig, ObjectMap argMap, IType[] args) {
|
||||
super(owner, orig, argMap, args);
|
||||
public CPPMethodInstance(ICPPClassType owner, ICPPMethod orig, CPPTemplateParameterMap tpmap, ICPPTemplateArgument[] args) {
|
||||
super(owner, orig, tpmap, args);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
@ -17,19 +17,18 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
* The specialization of a method in the context of a class-specialization.
|
||||
*/
|
||||
public class CPPMethodSpecialization extends CPPFunctionSpecialization
|
||||
implements ICPPMethod {
|
||||
|
||||
public CPPMethodSpecialization(IBinding orig, ICPPClassType owner, ObjectMap argMap ) {
|
||||
public CPPMethodSpecialization(IBinding orig, ICPPClassType owner, CPPTemplateParameterMap argMap ) {
|
||||
super(orig, owner, argMap );
|
||||
}
|
||||
|
||||
|
|
|
@ -6,27 +6,26 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
* The specialization of a method template in the context of a class specialization.
|
||||
*/
|
||||
public class CPPMethodTemplateSpecialization extends
|
||||
CPPFunctionTemplateSpecialization implements ICPPMethod {
|
||||
public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpecialization
|
||||
implements ICPPMethod {
|
||||
|
||||
public CPPMethodTemplateSpecialization(IBinding specialized,
|
||||
ICPPClassType owner, ObjectMap argumentMap) {
|
||||
super(specialized, owner, argumentMap);
|
||||
public CPPMethodTemplateSpecialization(IBinding specialized, ICPPClassType owner,
|
||||
CPPTemplateParameterMap ctmap) {
|
||||
super(specialized, owner, ctmap);
|
||||
}
|
||||
|
||||
public boolean isVirtual() {
|
||||
|
|
|
@ -15,8 +15,8 @@ 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.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
||||
/**
|
||||
* Binding for a specialization of a parameter.
|
||||
|
@ -24,8 +24,8 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
|||
public class CPPParameterSpecialization extends CPPSpecialization implements ICPPParameter {
|
||||
private IType type = null;
|
||||
|
||||
public CPPParameterSpecialization(ICPPParameter orig, IBinding owner, ObjectMap argMap) {
|
||||
super(orig, owner, argMap);
|
||||
public CPPParameterSpecialization(ICPPParameter orig, IBinding owner, CPPTemplateParameterMap tpmap) {
|
||||
super(orig, owner, tpmap);
|
||||
}
|
||||
|
||||
private ICPPParameter getParameter(){
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
|
@ -39,11 +40,11 @@ import org.eclipse.core.runtime.PlatformObject;
|
|||
public abstract class CPPSpecialization extends PlatformObject implements ICPPSpecialization, ICPPInternalBinding {
|
||||
private IBinding owner;
|
||||
private IBinding specialized;
|
||||
protected ObjectMap argumentMap;
|
||||
private CPPTemplateParameterMap argumentMap;
|
||||
protected IASTNode definition;
|
||||
private IASTNode[] declarations;
|
||||
|
||||
public CPPSpecialization(IBinding specialized, IBinding owner, ObjectMap argumentMap) {
|
||||
public CPPSpecialization(IBinding specialized, IBinding owner, CPPTemplateParameterMap argumentMap) {
|
||||
this.specialized = specialized;
|
||||
this.owner = owner;
|
||||
this.argumentMap = argumentMap;
|
||||
|
@ -51,14 +52,14 @@ public abstract class CPPSpecialization extends PlatformObject implements ICPPSp
|
|||
|
||||
public IType specializeType(IType type) throws DOMException {
|
||||
if (owner instanceof ICPPClassSpecialization) {
|
||||
return CPPTemplates.instantiateType(type, argumentMap, (ICPPClassSpecialization) owner);
|
||||
return CPPTemplates.instantiateType(type, getArgumentMap(), (ICPPClassSpecialization) owner);
|
||||
} else {
|
||||
return CPPTemplates.instantiateType(type, argumentMap, null);
|
||||
return CPPTemplates.instantiateType(type, getArgumentMap(), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IValue specializeValue(IValue value) {
|
||||
return CPPTemplates.instantiateValue(value, argumentMap);
|
||||
return CPPTemplates.instantiateValue(value, getArgumentMap());
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
|
@ -143,7 +144,12 @@ public abstract class CPPSpecialization extends PlatformObject implements ICPPSp
|
|||
return Linkage.CPP_LINKAGE;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return CPPTemplates.getArgumentMap(this, getTemplateParameterMap());
|
||||
}
|
||||
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return argumentMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
|
||||
/**
|
||||
* Implementation of template arguments, used by ast and index.
|
||||
*/
|
||||
public class CPPTemplateArgument implements ICPPTemplateArgument {
|
||||
private final IType fType;
|
||||
private final IValue fValue;
|
||||
|
||||
public CPPTemplateArgument(IValue value, IType type) {
|
||||
Assert.isNotNull(value);
|
||||
fType= type;
|
||||
fValue= value;
|
||||
}
|
||||
|
||||
public CPPTemplateArgument(IType type) {
|
||||
Assert.isNotNull(type);
|
||||
fType= type;
|
||||
fValue= null;
|
||||
}
|
||||
|
||||
public boolean isNonTypeValue() {
|
||||
return fValue != null;
|
||||
}
|
||||
|
||||
public IType getTypeValue() {
|
||||
return isNonTypeValue() ? null : fType;
|
||||
}
|
||||
|
||||
public IValue getNonTypeValue() {
|
||||
return fValue;
|
||||
}
|
||||
|
||||
public IType getTypeOfNonTypeValue() {
|
||||
return isNonTypeValue() ? fType : null;
|
||||
}
|
||||
|
||||
public boolean isSameValue(ICPPTemplateArgument arg) {
|
||||
if (fValue != null) {
|
||||
return fValue.equals(arg.getNonTypeValue()) && fType.equals(arg.getTypeOfNonTypeValue());
|
||||
}
|
||||
return fType.isSameType(arg.getTypeValue());
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
@ -18,7 +18,9 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
|
@ -28,13 +30,47 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
* Base implementation for template parameter bindings in the AST.
|
||||
*/
|
||||
public class CPPTemplateParameter extends PlatformObject implements ICPPTemplateParameter, ICPPInternalBinding {
|
||||
public abstract class CPPTemplateParameter extends PlatformObject implements ICPPTemplateParameter, ICPPInternalBinding {
|
||||
private IASTName [] declarations;
|
||||
private final int position;
|
||||
|
||||
public CPPTemplateParameter(IASTName name) {
|
||||
declarations = new IASTName[] { name };
|
||||
declarations = new IASTName[] {name};
|
||||
|
||||
int pos= -1;
|
||||
int nesting= -1;
|
||||
ICPPASTTemplateParameter tp= null;
|
||||
for (IASTNode node= name.getParent(); node != null; node= node.getParent()) {
|
||||
ICPPASTTemplateParameter[] tps= null;
|
||||
if (node instanceof ICPPASTTemplateParameter) {
|
||||
tp= (ICPPASTTemplateParameter) node;
|
||||
} else if (node instanceof ICPPASTTemplateDeclaration) {
|
||||
if (++nesting == 0) {
|
||||
tps= ((ICPPASTTemplateDeclaration) node).getTemplateParameters();
|
||||
}
|
||||
} else if (node instanceof ICPPASTTemplatedTypeTemplateParameter) {
|
||||
if (++nesting == 0) {
|
||||
tps= ((ICPPASTTemplatedTypeTemplateParameter) node).getTemplateParameters();
|
||||
}
|
||||
}
|
||||
|
||||
if (pos == -1 && tps != null && tp != null) {
|
||||
for (int i = 0; i < tps.length; i++) {
|
||||
if (tps[i] == tp) {
|
||||
pos= i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nesting < 0)
|
||||
nesting= 0;
|
||||
if (pos < 0)
|
||||
pos= 0;
|
||||
|
||||
position= (nesting << 16) + pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,6 +98,11 @@ public class CPPTemplateParameter extends PlatformObject implements ICPPTemplate
|
|||
return declarations[0].toCharArray();
|
||||
}
|
||||
|
||||
|
||||
public int getParameterPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public IASTName getPrimaryDeclaration () {
|
||||
return declarations[0];
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
|
@ -18,14 +18,16 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
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.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
* Specialization of a typedef in the context of a class-specialization.
|
||||
*/
|
||||
public class CPPTypedefSpecialization extends CPPSpecialization implements ITypedef, ITypeContainer {
|
||||
final static class RecursionResolvingBinding extends ProblemBinding {
|
||||
|
@ -40,8 +42,9 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements IType
|
|||
private IType type;
|
||||
private int fResolutionDepth;
|
||||
|
||||
public CPPTypedefSpecialization(IBinding specialized, ICPPClassType owner, ObjectMap argumentMap) {
|
||||
super(specialized, owner, argumentMap);
|
||||
public CPPTypedefSpecialization(IBinding specialized, ICPPClassType owner,
|
||||
CPPTemplateParameterMap tpmap) {
|
||||
super(specialized, owner, tpmap);
|
||||
}
|
||||
|
||||
private ITypedef getTypedef() {
|
||||
|
@ -60,10 +63,16 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements IType
|
|||
type= specializeType(getTypedef().getType());
|
||||
// A typedef pointing to itself is a sure recipe for an infinite loop -- replace
|
||||
// with a problem binding.
|
||||
if (type instanceof CPPTypedefSpecialization &&
|
||||
((CPPTypedefSpecialization) type).getSpecializedBinding().equals(getSpecializedBinding()) &&
|
||||
((CPPTypedefSpecialization) type).getArgumentMap().isEquivalent(argumentMap, IType.TYPE_MATCHER)) {
|
||||
type = new RecursionResolvingBinding(getDefinition(), getNameCharArray());
|
||||
if (type instanceof ITypedef && type instanceof ICPPSpecialization) {
|
||||
ITypedef td= (ITypedef) type;
|
||||
if (CharArrayUtils.equals(td.getNameCharArray(), getNameCharArray())) {
|
||||
IBinding owner= ((ICPPSpecialization) type).getOwner();
|
||||
if (owner instanceof IType) {
|
||||
if (((IType)owner).isSameType((ICPPClassType) getOwner())) {
|
||||
type = new RecursionResolvingBinding(getDefinition(), getNameCharArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
|
@ -45,6 +48,7 @@ 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.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
|
@ -75,10 +79,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
|
@ -114,6 +120,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameter;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateDefinition;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedefSpecialization;
|
||||
|
@ -303,12 +310,12 @@ public class CPPTemplates {
|
|||
return instance;
|
||||
|
||||
if (template instanceof ICPPClassTemplate) {
|
||||
instance = new CPPDeferredClassInstance((ICPPClassTemplate) template, arguments);
|
||||
instance = new CPPDeferredClassInstance((ICPPClassTemplate) template, convert(arguments));
|
||||
addInstance(template, arguments, instance);
|
||||
return instance;
|
||||
}
|
||||
if (template instanceof ICPPFunctionTemplate) {
|
||||
instance = new CPPDeferredFunctionInstance((ICPPFunctionTemplate) template, arguments);
|
||||
instance = new CPPDeferredFunctionInstance((ICPPFunctionTemplate) template, convert(arguments));
|
||||
addInstance(template, arguments, instance);
|
||||
return instance;
|
||||
}
|
||||
|
@ -590,7 +597,7 @@ public class CPPTemplates {
|
|||
inst= getInstance(template, args);
|
||||
if (inst == null) {
|
||||
IBinding owner= binding.getOwner();
|
||||
inst= new CPPClassInstance(owner, template, argMap, args);
|
||||
inst= new CPPClassInstance(owner, template, convert(argMap), convert(args));
|
||||
addInstance(template, args, inst);
|
||||
}
|
||||
if (inst instanceof ICPPInternalBinding) {
|
||||
|
@ -833,15 +840,15 @@ public class CPPTemplates {
|
|||
|
||||
ICPPTemplateInstance instance = null;
|
||||
if (template instanceof ICPPClassType) {
|
||||
instance = new CPPClassInstance(owner, (ICPPClassType) template, argMap, args);
|
||||
instance = new CPPClassInstance(owner, (ICPPClassType) template, convert(argMap), convert(args));
|
||||
} else if (owner instanceof ICPPClassType && template instanceof ICPPMethod) {
|
||||
if (template instanceof ICPPConstructor) {
|
||||
instance = new CPPConstructorInstance((ICPPClassType) owner, (ICPPConstructor) template, argMap, args);
|
||||
instance = new CPPConstructorInstance((ICPPClassType) owner, (ICPPConstructor) template, convert(argMap), convert(args));
|
||||
} else {
|
||||
instance = new CPPMethodInstance((ICPPClassType) owner, (ICPPMethod) template, argMap, args);
|
||||
instance = new CPPMethodInstance((ICPPClassType) owner, (ICPPMethod) template, convert(argMap), convert(args));
|
||||
}
|
||||
} else if (template instanceof ICPPFunction) {
|
||||
instance = new CPPFunctionInstance(owner, (ICPPFunction) template, argMap, args);
|
||||
instance = new CPPFunctionInstance(owner, (ICPPFunction) template, convert(argMap), convert(args));
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
@ -854,26 +861,26 @@ public class CPPTemplates {
|
|||
|
||||
ICPPSpecialization spec = null;
|
||||
if (decl instanceof ICPPClassTemplate) {
|
||||
spec = new CPPClassTemplateSpecialization((ICPPClassTemplate) decl, owner, argMap);
|
||||
spec = new CPPClassTemplateSpecialization((ICPPClassTemplate) decl, owner, convert(argMap));
|
||||
} else if (decl instanceof ICPPClassType) {
|
||||
spec = new CPPClassSpecialization((ICPPClassType) decl, owner, argMap);
|
||||
spec = new CPPClassSpecialization((ICPPClassType) decl, owner, convert(argMap));
|
||||
} else if (decl instanceof ICPPField) {
|
||||
spec = new CPPFieldSpecialization(decl, owner, argMap);
|
||||
spec = new CPPFieldSpecialization(decl, owner, convert(argMap));
|
||||
} else if (decl instanceof ICPPFunctionTemplate) {
|
||||
if (decl instanceof ICPPConstructor)
|
||||
spec = new CPPConstructorTemplateSpecialization(decl, owner, argMap);
|
||||
spec = new CPPConstructorTemplateSpecialization(decl, owner, convert(argMap));
|
||||
else if (decl instanceof ICPPMethod)
|
||||
spec = new CPPMethodTemplateSpecialization(decl, owner, argMap);
|
||||
spec = new CPPMethodTemplateSpecialization(decl, owner, convert(argMap));
|
||||
else
|
||||
spec = new CPPFunctionTemplateSpecialization(decl, owner, argMap);
|
||||
spec = new CPPFunctionTemplateSpecialization(decl, owner, convert(argMap));
|
||||
} else if (decl instanceof ICPPConstructor) {
|
||||
spec = new CPPConstructorSpecialization(decl, owner, argMap);
|
||||
spec = new CPPConstructorSpecialization(decl, owner, convert(argMap));
|
||||
} else if (decl instanceof ICPPMethod) {
|
||||
spec = new CPPMethodSpecialization(decl, owner, argMap);
|
||||
spec = new CPPMethodSpecialization(decl, owner, convert(argMap));
|
||||
} else if (decl instanceof ICPPFunction) {
|
||||
spec = new CPPFunctionSpecialization(decl, owner, argMap);
|
||||
spec = new CPPFunctionSpecialization(decl, owner, convert(argMap));
|
||||
} else if (decl instanceof ITypedef) {
|
||||
spec = new CPPTypedefSpecialization(decl, owner, argMap);
|
||||
spec = new CPPTypedefSpecialization(decl, owner, convert(argMap));
|
||||
}
|
||||
return spec;
|
||||
}
|
||||
|
@ -881,7 +888,7 @@ public class CPPTemplates {
|
|||
public static IValue instantiateValue(IValue value, ObjectMap argMap) {
|
||||
if (value == null)
|
||||
return null;
|
||||
// mstodo instantiate values
|
||||
// mstodo- instantiate values
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -1263,7 +1270,9 @@ public class CPPTemplates {
|
|||
* @param argA may be null
|
||||
* @param argB may be null
|
||||
* @return whether the two specified template arguments are the same
|
||||
* @deprecated use {@link ICPPTemplateArgument#isSameValue(ICPPTemplateArgument)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final boolean isSameTemplateArgument(IType argA, IType argB) {
|
||||
if (argA == argB)
|
||||
return true;
|
||||
|
@ -1705,7 +1714,7 @@ public class CPPTemplates {
|
|||
CPPASTLiteralExpression exp = new CPPASTLiteralExpression();
|
||||
exp.setValue(String.valueOf(i));
|
||||
CPPBasicType temp = (CPPBasicType) t.clone();
|
||||
temp.setFromExpression(exp); // mstodo is that necessary??
|
||||
temp.setFromExpression(exp); // mstodo- is that necessary??
|
||||
args[i] = temp;
|
||||
}
|
||||
} else {
|
||||
|
@ -2076,4 +2085,119 @@ public class CPPTemplates {
|
|||
}
|
||||
return dci;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
for (int i = 0; i < m1.length; i++) {
|
||||
if (!m1[i].isSameValue(m2[i])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// backwards compatibility, mstodo remove
|
||||
if (!m1[i].isNonTypeValue() && !m2[i].isNonTypeValue()) {
|
||||
if (!isSameTemplateArgument(m1[i].getTypeValue(), m2[i].getTypeValue())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated for backwards compatibility, only.
|
||||
*/
|
||||
@Deprecated
|
||||
public static IType[] getArguments(ICPPTemplateArgument[] arguments) {
|
||||
IType[] types= new IType[arguments.length];
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
final ICPPTemplateArgument arg = arguments[i];
|
||||
if (arg.isNonTypeValue()) {
|
||||
types[i]= arg.getTypeOfNonTypeValue();
|
||||
} else {
|
||||
types[i]= arg.getTypeValue();
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated for backwards compatibility, only.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ObjectMap getArgumentMap(IBinding b, ICPPTemplateParameterMap tpmap) {
|
||||
// backwards compatibility
|
||||
Integer[] keys= tpmap.getAllParameterPositions();
|
||||
if (keys.length == 0)
|
||||
return ObjectMap.EMPTY_MAP;
|
||||
|
||||
try {
|
||||
List<ICPPTemplateDefinition> defs= new ArrayList<ICPPTemplateDefinition>();
|
||||
IBinding owner= b;
|
||||
while (owner != null) {
|
||||
if (owner instanceof ICPPTemplateDefinition) {
|
||||
defs.add((ICPPTemplateDefinition) owner);
|
||||
} else if (owner instanceof ICPPTemplateInstance) {
|
||||
defs.add(((ICPPTemplateInstance) owner).getTemplateDefinition());
|
||||
}
|
||||
owner= owner.getOwner();
|
||||
}
|
||||
Collections.reverse(defs);
|
||||
|
||||
ObjectMap result= new ObjectMap(keys.length);
|
||||
for (int key: keys) {
|
||||
int nestingLevel= key >> 16;
|
||||
int numParam= key & 0xffff;
|
||||
|
||||
if (0 <= numParam && 0 <= nestingLevel && nestingLevel < defs.size()) {
|
||||
ICPPTemplateDefinition tdef= defs.get(nestingLevel);
|
||||
ICPPTemplateParameter[] tps= tdef.getTemplateParameters();
|
||||
if (numParam < tps.length) {
|
||||
ICPPTemplateArgument arg= tpmap.getArgument(key);
|
||||
IType type= arg.isNonTypeValue() ? arg.getTypeOfNonTypeValue() : arg.getTypeValue();
|
||||
result.put(tps[numParam], type);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return ObjectMap.EMPTY_MAP;
|
||||
}
|
||||
|
||||
/**
|
||||
* mstodo for intermediate use only.
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public static CPPTemplateParameterMap convert(ObjectMap argMap) {
|
||||
CPPTemplateParameterMap tpmap= new CPPTemplateParameterMap();
|
||||
Object[] tps= argMap.keyArray();
|
||||
for (Object tp : tps) {
|
||||
if (tp instanceof ICPPTemplateParameter) {
|
||||
IType t= (IType) argMap.get(tp);
|
||||
tpmap.put((ICPPTemplateParameter) tp, new CPPTemplateArgument(t));
|
||||
}
|
||||
}
|
||||
return tpmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* mstodo for intermediate use only.
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public static ICPPTemplateArgument[] convert(IType[] args) {
|
||||
ICPPTemplateArgument[] targs= new ICPPTemplateArgument[args.length];
|
||||
for (int i = 0; i < targs.length; i++) {
|
||||
targs[i]= new CPPTemplateArgument(args[i]);
|
||||
}
|
||||
return targs;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1586,7 +1586,7 @@ public class CPPVisitor {
|
|||
|
||||
// Currently, CPPBasicType objects are also used to represent non-type template argument
|
||||
// values. We must ensure the initializer expression is attached to the type if available.
|
||||
// mstodo can be removed
|
||||
// mstodo- can be removed
|
||||
if (declarator.getInitializer() instanceof IASTInitializerExpression) {
|
||||
IType utype= getUltimateTypeUptoPointers(baseType);
|
||||
if (utype instanceof CPPBasicType) {
|
||||
|
@ -2385,7 +2385,7 @@ public class CPPVisitor {
|
|||
/**
|
||||
* @param e1
|
||||
* @return the first non id-expression by following values assigned to basic types.
|
||||
* @deprecated mstodo remove
|
||||
* @deprecated mstodo- remove
|
||||
*/
|
||||
@Deprecated
|
||||
public static final IASTExpression reverseConstantPropagationLookup(IASTExpression e1) {
|
||||
|
|
|
@ -742,7 +742,7 @@ public class Conversions {
|
|||
if (src instanceof CPPBasicType && trg instanceof IPointerType) {
|
||||
//4.10-1 an integral constant expression of integer type that evaluates to 0 can be converted to a pointer type
|
||||
IASTExpression exp = ((CPPBasicType)src).getCreatedFromExpression();
|
||||
// mstodo improve by checking evaluation
|
||||
// mstodo- improve by checking evaluation
|
||||
if (exp instanceof IASTLiteralExpression &&
|
||||
((IASTLiteralExpression)exp).getKind() == IASTLiteralExpression.lk_integer_constant) {
|
||||
try {
|
||||
|
|
|
@ -13,8 +13,10 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPClassInstance extends CompositeCPPClassSpecialization implements ICPPTemplateInstance {
|
||||
|
@ -23,11 +25,21 @@ public class CompositeCPPClassInstance extends CompositeCPPClassSpecialization i
|
|||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
public IType[] getArguments() {
|
||||
return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||
return TemplateInstanceUtil.getTemplateDefinition(cf, rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return TemplateInstanceUtil.getTemplateArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return TemplateInstanceUtil.getTemplateParameterMap(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,12 +16,15 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope;
|
||||
|
@ -44,13 +47,20 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
return cf.getCompositeScope((IIndexScope) ((ICPPClassType) rbinding).getCompositeScope());
|
||||
}
|
||||
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
|
||||
public ICPPClassType getSpecializedBinding() {
|
||||
return (ICPPClassType) TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
try {
|
||||
IBinding owner= getOwner();
|
||||
if (owner instanceof ICPPSpecialization) {
|
||||
return ((ICPPSpecialization) owner).getTemplateParameterMap();
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return CPPTemplateParameterMap.EMPTY;
|
||||
}
|
||||
|
||||
public IBinding specializeMember(IBinding original) {
|
||||
if (specializationMap == null) {
|
||||
|
@ -175,4 +185,9 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
public ICPPMethod[] getMethods() throws DOMException {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,15 +7,19 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
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.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
@ -32,8 +36,36 @@ public class CompositeCPPClassTemplatePartialSpecialization extends CompositeCPP
|
|||
return (ICPPClassTemplate) cf.getCompositeBinding((IIndexFragmentBinding)preresult);
|
||||
}
|
||||
|
||||
public IType[] getArguments() { return TemplateInstanceUtil.getArguments(cf, (ICPPClassTemplatePartialSpecialization) rbinding); }
|
||||
public ObjectMap getArgumentMap() { return TemplateInstanceUtil.getArgumentMap(cf, rbinding); }
|
||||
public IBinding getSpecializedBinding() { return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding); }
|
||||
public int getSignatureHash() throws CoreException { return ((IPDOMOverloader) rbinding).getSignatureHash(); }
|
||||
public IBinding getSpecializedBinding() {
|
||||
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
|
||||
public int getSignatureHash() throws CoreException {
|
||||
return ((IPDOMOverloader) rbinding).getSignatureHash();
|
||||
}
|
||||
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
try {
|
||||
IBinding owner= getOwner();
|
||||
if (owner instanceof ICPPSpecialization) {
|
||||
return ((ICPPSpecialization) owner).getTemplateParameterMap();
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return CPPTemplateParameterMap.EMPTY;
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return TemplateInstanceUtil.getTemplateArguments(cf, (ICPPClassTemplatePartialSpecialization) rbinding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return TemplateInstanceUtil.getArguments(cf, (ICPPClassTemplatePartialSpecialization) rbinding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,10 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
|
@ -42,10 +44,14 @@ public class CompositeCPPDeferredClassInstance extends CompositeCPPClassType imp
|
|||
public ICPPConstructor[] getConstructors() {
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
}
|
||||
|
||||
public IType[] getArguments() { return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding); }
|
||||
public ObjectMap getArgumentMap() { return TemplateInstanceUtil.getArgumentMap(cf, rbinding); }
|
||||
public IBinding getSpecializedBinding() { return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding); }
|
||||
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return TemplateInstanceUtil.getTemplateParameterMap(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
|
||||
public IASTName getUnknownName() {
|
||||
return ((ICPPDeferredClassInstance) rbinding).getUnknownName();
|
||||
|
@ -61,4 +67,19 @@ public class CompositeCPPDeferredClassInstance extends CompositeCPPClassType imp
|
|||
public ICPPClassTemplate getClassTemplate() {
|
||||
return (ICPPClassTemplate) cf.getCompositeBinding((IIndexFragmentBinding) ((ICPPDeferredClassInstance) rbinding).getClassTemplate());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return TemplateInstanceUtil.getTemplateArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2008 Symbian 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -14,8 +15,10 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
|
@ -26,8 +29,29 @@ public class CompositeCPPDeferredFunctionInstance extends CompositeCPPFunction
|
|||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
public IType[] getArguments() { return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding); }
|
||||
public ICPPTemplateDefinition getTemplateDefinition() { return TemplateInstanceUtil.getTemplateDefinition(cf, rbinding); }
|
||||
public ObjectMap getArgumentMap() { return TemplateInstanceUtil.getArgumentMap(cf, rbinding); }
|
||||
public IBinding getSpecializedBinding() { return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding); }
|
||||
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||
return TemplateInstanceUtil.getTemplateDefinition(cf, rbinding);
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return TemplateInstanceUtil.getTemplateArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return TemplateInstanceUtil.getTemplateParameterMap(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2008 Symbian 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
|
@ -22,12 +26,23 @@ public class CompositeCPPFieldSpecialization extends CompositeCPPField implement
|
|||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
|
||||
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
try {
|
||||
IBinding owner= getOwner();
|
||||
if (owner instanceof ICPPSpecialization) {
|
||||
return ((ICPPSpecialization) owner).getTemplateParameterMap();
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return CPPTemplateParameterMap.EMPTY;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2008 Symbian 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -14,8 +15,10 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
|
@ -25,8 +28,29 @@ public class CompositeCPPFunctionInstance extends CompositeCPPFunction implement
|
|||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
public IType[] getArguments() { return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding); }
|
||||
public ICPPTemplateDefinition getTemplateDefinition() { return TemplateInstanceUtil.getTemplateDefinition(cf, rbinding); }
|
||||
public ObjectMap getArgumentMap() { return TemplateInstanceUtil.getArgumentMap(cf, rbinding); }
|
||||
public IBinding getSpecializedBinding() { return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding); }
|
||||
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||
return TemplateInstanceUtil.getTemplateDefinition(cf, rbinding);
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return TemplateInstanceUtil.getTemplateArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return TemplateInstanceUtil.getTemplateParameterMap(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2008 Symbian 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
|
||||
|
@ -7,14 +7,17 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
|
@ -24,6 +27,21 @@ public class CompositeCPPFunctionSpecialization extends CompositeCPPFunction imp
|
|||
super(cf, ft);
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
try {
|
||||
IBinding owner= getOwner();
|
||||
if (owner instanceof ICPPSpecialization) {
|
||||
return ((ICPPSpecialization) owner).getTemplateParameterMap();
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return CPPTemplateParameterMap.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
|
@ -35,11 +53,8 @@ public class CompositeCPPFunctionSpecialization extends CompositeCPPFunction imp
|
|||
return result.toString();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2008 Symbian 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
@ -22,12 +26,23 @@ public class CompositeCPPParameterSpecialization extends CompositeCPPParameter i
|
|||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
try {
|
||||
IBinding owner= getOwner();
|
||||
if (owner instanceof ICPPSpecialization) {
|
||||
return ((ICPPSpecialization) owner).getTemplateParameterMap();
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return CPPTemplateParameterMap.EMPTY;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPTemplateNonTypeParameter extends CompositeCPPVariable implements ICPPTemplateNonTypeParameter {
|
||||
|
@ -32,4 +34,8 @@ public class CompositeCPPTemplateNonTypeParameter extends CompositeCPPVariable i
|
|||
public IASTExpression getDefault() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getParameterPosition() {
|
||||
return ((ICPPTemplateParameter)rbinding).getParameterPosition();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -14,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
|
@ -34,6 +36,10 @@ public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding
|
|||
return cf.getCompositeType(preresult);
|
||||
}
|
||||
|
||||
public int getParameterPosition() {
|
||||
return ((ICPPTemplateParameter)rbinding).getParameterPosition();
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
return ((IType)rbinding).isSameType(type);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2008 Symbian 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
|
@ -21,11 +25,23 @@ class CompositeCPPTypedefSpecialization extends CompositeCPPTypedef implements I
|
|||
super(cf, delegate);
|
||||
}
|
||||
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
try {
|
||||
IBinding owner= getOwner();
|
||||
if (owner instanceof ICPPSpecialization) {
|
||||
return ((ICPPSpecialization) owner).getTemplateParameterMap();
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return CPPTemplateParameterMap.EMPTY;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -15,12 +16,16 @@ 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.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
@ -29,6 +34,62 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
|||
* For implementation re-use in the absence of multiple inheritance
|
||||
*/
|
||||
public class TemplateInstanceUtil {
|
||||
public static ICPPTemplateParameterMap getTemplateParameterMap(ICompositesFactory cf, ICPPTemplateInstance rbinding) {
|
||||
ICPPTemplateParameterMap preresult= rbinding.getTemplateParameterMap();
|
||||
CPPTemplateParameterMap result= new CPPTemplateParameterMap();
|
||||
Integer[] keys= preresult.getAllParameterPositions();
|
||||
|
||||
try {
|
||||
for(int i = 0; i < keys.length; i++) {
|
||||
ICPPTemplateArgument arg= preresult.getArgument(keys[i]);
|
||||
result.put(keys[i], convert(cf, arg));
|
||||
}
|
||||
} catch(DOMException de) {
|
||||
CCorePlugin.log(de);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ICPPTemplateArgument[] getTemplateArguments(ICompositesFactory cf, ICPPTemplateInstance rbinding) {
|
||||
return convert(cf, rbinding.getTemplateArguments());
|
||||
}
|
||||
|
||||
public static ICPPTemplateArgument[] getTemplateArguments(ICompositesFactory cf, ICPPClassTemplatePartialSpecialization rbinding) {
|
||||
return convert(cf, rbinding.getTemplateArguments());
|
||||
}
|
||||
|
||||
public static IBinding getSpecializedBinding(ICompositesFactory cf, IIndexBinding rbinding) {
|
||||
IBinding preresult= ((ICPPSpecialization) rbinding).getSpecializedBinding();
|
||||
return cf.getCompositeBinding((IIndexFragmentBinding) preresult);
|
||||
}
|
||||
|
||||
public static ICPPTemplateDefinition getTemplateDefinition(ICompositesFactory cf, IIndexBinding rbinding) {
|
||||
ICPPTemplateDefinition preresult= ((ICPPTemplateInstance)rbinding).getTemplateDefinition();
|
||||
return (ICPPTemplateDefinition) cf.getCompositeBinding((IIndexFragmentBinding)preresult);
|
||||
}
|
||||
|
||||
public static ICPPTemplateArgument[] convert(ICompositesFactory cf, ICPPTemplateArgument[] arguments) {
|
||||
try {
|
||||
ICPPTemplateArgument[] result= new ICPPTemplateArgument[arguments.length];
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
result[i]= convert(cf, arguments[i]);
|
||||
}
|
||||
return result;
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
}
|
||||
|
||||
static ICPPTemplateArgument convert(ICompositesFactory cf, ICPPTemplateArgument arg) throws DOMException {
|
||||
if (arg.isNonTypeValue()) {
|
||||
return arg;
|
||||
}
|
||||
IType t= cf.getCompositeType((IIndexType) arg.getTypeValue());
|
||||
return new CPPTemplateArgument(t);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static ObjectMap getArgumentMap(ICompositesFactory cf, IIndexBinding rbinding) {
|
||||
ICPPSpecialization specn= (ICPPSpecialization) rbinding;
|
||||
IBinding specd= ((CPPCompositesFactory)cf).findOneBinding(specn.getSpecializedBinding());
|
||||
|
@ -57,17 +118,13 @@ public class TemplateInstanceUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static IBinding getSpecializedBinding(ICompositesFactory cf, IIndexBinding rbinding) {
|
||||
IBinding preresult= ((ICPPSpecialization)rbinding).getSpecializedBinding();
|
||||
return cf.getCompositeBinding((IIndexFragmentBinding)preresult);
|
||||
}
|
||||
|
||||
|
||||
public static IType[] getArguments(ICompositesFactory cf, ICPPTemplateInstance rbinding) {
|
||||
@Deprecated
|
||||
public static IType[] getArguments(ICompositesFactory cf, ICPPTemplateInstance rbinding) {
|
||||
return getArguments(cf, rbinding.getArguments());
|
||||
}
|
||||
|
||||
public static IType[] getArguments(ICompositesFactory cf, ICPPClassTemplatePartialSpecialization rbinding) {
|
||||
@Deprecated
|
||||
public static IType[] getArguments(ICompositesFactory cf, ICPPClassTemplatePartialSpecialization rbinding) {
|
||||
try {
|
||||
return getArguments(cf, rbinding.getArguments());
|
||||
} catch(DOMException de) {
|
||||
|
@ -76,7 +133,8 @@ public class TemplateInstanceUtil {
|
|||
}
|
||||
}
|
||||
|
||||
private static IType[] getArguments(ICompositesFactory cf, IType[] result) {
|
||||
@Deprecated
|
||||
private static IType[] getArguments(ICompositesFactory cf, IType[] result) {
|
||||
try {
|
||||
for(int i=0; i<result.length; i++) {
|
||||
result[i] = cf.getCompositeType((IIndexType)result[i]);
|
||||
|
@ -86,9 +144,4 @@ public class TemplateInstanceUtil {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ICPPTemplateDefinition getTemplateDefinition(ICompositesFactory cf, IIndexBinding rbinding) {
|
||||
ICPPTemplateDefinition preresult= ((ICPPTemplateInstance)rbinding).getTemplateDefinition();
|
||||
return (ICPPTemplateDefinition) cf.getCompositeBinding((IIndexFragmentBinding)preresult);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2008 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
@ -28,8 +27,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* Models integral c-types.
|
||||
*/
|
||||
class PDOMCBasicType extends PDOMNode implements ICBasicType, IIndexType {
|
||||
|
||||
|
@ -93,9 +91,8 @@ class PDOMCBasicType extends PDOMNode implements ICBasicType, IIndexType {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IASTExpression getValue() throws DOMException {
|
||||
// Returning null for now, not sure what needs to be here if anything
|
||||
// Values only seem to be used at type resolution time.
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
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.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IString;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Collects methods to store an argument list in the database
|
||||
*/
|
||||
public class PDOMCPPArgumentList {
|
||||
/**
|
||||
* Stores the given template arguments in the database.
|
||||
* @return the record by which the arguments can be referenced.
|
||||
*/
|
||||
public static int putArguments(PDOMNode parent, ICPPTemplateArgument[] templateArguments) throws CoreException {
|
||||
final PDOMLinkage linkage= parent.getLinkage();
|
||||
final Database db= linkage.getPDOM().getDB();
|
||||
final short len= (short) Math.min(templateArguments.length, (Database.MAX_MALLOC_SIZE-2)/8);
|
||||
final int block= db.malloc(2+8*len);
|
||||
int p= block;
|
||||
|
||||
db.putShort(p, len); p+=2;
|
||||
for (int i=0; i<len; i++, p+=8) {
|
||||
final ICPPTemplateArgument arg = templateArguments[i];
|
||||
final boolean isNonType= arg.isNonTypeValue();
|
||||
if (isNonType) {
|
||||
final PDOMNode type= linkage.addType(parent, arg.getTypeOfNonTypeValue());
|
||||
// type can be null, if it is a local type
|
||||
db.putInt(p, type == null ? 0 : type.getRecord());
|
||||
final IString s= db.newString(arg.getNonTypeValue().getCanonicalRepresentation());
|
||||
db.putInt(p+4, s.getRecord());
|
||||
} else {
|
||||
final PDOMNode type= linkage.addType(parent, arg.getTypeValue());
|
||||
// type can be null, if it is a local type.
|
||||
db.putInt(p, type == null ? 0 : type.getRecord());
|
||||
}
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restores an array of template arguments from the database.
|
||||
*/
|
||||
public static void clearArguments(PDOMNode parent, int rec) throws CoreException {
|
||||
final PDOMLinkage linkage= parent.getLinkage();
|
||||
final Database db= linkage.getPDOM().getDB();
|
||||
final short len= db.getShort(rec);
|
||||
|
||||
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/8);
|
||||
rec+=2;
|
||||
for (int i=0; i<len; i++) {
|
||||
rec++;
|
||||
final int typeRec= db.getInt(rec);
|
||||
if (typeRec != 0) {
|
||||
final IType t= (IType) linkage.getNode(typeRec);
|
||||
linkage.deleteType(t, parent.getRecord());
|
||||
}
|
||||
final int nonTypeValueRec= db.getInt(rec+4);
|
||||
if (nonTypeValueRec != 0) {
|
||||
db.getString(nonTypeValueRec).delete();
|
||||
}
|
||||
rec+= 8;
|
||||
}
|
||||
db.free(rec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores an array of template arguments from the database.
|
||||
*/
|
||||
public static ICPPTemplateArgument[] getArguments(PDOMNode parent, int rec) throws CoreException {
|
||||
final PDOMLinkage linkage= parent.getLinkage();
|
||||
final Database db= linkage.getPDOM().getDB();
|
||||
final short len= db.getShort(rec);
|
||||
|
||||
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/8);
|
||||
if (len == 0) {
|
||||
return ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
}
|
||||
|
||||
rec+=2;
|
||||
ICPPTemplateArgument[] result= new ICPPTemplateArgument[len];
|
||||
for (int i=0; i<len; i++) {
|
||||
final int typeRec= db.getInt(rec);
|
||||
final IType type= typeRec == 0 ? new CPPBasicType(-1,0) : (IType) linkage.getNode(typeRec);
|
||||
final int nonTypeValRec= db.getInt(rec+4);
|
||||
if (nonTypeValRec != 0) {
|
||||
final IString s= db.getString(nonTypeValRec);
|
||||
result[i]= new CPPTemplateArgument(Value.fromCanonicalRepresentation(s.getString()), type);
|
||||
} else {
|
||||
result[i]= new CPPTemplateArgument(type);
|
||||
}
|
||||
rec+= 8;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -1,16 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2008 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
@ -34,8 +33,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* Models built-in c++ types.
|
||||
*/
|
||||
class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
|
||||
|
||||
|
@ -123,7 +121,9 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IASTExpression getValue() throws DOMException {
|
||||
// mstodo remove implementation
|
||||
try {
|
||||
/*
|
||||
* If the expression was an integral we can emulate what would
|
||||
|
|
|
@ -6,35 +6,30 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
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.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
* Result of instantiating a class template.
|
||||
*/
|
||||
class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTemplateInstance {
|
||||
|
||||
|
@ -49,51 +44,15 @@ class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTem
|
|||
public PDOMCPPClassInstance(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMBinding orig)
|
||||
throws CoreException {
|
||||
super(pdom, parent, classType, orig);
|
||||
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||
IType[] args = ((ICPPTemplateInstance) classType).getArguments();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
PDOMNode typeNode = getLinkageImpl().addType(this, args[i]);
|
||||
if (typeNode != null)
|
||||
list.addMember(typeNode);
|
||||
}
|
||||
final ICPPTemplateInstance asInstance= (ICPPTemplateInstance) classType;
|
||||
final int argListRec= PDOMCPPArgumentList.putArguments(this, asInstance.getTemplateArguments());
|
||||
pdom.getDB().putInt(record+ARGUMENTS, argListRec);
|
||||
}
|
||||
|
||||
public PDOMCPPClassInstance(PDOM pdom, int bindingRecord) {
|
||||
super(pdom, bindingRecord);
|
||||
}
|
||||
|
||||
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||
return (ICPPTemplateDefinition) getSpecializedBinding();
|
||||
}
|
||||
|
||||
private static class TemplateArgumentCollector implements IPDOMVisitor {
|
||||
private List<IType> args = new ArrayList<IType>();
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof IType)
|
||||
args.add((IType) node);
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public IType[] getTemplateArguments() {
|
||||
return args.toArray(new IType[args.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
public IType[] getArguments() {
|
||||
try {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||
TemplateArgumentCollector visitor = new TemplateArgumentCollector();
|
||||
list.accept(visitor);
|
||||
|
||||
return visitor.getTemplateArguments();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return IType.EMPTY_TYPE_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
|
@ -103,6 +62,20 @@ class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTem
|
|||
public int getNodeType() {
|
||||
return IIndexCPPBindingConstants.CPP_CLASS_INSTANCE;
|
||||
}
|
||||
|
||||
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||
return (ICPPTemplateDefinition) getSpecializedBinding();
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
try {
|
||||
final int rec= getPDOM().getDB().getInt(record+ARGUMENTS);
|
||||
return PDOMCPPArgumentList.getArguments(this, rec);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType type) {
|
||||
|
@ -129,15 +102,11 @@ class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTem
|
|||
if (!orig1.isSameType(orig2))
|
||||
return false;
|
||||
|
||||
IType[] args1= getArguments();
|
||||
IType[] args2= ((ICPPTemplateInstance) type).getArguments();
|
||||
if (args1.length != args2.length)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < args1.length; i++) {
|
||||
if (!CPPTemplates.isSameTemplateArgument(args1[i], args2[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return CPPTemplates.haveSameArguments(this, (ICPPTemplateInstance) type);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,24 +6,22 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
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.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
|
@ -31,7 +29,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
|||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
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.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
|
@ -39,10 +37,10 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
* Partial specialization of a class template for the index.
|
||||
*/
|
||||
class PDOMCPPClassTemplatePartialSpecialization extends
|
||||
PDOMCPPClassTemplate implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization, IPDOMOverloader {
|
||||
class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
|
||||
implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization, IPDOMOverloader {
|
||||
|
||||
private static final int ARGUMENTS = PDOMCPPClassTemplate.RECORD_SIZE + 0;
|
||||
private static final int SIGNATURE_HASH = PDOMCPPClassTemplate.RECORD_SIZE + 4;
|
||||
|
@ -111,40 +109,31 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
|||
return getPrimaryClassTemplate();
|
||||
}
|
||||
|
||||
public void addArgument(IType type) throws CoreException {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||
PDOMNode typeNode = getLinkageImpl().addType(this, type);
|
||||
if (typeNode != null)
|
||||
list.addMember(typeNode);
|
||||
}
|
||||
|
||||
private static class TemplateArgumentCollector implements IPDOMVisitor {
|
||||
private List<IType> args = new ArrayList<IType>();
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof IType)
|
||||
args.add((IType) node);
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public IType[] getTemplateArguments() {
|
||||
return args.toArray(new IType[args.size()]);
|
||||
public void setArguments(ICPPTemplateArgument[] templateArguments) throws CoreException {
|
||||
final Database db = getPDOM().getDB();
|
||||
int oldRec = db.getInt(record+ARGUMENTS);
|
||||
int rec= PDOMCPPArgumentList.putArguments(this, templateArguments);
|
||||
db.putInt(record+ARGUMENTS, rec);
|
||||
if (oldRec != 0) {
|
||||
PDOMCPPArgumentList.clearArguments(this, oldRec);
|
||||
}
|
||||
}
|
||||
|
||||
public IType[] getArguments() {
|
||||
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
try {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||
TemplateArgumentCollector visitor = new TemplateArgumentCollector();
|
||||
list.accept(visitor);
|
||||
|
||||
return visitor.getTemplateArguments();
|
||||
final int rec= getPDOM().getDB().getInt(record+ARGUMENTS);
|
||||
return PDOMCPPArgumentList.getArguments(this, rec);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new IType[0];
|
||||
return ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int pdomCompareTo(PDOMBinding other) {
|
||||
int cmp = super.pdomCompareTo(other);
|
||||
|
@ -164,43 +153,19 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
|||
}
|
||||
return cmp;
|
||||
}
|
||||
|
||||
private static class NodeCollector implements IPDOMVisitor {
|
||||
private List<IPDOMNode> nodes = new ArrayList<IPDOMNode>();
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
nodes.add(node);
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public IPDOMNode[] getNodes() {
|
||||
return nodes.toArray(new IPDOMNode[nodes.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectMap getArgumentMap() {
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
CPPTemplateParameterMap result= new CPPTemplateParameterMap();
|
||||
try {
|
||||
PDOMNodeLinkedList argList = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||
ICPPTemplateParameter[] params;
|
||||
try {
|
||||
params = getPrimaryClassTemplate().getTemplateParameters();
|
||||
} catch (DOMException e) {
|
||||
return ObjectMap.EMPTY_MAP;
|
||||
ICPPTemplateParameter[] params = getPrimaryClassTemplate().getTemplateParameters();
|
||||
ICPPTemplateArgument[] args= getTemplateArguments();
|
||||
int len= Math.min(params.length, args.length);
|
||||
for (int i = 0; i < len; i++) {
|
||||
result.put(params[i], args[i]);
|
||||
}
|
||||
NodeCollector argVisitor = new NodeCollector();
|
||||
argList.accept(argVisitor);
|
||||
IPDOMNode[] argNodes = argVisitor.getNodes();
|
||||
|
||||
ObjectMap map = new ObjectMap(params.length);
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
map.put(params[i], argNodes[i]);
|
||||
}
|
||||
|
||||
return map;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return null;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -216,24 +181,44 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
|||
}
|
||||
}
|
||||
|
||||
if( type instanceof ICPPSpecialization ) {
|
||||
ICPPClassType ct1= (ICPPClassType) getSpecializedBinding();
|
||||
ICPPClassType ct2= (ICPPClassType) ((ICPPSpecialization)type).getSpecializedBinding();
|
||||
if(!ct1.isSameType(ct2))
|
||||
return false;
|
||||
|
||||
ObjectMap m1 = getArgumentMap(), m2 = ((ICPPSpecialization)type).getArgumentMap();
|
||||
if( m1 == null || m2 == null || m1.size() != m2.size())
|
||||
return false;
|
||||
for( int i = 0; i < m1.size(); i++ ){
|
||||
IType t1 = (IType) m1.getAt( i );
|
||||
IType t2 = (IType) m2.getAt( i );
|
||||
if(!CPPTemplates.isSameTemplateArgument(t1, t2 ))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
if (!(type instanceof ICPPClassTemplatePartialSpecialization)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ICPPClassTemplatePartialSpecialization rhs = (ICPPClassTemplatePartialSpecialization)type;
|
||||
try {
|
||||
ICPPClassType ct1= getPrimaryClassTemplate();
|
||||
ICPPClassType ct2= rhs.getPrimaryClassTemplate();
|
||||
if(!ct1.isSameType(ct2))
|
||||
return false;
|
||||
|
||||
ICPPTemplateArgument[] args1= getTemplateArguments();
|
||||
ICPPTemplateArgument[] args2= rhs.getTemplateArguments();
|
||||
if (args1.length != args2.length)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < args2.length; i++) {
|
||||
if (args1[i].isSameValue(args2[i]))
|
||||
return false;
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
try {
|
||||
ICPPTemplateParameter[] params = getPrimaryClassTemplate().getTemplateParameters();
|
||||
ICPPTemplateArgument[] args= getTemplateArguments();
|
||||
int len= Math.min(params.length, args.length);
|
||||
ObjectMap result= new ObjectMap(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
result.put(params[i], args[i]);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return ObjectMap.EMPTY_MAP;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,16 +6,12 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
|
@ -31,8 +27,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
@ -46,7 +42,8 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
* Deferred class instances collect information about an instantiation until it can be
|
||||
* carried out.
|
||||
*/
|
||||
class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPPDeferredClassInstance, IPDOMMemberOwner, IIndexType {
|
||||
|
||||
|
@ -64,13 +61,8 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
|
|||
throws CoreException {
|
||||
super(pdom, parent, classType, instantiated);
|
||||
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||
IType[] args = ((ICPPTemplateInstance) classType).getArguments();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
PDOMNode typeNode = getLinkageImpl().addType(this, args[i]);
|
||||
if (typeNode != null)
|
||||
list.addMember(typeNode);
|
||||
}
|
||||
final int argListRec= PDOMCPPArgumentList.putArguments(this, classType.getTemplateArguments());
|
||||
pdom.getDB().putInt(record+ARGUMENTS, argListRec);
|
||||
}
|
||||
|
||||
public PDOMCPPDeferredClassInstance(PDOM pdom, int bindingRecord) {
|
||||
|
@ -109,21 +101,7 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
|
|||
if (!classTemplate.isSameType((IType) rhs.getSpecializedBinding()))
|
||||
return false;
|
||||
|
||||
IType[] lhsArgs= getArguments();
|
||||
IType[] rhsArgs= rhs.getArguments();
|
||||
if (lhsArgs != rhsArgs) {
|
||||
if (lhsArgs == null || rhsArgs == null)
|
||||
return false;
|
||||
|
||||
if (lhsArgs.length != rhsArgs.length)
|
||||
return false;
|
||||
|
||||
for (int i= 0; i < lhsArgs.length; i++) {
|
||||
if (!CPPTemplates.isSameTemplateArgument(lhsArgs[i], rhsArgs[i]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return CPPTemplates.haveSameArguments(this, rhs);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -207,31 +185,19 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
|
|||
return (ICPPTemplateDefinition) getSpecializedBinding();
|
||||
}
|
||||
|
||||
private static class TemplateArgumentCollector implements IPDOMVisitor {
|
||||
private List<IType> args = new ArrayList<IType>();
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof IType)
|
||||
args.add((IType) node);
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public IType[] getTemplateArguments() {
|
||||
return args.toArray(new IType[args.size()]);
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
try {
|
||||
final int rec= getPDOM().getDB().getInt(record+ARGUMENTS);
|
||||
return PDOMCPPArgumentList.getArguments(this, rec);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
try {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||
TemplateArgumentCollector visitor = new TemplateArgumentCollector();
|
||||
list.accept(visitor);
|
||||
|
||||
return visitor.getTemplateArguments();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return IType.EMPTY_TYPE_ARRAY;
|
||||
}
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
}
|
||||
|
||||
public boolean isAnonymous() {
|
||||
|
|
|
@ -1,39 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 QNX Software Systems and others.
|
||||
* Copyright (c) 2007, 2008 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*
|
||||
* Result of instantiating a function template.
|
||||
*/
|
||||
class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements ICPPTemplateInstance {
|
||||
private static final int ARGUMENTS = PDOMCPPFunctionSpecialization.RECORD_SIZE + 0;
|
||||
|
@ -44,13 +39,9 @@ class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements I
|
|||
throws CoreException {
|
||||
super(pdom, parent, function, orig);
|
||||
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||
IType[] args = ((ICPPTemplateInstance) function).getArguments();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
PDOMNode typeNode = getLinkageImpl().addType(this, args[i]);
|
||||
if (typeNode != null)
|
||||
list.addMember(typeNode);
|
||||
}
|
||||
final ICPPTemplateInstance asInstance= (ICPPTemplateInstance) function;
|
||||
final int argListRec= PDOMCPPArgumentList.putArguments(this, asInstance.getTemplateArguments());
|
||||
pdom.getDB().putInt(record+ARGUMENTS, argListRec);
|
||||
}
|
||||
|
||||
public PDOMCPPFunctionInstance(PDOM pdom, int bindingRecord) {
|
||||
|
@ -72,31 +63,19 @@ class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements I
|
|||
return (ICPPTemplateDefinition) getSpecializedBinding();
|
||||
}
|
||||
|
||||
private static class TemplateArgumentCollector implements IPDOMVisitor {
|
||||
private List<IType> args = new ArrayList<IType>();
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof IType)
|
||||
args.add((IType) node);
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public IType[] getTemplateArguments() {
|
||||
return args.toArray(new IType[args.size()]);
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
try {
|
||||
final int rec= getPDOM().getDB().getInt(record+ARGUMENTS);
|
||||
return PDOMCPPArgumentList.getArguments(this, rec);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
try {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||
TemplateArgumentCollector visitor = new TemplateArgumentCollector();
|
||||
list.accept(visitor);
|
||||
|
||||
return visitor.getTemplateArguments();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return IType.EMPTY_TYPE_ARRAY;
|
||||
}
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
|
@ -52,6 +52,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
|
@ -86,7 +87,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
* Container for c++-entities.
|
||||
*/
|
||||
class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||
|
||||
|
@ -160,14 +161,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
|
||||
public void run() {
|
||||
try {
|
||||
IType[] args = binding.getArguments();
|
||||
for (IType arg : args) {
|
||||
partial.addArgument(arg);
|
||||
}
|
||||
ICPPTemplateArgument[] args = binding.getTemplateArguments();
|
||||
partial.setArguments(args);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
} finally {
|
||||
partial = null;
|
||||
binding = null;
|
||||
|
|
|
@ -6,93 +6,53 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
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.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
* Base class for specializations and instances of other bindings.
|
||||
*/
|
||||
abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements ICPPSpecialization, IPDOMOverloader {
|
||||
|
||||
private static final int ARGMAP_PARAMS = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||
private static final int ARGMAP_ARGS = PDOMCPPBinding.RECORD_SIZE + 4;
|
||||
private static final int SIGNATURE_HASH = PDOMCPPBinding.RECORD_SIZE + 8;
|
||||
private static final int SPECIALIZED = PDOMCPPBinding.RECORD_SIZE + 12;
|
||||
private static final int ARGMAP = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||
private static final int SIGNATURE_HASH = PDOMCPPBinding.RECORD_SIZE + 4;
|
||||
private static final int SPECIALIZED = PDOMCPPBinding.RECORD_SIZE + 8;
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPSpecialization record in the database.
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 16;
|
||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 12;
|
||||
|
||||
private IBinding fSpecializedCache= null;
|
||||
private ObjectMap fArgMap;
|
||||
private ICPPTemplateParameterMap fArgMap;
|
||||
|
||||
public PDOMCPPSpecialization(PDOM pdom, PDOMNode parent, ICPPSpecialization spec, IPDOMBinding specialized)
|
||||
throws CoreException {
|
||||
super(pdom, parent, spec.getNameCharArray());
|
||||
pdom.getDB().putInt(record + SPECIALIZED, specialized.getRecord());
|
||||
|
||||
// specializations that are no instances have the same argmap as their owner.
|
||||
// specializations that are no instances have the same map as their owner.
|
||||
if (this instanceof ICPPTemplateInstance) {
|
||||
PDOMNodeLinkedList paramList = new PDOMNodeLinkedList(pdom, record + ARGMAP_PARAMS, getLinkageImpl());
|
||||
PDOMNodeLinkedList argList = new PDOMNodeLinkedList(pdom, record + ARGMAP_ARGS, getLinkageImpl());
|
||||
ObjectMap argMap = spec.getArgumentMap();
|
||||
if (argMap != null) {
|
||||
for (int i = 0; i < argMap.size(); i++) {
|
||||
Object param = argMap.keyAt(i);
|
||||
Object arg = argMap.getAt(i);
|
||||
|
||||
// TODO - non-type template arguments still needs attention
|
||||
if (param instanceof ICPPTemplateNonTypeParameter && arg instanceof IType) {
|
||||
try {
|
||||
ICPPTemplateNonTypeParameter nontype= (ICPPTemplateNonTypeParameter) param;
|
||||
PDOMNode paramNode= ((PDOMCPPLinkage)getLinkageImpl()).createBinding(this, nontype);
|
||||
PDOMNode argNode= getLinkageImpl().addType(this, (IType) arg);
|
||||
if (paramNode != null && argNode != null) {
|
||||
paramList.addMember(paramNode);
|
||||
argList.addMember(argNode);
|
||||
}
|
||||
} catch(DOMException de) {
|
||||
CCorePlugin.log(de);
|
||||
}
|
||||
}
|
||||
|
||||
if (param instanceof IType && arg instanceof IType) {
|
||||
PDOMNode paramNode = getLinkageImpl().addType(this, (IType) param);
|
||||
PDOMNode argNode = getLinkageImpl().addType(this, (IType) arg);
|
||||
if (paramNode != null && argNode != null) {
|
||||
paramList.addMember(paramNode);
|
||||
argList.addMember(argNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int rec= PDOMCPPTemplateParameterMap.putMap(this, spec.getTemplateParameterMap());
|
||||
pdom.getDB().putInt(record+ARGMAP, rec);
|
||||
}
|
||||
try {
|
||||
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(spec);
|
||||
|
@ -116,43 +76,22 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements ICPPSpeci
|
|||
}
|
||||
return fSpecializedCache;
|
||||
}
|
||||
|
||||
private static class NodeCollector implements IPDOMVisitor {
|
||||
private List<IPDOMNode> nodes = new ArrayList<IPDOMNode>();
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
nodes.add(node);
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public IPDOMNode[] getNodes() {
|
||||
return nodes.toArray(new IPDOMNode[nodes.size()]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return CPPTemplates.getArgumentMap(this, getTemplateParameterMap());
|
||||
}
|
||||
|
||||
public ObjectMap getArgumentMap() {
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
if (fArgMap == null) {
|
||||
try {
|
||||
if (this instanceof ICPPTemplateInstance) {
|
||||
PDOMNodeLinkedList paramList = new PDOMNodeLinkedList(pdom, record + ARGMAP_PARAMS, getLinkageImpl());
|
||||
PDOMNodeLinkedList argList = new PDOMNodeLinkedList(pdom, record + ARGMAP_ARGS, getLinkageImpl());
|
||||
NodeCollector paramVisitor = new NodeCollector();
|
||||
paramList.accept(paramVisitor);
|
||||
IPDOMNode[] paramNodes = paramVisitor.getNodes();
|
||||
NodeCollector argVisitor = new NodeCollector();
|
||||
argList.accept(argVisitor);
|
||||
IPDOMNode[] argNodes = argVisitor.getNodes();
|
||||
|
||||
ObjectMap map = new ObjectMap(paramNodes.length);
|
||||
for (int i = 0; i < paramNodes.length; i++) {
|
||||
map.put(paramNodes[i], argNodes[i]);
|
||||
}
|
||||
fArgMap= map;
|
||||
fArgMap= PDOMCPPTemplateParameterMap.getMap(this, getInt(record + ARGMAP));
|
||||
} else {
|
||||
// specializations that are no instances have the same argmap as their owner.
|
||||
IBinding owner= getOwner();
|
||||
if (owner instanceof ICPPSpecialization) {
|
||||
fArgMap= ((ICPPSpecialization) owner).getArgumentMap();
|
||||
fArgMap= ((ICPPSpecialization) owner).getTemplateParameterMap();
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
|
@ -166,38 +105,6 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements ICPPSpeci
|
|||
return pdom.getDB().getInt(record + SIGNATURE_HASH);
|
||||
}
|
||||
|
||||
private IType[] getArguments() {
|
||||
if (!(this instanceof ICPPTemplateDefinition)
|
||||
&& getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||
ICPPTemplateDefinition template = (ICPPTemplateDefinition) getSpecializedBinding();
|
||||
try {
|
||||
ICPPTemplateParameter[] params = template.getTemplateParameters();
|
||||
ObjectMap argMap = getArgumentMap();
|
||||
IType[] args = new IType[params.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
args[i] = (IType) argMap.get(params[i]);
|
||||
}
|
||||
return args;
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
|
||||
return IType.EMPTY_TYPE_ARRAY;
|
||||
}
|
||||
|
||||
public boolean matchesArguments(IType[] arguments) {
|
||||
IType[] args = getArguments();
|
||||
if (args.length == arguments.length) {
|
||||
int i = 0;
|
||||
for (; i < args.length; i++) {
|
||||
if (!CPPTemplates.isSameTemplateArgument(args[i], arguments[i]))
|
||||
break;
|
||||
}
|
||||
return i == args.length;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* For debug purposes only
|
||||
*/
|
||||
|
|
|
@ -6,40 +6,46 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
* Binding for template non-type parameter in the index.
|
||||
*/
|
||||
class PDOMCPPTemplateNonTypeParameter extends PDOMCPPVariable implements IPDOMMemberOwner,
|
||||
ICPPTemplateNonTypeParameter {
|
||||
|
||||
private static final int MEMBERLIST = PDOMCPPVariable.RECORD_SIZE;
|
||||
private static final int PARAMETERPOS= PDOMCPPVariable.RECORD_SIZE + 4;
|
||||
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPTemplateTypeParameter record in the database.
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPVariable.RECORD_SIZE + 4;
|
||||
protected static final int RECORD_SIZE = PDOMCPPVariable.RECORD_SIZE + 8;
|
||||
|
||||
public PDOMCPPTemplateNonTypeParameter(PDOM pdom, PDOMNode parent,
|
||||
ICPPTemplateNonTypeParameter param) throws CoreException {
|
||||
super(pdom, parent, param);
|
||||
final Database db = pdom.getDB();
|
||||
db.putInt(record + PARAMETERPOS, param.getParameterPosition());
|
||||
}
|
||||
|
||||
public PDOMCPPTemplateNonTypeParameter(PDOM pdom, int bindingRecord) {
|
||||
|
@ -56,6 +62,16 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPVariable implements IPDOMMe
|
|||
return IIndexCPPBindingConstants.CPP_TEMPLATE_NON_TYPE_PARAMETER;
|
||||
}
|
||||
|
||||
public int getParameterPosition() {
|
||||
try {
|
||||
final Database db = pdom.getDB();
|
||||
return db.getInt(record + PARAMETERPOS);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChild(PDOMNode member) throws CoreException {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
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.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IString;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Collects methods to store an argument list in the database
|
||||
*/
|
||||
public class PDOMCPPTemplateParameterMap {
|
||||
/**
|
||||
* Stores the given template parameter map in the database.
|
||||
* @return the record by which the arguments can be referenced.
|
||||
*/
|
||||
public static int putMap(PDOMNode parent, ICPPTemplateParameterMap map) throws CoreException {
|
||||
final PDOMLinkage linkage= parent.getLinkage();
|
||||
final Database db= linkage.getPDOM().getDB();
|
||||
Integer[] keys= map.getAllParameterPositions();
|
||||
final short len= (short) Math.min(keys.length, (Database.MAX_MALLOC_SIZE-2)/12);
|
||||
final int block= db.malloc(2+12*len);
|
||||
int p= block;
|
||||
|
||||
db.putShort(p, len); p+=2;
|
||||
for (int i=0; i<len; i++) {
|
||||
final Integer paramPos = keys[i];
|
||||
db.putInt(p, paramPos);
|
||||
p+=4;
|
||||
final ICPPTemplateArgument arg = map.getArgument(paramPos);
|
||||
if (arg.isNonTypeValue()) {
|
||||
final PDOMNode type= linkage.addType(parent, arg.getTypeOfNonTypeValue());
|
||||
// type can be null, if it is local
|
||||
db.putInt(p, type == null ? 0 : type.getRecord());
|
||||
final IString s= db.newString(arg.getNonTypeValue().getCanonicalRepresentation());
|
||||
db.putInt(p+4, s.getRecord());
|
||||
} else {
|
||||
final PDOMNode type= linkage.addType(parent, arg.getTypeValue());
|
||||
// type can be null, if it is local
|
||||
db.putInt(p, type == null ? 0 : type.getRecord());
|
||||
}
|
||||
p+=8;
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears the map in the database.
|
||||
*/
|
||||
public static void clearMap(PDOMNode parent, int rec) throws CoreException {
|
||||
final PDOMLinkage linkage= parent.getLinkage();
|
||||
final Database db= linkage.getPDOM().getDB();
|
||||
final short len= db.getShort(rec);
|
||||
|
||||
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/12);
|
||||
rec+=2;
|
||||
for (int i=0; i<len; i++) {
|
||||
rec+=4;
|
||||
final int typeRec= db.getInt(rec);
|
||||
if (typeRec != 0) {
|
||||
final IType t= (IType) linkage.getNode(typeRec);
|
||||
linkage.deleteType(t, parent.getRecord());
|
||||
}
|
||||
final int nonTypeValueRec= db.getInt(rec+4);
|
||||
if (nonTypeValueRec != 0) {
|
||||
db.getString(nonTypeValueRec).delete();
|
||||
}
|
||||
rec+= 8;
|
||||
}
|
||||
db.free(rec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the map from from the database.
|
||||
*/
|
||||
public static CPPTemplateParameterMap getMap(PDOMNode parent, int rec) throws CoreException {
|
||||
final PDOMLinkage linkage= parent.getLinkage();
|
||||
final Database db= linkage.getPDOM().getDB();
|
||||
final short len= db.getShort(rec);
|
||||
|
||||
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/12);
|
||||
if (len == 0) {
|
||||
return new CPPTemplateParameterMap();
|
||||
}
|
||||
|
||||
rec+=2;
|
||||
CPPTemplateParameterMap result= new CPPTemplateParameterMap();
|
||||
for (int i=0; i<len; i++) {
|
||||
final int parPos= db.getInt(rec);
|
||||
final int typeRec= db.getInt(rec+4);
|
||||
final IType type= typeRec == 0 ? new CPPBasicType(-1, 0) : (IType) linkage.getNode(typeRec);
|
||||
final int nonTypeValRec= db.getInt(rec+8);
|
||||
ICPPTemplateArgument arg;
|
||||
if (nonTypeValRec != 0) {
|
||||
final IString s= db.getString(nonTypeValRec);
|
||||
arg= new CPPTemplateArgument(Value.fromCanonicalRepresentation(s.getString()), type);
|
||||
} else {
|
||||
arg= new CPPTemplateArgument(type);
|
||||
}
|
||||
result.put(parPos, arg);
|
||||
rec+= 12;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
|
@ -27,25 +27,27 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
|||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
* Binding for template type parameters in the index.
|
||||
*/
|
||||
class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMemberOwner,
|
||||
ICPPTemplateTypeParameter, ICPPUnknownBinding, IIndexType {
|
||||
|
||||
private static final int DEFAULT_TYPE = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4;
|
||||
private static final int PARAMETERPOS= PDOMCPPBinding.RECORD_SIZE + 8;
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPTemplateTypeParameter record in the database.
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 8;
|
||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 12;
|
||||
private ICPPScope fUnknownScope;
|
||||
|
||||
public PDOMCPPTemplateTypeParameter(PDOM pdom, PDOMNode parent,
|
||||
|
@ -53,11 +55,13 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
|
|||
super(pdom, parent, param.getNameCharArray());
|
||||
|
||||
try {
|
||||
final Database db = pdom.getDB();
|
||||
db.putInt(record + PARAMETERPOS, param.getParameterPosition());
|
||||
IType dflt = param.getDefault();
|
||||
if (dflt != null) {
|
||||
PDOMNode typeNode = getLinkageImpl().addType(this, dflt);
|
||||
if (typeNode != null) {
|
||||
pdom.getDB().putInt(record + DEFAULT_TYPE, typeNode.getRecord());
|
||||
db.putInt(record + DEFAULT_TYPE, typeNode.getRecord());
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
|
@ -79,6 +83,16 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
|
|||
return IIndexCPPBindingConstants.CPP_TEMPLATE_TYPE_PARAMETER;
|
||||
}
|
||||
|
||||
public int getParameterPosition() {
|
||||
try {
|
||||
final Database db = pdom.getDB();
|
||||
return db.getInt(record + PARAMETERPOS);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChild(PDOMNode member) throws CoreException {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
|
||||
|
@ -115,7 +129,7 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
|
|||
return false;
|
||||
}
|
||||
|
||||
public IType getDefault() throws DOMException {
|
||||
public IType getDefault() {
|
||||
try {
|
||||
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + DEFAULT_TYPE));
|
||||
if (node instanceof IType) {
|
||||
|
|
|
@ -77,7 +77,8 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
|||
|
||||
private void setValue(Database db, IVariable variable) throws CoreException {
|
||||
IValue val= variable.getInitialValue();
|
||||
db.putInt(record + VALUE_OFFSET, val == null ? 0 : db.newString(val.getCanonicalRepresentation()).getRecord());
|
||||
int valueRec= val == null ? 0 : db.newString(val.getCanonicalRepresentation()).getRecord();
|
||||
db.putInt(record + VALUE_OFFSET, valueRec);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -99,6 +99,7 @@ public class C99BasicType implements ICBasicType {
|
|||
this.isLongLong = isLongLong;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IASTExpression getValue() {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue