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

Code formatting.

This commit is contained in:
Sergey Prigogin 2008-01-28 04:21:07 +00:00
parent 31f3a10fe2
commit 1fd562b49a

View file

@ -246,12 +246,12 @@ public class CPPTemplates {
decl = decl.getParent(); decl = decl.getParent();
if (decl instanceof ICPPASTExplicitTemplateInstantiation && if (decl instanceof ICPPASTExplicitTemplateInstantiation &&
parent instanceof ICPPASTElaboratedTypeSpecifier && segment != 0 ) parent instanceof ICPPASTElaboratedTypeSpecifier && segment != 0) {
{
return createClassExplicitInstantiation((ICPPASTElaboratedTypeSpecifier) parent); return createClassExplicitInstantiation((ICPPASTElaboratedTypeSpecifier) parent);
} else if( ( (parent instanceof ICPPASTElaboratedTypeSpecifier && decl instanceof ICPPASTTemplateDeclaration) || } else if (((parent instanceof ICPPASTElaboratedTypeSpecifier &&
parent instanceof ICPPASTCompositeTypeSpecifier ) decl instanceof ICPPASTTemplateDeclaration) ||
&& segment != 0 ){ parent instanceof ICPPASTCompositeTypeSpecifier) &&
segment != 0) {
return createClassSpecialization((ICPPASTDeclSpecifier) parent); return createClassSpecialization((ICPPASTDeclSpecifier) parent);
} else if (parent instanceof ICPPASTFunctionDeclarator && segment != 0) { } else if (parent instanceof ICPPASTFunctionDeclarator && segment != 0) {
return createFunctionSpecialization(id); return createFunctionSpecialization(id);
@ -262,8 +262,7 @@ public class CPPTemplates {
if (parent instanceof ICPPASTNamedTypeSpecifier || if (parent instanceof ICPPASTNamedTypeSpecifier ||
parent instanceof ICPPASTElaboratedTypeSpecifier || parent instanceof ICPPASTElaboratedTypeSpecifier ||
parent instanceof ICPPASTBaseSpecifier || parent instanceof ICPPASTBaseSpecifier ||
segment == 0 ) segment == 0) {
{
//class template //class template
IASTName templateName = id.getTemplateName(); IASTName templateName = id.getTemplateName();
template = templateName.resolveBinding(); template = templateName.resolveBinding();
@ -487,8 +486,9 @@ public class CPPTemplates {
continue; continue;
} else if (o instanceof IBinding) { } else if (o instanceof IBinding) {
temp = (IBinding) o; temp = (IBinding) o;
} else } else {
continue; continue;
}
if (temp instanceof ICPPTemplateInstance) if (temp instanceof ICPPTemplateInstance)
temp = ((ICPPTemplateInstance)temp).getTemplateDefinition(); temp = ((ICPPTemplateInstance)temp).getTemplateDefinition();
@ -541,13 +541,14 @@ public class CPPTemplates {
ICPPTemplateParameter param = params[j]; ICPPTemplateParameter param = params[j];
if (j < numArgs) { if (j < numArgs) {
arg = templateArguments[j]; arg = templateArguments[j];
} else } else {
arg = null; arg = null;
}
if (map.containsKey(param)) { if (map.containsKey(param)) {
IType t = (IType) map.get(param); IType t = (IType) map.get(param);
if( arg == null ) if (arg == null) {
arg = t; arg = t;
else if( !t.isSameType( arg ) ){ } else if (!t.isSameType(arg)) {
continue outer; continue outer;
} }
} else if (arg == null || !matchTemplateParameterAndArgument(param, arg, map)) { } else if (arg == null || !matchTemplateParameterAndArgument(param, arg, map)) {
@ -823,14 +824,16 @@ public class CPPTemplates {
IASTDeclaration currDecl = decl; IASTDeclaration currDecl = decl;
for (int j = 0; j < ns.length; j++) { for (int j = 0; j < ns.length; j++) {
if (ns[j] instanceof ICPPASTTemplateId || j + 1 == ns.length) { if (ns[j] instanceof ICPPASTTemplateId || j + 1 == ns.length) {
if( currDecl == templateDecl ) if (currDecl == templateDecl) {
return ns[j]; return ns[j];
if( currDecl instanceof ICPPASTTemplateDeclaration ) }
if (currDecl instanceof ICPPASTTemplateDeclaration) {
currDecl = ((ICPPASTTemplateDeclaration)currDecl).getDeclaration(); currDecl = ((ICPPASTTemplateDeclaration)currDecl).getDeclaration();
else } else {
return null; return null;
} }
} }
}
} else { } else {
return name; return name;
} }
@ -1024,12 +1027,12 @@ public class CPPTemplates {
IType arg = (i < numTemplateArgs) ? CPPVisitor.createType(templateArguments[i]) : null; IType arg = (i < numTemplateArgs) ? CPPVisitor.createType(templateArguments[i]) : null;
IType mapped = (IType) map.get(templateParams[i]); IType mapped = (IType) map.get(templateParams[i]);
if( arg != null && mapped != null ) if (arg != null && mapped != null) {
if (arg.isSameType(mapped)) if (arg.isSameType(mapped))
instanceArgs = (IType[]) ArrayUtil.append(IType.class, instanceArgs, arg); instanceArgs = (IType[]) ArrayUtil.append(IType.class, instanceArgs, arg);
else else
continue outer; continue outer;
else if( arg == null && mapped == null ) { } else if (arg == null && mapped == null) {
IType def = null; IType def = null;
try { try {
if (templateParams[i] instanceof ICPPTemplateTypeParameter) { if (templateParams[i] instanceof ICPPTemplateTypeParameter) {
@ -1051,11 +1054,13 @@ public class CPPTemplates {
} }
} }
instanceArgs = (IType[]) ArrayUtil.append(IType.class, instanceArgs, def); instanceArgs = (IType[]) ArrayUtil.append(IType.class, instanceArgs, def);
} else } else {
continue outer; continue outer;
} else }
} else {
instanceArgs = (IType[]) ArrayUtil.append(IType.class, instanceArgs, (arg != null) ? arg : mapped); instanceArgs = (IType[]) ArrayUtil.append(IType.class, instanceArgs, (arg != null) ? arg : mapped);
} }
}
instanceArgs = (IType[]) ArrayUtil.trim(IType.class, instanceArgs); instanceArgs = (IType[]) ArrayUtil.trim(IType.class, instanceArgs);
ICPPSpecialization temp = (ICPPSpecialization) ((ICPPInternalTemplateInstantiator)template).instantiate(instanceArgs); ICPPSpecialization temp = (ICPPSpecialization) ((ICPPInternalTemplateInstantiator)template).instantiate(instanceArgs);
if (temp != null) if (temp != null)
@ -1267,11 +1272,11 @@ public class CPPTemplates {
* @param template * @param template
* @return * @return
* -for each type template parameter, synthesize a unique type and substitute that for each * -for each type template parameter, synthesize a unique type and substitute that for each
* occurence of that parameter in the function parameter list * occurrence of that parameter in the function parameter list
* -for each non-type template parameter, synthesize a unique value of the appropriate type and * -for each non-type template parameter, synthesize a unique value of the appropriate type and
* susbstitute that for each occurence of that parameter in the function parameter list * substitute that for each occurrence of that parameter in the function parameter list
* for each template template parameter, synthesize a unique class template and substitute that * for each template template parameter, synthesize a unique class template and substitute that
* for each occurence of that parameter in the function parameter list * for each occurrence of that parameter in the function parameter list
* @throws DOMException * @throws DOMException
*/ */
@ -1474,6 +1479,7 @@ public class CPPTemplates {
//TODO //TODO
return true; return true;
} }
static protected boolean matchTemplateParameterAndArgument(ICPPTemplateParameter param, IType argument, ObjectMap map) { static protected boolean matchTemplateParameterAndArgument(ICPPTemplateParameter param, IType argument, ObjectMap map) {
if (!isValidArgument(param, argument)) { if (!isValidArgument(param, argument)) {
return false; return false;
@ -1619,7 +1625,7 @@ public class CPPTemplates {
arg = (IType) map.get(defaultType); arg = (IType) map.get(defaultType);
} }
} else if (defaultType instanceof ICPPInternalDeferredClassInstance) { } else if (defaultType instanceof ICPPInternalDeferredClassInstance) {
// Default template parameter may be depend on a previously defined // A default template parameter may be depend on a previously defined
// parameter: template<typename T1, typename T2 = A<T1> > class B {}; // parameter: template<typename T1, typename T2 = A<T1> > class B {};
arg = ((ICPPInternalDeferredClassInstance) defaultType).instantiate(map); arg = ((ICPPInternalDeferredClassInstance) defaultType).instantiate(map);
} else { } else {
@ -1665,8 +1671,8 @@ public class CPPTemplates {
} }
/** /**
* Returns an array of specialised bases. The bases will be specialised versions of * Returns an array of specialized bases. The bases will be specialized versions of
* the template instances associated specialised bindings bases. * the template instances associated specialized bindings bases.
* binding. * binding.
* @param classInstance * @param classInstance
* @return * @return