Skip to content

Commit

Permalink
[mtype.d] use early returns in addSTC
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator authored and dlang-bot committed Oct 8, 2024
1 parent 6692074 commit 2e4d80b
Showing 1 changed file with 43 additions and 42 deletions.
85 changes: 43 additions & 42 deletions compiler/src/dmd/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -1116,65 +1116,66 @@ extern (C++) abstract class Type : ASTNode
Type t = this;
if (t.isImmutable())
{
return t;
}
else if (stc & STC.immutable_)
{
t = t.makeImmutable();
return t;
}
else

if ((stc & STC.shared_) && !t.isShared())
{
if (t.isWild())
{
if (t.isConst())
t = t.makeSharedWildConst();
else
t = t.makeSharedWild();
}
else
{
if (t.isConst())
t = t.makeSharedConst();
else
t = t.makeShared();
}
}
if ((stc & STC.const_) && !t.isConst())
{
if ((stc & STC.shared_) && !t.isShared())
if (t.isShared())
{
if (t.isWild())
{
if (t.isConst())
t = t.makeSharedWildConst();
else
t = t.makeSharedWild();
}
t = t.makeSharedWildConst();
else
{
if (t.isConst())
t = t.makeSharedConst();
else
t = t.makeShared();
}
t = t.makeSharedConst();
}
else
{
if (t.isWild())
t = t.makeWildConst();
else
t = t.makeConst();
}
if ((stc & STC.const_) && !t.isConst())
}
if ((stc & STC.wild) && !t.isWild())
{
if (t.isShared())
{
if (t.isShared())
{
if (t.isWild())
t = t.makeSharedWildConst();
else
t = t.makeSharedConst();
}
if (t.isConst())
t = t.makeSharedWildConst();
else
{
if (t.isWild())
t = t.makeWildConst();
else
t = t.makeConst();
}
t = t.makeSharedWild();
}
if ((stc & STC.wild) && !t.isWild())
else
{
if (t.isShared())
{
if (t.isConst())
t = t.makeSharedWildConst();
else
t = t.makeSharedWild();
}
if (t.isConst())
t = t.makeWildConst();
else
{
if (t.isConst())
t = t.makeWildConst();
else
t = t.makeWild();
}
t = t.makeWild();
}
}

return t;
}

Expand Down

0 comments on commit 2e4d80b

Please sign in to comment.