use std::fmt;
use std::hash::{Hash, Hasher};
+pub trait ValueTrait: fmt::Debug {
+ fn to_llvm(&self) -> &llvm::Value;
+ fn of_llvm(&llvm::Value) -> &Self;
+}
+
impl PartialEq for Value {
fn eq(&self, other: &Self) -> bool {
self as *const _ == other as *const _
}
}
+impl ValueTrait for Value {
+ fn to_llvm(&self) -> &llvm::Value {
+ &self
+ }
+ fn of_llvm(v: &llvm::Value) -> &Self {
+ &v
+ }
+}
+
impl Eq for Value {}
impl Hash for Value {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(&llvm::build_string(|s| unsafe {
llvm::LLVMRustWriteValueToString(self, s);
- }).expect("nun-UTF8 value description from LLVM"))
+ }).expect("non-UTF8 value description from LLVM"))
}
}