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

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-10-21 21:44:05 -07:00
parent a5fd074d08
commit 422dd2eb1d

View file

@ -174,8 +174,8 @@ public class CPPTemplates {
private static IBinding instantiate(ICPPClassTemplate template, ICPPTemplateArgument[] args, private static IBinding instantiate(ICPPClassTemplate template, ICPPTemplateArgument[] args,
boolean isDefinition, boolean isExplicitSpecialization, IASTNode point) { boolean isDefinition, boolean isExplicitSpecialization, IASTNode point) {
try { try {
// Add default arguments, if necessary.
ICPPTemplateArgument[] arguments= SemanticUtil.getSimplifiedArguments(args); ICPPTemplateArgument[] arguments= SemanticUtil.getSimplifiedArguments(args);
// Add default arguments, if necessary.
arguments= addDefaultArguments(template, arguments, point); arguments= addDefaultArguments(template, arguments, point);
if (arguments == null) if (arguments == null)
return createProblem(template, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, point); return createProblem(template, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, point);
@ -208,7 +208,7 @@ public class CPPTemplates {
} }
if (i < numArgs) { if (i < numArgs) {
ICPPTemplateArgument arg= arguments[i]; ICPPTemplateArgument arg= arguments[i];
ICPPTemplateArgument newArg = CPPTemplates.matchTemplateParameterAndArgument(param, arg, map, point); ICPPTemplateArgument newArg = matchTemplateParameterAndArgument(param, arg, map, point);
if (newArg == null) if (newArg == null)
return createProblem(template, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, point); return createProblem(template, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, point);
if (newArg != arg) { if (newArg != arg) {
@ -239,7 +239,7 @@ public class CPPTemplates {
return prim; return prim;
if (!isExplicitSpecialization) { if (!isExplicitSpecialization) {
IBinding result= CPPTemplates.selectSpecialization(template, arguments, isDefinition, point); IBinding result= selectSpecialization(template, arguments, isDefinition, point);
if (result != null) if (result != null)
return result; return result;
} }
@ -314,7 +314,7 @@ public class CPPTemplates {
} }
IBinding owner= template.getOwner(); IBinding owner= template.getOwner();
instance = CPPTemplates.createInstance(owner, template, map, arguments, point); instance = createInstance(owner, template, map, arguments, point);
addInstance(template, arguments, instance); addInstance(template, arguments, instance);
return instance; return instance;
} }
@ -354,7 +354,7 @@ public class CPPTemplates {
} }
IBinding owner= template.getOwner(); IBinding owner= template.getOwner();
instance = CPPTemplates.createInstance(owner, template, map, arguments, point); instance = createInstance(owner, template, map, arguments, point);
addInstance(template, arguments, instance); addInstance(template, arguments, instance);
return instance; return instance;
} }
@ -423,7 +423,7 @@ public class CPPTemplates {
if (tpars[tparCount - 1].isParameterPack()) if (tpars[tparCount - 1].isParameterPack())
return arguments; return arguments;
if (havePackExpansion && tparCount+1 == argCount) if (havePackExpansion && tparCount + 1 == argCount)
return arguments; return arguments;
return null; return null;
} }
@ -476,7 +476,7 @@ public class CPPTemplates {
if (ct instanceof ICPPClassTemplatePartialSpecialization) { if (ct instanceof ICPPClassTemplatePartialSpecialization) {
args= ((ICPPClassTemplatePartialSpecialization) ct).getTemplateArguments(); args= ((ICPPClassTemplatePartialSpecialization) ct).getTemplateArguments();
} else { } else {
args = CPPTemplates.templateParametersAsArguments(ct.getTemplateParameters()); args = templateParametersAsArguments(ct.getTemplateParameters());
} }
return new CPPDeferredClassInstance(ct, args, (ICPPScope) ct.getCompositeScope()); return new CPPDeferredClassInstance(ct, args, (ICPPScope) ct.getCompositeScope());
} }
@ -741,7 +741,7 @@ public class CPPTemplates {
} else if (template instanceof ICPPFunction) { } else if (template instanceof ICPPFunction) {
ICPPFunction func= (ICPPFunction) template; ICPPFunction func= (ICPPFunction) template;
ICPPClassSpecialization within = getSpecializationContext(owner); ICPPClassSpecialization within = getSpecializationContext(owner);
ICPPFunctionType type= (ICPPFunctionType) CPPTemplates.instantiateType(func.getType(), tpMap, -1, within, point); ICPPFunctionType type= (ICPPFunctionType) instantiateType(func.getType(), tpMap, -1, within, point);
IType[] exceptionSpecs= instantiateTypes(func.getExceptionSpecification(), tpMap, -1, within, point); IType[] exceptionSpecs= instantiateTypes(func.getExceptionSpecification(), tpMap, -1, within, point);
if (owner instanceof ICPPClassType && template instanceof ICPPMethod) { if (owner instanceof ICPPClassType && template instanceof ICPPMethod) {
if (template instanceof ICPPConstructor) { if (template instanceof ICPPConstructor) {
@ -766,7 +766,7 @@ public class CPPTemplates {
ICPPClassTemplate template= pspec.getPrimaryClassTemplate(); ICPPClassTemplate template= pspec.getPrimaryClassTemplate();
ICPPTemplateArgument[] args = pspec.getTemplateArguments(); ICPPTemplateArgument[] args = pspec.getTemplateArguments();
template= (ICPPClassTemplate) owner.specializeMember(template, point); template= (ICPPClassTemplate) owner.specializeMember(template, point);
args= CPPTemplates.instantiateArguments(args, tpMap, -1, within, point); args= instantiateArguments(args, tpMap, -1, within, point);
spec= new CPPClassTemplatePartialSpecializationSpecialization(pspec, tpMap, template, args); spec= new CPPClassTemplatePartialSpecializationSpecialization(pspec, tpMap, template, args);
} catch (DOMException e) { } catch (DOMException e) {
} }
@ -782,13 +782,13 @@ public class CPPTemplates {
} else if (decl instanceof ICPPField) { } else if (decl instanceof ICPPField) {
final ICPPClassSpecialization within = getSpecializationContext(owner); final ICPPClassSpecialization within = getSpecializationContext(owner);
ICPPField field= (ICPPField) decl; ICPPField field= (ICPPField) decl;
IType type= CPPTemplates.instantiateType(field.getType(), tpMap, -1, within, point); IType type= instantiateType(field.getType(), tpMap, -1, within, point);
IValue value= CPPTemplates.instantiateValue(field.getInitialValue(), tpMap, -1, within, Value.MAX_RECURSION_DEPTH, point); IValue value= instantiateValue(field.getInitialValue(), tpMap, -1, within, Value.MAX_RECURSION_DEPTH, point);
spec = new CPPFieldSpecialization(decl, owner, tpMap, type, value); spec = new CPPFieldSpecialization(decl, owner, tpMap, type, value);
} else if (decl instanceof ICPPFunction) { } else if (decl instanceof ICPPFunction) {
ICPPFunction func= (ICPPFunction) decl; ICPPFunction func= (ICPPFunction) decl;
ICPPClassSpecialization within = getSpecializationContext(owner); ICPPClassSpecialization within = getSpecializationContext(owner);
ICPPFunctionType type= (ICPPFunctionType) CPPTemplates.instantiateType(func.getType(), tpMap, -1, within, point); ICPPFunctionType type= (ICPPFunctionType) instantiateType(func.getType(), tpMap, -1, within, point);
IType[] exceptionSpecs= instantiateTypes(func.getExceptionSpecification(), tpMap, -1, within, point); IType[] exceptionSpecs= instantiateTypes(func.getExceptionSpecification(), tpMap, -1, within, point);
if (decl instanceof ICPPFunctionTemplate) { if (decl instanceof ICPPFunctionTemplate) {
@ -808,7 +808,7 @@ public class CPPTemplates {
spec = new CPPFunctionSpecialization((ICPPFunction) decl, oldOwner, tpMap, type, exceptionSpecs); spec = new CPPFunctionSpecialization((ICPPFunction) decl, oldOwner, tpMap, type, exceptionSpecs);
} }
} else if (decl instanceof ITypedef) { } else if (decl instanceof ITypedef) {
IType type= CPPTemplates.instantiateType(((ITypedef) decl).getType(), tpMap, -1, getSpecializationContext(owner), point); IType type= instantiateType(((ITypedef) decl).getType(), tpMap, -1, getSpecializationContext(owner), point);
spec = new CPPTypedefSpecialization(decl, owner, tpMap, type); spec = new CPPTypedefSpecialization(decl, owner, tpMap, type);
} else if (decl instanceof IEnumeration || decl instanceof IEnumerator) { } else if (decl instanceof IEnumeration || decl instanceof IEnumerator) {
// TODO(sprigogin): Deal with a case when an enumerator value depends on a template parameter. // TODO(sprigogin): Deal with a case when an enumerator value depends on a template parameter.
@ -820,7 +820,7 @@ public class CPPTemplates {
for (IBinding delegate : delegates) { for (IBinding delegate : delegates) {
try { try {
if (delegate instanceof ICPPUnknownBinding) { if (delegate instanceof ICPPUnknownBinding) {
delegate= CPPTemplates.resolveUnknown((ICPPUnknownBinding) delegate, tpMap, -1, within, point); delegate= resolveUnknown((ICPPUnknownBinding) delegate, tpMap, -1, within, point);
} }
if (delegate instanceof CPPFunctionSet) { if (delegate instanceof CPPFunctionSet) {
for (IBinding b : ((CPPFunctionSet) delegate).getBindings()) { for (IBinding b : ((CPPFunctionSet) delegate).getBindings()) {
@ -998,12 +998,12 @@ public class CPPTemplates {
System.arraycopy(result, 0, newResult, 0, j); System.arraycopy(result, 0, newResult, 0, j);
result= newResult; result= newResult;
for (int k= 0; k < packSize; k++) { for (int k= 0; k < packSize; k++) {
result[j++]= CPPTemplates.instantiateType(origType, tpMap, k, within, point); result[j++]= instantiateType(origType, tpMap, k, within, point);
} }
continue; continue;
} }
} else { } else {
newType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within, point); newType = instantiateType(origType, tpMap, packOffset, within, point);
} }
if (result != types) { if (result != types) {
result[j++]= newType; result[j++]= newType;
@ -1043,14 +1043,14 @@ public class CPPTemplates {
ICPPTemplateArgument[] newResult= new ICPPTemplateArgument[args.length + resultShift + shift]; ICPPTemplateArgument[] newResult= new ICPPTemplateArgument[args.length + resultShift + shift];
System.arraycopy(result, 0, newResult, 0, i + resultShift); System.arraycopy(result, 0, newResult, 0, i + resultShift);
for (int j= 0; j < packSize; j++) { for (int j= 0; j < packSize; j++) {
newResult[i + resultShift + j]= CPPTemplates.instantiateArgument(origArg, tpMap, j, within, point); newResult[i + resultShift + j]= instantiateArgument(origArg, tpMap, j, within, point);
} }
result= newResult; result= newResult;
resultShift += shift; resultShift += shift;
continue; continue;
} }
} else { } else {
newArg = CPPTemplates.instantiateArgument(origArg, tpMap, packOffset, within, point); newArg = instantiateArgument(origArg, tpMap, packOffset, within, point);
} }
if (result != args) { if (result != args) {
result[i + resultShift]= newArg; result[i + resultShift]= newArg;
@ -1480,7 +1480,7 @@ public class CPPTemplates {
while(true) { while(true) {
ICPPASTTemplateParameter[] pars = tdecl.getTemplateParameters(); ICPPASTTemplateParameter[] pars = tdecl.getTemplateParameters();
for (ICPPASTTemplateParameter par : pars) { for (ICPPASTTemplateParameter par : pars) {
IASTName name= CPPTemplates.getTemplateParameterName(par); IASTName name= getTemplateParameterName(par);
if (name != null) if (name != null)
set.put(name.getLookupKey()); set.put(name.getLookupKey());
} }
@ -2433,14 +2433,14 @@ public class CPPTemplates {
return unknown; return unknown;
IBinding result = unknown; IBinding result = unknown;
IType ot1 = CPPTemplates.instantiateType(ot0, tpMap, packOffset, within, point); IType ot1 = instantiateType(ot0, tpMap, packOffset, within, point);
if (ot1 != null) { if (ot1 != null) {
ot1 = SemanticUtil.getUltimateType(ot1, false); ot1 = SemanticUtil.getUltimateType(ot1, false);
if (ot1 instanceof ICPPUnknownType) { if (ot1 instanceof ICPPUnknownType) {
if (unknown instanceof ICPPUnknownMemberClassInstance) { if (unknown instanceof ICPPUnknownMemberClassInstance) {
ICPPUnknownMemberClassInstance ucli= (ICPPUnknownMemberClassInstance) unknown; ICPPUnknownMemberClassInstance ucli= (ICPPUnknownMemberClassInstance) unknown;
ICPPTemplateArgument[] args0 = ucli.getArguments(); ICPPTemplateArgument[] args0 = ucli.getArguments();
ICPPTemplateArgument[] args1 = CPPTemplates.instantiateArguments(args0, tpMap, packOffset, within, point); ICPPTemplateArgument[] args1 = instantiateArguments(args0, tpMap, packOffset, within, point);
if (args0 != args1 || !ot1.isSameType(ot0)) { if (args0 != args1 || !ot1.isSameType(ot0)) {
args1= SemanticUtil.getSimplifiedArguments(args1); args1= SemanticUtil.getSimplifiedArguments(args1);
result= new CPPUnknownClassInstance(ot1, ucli.getNameCharArray(), args1); result= new CPPUnknownClassInstance(ot1, ucli.getNameCharArray(), args1);
@ -2457,7 +2457,7 @@ public class CPPTemplates {
if (s != null) { if (s != null) {
result= CPPSemantics.resolveUnknownName(s, unknown, point); result= CPPSemantics.resolveUnknownName(s, unknown, point);
if (unknown instanceof ICPPUnknownMemberClassInstance && result instanceof ICPPTemplateDefinition) { if (unknown instanceof ICPPUnknownMemberClassInstance && result instanceof ICPPTemplateDefinition) {
ICPPTemplateArgument[] args1 = CPPTemplates.instantiateArguments( ICPPTemplateArgument[] args1 = instantiateArguments(
((ICPPUnknownMemberClassInstance) unknown).getArguments(), tpMap, packOffset, within, point); ((ICPPUnknownMemberClassInstance) unknown).getArguments(), tpMap, packOffset, within, point);
if (result instanceof ICPPClassTemplate) { if (result instanceof ICPPClassTemplate) {
result = instantiate((ICPPClassTemplate) result, args1, point); result = instantiate((ICPPClassTemplate) result, args1, point);
@ -2477,7 +2477,7 @@ public class CPPTemplates {
ICPPTemplateArgument[] arguments = dci.getTemplateArguments(); ICPPTemplateArgument[] arguments = dci.getTemplateArguments();
ICPPTemplateArgument[] newArgs; ICPPTemplateArgument[] newArgs;
try { try {
newArgs = CPPTemplates.instantiateArguments(arguments, tpMap, packOffset, within, point); newArgs = instantiateArguments(arguments, tpMap, packOffset, within, point);
} catch (DOMException e) { } catch (DOMException e) {
return e.getProblem(); return e.getProblem();
} }