Skip to content

Commit c9a49f6

Browse files
committed
Add some Debug implementations
1 parent e1fb4b4 commit c9a49f6

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/block.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ use ffi::prelude::LLVMBasicBlockRef;
33
use std::iter::{Iterator, DoubleEndedIterator, IntoIterator};
44
use std::marker::PhantomData;
55
use std::mem;
6+
use std::ops::Deref;
67
use value::{Function, Value};
78
use util::{self, Sub};
89

910
/// A container of instructions that execute sequentially.
1011
pub struct BasicBlock(PhantomData<[u8]>);
12+
deref!{BasicBlock, Value}
1113
native_ref!(&BasicBlock = LLVMBasicBlockRef);
1214

1315
unsafe impl Sub<Value> for BasicBlock {

src/value.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl Deref for $this {
3838
/// A typed value that can be used as an operand in instructions.
3939
pub struct Value(PhantomData<[u8]>);
4040
native_ref!(&Value = LLVMValueRef);
41+
to_str!{Value, LLVMPrintValueToString}
4142
impl Value {
4243
/// Create a new constant struct from the values given.
4344
pub fn new_struct<'a>(context: &'a Context, vals: &[&'a Value], packed: bool) -> &'a Value {
@@ -92,6 +93,7 @@ pub enum Predicate {
9293
pub struct Arg(PhantomData<[u8]>);
9394
native_ref!(&Arg = LLVMValueRef);
9495
sub!{Arg, LLVMIsAArgument}
96+
to_str!{Arg, LLVMPrintValueToString}
9597
impl Arg {
9698
/// Add the attribute given to this argument.
9799
pub fn add_attribute(&self, attr: Attribute) {
@@ -135,6 +137,7 @@ impl Arg {
135137
pub struct GlobalValue(PhantomData<[u8]>);
136138
native_ref!(&GlobalValue = LLVMValueRef);
137139
sub!{GlobalValue, LLVMIsAGlobalValue}
140+
to_str!{GlobalValue, LLVMPrintValueToString}
138141
impl GlobalValue {
139142
/// Set the linkage type for this global
140143
pub fn set_linkage(&self, linkage: Linkage) {
@@ -161,6 +164,7 @@ impl GlobalValue {
161164
pub struct GlobalVariable(PhantomData<[u8]>);
162165
native_ref!(&GlobalVariable = LLVMValueRef);
163166
sub!{GlobalVariable, LLVMIsAGlobalVariable, GlobalValue}
167+
to_str!{GlobalVariable, LLVMPrintValueToString}
164168
impl GlobalVariable {
165169
/// Set the initial value of the global
166170
pub fn set_initializer(&self, val: &Value) {
@@ -193,13 +197,15 @@ impl GlobalVariable {
193197
pub struct Alias(PhantomData<[u8]>);
194198
native_ref!(&Alias = LLVMValueRef);
195199
sub!{Alias, LLVMIsAGlobalAlias, GlobalValue}
200+
to_str!{Alias, LLVMPrintValueToString}
196201
/// A function is a kind of value that can be called and contains blocks of code.
197202
///
198203
/// To get the value of each argument to a function, you can use the index operator.
199204
/// For example, `&func[0]` is the value that represents the first argument to the function.
200205
pub struct Function(PhantomData<[u8]>);
201206
native_ref!(&Function = LLVMValueRef);
202207
sub!{Function, LLVMIsAFunction, GlobalValue}
208+
to_str!{Function, LLVMPrintValueToString}
203209
impl Index<usize> for Function {
204210
type Output = Arg;
205211
fn index(&self, index: usize) -> &Arg {
@@ -394,5 +400,4 @@ impl GetContext for Value {
394400
fn get_context(&self) -> &Context {
395401
self.get_type().get_context()
396402
}
397-
}
398-
to_str!(Value, LLVMPrintValueToString);
403+
}

0 commit comments

Comments
 (0)