Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor opover.d to improve style #20807

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,9 @@ TupleDeclaration isAliasThisTuple(Expression e)
* Runs semantic on ae.arguments. Declares temporary variables
* if '$' was used.
*/
Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
Expression resolveOpDollar(Scope* sc, ArrayExp ae, out Expression pe0)
{
assert(!ae.lengthVar);
*pe0 = null;
AggregateDeclaration ad = isAggregate(ae.e1.type);
Dsymbol slice = search_function(ad, Id.opSlice);
//printf("slice = %s %s\n", slice.kind(), slice.toChars());
Expand All @@ -679,7 +678,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
foreach (i, e; *ae.arguments)
{
if (i == 0)
*pe0 = extractOpDollarSideEffect(sc, ae);
pe0 = extractOpDollarSideEffect(sc, ae);

if (e.op == EXP.interval && !(slice && slice.isTemplateDeclaration()))
{
Expand All @@ -702,7 +701,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
// If $ was used, declare it now
Expression de = new DeclarationExp(ae.loc, ae.lengthVar);
de = de.expressionSemantic(sc);
*pe0 = Expression.combine(*pe0, de);
pe0 = Expression.combine(pe0, de);
}
sc = sc.pop();

Expand All @@ -725,7 +724,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
if (!fslice)
return fallback();

e = new DotTemplateInstanceExp(ae.loc, ae.e1, slice.ident, tiargs);
e = new DotTemplateInstanceExp(ae.loc, ae.e1, Id.opSlice, tiargs);
e = new CallExp(ae.loc, e, fargs);
e = e.expressionSemantic(sc);
}
Expand All @@ -749,7 +748,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
* Returns:
* ae, or ErrorExp if errors occurred
*/
Expression resolveOpDollar(Scope* sc, ArrayExp ae, IntervalExp ie, Expression* pe0)
Expression resolveOpDollar(Scope* sc, ArrayExp ae, IntervalExp ie, ref Expression pe0)
{
//assert(!ae.lengthVar);
if (!ie)
Expand Down Expand Up @@ -786,7 +785,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, IntervalExp ie, Expression* p
// If $ was used, declare it now
Expression de = new DeclarationExp(ae.loc, ae.lengthVar);
de = de.expressionSemantic(sc);
*pe0 = Expression.combine(*pe0, de);
pe0 = Expression.combine(pe0, de);
}

sc = sc.pop();
Expand Down Expand Up @@ -10335,7 +10334,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
if (search_function(ad, Id.opIndexAssign))
{
// Deal with $
res = resolveOpDollar(sc, ae, &e0);
res = resolveOpDollar(sc, ae, e0);
if (!res) // a[i..j] = e2 might be: a.opSliceAssign(e2, i, j)
goto Lfallback;
if (res.op == EXP.error)
Expand Down Expand Up @@ -10365,7 +10364,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
if (maybeSlice && search_function(ad, Id.opSliceAssign))
{
// Deal with $
res = resolveOpDollar(sc, ae, ie, &e0);
res = resolveOpDollar(sc, ae, ie, e0);
if (res.op == EXP.error)
return setResult(res);

Expand Down
Loading
Loading