From 33f7e1599cbecb32c23787b37b2bf3b34bdd5c84 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 25 Aug 2021 10:27:22 -0700 Subject: 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. --- source/slang/core.meta.slang | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/slang/core.meta.slang') 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 __intrinsic_op($(kIROp_BitCast)) T bit_cast(U value); +// Create Existential object +__generic +[__unsafeForceInlineEarly] +__intrinsic_op($(kIROp_CreateExistentialObject)) +T createDynamicObject(uint typeId, U value); + // Specialized function /// Given a string returns an integer hash of that string. -- cgit v1.2.3