Skip to content
Open
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
14 changes: 7 additions & 7 deletions compiler/src/dmd/clone.d
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc)
e4 = new BlitExp(loc, new IdentifierExp(loc, Id.p), new VarExp(loc, swap));
}

e = Expression.combine(e1, e2, e3, e4);
e = combine(e1, e2, e3, e4);
}
/* postblit was called when the value was passed to opAssign, we just need to blit the result */
else if (sd.postblit)
Expand All @@ -367,7 +367,7 @@ FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc)
auto ec = new AssignExp(loc,
new DotVarExp(loc, new ThisExp(loc), v),
new DotVarExp(loc, new IdentifierExp(loc, Id.p), v));
e = Expression.combine(e, ec);
e = combine(e, ec);
}
}
if (e)
Expand Down Expand Up @@ -991,7 +991,7 @@ void buildDtors(AggregateDeclaration ad, Scope* sc)

ex = new CallExp(loc, new IdentifierExp(loc, Id.__ArrayDtor), se);
}
e = Expression.combine(ex, e); // combine in reverse order
e = combine(ex, e); // combine in reverse order
}

if (e || (stc & STC.disable))
Expand Down Expand Up @@ -1051,7 +1051,7 @@ void buildDtors(AggregateDeclaration ad, Scope* sc)
ex = new DotVarExp(loc, ex, fd, false);
CallExp ce = new CallExp(loc, ex);
ce.directcall = true;
e = Expression.combine(e, ce);
e = combine(e, ce);
}
auto dd = new DtorDeclaration(declLoc, Loc.initial, stc, Id.__aggrDtor);
dd.isGenerated = true;
Expand Down Expand Up @@ -1248,7 +1248,7 @@ FuncDeclaration buildInv(AggregateDeclaration ad, Scope* sc)
break;
}
}
e = Expression.combine(e, new CallExp(Loc.initial, new VarExp(Loc.initial, inv, false)));
e = combine(e, new CallExp(Loc.initial, new VarExp(Loc.initial, inv, false)));
}
auto inv = new InvariantDeclaration(ad.loc, Loc.initial, stc | stcx,
Id.classInvariant, new ExpStatement(Loc.initial, e));
Expand Down Expand Up @@ -1501,7 +1501,7 @@ FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc)
Expression ex = new ThisExp(loc);
ex = new DotVarExp(loc, ex, fd, false);
ex = new CallExp(loc, ex);
e = Expression.combine(e, ex);
e = combine(e, ex);
}

checkShared();
Expand Down Expand Up @@ -1606,7 +1606,7 @@ private Statement generateCtorBody(StructDeclaration sd, bool move)
auto ec = new AssignExp(loc,
new DotVarExp(loc, new ThisExp(loc), v),
rhs);
e = Expression.combine(e, ec);
e = combine(e, ec);
//printf("e.toChars = %s\n", e.toChars());
}
Statement s1 = new ExpStatement(loc, e);
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dmd/dcast.d
Original file line number Diff line number Diff line change
Expand Up @@ -3181,7 +3181,7 @@ Expression castTo(Expression e, Scope* sc, Type t, Type att = null)
}

auto ini = t.defaultInitLiteral(e.loc);
return Expression.combine(e, ini);
return combine(e, ini);
}

switch (e.op)
Expand Down Expand Up @@ -4593,5 +4593,5 @@ IntRange getIntRange(Expression e)
*/
Expression specialNoreturnCast(Expression toBeCasted, Type to)
{
return Expression.combine(toBeCasted, to.defaultInitLiteral(toBeCasted.loc));
return combine(toBeCasted, to.defaultInitLiteral(toBeCasted.loc));
}
4 changes: 2 additions & 2 deletions compiler/src/dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -2406,7 +2406,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor

iexps.remove(pos);
iexps.insert(pos, te.exps);
(*iexps)[pos] = Expression.combine(te.e0, (*iexps)[pos]);
(*iexps)[pos] = combine(te.e0, (*iexps)[pos]);
goto Lexpand1;
}
else if (isAliasThisTuple(e))
Expand Down Expand Up @@ -2488,7 +2488,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
{
einit = (*te.exps)[i];
if (i == 0)
einit = Expression.combine(te.e0, einit);
einit = combine(te.e0, einit);
}
// Use the original initializer location, not the tuple element's location,
// so error messages point to the declaration site
Expand Down
64 changes: 0 additions & 64 deletions compiler/src/dmd/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -215,70 +215,6 @@ extern (C++) abstract class Expression : ASTNode
return .toChars(this);
}

/**********************************
* Combine e1 and e2 by CommaExp if both are not NULL.
*/
extern (D) static Expression combine(Expression e1, Expression e2) @safe
{
if (e1)
{
if (e2)
{
e1 = new CommaExp(e1.loc, e1, e2);
e1.type = e2.type;
}
}
else
e1 = e2;
return e1;
}

extern (D) static Expression combine(Expression e1, Expression e2, Expression e3) @safe
{
return combine(combine(e1, e2), e3);
}

extern (D) static Expression combine(Expression e1, Expression e2, Expression e3, Expression e4) @safe
{
return combine(combine(e1, e2), combine(e3, e4));
}

/**********************************
* If 'e' is a tree of commas, returns the rightmost expression
* by stripping off it from the tree. The remained part of the tree
* is returned via e0.
* Otherwise 'e' is directly returned and e0 is set to NULL.
*/
extern (D) static Expression extractLast(Expression e, out Expression e0) @trusted
{
if (e.op != EXP.comma)
{
return e;
}

CommaExp ce = cast(CommaExp)e;
if (ce.e2.op != EXP.comma)
{
e0 = ce.e1;
return ce.e2;
}
else
{
e0 = e;

Expression* pce = &ce.e2;
while ((cast(CommaExp)(*pce)).e2.op == EXP.comma)
{
pce = &(cast(CommaExp)(*pce)).e2;
}
assert((*pce).op == EXP.comma);
ce = cast(CommaExp)(*pce);
*pce = ce.e1;

return ce.e2;
}
}

extern (D) static Expressions* arraySyntaxCopy(Expressions* exps)
{
Expressions* a = null;
Expand Down
Loading
Loading