From e0389f5a1f32cb611e5a595a5974ee1d5c15f43d Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 15 Jun 2017 16:35:10 -0700 Subject: Replace `DeclRef` approach For context: a `DeclRef` is supposed to capture both a pointer to a particualr declaration, and also any information needed to specialize that declaration for a context (e.g., generic parameter substitutions). The existing approach had a hiearchy of specialized decl-ref types that mirrored the AST hierarchy, but that led to a lot of boilerplate where you had to recapitulate the exact same hierarchy. The new appraoch basically treats `DeclRef` as a sort of "smart pointer" in that it wraps a pointer to a `T` (the declaration), plus a side field for the specialization info, and then allows it to be cast as needed to other types (where the pointer cast would be allowed), while carrying along the side info. To enable this, all the things that used to be member functions of declaration-reference types are now free functions that take a `DeclRef` for some specific `T` as a parameter. --- source/slang/parser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/slang/parser.cpp') diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp index df2986959..29b02f816 100644 --- a/source/slang/parser.cpp +++ b/source/slang/parser.cpp @@ -754,7 +754,7 @@ namespace Slang if( lookupResult.isValid() && !lookupResult.isOverloaded() ) { auto& item = lookupResult.item; - auto decl = item.declRef.GetDecl(); + auto decl = item.declRef.getDecl(); if( auto modifierDecl = dynamic_cast(decl) ) { @@ -1910,7 +1910,7 @@ namespace Slang auto paramConstraint = new GenericTypeConstraintDecl(); parser->FillPosition(paramConstraint); - auto paramType = DeclRefType::Create(DeclRef(paramDecl, nullptr)); + auto paramType = DeclRefType::Create(DeclRef(paramDecl, nullptr)); auto paramTypeExpr = new SharedTypeExpr(); paramTypeExpr->Position = paramDecl->Position; @@ -2365,7 +2365,7 @@ parser->ReadToken(TokenType::Comma); if(!lookupResult.isValid() || lookupResult.isOverloaded()) return false; - auto decl = lookupResult.item.declRef.GetDecl(); + auto decl = lookupResult.item.declRef.getDecl(); if( auto typeDecl = dynamic_cast(decl) ) { return true; -- cgit v1.2.3