summaryrefslogtreecommitdiffstats
path: root/source/slang/parser.cpp
diff options
context:
space:
mode:
authorYong He <yongh@outlook.com>2018-01-09 13:26:42 -0800
committerYong He <yonghe@outlook.com>2018-01-12 23:55:38 -0500
commit4b284daeb0cc3f6df0835befad4326c81abeb374 (patch)
treead8d29e14cc483f2eb66bcae7b0f7ffdfd574b86 /source/slang/parser.cpp
parentdf6eeb93c1718334779ae328db277cdf7a9d7b04 (diff)
Support nested generics
fixes #362
Diffstat (limited to 'source/slang/parser.cpp')
-rw-r--r--source/slang/parser.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp
index 11e3eb159..1378191ca 100644
--- a/source/slang/parser.cpp
+++ b/source/slang/parser.cpp
@@ -2216,20 +2216,9 @@ namespace Slang
return blockVarDecl;
}
- static RefPtr<RefObject> ParseExtensionDecl(Parser* parser, void* /*userData*/)
- {
- RefPtr<ExtensionDecl> decl = new ExtensionDecl();
- parser->FillPosition(decl.Ptr());
- decl->targetType = parser->ParseTypeExp();
-
- parseAggTypeDeclBody(parser, decl.Ptr());
-
- return decl;
- }
-
- static void parseOptionalInheritanceClause(Parser* parser, AggTypeDecl* decl)
+ static void parseOptionalInheritanceClause(Parser* parser, AggTypeDeclBase* decl)
{
- if( AdvanceIf(parser, TokenType::Colon) )
+ if (AdvanceIf(parser, TokenType::Colon))
{
do
{
@@ -2242,10 +2231,22 @@ namespace Slang
AddMember(decl, inheritanceDecl);
- } while( AdvanceIf(parser, TokenType::Comma) );
+ } while (AdvanceIf(parser, TokenType::Comma));
}
}
+ static RefPtr<RefObject> ParseExtensionDecl(Parser* parser, void* /*userData*/)
+ {
+ RefPtr<ExtensionDecl> decl = new ExtensionDecl();
+ parser->FillPosition(decl.Ptr());
+ decl->targetType = parser->ParseTypeExp();
+ parseOptionalInheritanceClause(parser, decl);
+ parseAggTypeDeclBody(parser, decl.Ptr());
+
+ return decl;
+ }
+
+
void parseOptionalGenericConstraints(Parser * parser, ContainerDecl* decl)
{
if (AdvanceIf(parser, TokenType::Colon))
@@ -2255,6 +2256,7 @@ namespace Slang
RefPtr<GenericTypeConstraintDecl> paramConstraint = new GenericTypeConstraintDecl();
parser->FillPosition(paramConstraint);
+ // substitution needs to be filled during check
RefPtr<DeclRefType> paramType = DeclRefType::Create(
parser->getSession(),
DeclRef<Decl>(decl, nullptr));
@@ -2279,7 +2281,7 @@ namespace Slang
auto nameToken = parser->ReadToken(TokenType::Identifier);
assocTypeDecl->nameAndLoc = NameLoc(nameToken);
assocTypeDecl->loc = nameToken.loc;
- parseOptionalInheritanceClause(parser, assocTypeDecl);
+ parseOptionalGenericConstraints(parser, assocTypeDecl);
parser->ReadToken(TokenType::Semicolon);
return assocTypeDecl;
}