Skip to content
Draft
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
29 changes: 8 additions & 21 deletions compiler/src/dmd/statementsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -3972,7 +3972,6 @@ private extern(D) Expression applyDelegate(ForeachStatement fs, Expression flde,
private extern(D) Expression applyArray(ForeachStatement fs, Expression flde,
Type tab, Scope* sc2, Type tn, Type tnv)
{
Expression ec;
const dim = fs.parameters.length;
const loc = fs.loc;
/* Call:
Expand Down Expand Up @@ -4009,29 +4008,17 @@ private extern(D) Expression applyArray(ForeachStatement fs, Expression flde,
int j = snprintf(fdname.ptr, BUFFER_LEN, "_aApply%s%.*s%llu", r, 2, fntab[flag].ptr, cast(ulong)dim);
assert(j < BUFFER_LEN);

FuncDeclaration fdapply;
TypeDelegate dgty;
auto params = new Parameters(new Parameter(Loc.initial, STC.in_, tn.arrayOf(), null, null, null));
auto dgparams = new Parameters(new Parameter(Loc.initial, STC.none, Type.tvoidptr, null, null, null));
if (dim == 2)
dgparams.push(new Parameter(Loc.initial, STC.none, Type.tvoidptr, null, null, null));
dgty = new TypeDelegate(new TypeFunction(ParameterList(dgparams), Type.tint32, LINK.d));
params.push(new Parameter(Loc.initial, STC.none, dgty, null, null, null));
fdapply = genCfunc(params, Type.tint32, fdname.ptr);
// Lower to `.object._aApply(aggr, flde)`
Expression ec = new IdentifierExp(loc, Id.empty);
ec = new DotIdExp(loc, ec, Id.object);
ec = new DotIdExp(loc, ec, Identifier.idPool(fdname.ptr, j));
ec = ec.expressionSemantic(sc2);

if (tab.isTypeSArray())
fs.aggr = fs.aggr.castTo(sc2, tn.arrayOf());
// paint delegate argument to the type runtime expects
Expression fexp = flde;
if (!dgty.equals(flde.type))
{
fexp = new CastExp(loc, flde, flde.type);
fexp.type = dgty;
}
ec = new VarExp(Loc.initial, fdapply, false);
ec = new CallExp(loc, ec, fs.aggr, fexp);
ec.type = Type.tint32; // don't run semantic() on ec
return ec;

ec = new CallExp(loc, ec, fs.aggr, flde);
return ec.expressionSemantic(sc2);
}

private extern(D) Expression applyAssocArray(ForeachStatement fs, Expression flde, Type tab)
Expand Down
1 change: 1 addition & 0 deletions druntime/mak/COPY
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ COPY=\
$(IMPDIR)\core\internal\array\capacity.d \
$(IMPDIR)\core\internal\array\concatenation.d \
$(IMPDIR)\core\internal\array\duplication.d \
$(IMPDIR)\core\internal\array\iteration.d \
$(IMPDIR)\core\internal\array\operations.d \
$(IMPDIR)\core\internal\array\utils.d \
\
Expand Down
3 changes: 1 addition & 2 deletions druntime/mak/DOCS
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ DOCS=\
$(DOCDIR)\core_internal_array_concatenation.html \
$(DOCDIR)\core_internal_array_duplication.html \
$(DOCDIR)\core_internal_array_equality.html \
$(DOCDIR)\core_internal_array_iteration.html \
$(DOCDIR)\core_internal_array_operations.html \
$(DOCDIR)\core_internal_array_utils.html \
$(DOCDIR)\core_internal_array_appending.html \
Expand Down Expand Up @@ -552,8 +553,6 @@ DOCS=\
$(DOCDIR)\core_internal_gc_impl_manual_gc.html \
$(DOCDIR)\core_internal_gc_impl_proto_gc.html \
\
$(DOCDIR)\rt_aApply.html \
$(DOCDIR)\rt_aApplyR.html \
$(DOCDIR)\rt_alloca.html \
$(DOCDIR)\rt_arraycat.html \
$(DOCDIR)\rt_config.html \
Expand Down
3 changes: 1 addition & 2 deletions druntime/mak/SRCS
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ SRCS=\
src\core\internal\array\capacity.d \
src\core\internal\array\concatenation.d \
src\core\internal\array\duplication.d \
src\core\internal\array\iteration.d \
src\core\internal\array\operations.d \
src\core\internal\array\utils.d \
\
Expand Down Expand Up @@ -566,8 +567,6 @@ SRCS=\
src\core\thread\context.d \
src\core\thread\package.d \
\
src\rt\aApply.d \
src\rt\aApplyR.d \
src\rt\alloca.d \
src\rt\arraycat.d \
src\rt\cmath2.d \
Expand Down
Loading
Loading