Skip to content

Commit af96549

Browse files
thewilsonatorGeod24
authored andcommitted
Reduce indentation in TemplateDeclaration constructor
also rename TemplateDeclaration members `isAlias` and `isAliasSeq` to `isTrivialAlias` and `isTrivialAliasSeq`
1 parent c4084c3 commit af96549

File tree

3 files changed

+46
-47
lines changed

3 files changed

+46
-47
lines changed

src/dmd/dsymbolsem.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5919,15 +5919,15 @@ void templateInstanceSemantic(TemplateInstance tempinst, Scope* sc, Expressions*
59195919

59205920
/* Greatly simplified semantic processing for AliasSeq templates
59215921
*/
5922-
if (tempdecl.isAliasSeq)
5922+
if (tempdecl.isTrivialAliasSeq)
59235923
{
59245924
tempinst.inst = tempinst;
59255925
return aliasSeqInstanceSemantic(tempinst, sc, fargs, tempdecl);
59265926
}
59275927

59285928
/* Greatly simplified semantic processing for Alias templates
59295929
*/
5930-
else if (tempdecl.isAlias)
5930+
else if (tempdecl.isTrivialAlias)
59315931
{
59325932
tempinst.inst = tempinst;
59335933
return aliasInstanceSemantic(tempinst, sc, fargs, tempdecl);

src/dmd/dtemplate.d

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
558558
bool literal; // this template declaration is a literal
559559
bool ismixin; // this is a mixin template declaration
560560
bool isstatic; // this is static template declaration
561-
bool isAliasSeq; /// matches pattern `template AliasSeq(T...) { alias AliasSeq = T; }`
562-
bool isAlias; /// matches pattern `template Alias(T) { alias Alias = qualifiers(T); }`
561+
bool isTrivialAliasSeq; /// matches pattern `template AliasSeq(T...) { alias AliasSeq = T; }`
562+
bool isTrivialAlias; /// matches pattern `template Alias(T) { alias Alias = qualifiers(T); }`
563563
Prot protection;
564564
int inuse; /// for recursive expansion detection
565565

@@ -602,49 +602,48 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
602602

603603
// Compute in advance for Ddoc's use
604604
// https://issues.dlang.org/show_bug.cgi?id=11153: ident could be NULL if parsing fails.
605-
if (members && ident)
606-
{
607-
Dsymbol s;
608-
if (Dsymbol.oneMembers(members, &s, ident) && s)
609-
{
610-
onemember = s;
611-
s.parent = this;
605+
if (!members || !ident)
606+
return;
612607

613-
/* Set isAliasSeq if this fits the pattern:
614-
* template AliasSeq(T...) { alias AliasSeq = T; }
615-
* or set isAlias if this fits the pattern:
616-
* template Alias(T) { alias Alias = qualifiers(T); }
617-
*/
618-
if (!(parameters && parameters.length == 1))
619-
return;
608+
Dsymbol s;
609+
if (!Dsymbol.oneMembers(members, &s, ident) || !s)
610+
return;
620611

621-
if (auto ad = s.isAliasDeclaration())
622-
{
623-
if (!ad.type)
624-
return;
625-
if (auto ti = ad.type.isTypeIdentifier())
626-
{
627-
if (auto ttp = (*parameters)[0].isTemplateTupleParameter())
628-
{
629-
if (ti.idents.length == 0 &&
630-
ti.ident is ttp.ident &&
631-
ti.mod == 0)
632-
{
633-
//printf("found isAliasSeq %s %s\n", s.toChars(), ad.type.toChars());
634-
isAliasSeq = true;
635-
}
636-
}
637-
else if (auto ttp = (*parameters)[0].isTemplateTypeParameter())
638-
{
639-
if (ti.idents.length == 0 &&
640-
ti.ident is ttp.ident)
641-
{
642-
//printf("found isAlias %s %s\n", s.toChars(), ad.type.toChars());
643-
isAlias = true;
644-
}
645-
}
646-
}
647-
}
612+
onemember = s;
613+
s.parent = this;
614+
615+
/* Set isTrivialAliasSeq if this fits the pattern:
616+
* template AliasSeq(T...) { alias AliasSeq = T; }
617+
* or set isTrivialAlias if this fits the pattern:
618+
* template Alias(T) { alias Alias = qualifiers(T); }
619+
*/
620+
if (!(parameters && parameters.length == 1))
621+
return;
622+
623+
auto ad = s.isAliasDeclaration();
624+
if (!ad || !ad.type)
625+
return;
626+
627+
auto ti = ad.type.isTypeIdentifier();
628+
629+
if (!ti || ti.idents.length != 0)
630+
return;
631+
632+
if (auto ttp = (*parameters)[0].isTemplateTupleParameter())
633+
{
634+
if (ti.ident is ttp.ident &&
635+
ti.mod == 0)
636+
{
637+
//printf("found isTrivialAliasSeq %s %s\n", s.toChars(), ad.type.toChars());
638+
isTrivialAliasSeq = true;
639+
}
640+
}
641+
else if (auto ttp = (*parameters)[0].isTemplateTypeParameter())
642+
{
643+
if (ti.ident is ttp.ident)
644+
{
645+
//printf("found isTrivialAlias %s %s\n", s.toChars(), ad.type.toChars());
646+
isTrivialAlias = true;
648647
}
649648
}
650649
}

src/dmd/template.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class TemplateDeclaration : public ScopeDsymbol
6666
bool literal; // this template declaration is a literal
6767
bool ismixin; // template declaration is only to be used as a mixin
6868
bool isstatic; // this is static template declaration
69-
bool isAliasSeq; // matches `template AliasSeq(T...) { alias AliasSeq = T; }
70-
bool isAlias; // matches `template Alias(T) { alias Alias = T; }
69+
bool isTrivialAliasSeq; // matches `template AliasSeq(T...) { alias AliasSeq = T; }
70+
bool isTrivialAlias; // matches pattern `template Alias(T) { alias Alias = qualifiers(T); }`
7171
Prot protection;
7272
int inuse; // for recursive expansion detection
7373

0 commit comments

Comments
 (0)