diff options
| author | Yong He <yonghe@outlook.com> | 2024-05-03 12:18:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-03 12:18:47 -0700 |
| commit | 47a917c964f4fda32d75f200efe863f6d68c737c (patch) | |
| tree | 0957d915e937113af1322e5c0179012074fa7976 /source/slang | |
| parent | 13250ffa4d54c4e51b0a6473927e50a5da351ab3 (diff) | |
Fix `Ptr::__subscript` to accept any integer index. (#4100)
* Fix `Ptr::__subscript` to accept any integer index.
* Fix `Ptr::__subscript` to allow 64bit indices.
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/core.meta.slang | 3 | ||||
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 4 | ||||
| -rw-r--r-- | source/slang/slang-parser.cpp | 1 |
3 files changed, 7 insertions, 1 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index e6a98bc40..3fc2fc570 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -694,7 +694,8 @@ struct Ptr __intrinsic_op($(kIROp_CastIntToPtr)) __init(int64_t val); - __subscript(int index) -> T + __generic<TInt : __BuiltinIntegerType> + __subscript(TInt index) -> T { __intrinsic_op($(kIROp_GetOffsetPtr)) ref; diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 2bf5f1e96..a8cf11cdc 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -10050,6 +10050,10 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> { return ensureDecl(context, typedefDecl); } + else if (auto subscriptDecl = as<SubscriptDecl>(genDecl->inner)) + { + return ensureDecl(context, subscriptDecl); + } SLANG_RELEASE_ASSERT(false); UNREACHABLE_RETURN(LoweredValInfo()); } diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index ad0398e2f..d90e541f8 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -4311,6 +4311,7 @@ namespace Slang case ASTNodeType::TypeAliasDecl: case ASTNodeType::TypeDefDecl: case ASTNodeType::ExtensionDecl: + case ASTNodeType::SubscriptDecl: return true; default: return false; |
