1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

Rename instantiateCommaSeparatedSubexpressions() to instantiateExpressions()

instantiateCommaSeparatedSubexpressions() is a clunky name, and in C++17
(with fold expressions) the function will no longer be limited to comma-
separated expressions.

Change-Id: Id242f58bb291e79cefe2b28db12dbde4bafba4ed
This commit is contained in:
Nathan Ridge 2018-11-30 22:05:22 -05:00
parent 499cdbf01d
commit f5322a32d3
4 changed files with 12 additions and 12 deletions

View file

@ -108,12 +108,12 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
* This code is similar to CPPTemplates.instantiateArguments(), but applies to evaluations * This code is similar to CPPTemplates.instantiateArguments(), but applies to evaluations
* rather than template arguments. * rather than template arguments.
*/ */
protected static ICPPEvaluation[] instantiateCommaSeparatedSubexpressions(ICPPEvaluation[] subexpressions, protected static ICPPEvaluation[] instantiateExpressions(ICPPEvaluation[] expressions, InstantiationContext context,
InstantiationContext context, int maxDepth) { int maxDepth) {
ICPPEvaluation[] result = subexpressions; ICPPEvaluation[] result = expressions;
int resultShift = 0; int resultShift = 0;
for (int i = 0; i < subexpressions.length; i++) { for (int i = 0; i < expressions.length; i++) {
ICPPEvaluation origEval = subexpressions[i]; ICPPEvaluation origEval = expressions[i];
ICPPEvaluation newEval; ICPPEvaluation newEval;
if (origEval instanceof EvalPackExpansion) { if (origEval instanceof EvalPackExpansion) {
ICPPEvaluation pattern = ((EvalPackExpansion) origEval).getExpansionPattern(); ICPPEvaluation pattern = ((EvalPackExpansion) origEval).getExpansionPattern();
@ -129,7 +129,7 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
newEval = origEval.instantiate(context, maxDepth); newEval = origEval.instantiate(context, maxDepth);
} else { } else {
int shift = packSize - 1; int shift = packSize - 1;
ICPPEvaluation[] newResult = new ICPPEvaluation[subexpressions.length + resultShift + shift]; ICPPEvaluation[] newResult = new ICPPEvaluation[expressions.length + resultShift + shift];
System.arraycopy(result, 0, newResult, 0, i + resultShift); System.arraycopy(result, 0, newResult, 0, i + resultShift);
int oldPackOffset = context.getPackOffset(); int oldPackOffset = context.getPackOffset();
for (int j = 0; j < packSize; ++j) { for (int j = 0; j < packSize; ++j) {
@ -147,12 +147,12 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
newEval = origEval.instantiate(context, maxDepth); newEval = origEval.instantiate(context, maxDepth);
} }
if (result != subexpressions) { if (result != expressions) {
result[i + resultShift] = newEval; result[i + resultShift] = newEval;
} else if (newEval != origEval) { } else if (newEval != origEval) {
assert resultShift == 0; assert resultShift == 0;
result = new ICPPEvaluation[subexpressions.length]; result = new ICPPEvaluation[expressions.length];
System.arraycopy(subexpressions, 0, result, 0, i); System.arraycopy(expressions, 0, result, 0, i);
result[i] = newEval; result[i] = newEval;
} }
} }

View file

@ -229,7 +229,7 @@ public final class EvalFunctionCall extends CPPDependentEvaluation {
@Override @Override
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) { public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
ICPPEvaluation[] args = instantiateCommaSeparatedSubexpressions(fArguments, context, maxDepth); ICPPEvaluation[] args = instantiateExpressions(fArguments, context, maxDepth);
if (args == fArguments) if (args == fArguments)
return this; return this;

View file

@ -138,7 +138,7 @@ public class EvalInitList extends CPPDependentEvaluation {
@Override @Override
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) { public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
ICPPEvaluation[] clauses = instantiateCommaSeparatedSubexpressions(fClauses, context, maxDepth); ICPPEvaluation[] clauses = instantiateExpressions(fClauses, context, maxDepth);
if (clauses == fClauses) if (clauses == fClauses)
return this; return this;
return new EvalInitList(clauses, getTemplateDefinition()); return new EvalInitList(clauses, getTemplateDefinition());

View file

@ -379,7 +379,7 @@ public class EvalTypeId extends CPPDependentEvaluation {
@Override @Override
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) { public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
ICPPEvaluation[] args = instantiateCommaSeparatedSubexpressions(fArguments, context, maxDepth); ICPPEvaluation[] args = instantiateExpressions(fArguments, context, maxDepth);
IType type = CPPTemplates.instantiateType(fInputType, context); IType type = CPPTemplates.instantiateType(fInputType, context);
if (args == fArguments && type == fInputType) if (args == fArguments && type == fInputType)
return this; return this;