Skip to content

Commit ce6b9f6

Browse files
committed
added builder function for extract_value and minor fixes
1 parent 94beaa9 commit ce6b9f6

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use ffi::core;
22
use ffi::prelude::LLVMBasicBlockRef;
3-
use value::Value;
3+
use value::Function;
44
use util;
55

66
/// A container of instructions that execute sequentially.
77
pub struct BasicBlock;
88
native_ref!(&BasicBlock = LLVMBasicBlockRef);
99
impl BasicBlock {
1010
/// Return the enclosing method, or `None` if it is not attached to a method.
11-
pub fn get_parent(&self) -> Option<&Value> {
11+
pub fn get_parent(&self) -> Option<&Function> {
1212
unsafe { util::ptr_to_null(core::LLVMGetBasicBlockParent(self.into())) }
1313
}
1414
/// Move this basic block after the `other` basic block in its function.

src/builder.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ impl Builder {
118118
pub fn build_insert_value(&self, agg: &Value, elem: &Value, index: usize) -> &Value {
119119
unsafe { core::LLVMBuildInsertValue(self.into(), agg.into(), elem.into(), index as c_uint, NULL_NAME.as_ptr()).into() }
120120
}
121+
/// Build an instruction that extracts a value from an aggregate data value.
122+
pub fn build_extract_value(&self, agg: &Value, index: usize) -> &Value {
123+
unsafe { core::LLVMBuildExtractValue(self.into(), agg.into(), index as c_uint, NULL_NAME.as_ptr()).into() }
124+
}
121125
/// Build an instruction that computes the address of a subelement of an aggregate data structure.
122126
///
123127
/// Basically type-safe pointer arithmetic.

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ pub use module::{AddressSpace, Module, Functions};
3333
pub use object::{ObjectFile, Symbol, Symbols};
3434
pub use target::{TargetData, Target};
3535
pub use ty::{FunctionType, StructType, Type};
36-
pub use value::{Arg, Attribute, Value, Function, GlobalValue, GlobalVariable, Linkage, Predicate};
36+
pub use value::{Alias, Arg, Attribute, Value, Function, GlobalValue, GlobalVariable, Linkage, Predicate};
3737
pub use util::CastFrom;

0 commit comments

Comments
 (0)