2011-03-15 21:57:26 +00:00
|
|
|
//===- RustWrapper.cpp - Rust wrapper for core functions --------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines alternate interfaces to core functions that are more
|
|
|
|
// readily callable by Rust's FFI.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm-c/Core.h"
|
|
|
|
#include "llvm-c/Object.h"
|
|
|
|
#include <cstdlib>
|
|
|
|
|
|
|
|
static char *LLVMRustError;
|
|
|
|
|
|
|
|
extern "C" LLVMMemoryBufferRef
|
|
|
|
LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) {
|
|
|
|
LLVMMemoryBufferRef MemBuf = NULL;
|
|
|
|
LLVMCreateMemoryBufferWithContentsOfFile(Path, &MemBuf, &LLVMRustError);
|
|
|
|
return MemBuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" const char *LLVMRustGetLastError(void) {
|
|
|
|
return LLVMRustError;
|
|
|
|
}
|
|
|
|
|
2011-04-13 17:53:19 +00:00
|
|
|
extern "C" void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM);
|
|
|
|
|
|
|
|
void (*RustHackToFetchPassesO)(LLVMPassManagerRef PM) =
|
|
|
|
LLVMAddBasicAliasAnalysisPass;
|