mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
expressionsem.d remove goto (#16845)
This commit is contained in:
parent
f4e21aec67
commit
d578c61fc4
1 changed files with 9 additions and 6 deletions
|
@ -665,6 +665,13 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
|
||||||
AggregateDeclaration ad = isAggregate(ae.e1.type);
|
AggregateDeclaration ad = isAggregate(ae.e1.type);
|
||||||
Dsymbol slice = search_function(ad, Id.slice);
|
Dsymbol slice = search_function(ad, Id.slice);
|
||||||
//printf("slice = %s %s\n", slice.kind(), slice.toChars());
|
//printf("slice = %s %s\n", slice.kind(), slice.toChars());
|
||||||
|
Expression fallback()
|
||||||
|
{
|
||||||
|
if (ae.arguments.length == 1)
|
||||||
|
return null;
|
||||||
|
error(ae.loc, "multi-dimensional slicing requires template `opSlice`");
|
||||||
|
return ErrorExp.get();
|
||||||
|
}
|
||||||
foreach (i, e; *ae.arguments)
|
foreach (i, e; *ae.arguments)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
|
@ -672,11 +679,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
|
||||||
|
|
||||||
if (e.op == EXP.interval && !(slice && slice.isTemplateDeclaration()))
|
if (e.op == EXP.interval && !(slice && slice.isTemplateDeclaration()))
|
||||||
{
|
{
|
||||||
Lfallback:
|
return fallback();
|
||||||
if (ae.arguments.length == 1)
|
|
||||||
return null;
|
|
||||||
error(ae.loc, "multi-dimensional slicing requires template `opSlice`");
|
|
||||||
return ErrorExp.get();
|
|
||||||
}
|
}
|
||||||
//printf("[%d] e = %s\n", i, e.toChars());
|
//printf("[%d] e = %s\n", i, e.toChars());
|
||||||
|
|
||||||
|
@ -716,7 +719,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, Expression* pe0)
|
||||||
sc = sc.pop();
|
sc = sc.pop();
|
||||||
global.endGagging(xerrors);
|
global.endGagging(xerrors);
|
||||||
if (!fslice)
|
if (!fslice)
|
||||||
goto Lfallback;
|
return fallback();
|
||||||
|
|
||||||
e = new DotTemplateInstanceExp(ae.loc, ae.e1, slice.ident, tiargs);
|
e = new DotTemplateInstanceExp(ae.loc, ae.e1, slice.ident, tiargs);
|
||||||
e = new CallExp(ae.loc, e, fargs);
|
e = new CallExp(ae.loc, e, fargs);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue