summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-impl.h
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-10-24 22:19:38 -0700
committerGitHub <noreply@github.com>2022-10-24 22:19:38 -0700
commit41cb7c13e37ec32ffb6557d21da079d77151e136 (patch)
tree38d2c44938e2679c42c5c0e73f5411e59015df93 /source/slang/slang-check-impl.h
parent1093218d6f0e114eb9fa52d60ca525bf9dd9f98a (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-check-impl.h')
-rw-r--r--source/slang/slang-check-impl.h47
1 files changed, 12 insertions, 35 deletions
diff --git a/source/slang/slang-check-impl.h b/source/slang/slang-check-impl.h
index 5c1c20e3a..0877f2d6e 100644
--- a/source/slang/slang-check-impl.h
+++ b/source/slang/slang-check-impl.h
@@ -209,32 +209,10 @@ namespace Slang
Substitutions* subst = nullptr;
};
- struct LookupRequestKey
- {
- NodeBase* base;
- Name* name;
- LookupOptions options;
- LookupMask mask;
- bool operator==(const LookupRequestKey& other) const
- {
- return base == other.base && name == other.name && options == other.options && mask == other.mask;
- }
- HashCode getHashCode() const
- {
- Hasher hasher;
- hasher.hashValue(base);
- hasher.hashValue(name);
- hasher.hashValue(options);
- hasher.hashValue(mask);
- return hasher.getResult();
- }
- };
-
struct TypeCheckingCache
{
Dictionary<OperatorOverloadCacheKey, OverloadCandidate> resolvedOperatorOverloadCache;
Dictionary<BasicTypeKeyPair, ConversionCost> conversionCostCache;
- Dictionary<LookupRequestKey, LookupResult> lookupCache;
};
struct DifferentiableTypeSemanticContext
@@ -305,11 +283,6 @@ namespace Slang
bool m_isTypeDictionaryRequired = false;
};
- /// Give a cache and a name, will remove all entries associated with a name
- /// Might be useful/necessary if a new name is introduced
- void removeLookupForName(TypeCheckingCache* cache, Name* name);
-
-
/// Shared state for a semantics-checking session.
struct SharedSemanticsContext
{
@@ -525,6 +498,13 @@ namespace Slang
return result;
}
+ SemanticsContext allowStaticReferenceToNonStaticMember()
+ {
+ SemanticsContext result(*this);
+ result.m_allowStaticReferenceToNonStaticMember = true;
+ return result;
+ }
+
private:
SharedSemanticsContext* m_shared = nullptr;
@@ -545,6 +525,10 @@ namespace Slang
/// The type of a try clause (if any) enclosing current expr.
TryClauseType m_enclosingTryClauseType = TryClauseType::None;
+ /// Whether an expr referencing to a non-static member in static style (e.g. `Type.member`)
+ /// is considered valid in the current context.
+ bool m_allowStaticReferenceToNonStaticMember = false;
+
ASTBuilder* m_astBuilder = nullptr;
};
@@ -819,11 +803,6 @@ namespace Slang
// Check and register a type if it is differentiable.
void maybeRegisterDifferentiableType(ASTBuilder* builder, Type* type);
- // Check if a term is referencing a member, and add a decoration to it's
- // differential getter function, if one exists.
- //
- Expr* maybeMakeDifferentialExpr(Expr* checkedTerm);
-
// Construct the differential for 'type', if it exists.
Type* _getDifferential(ASTBuilder* builder, Type* type);
@@ -1018,7 +997,7 @@ namespace Slang
bool getAttributeTargetSyntaxClasses(SyntaxClass<NodeBase> & cls, uint32_t typeFlags);
- bool validateAttribute(Attribute* attr, AttributeDecl* attribClassDecl);
+ bool validateAttribute(Attribute* attr, AttributeDecl* attribClassDecl, ModifiableSyntaxNode* attrTarget);
AttributeBase* checkAttribute(
UncheckedAttribute* uncheckedAttr,
@@ -1924,8 +1903,6 @@ namespace Slang
Expr* visitVarExpr(VarExpr *expr);
- Expr* visitDifferentiableDeclRefExpr(DifferentiableDeclRefExpr *expr);
-
Expr* visitTypeCastExpr(TypeCastExpr * expr);
Expr* visitTryExpr(TryExpr* expr);