summaryrefslogtreecommitdiffstats
path: root/source/slang/parser.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2017-10-31 11:12:08 -0400
committerYong He <yonghe@outlook.com>2017-10-31 11:12:08 -0400
commit093bf1eb9149ba82258b5a5a159b2f54263b17c2 (patch)
tree8ee5c2bd4b730d3bd446546dd50f0284d3e47161 /source/slang/parser.cpp
parent84f381cc180b3176d6a58da4085ee8470f246922 (diff)
work in-progress: type checking associated types
Diffstat (limited to 'source/slang/parser.cpp')
-rw-r--r--source/slang/parser.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp
index 554eebc18..224450a66 100644
--- a/source/slang/parser.cpp
+++ b/source/slang/parser.cpp
@@ -544,21 +544,6 @@ namespace Slang
return typeDefDecl;
}
- RefPtr<RefObject> ParseAssocType(Parser * parser, void *)
- {
- RefPtr<AssocTypeDecl> assocTypeDecl = new AssocTypeDecl();
-
- auto nameToken = parser->ReadToken(TokenType::Identifier);
- assocTypeDecl->nameAndLoc = NameLoc(nameToken);
- assocTypeDecl->loc = nameToken.loc;
- if (parser->LookAheadToken(TokenType::Colon))
- {
- auto type = parser->ParseTypeExp();
- assocTypeDecl->constraint = type;
- }
- return assocTypeDecl;
- }
-
// Add a modifier to a list of modifiers being built
static void AddModifier(RefPtr<Modifier>** ioModifierLink, RefPtr<Modifier> modifier)
{
@@ -2102,7 +2087,7 @@ namespace Slang
return decl;
}
- static void parseOptionalInheritanceClause(Parser* parser, AggTypeDecl* decl)
+ static void parseOptionalInheritanceClause(Parser* parser, ContainerDecl* decl)
{
if( AdvanceIf(parser, TokenType::Colon) )
{
@@ -2121,6 +2106,18 @@ namespace Slang
}
}
+ RefPtr<RefObject> ParseAssocType(Parser * parser, void *)
+ {
+ RefPtr<AssocTypeDecl> assocTypeDecl = new AssocTypeDecl();
+
+ auto nameToken = parser->ReadToken(TokenType::Identifier);
+ assocTypeDecl->nameAndLoc = NameLoc(nameToken);
+ assocTypeDecl->loc = nameToken.loc;
+ parseOptionalInheritanceClause(parser, assocTypeDecl.Ptr());
+ parser->ReadToken(TokenType::Semicolon);
+ return assocTypeDecl;
+ }
+
static RefPtr<RefObject> parseInterfaceDecl(Parser* parser, void* /*userData*/)
{
RefPtr<InterfaceDecl> decl = new InterfaceDecl();
@@ -4062,7 +4059,7 @@ namespace Slang
#define DECL(KEYWORD, CALLBACK) \
addBuiltinSyntax<Decl>(session, scope, #KEYWORD, &CALLBACK)
DECL(typedef, ParseTypeDef);
- DECL(assoctype, ParseAssocType);
+ DECL(associatedtype,ParseAssocType);
DECL(cbuffer, parseHLSLCBufferDecl);
DECL(tbuffer, parseHLSLTBufferDecl);
DECL(__generic, ParseGenericDecl);