diff options
| author | Yong He <yonghe@outlook.com> | 2022-10-24 22:19:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-24 22:19:38 -0700 |
| commit | 41cb7c13e37ec32ffb6557d21da079d77151e136 (patch) | |
| tree | 38d2c44938e2679c42c5c0e73f5411e59015df93 /source/slang/slang-lookup.cpp | |
| parent | 1093218d6f0e114eb9fa52d60ca525bf9dd9f98a (diff) | |
Rework differentiation of member access through `[DerivativeMember(DiffType.field)]` (#2460)
* wip: remove auto-diff for member access, add diff through property accessors.
* Fix getter-setter test.
* Fix getter-setter-multi test.
* Fix nested-jvp test.
* Use [DerivativeMember] attribute to differentiate through member access.
* Clean up.
* More cleanup.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-lookup.cpp')
| -rw-r--r-- | source/slang/slang-lookup.cpp | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/source/slang/slang-lookup.cpp b/source/slang/slang-lookup.cpp index cddf3d7ce..c574be4ea 100644 --- a/source/slang/slang-lookup.cpp +++ b/source/slang/slang-lookup.cpp @@ -89,6 +89,18 @@ void buildMemberDictionary(ContainerDecl* decl) bool DeclPassesLookupMask(Decl* decl, LookupMask mask) { + // Always exclude extern members from lookup result. + if (decl->hasModifier<ExtensionExternVarModifier>()) + { + return false; + } + else if (decl->hasModifier<ExternModifier>()) + { + if (as<ExtensionDecl>(decl->parentDecl)) + { + return false; + } + } // type declarations if(auto aggTypeDecl = as<AggTypeDecl>(decl)) { @@ -108,7 +120,7 @@ bool DeclPassesLookupMask(Decl* decl, LookupMask mask) { return (int(mask) & int(LookupMask::Attribute)) != 0; } - + // default behavior is to assume a value declaration // (no overloading allowed) @@ -942,7 +954,7 @@ static void _lookUpInScopes( // The implicit `this`/`This` for a function-like declaration // depends on modifiers attached to the declaration. // - if (funcDeclRef.getDecl()->hasModifier<HLSLStaticModifier>()) + if (isEffectivelyStatic(funcDeclRef.getDecl())) { // A `static` method only has access to an implicit `This`, // and does not have a `this` expression available. @@ -1002,26 +1014,8 @@ LookupResult lookUp( LookupMask mask) { LookupResult result; - LookupRequestKey key; - TypeCheckingCache* typeCheckingCache = nullptr; - if (semantics) - { - typeCheckingCache = semantics->getLinkage()->getTypeCheckingCache(); - key.base = scope; - key.name = name; - key.options = LookupOptions::None; - key.mask = mask; - if (typeCheckingCache->lookupCache.TryGetValue(key, result)) - { - return result; - } - } LookupRequest request = initLookupRequest(semantics, name, mask, LookupOptions::None, scope); _lookUpInScopes(astBuilder, name, request, result); - if (typeCheckingCache) - { - typeCheckingCache->lookupCache[key] = result; - } return result; } @@ -1033,20 +1027,9 @@ LookupResult lookUpMember( LookupMask mask, LookupOptions options) { - TypeCheckingCache* typeCheckingCache = semantics->getLinkage()->getTypeCheckingCache(); - LookupRequestKey key; - key.base = type; - key.name = name; - key.options = options; - key.mask = mask; LookupResult result; - if (typeCheckingCache->lookupCache.TryGetValue(key, result)) - { - return result; - } LookupRequest request = initLookupRequest(semantics, name, mask, options, nullptr); _lookUpMembersInType(astBuilder, name, type, request, result, nullptr); - typeCheckingCache->lookupCache[key] = result; return result; } |
