Skip to content

Commit

Permalink
Quick first pass at simplifying API restrictions on cheap copy types …
Browse files Browse the repository at this point in the history
…requiring references
  • Loading branch information
TheDan64 committed Apr 23, 2018
1 parent ebf8be2 commit 99f3e0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@ llvm-sys = "38"
[badges]
travis-ci = { repository = "TheDan64/inkwell" }
codecov = { repository = "TheDan64/inkwell" }

[profile.dev]
codegen-units=32 # TODO: Remove when default in rust, cuts compile time ~50%
9 changes: 5 additions & 4 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ impl Builder {
Builder::new(builder)
}

// REVIEW: Would probably make this API a bit simpler by taking Into<Option<&BasicValue>>
// So that you could just do build_return(&value) or build_return(None)
// REVIEW: Would probably make this API a bit simpler by taking Into<Option<impl BasicValue>>
// So that you could just do build_return(value) or build_return(None)
// Is that frowned upon?
// TODO: Option<impl BasicValue>
pub fn build_return(&self, value: Option<&BasicValue>) -> InstructionValue {
// let value = unsafe {
// value.map_or(LLVMBuildRetVoid(self.builder), |value| LLVMBuildRet(self.builder, value.value))
Expand Down Expand Up @@ -93,7 +94,7 @@ impl Builder {
}

// REVIEW: Doesn't GEP work on array too?
pub fn build_gep(&self, ptr: &PointerValue, ordered_indexes: &[&IntValue], name: &str) -> PointerValue {
pub fn build_gep(&self, ptr: &PointerValue, ordered_indexes: &[IntValue], name: &str) -> PointerValue {
let c_string = CString::new(name).expect("Conversion to CString failed unexpectedly");

let mut index_values: Vec<LLVMValueRef> = ordered_indexes.iter()
Expand All @@ -107,7 +108,7 @@ impl Builder {
}

// REVIEW: Doesn't GEP work on array too?
pub fn build_in_bounds_gep(&self, ptr: &PointerValue, ordered_indexes: &[&IntValue], name: &str) -> PointerValue {
pub fn build_in_bounds_gep(&self, ptr: &PointerValue, ordered_indexes: &[IntValue], name: &str) -> PointerValue {
let c_string = CString::new(name).expect("Conversion to CString failed unexpectedly");

let mut index_values: Vec<LLVMValueRef> = ordered_indexes.iter()
Expand Down

0 comments on commit 99f3e0a

Please sign in to comment.