Example #1
0
        /// <summary>Add a module to the engine</summary>
        /// <param name="module">The module to add to the engine</param>
        /// <param name="resolver">Symbol resolver delegate</param>
        /// <returns>Handle for the module in the engine</returns>
        /// <remarks>
        /// <note type="note">
        /// With <see cref="OrcJit"/> the module is shared with the engine using a reference
        /// count. In this case the module is not disposed and the <see cref="BitcodeModule.IsShared"/>
        /// property is set to <see langword="true"/>. Callers may continue to use the module in this case,
        /// though modifying it or interned data from it's context may result in undefined behavior.
        /// </note>
        /// </remarks>
        public OrcJitHandle AddModule(BitcodeModule module, SymbolResolver resolver)
        {
            module.MakeShared( );
            var err = LLVMOrcAddEagerlyCompiledIR(JitStackHandle, out LLVMOrcModuleHandle retHandle, module.SharedModuleRef, resolver, IntPtr.Zero);

            if (err != LLVMOrcErrorCode.LLVMOrcErrSuccess)
            {
                throw new Exception(LLVMOrcGetErrorMsg(JitStackHandle));
            }

            return(new OrcJitHandle(retHandle));
        }