Пример #1
0
        public bool TryCreateInterpreter(out LLVMExecutionEngineRef OutInterp, out string OutError)
        {
            fixed(LLVMExecutionEngineRef *pOutInterp = &OutInterp)
            {
                sbyte *pError = null;
                var    result = LLVM.CreateInterpreterForModule((LLVMOpaqueExecutionEngine **)pOutInterp, this, &pError);

                if (pError == null)
                {
                    OutError = string.Empty;
                }
                else
                {
                    var span = new ReadOnlySpan <byte>(pError, int.MaxValue);
                    OutError = span.Slice(0, span.IndexOf((byte)'\0')).AsString();
                }

                return(result == 0);
            }
        }
Пример #2
0
        public bool TryCreateMCJITCompiler(out LLVMExecutionEngineRef OutJIT, ref LLVMMCJITCompilerOptions Options, out string OutError)
        {
            fixed(LLVMExecutionEngineRef *pOutJIT = &OutJIT)
            fixed(LLVMMCJITCompilerOptions * pOptions = &Options)
            {
                sbyte *pError = null;
                var    result = LLVM.CreateMCJITCompilerForModule((LLVMOpaqueExecutionEngine **)pOutJIT, this, pOptions, (UIntPtr)Marshal.SizeOf <LLVMMCJITCompilerOptions>(), &pError);

                if (pError == null)
                {
                    OutError = string.Empty;
                }
                else
                {
                    var span = new ReadOnlySpan <byte>(pError, int.MaxValue);
                    OutError = span.Slice(0, span.IndexOf((byte)'\0')).AsString();
                }

                return(result == 0);
            }
        }
Пример #3
0
        public bool TryCreateMCJITCompiler(out LLVMExecutionEngineRef OutJIT, out string OutError)
        {
            var Options = LLVMMCJITCompilerOptions.Create();

            return(TryCreateMCJITCompiler(out OutJIT, ref Options, out OutError));
        }