diff options
| author | Yong He <yonghe@outlook.com> | 2021-08-25 10:27:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-25 10:27:22 -0700 |
| commit | 33f7e1599cbecb32c23787b37b2bf3b34bdd5c84 (patch) | |
| tree | 1fcdadfa1d03a21668606439402e80e6a754162c /source/slang/core.meta.slang | |
| parent | 3b0b920608928f8cb39dc9116043d5a8644149c3 (diff) | |
Add `createDynamicObject` stdlib function. (#1923)
This function takes a user provided `typeID` and arbitrary typed value, and turns them into an existential value whose `witnessTableID` is `typeID` and whose `anyValue` is the user provided value. This allows the users to pack the runtime type id info in arbitrary way.
Diffstat (limited to 'source/slang/core.meta.slang')
| -rw-r--r-- | source/slang/core.meta.slang | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index d1dc25cc7..28fd1a545 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -1901,6 +1901,12 @@ __generic<T, U> __intrinsic_op($(kIROp_BitCast)) T bit_cast(U value); +// Create Existential object +__generic<T, U> +[__unsafeForceInlineEarly] +__intrinsic_op($(kIROp_CreateExistentialObject)) +T createDynamicObject(uint typeId, U value); + // Specialized function /// Given a string returns an integer hash of that string. |
