예제 #1
0
        public LLVMModuleRef ParseIR(LLVMMemoryBufferRef MemBuf)
        {
            if (!TryParseIR(MemBuf, out LLVMModuleRef M, out string Message))
            {
                throw new ExternalException(Message);
            }

            return(M);
        }
예제 #2
0
        public LLVMModuleRef GetBitcodeModule(LLVMMemoryBufferRef MemBuf)
        {
            if (!TryGetBitcodeModule(MemBuf, out LLVMModuleRef M, out string Message))
            {
                throw new ExternalException(Message);
            }

            return(M);
        }
예제 #3
0
        public bool TryParseIR(LLVMMemoryBufferRef MemBuf, out LLVMModuleRef OutM, out string OutMessage)
        {
            fixed(LLVMModuleRef *pOutM = &OutM)
            {
                sbyte *pMessage = null;
                var    result   = LLVM.ParseIRInContext(this, MemBuf, (LLVMOpaqueModule **)pOutM, &pMessage);

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

                return(result == 0);
            }
        }
 /// <summary>Convenience wrapper for LLVM.GetErrorMessage.</summary>
 public static void Close(this LLVMMemoryBufferRef self)
 {
     LLVM.DisposeMemoryBuffer(self);
     self.Handle = default;
 }