Skip to content

Commit

Permalink
Rename instantiateCommaSeparatedSubexpressions() to instantiateExpres…
Browse files Browse the repository at this point in the history
…sions()

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
  • Loading branch information
HighCommander4 committed Dec 1, 2018
1 parent 499cdbf commit f5322a3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ protected void marshalTemplateDefinition(ITypeMarshalBuffer buffer) throws CoreE
* This code is similar to CPPTemplates.instantiateArguments(), but applies to evaluations
* rather than template arguments.
*/
protected static ICPPEvaluation[] instantiateCommaSeparatedSubexpressions(ICPPEvaluation[] subexpressions,
InstantiationContext context, int maxDepth) {
ICPPEvaluation[] result = subexpressions;
protected static ICPPEvaluation[] instantiateExpressions(ICPPEvaluation[] expressions, InstantiationContext context,
int maxDepth) {
ICPPEvaluation[] result = expressions;
int resultShift = 0;
for (int i = 0; i < subexpressions.length; i++) {
ICPPEvaluation origEval = subexpressions[i];
for (int i = 0; i < expressions.length; i++) {
ICPPEvaluation origEval = expressions[i];
ICPPEvaluation newEval;
if (origEval instanceof EvalPackExpansion) {
ICPPEvaluation pattern = ((EvalPackExpansion) origEval).getExpansionPattern();
Expand All @@ -129,7 +129,7 @@ protected static ICPPEvaluation[] instantiateCommaSeparatedSubexpressions(ICPPEv
newEval = origEval.instantiate(context, maxDepth);
} else {
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);
int oldPackOffset = context.getPackOffset();
for (int j = 0; j < packSize; ++j) {
Expand All @@ -147,12 +147,12 @@ protected static ICPPEvaluation[] instantiateCommaSeparatedSubexpressions(ICPPEv
newEval = origEval.instantiate(context, maxDepth);
}

if (result != subexpressions) {
if (result != expressions) {
result[i + resultShift] = newEval;
} else if (newEval != origEval) {
assert resultShift == 0;
result = new ICPPEvaluation[subexpressions.length];
System.arraycopy(subexpressions, 0, result, 0, i);
result = new ICPPEvaluation[expressions.length];
System.arraycopy(expressions, 0, result, 0, i);
result[i] = newEval;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public static ICPPEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buff

@Override
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
ICPPEvaluation[] args = instantiateCommaSeparatedSubexpressions(fArguments, context, maxDepth);
ICPPEvaluation[] args = instantiateExpressions(fArguments, context, maxDepth);
if (args == fArguments)
return this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static ICPPEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buff

@Override
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
ICPPEvaluation[] clauses = instantiateCommaSeparatedSubexpressions(fClauses, context, maxDepth);
ICPPEvaluation[] clauses = instantiateExpressions(fClauses, context, maxDepth);
if (clauses == fClauses)
return this;
return new EvalInitList(clauses, getTemplateDefinition());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public static ICPPEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buff

@Override
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);
if (args == fArguments && type == fInputType)
return this;
Expand Down

0 comments on commit f5322a3

Please sign in to comment.