diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2023-07-26 17:15:21 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-26 17:15:21 -0400 |
| commit | ba89fc84267bfd09f1c8abf10a5b85d09bbc79de (patch) | |
| tree | 2c79fc5dafb89a030d22fa86cd6fa3d69a89a785 /source/slang/slang-check-impl.h | |
| parent | b8ade05df10a2774d3da5ef1fb2c7479ff48989a (diff) | |
Refactor `dmul(This, Differential)` to `dmul<T:Real>(T, Differential)` (#3029)
* Refactor `dmul(This, Differential)` to `dmul<T:Real>(T, Differential)`
- Add AST synthesis support for generic containers
- Refactor relevant tests
* Merge dmul synthesis with dadd and dzero, and disambiguate using an enum
* Fix trailing spaces
Diffstat (limited to 'source/slang/slang-check-impl.h')
| -rw-r--r-- | source/slang/slang-check-impl.h | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/source/slang/slang-check-impl.h b/source/slang/slang-check-impl.h index 04112743a..575d4aff7 100644 --- a/source/slang/slang-check-impl.h +++ b/source/slang/slang-check-impl.h @@ -1467,6 +1467,13 @@ namespace Slang DeclRef<FuncDecl> requiredMemberDeclRef, List<Expr*>& synArgs, ThisExpr*& synThis); + + GenericDecl* synthesizeGenericSignatureForRequirementWitness( + ConformanceCheckingContext* context, + DeclRef<GenericDecl> requiredMemberDeclRef, + List<Expr*>& synArgs, + List<Expr*>& synGenericArgs, + ThisExpr*& synThis); void _addMethodWitness( WitnessTable* witnessTable, @@ -1503,15 +1510,39 @@ namespace Slang LookupResult const& lookupResult, DeclRef<Decl> requiredMemberDeclRef, RefPtr<WitnessTable> witnessTable); + - /// Attempt to synthesize `zero`, `dadd` and `dmul` methods for a type that conforms to + enum SynthesisPattern + { + // Synthesized method inducts over all arguments. + // T fn(T x, T y, T z, ...) + // { + // typeof(T::member0)::fn(x.member0, y.member0, z.member0, ...); + // typeof(T::member1)::fn(x.member1, y.member1, z.member1, ...); + // ... + // } + // + AllInductive, + + // Synthesized method inducts over all arguments except the first. + // T fn(U x, T y, T z) + // { + // typeof(T::member0)::fn(x, y.member0, z.member0, ...); + // typeof(T::member1)::fn(x, y.member1, z.member1, ...); + // ... + // } + FixedFirstArg + }; + + /// Attempt to synthesize `zero`, `dadd` & `dmul` methods for a type that conforms to /// `IDifferentiable`. /// On success, installs the syntethesized functions and returns `true`. /// Otherwise, returns `false`. bool trySynthesizeDifferentialMethodRequirementWitness( ConformanceCheckingContext* context, DeclRef<Decl> requirementDeclRef, - RefPtr<WitnessTable> witnessTable); + RefPtr<WitnessTable> witnessTable, + SynthesisPattern pattern); /// Attempt to synthesize an associated `Differential` type for a type that conforms to /// `IDifferentiable`. |
