diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-06-15 16:35:10 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-06-15 16:35:10 -0700 |
| commit | e0389f5a1f32cb611e5a595a5974ee1d5c15f43d (patch) | |
| tree | 7bee1ed3a1f235ac97de9f8d9893f2994015c5c3 /source/slang/parser.cpp | |
| parent | 04d43cd71f081f1b8d2f0fd803a47cb6342e4fcd (diff) | |
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<T>` 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<T>` for some specific `T` as a parameter.
Diffstat (limited to 'source/slang/parser.cpp')
| -rw-r--r-- | source/slang/parser.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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<ModifierDecl*>(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<Decl>(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<AggTypeDecl*>(decl) ) { return true; |
