From e99657c741b636aace71bccc593b2889f3aad5a8 Mon Sep 17 00:00:00 2001 From: OranGot Date: Mon, 16 Sep 2024 08:05:01 +0400 Subject: [PATCH 1/7] improved documentation for build_int_mul, build_int_sub, build_float_sub, build_float_mul --- src/builder.rs | 126 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 4 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 084a3d03e25..91f5418c92f 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -2410,7 +2410,36 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - + ///creates integer subtraction given `lhs` and `rhs`. It returns either an `IntValue` or `BuilderError` + ///```rust,no_run + ///fn int_subtraction(lhs: i8, rhs: i8) -> i8{ + /// lhs-rhs + /// } + /// ``` + /// # Example in inkwell: + /// The rust code above demonstrates how the example below could have been written if it was rust: + ///```rust,no_run + /// use inkwell::context::Context; + /// + /// // Setup + /// let context = Context::create(); + /// let module = context.create_module("my_module"); + /// let builder = context.create_builder(); + /// let i8_type = context.i8_type(); + /// let fn_type = i8_type.fn_type(&[i8_type.into(), i8_type.into()], false); + /// + /// // Function Definition + /// let function = module.add_function("int_subtraction", fn_type, None); + /// let value1 = function.get_first_param().unwrap().into_int_value(); + /// let value2 = function.get_nth_param(1).unwrap().into_int_value(); + /// let entry_block = context.append_basic_block(function, "entry"); + /// + /// builder.position_at_end(entry_block); + /// + /// let sub = builder.build_int_sub(value1, value2, "int_subtract").unwrap(); + /// + /// builder.build_return(Some(&sub)).unwrap(); + ///``` // SubType: (&self, lhs: &IntValue, rhs: &IntValue, name: &str) -> IntValue { pub fn build_int_sub>(&self, lhs: T, rhs: T, name: &str) -> Result { if self.positioned.get() != PositionState::Set { @@ -2444,7 +2473,36 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - + ///creates float subtraction given `lhs` and `rhs` as FloatValue. It returns either an `FloatValue` or `BuilderError` + ///```rust,no_run + ///fn float_subtraction(lhs: f16, rhs: f16) -> f16{ + /// lhs-rhs + /// } + /// ``` + /// # Example in inkwell: + /// The rust code above demonstrates how the example below could have been written if it was rust: + ///```rust,no_run + /// use inkwell::context::Context; + /// + /// // Setup + /// let context = Context::create(); + /// let module = context.create_module("my_module"); + /// let builder = context.create_builder(); + /// let f16_type = context.f16_type(); + /// let fn_type = f16_type.fn_type(&[f16_type.into(), f16_type.into()], false); + /// + /// // Function Definition + /// let function = module.add_function("float_subtraction", fn_type, None); + /// let value = function.get_first_param().unwrap().into_float_value(); + /// let value2 = function.get_nth_param(1).unwrap().into_float_value(); + /// let entry_block = context.append_basic_block(function, "entry"); + /// + /// builder.position_at_end(entry_block); + /// + /// let sub = builder.build_float_sub(value1, value2, "float_subtract").unwrap(); + /// + /// builder.build_return(Some(&sub)).unwrap(); + ///``` // SubType: (&self, lhs: &FloatValue, rhs: &FloatValue, name: &str) -> FloatValue { pub fn build_float_sub>(&self, lhs: T, rhs: T, name: &str) -> Result { if self.positioned.get() != PositionState::Set { @@ -2455,7 +2513,37 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - + ///creates int multiplication given `lhs` and `rhs` as IntValue. It returns either an + ///`IntValue` or `BuilderError` + ///```rust,no_run + ///fn int_mul(lhs: i8, rhs: i8) -> i8{ + /// lhs*rhs + /// } + /// ``` + /// # Example in inkwell: + /// The rust code above demonstrates how the example below could have been written if it was rust: + ///```rust,no_run + /// use inkwell::context::Context; + /// + /// // Setup + /// let context = Context::create(); + /// let module = context.create_module("my_module"); + /// let builder = context.create_builder(); + /// let i8_type = context.i8_type(); + /// let fn_type = i8_type.fn_type(&[i8_type.into(), i8_type.into()], false); + /// + /// // Function Definition + /// let function = module.add_function("float_subtraction", fn_type, None); + /// let value = function.get_first_param().unwrap().into_int_value(); + /// let value2 = function.get_nth_param(1).unwrap().into_int_value(); + /// let entry_block = context.append_basic_block(function, "entry"); + /// + /// builder.position_at_end(entry_block); + /// + /// let mul = builder.build_int_mul(value1, value2, "int_multiplication").unwrap(); + /// + /// builder.build_return(Some(&mul)).unwrap(); + ///``` // SubType: (&self, lhs: &IntValue, rhs: &IntValue, name: &str) -> IntValue { pub fn build_int_mul>(&self, lhs: T, rhs: T, name: &str) -> Result { if self.positioned.get() != PositionState::Set { @@ -2490,7 +2578,37 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - + ///creates float multiplication + /// given `lhs` and `rhs` as FloatValue. It returns either an `FloatValue` or `BuilderError` + ///```rust,no_run + ///fn float_subtraction(lhs: f16, rhs: f16) -> f16{ + /// lhs*rhs + /// } + /// ``` + /// # Example in inkwell: + /// The rust code above demonstrates how the example below could have been written if it was rust: + ///```rust,no_run + /// use inkwell::context::Context; + /// + /// // Setup + /// let context = Context::create(); + /// let module = context.create_module("my_module"); + /// let builder = context.create_builder(); + /// let f16_type = context.f16_type(); + /// let fn_type = f16_type.fn_type(&[f16_type.into(), f16_type.into()], false); + /// + /// // Function Definition + /// let function = module.add_function("float_subtraction", fn_type, None); + /// let value = function.get_first_param().unwrap().into_float_value(); + /// let value2 = function.get_nth_param(1).unwrap().into_float_value(); + /// let entry_block = context.append_basic_block(function, "entry"); + /// + /// builder.position_at_end(entry_block); + /// + /// let sub = builder.build_float_mul(value1, value2, "float_mul").unwrap(); + /// + /// builder.build_return(Some(&sub)).unwrap(); + ///``` // SubType: (&self, lhs: &FloatValue, rhs: &FloatValue, name: &str) -> FloatValue { pub fn build_float_mul>(&self, lhs: T, rhs: T, name: &str) -> Result { if self.positioned.get() != PositionState::Set { From 80e5c69d28d025c8b1eb4353ce7e43f9104dd20f Mon Sep 17 00:00:00 2001 From: OranGot Date: Fri, 20 Sep 2024 10:50:53 +0400 Subject: [PATCH 2/7] capitalized C in creates and fixed spacing after the slashes --- src/builder.rs | 140 ++++++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 91f5418c92f..7bc735d8a1d 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -2410,35 +2410,35 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - ///creates integer subtraction given `lhs` and `rhs`. It returns either an `IntValue` or `BuilderError` + ///Creates integer subtraction given `lhs` and `rhs`. It returns either an `IntValue` or `BuilderError` ///```rust,no_run - ///fn int_subtraction(lhs: i8, rhs: i8) -> i8{ - /// lhs-rhs - /// } + ///fn int_subtraction(lhs: i8, rhs: i8) -> i8 { + /// lhs-rhs + ///} /// ``` /// # Example in inkwell: - /// The rust code above demonstrates how the example below could have been written if it was rust: + ///The rust code above demonstrates how the example below could have been written if it was rust: ///```rust,no_run - /// use inkwell::context::Context; + ///use inkwell::context::Context; /// /// // Setup - /// let context = Context::create(); - /// let module = context.create_module("my_module"); - /// let builder = context.create_builder(); - /// let i8_type = context.i8_type(); - /// let fn_type = i8_type.fn_type(&[i8_type.into(), i8_type.into()], false); + ///let context = Context::create(); + ///let module = context.create_module("my_module"); + ///let builder = context.create_builder(); + ///let i8_type = context.i8_type(); + ///let fn_type = i8_type.fn_type(&[i8_type.into(), i8_type.into()], false); /// /// // Function Definition - /// let function = module.add_function("int_subtraction", fn_type, None); - /// let value1 = function.get_first_param().unwrap().into_int_value(); - /// let value2 = function.get_nth_param(1).unwrap().into_int_value(); - /// let entry_block = context.append_basic_block(function, "entry"); + ///let function = module.add_function("int_subtraction", fn_type, None); + ///let value1 = function.get_first_param().unwrap().into_int_value(); + ///let value2 = function.get_nth_param(1).unwrap().into_int_value(); + ///let entry_block = context.append_basic_block(function, "entry"); /// - /// builder.position_at_end(entry_block); + ///builder.position_at_end(entry_block); /// - /// let sub = builder.build_int_sub(value1, value2, "int_subtract").unwrap(); + ///let sub = builder.build_int_sub(value1, value2, "int_subtract").unwrap(); /// - /// builder.build_return(Some(&sub)).unwrap(); + ///builder.build_return(Some(&sub)).unwrap(); ///``` // SubType: (&self, lhs: &IntValue, rhs: &IntValue, name: &str) -> IntValue { pub fn build_int_sub>(&self, lhs: T, rhs: T, name: &str) -> Result { @@ -2473,35 +2473,35 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - ///creates float subtraction given `lhs` and `rhs` as FloatValue. It returns either an `FloatValue` or `BuilderError` + ///Creates float subtraction given `lhs` and `rhs` as FloatValue. It returns either an `FloatValue` or `BuilderError` ///```rust,no_run - ///fn float_subtraction(lhs: f16, rhs: f16) -> f16{ - /// lhs-rhs - /// } + ///fn float_subtraction(lhs: f16, rhs: f16) -> f16 { + /// lhs-rhs + ///} /// ``` /// # Example in inkwell: - /// The rust code above demonstrates how the example below could have been written if it was rust: + ///The rust code above demonstrates how the example below could have been written if it was rust: ///```rust,no_run - /// use inkwell::context::Context; + ///use inkwell::context::Context; /// /// // Setup - /// let context = Context::create(); - /// let module = context.create_module("my_module"); - /// let builder = context.create_builder(); - /// let f16_type = context.f16_type(); - /// let fn_type = f16_type.fn_type(&[f16_type.into(), f16_type.into()], false); + ///let context = Context::create(); + ///let module = context.create_module("my_module"); + ///let builder = context.create_builder(); + ///let f16_type = context.f16_type(); + ///let fn_type = f16_type.fn_type(&[f16_type.into(), f16_type.into()], false); /// /// // Function Definition - /// let function = module.add_function("float_subtraction", fn_type, None); - /// let value = function.get_first_param().unwrap().into_float_value(); - /// let value2 = function.get_nth_param(1).unwrap().into_float_value(); - /// let entry_block = context.append_basic_block(function, "entry"); + ///let function = module.add_function("float_subtraction", fn_type, None); + ///let value = function.get_first_param().unwrap().into_float_value(); + ///let value2 = function.get_nth_param(1).unwrap().into_float_value(); + ///let entry_block = context.append_basic_block(function, "entry"); /// - /// builder.position_at_end(entry_block); + ///builder.position_at_end(entry_block); /// - /// let sub = builder.build_float_sub(value1, value2, "float_subtract").unwrap(); + ///let sub = builder.build_float_sub(value1, value2, "float_subtract").unwrap(); /// - /// builder.build_return(Some(&sub)).unwrap(); + ///builder.build_return(Some(&sub)).unwrap(); ///``` // SubType: (&self, lhs: &FloatValue, rhs: &FloatValue, name: &str) -> FloatValue { pub fn build_float_sub>(&self, lhs: T, rhs: T, name: &str) -> Result { @@ -2513,36 +2513,36 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - ///creates int multiplication given `lhs` and `rhs` as IntValue. It returns either an + ///Creates int multiplication given `lhs` and `rhs` as IntValue. It returns either an ///`IntValue` or `BuilderError` ///```rust,no_run - ///fn int_mul(lhs: i8, rhs: i8) -> i8{ - /// lhs*rhs - /// } + ///fn int_mul(lhs: i8, rhs: i8) -> i8 { + /// lhs*rhs + ///} /// ``` /// # Example in inkwell: - /// The rust code above demonstrates how the example below could have been written if it was rust: + ///The rust code above demonstrates how the example below could have been written if it was rust: ///```rust,no_run - /// use inkwell::context::Context; + ///use inkwell::context::Context; /// /// // Setup - /// let context = Context::create(); - /// let module = context.create_module("my_module"); - /// let builder = context.create_builder(); - /// let i8_type = context.i8_type(); - /// let fn_type = i8_type.fn_type(&[i8_type.into(), i8_type.into()], false); + ///let context = Context::create(); + ///let module = context.create_module("my_module"); + ///let builder = context.create_builder(); + ///let i8_type = context.i8_type(); + ///let fn_type = i8_type.fn_type(&[i8_type.into(), i8_type.into()], false); /// /// // Function Definition - /// let function = module.add_function("float_subtraction", fn_type, None); - /// let value = function.get_first_param().unwrap().into_int_value(); - /// let value2 = function.get_nth_param(1).unwrap().into_int_value(); - /// let entry_block = context.append_basic_block(function, "entry"); + ///let function = module.add_function("float_subtraction", fn_type, None); + ///let value = function.get_first_param().unwrap().into_int_value(); + ///let value2 = function.get_nth_param(1).unwrap().into_int_value(); + ///let entry_block = context.append_basic_block(function, "entry"); /// - /// builder.position_at_end(entry_block); + ///builder.position_at_end(entry_block); /// - /// let mul = builder.build_int_mul(value1, value2, "int_multiplication").unwrap(); + ///let mul = builder.build_int_mul(value1, value2, "int_multiplication").unwrap(); /// - /// builder.build_return(Some(&mul)).unwrap(); + ///builder.build_return(Some(&mul)).unwrap(); ///``` // SubType: (&self, lhs: &IntValue, rhs: &IntValue, name: &str) -> IntValue { pub fn build_int_mul>(&self, lhs: T, rhs: T, name: &str) -> Result { @@ -2578,36 +2578,36 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - ///creates float multiplication + ///Creates float multiplication /// given `lhs` and `rhs` as FloatValue. It returns either an `FloatValue` or `BuilderError` ///```rust,no_run ///fn float_subtraction(lhs: f16, rhs: f16) -> f16{ - /// lhs*rhs + /// lhs*rhs /// } /// ``` /// # Example in inkwell: - /// The rust code above demonstrates how the example below could have been written if it was rust: + ///The rust code above demonstrates how the example below could have been written if it was rust: ///```rust,no_run - /// use inkwell::context::Context; + ///use inkwell::context::Context; /// /// // Setup - /// let context = Context::create(); - /// let module = context.create_module("my_module"); - /// let builder = context.create_builder(); - /// let f16_type = context.f16_type(); - /// let fn_type = f16_type.fn_type(&[f16_type.into(), f16_type.into()], false); + ///let context = Context::create(); + ///let module = context.create_module("my_module"); + ///let builder = context.create_builder(); + ///let f16_type = context.f16_type(); + ///let fn_type = f16_type.fn_type(&[f16_type.into(), f16_type.into()], false); /// /// // Function Definition - /// let function = module.add_function("float_subtraction", fn_type, None); - /// let value = function.get_first_param().unwrap().into_float_value(); - /// let value2 = function.get_nth_param(1).unwrap().into_float_value(); - /// let entry_block = context.append_basic_block(function, "entry"); + ///let function = module.add_function("float_subtraction", fn_type, None); + ///let value = function.get_first_param().unwrap().into_float_value(); + ///let value2 = function.get_nth_param(1).unwrap().into_float_value(); + ///let entry_block = context.append_basic_block(function, "entry"); /// - /// builder.position_at_end(entry_block); + ///builder.position_at_end(entry_block); /// - /// let sub = builder.build_float_mul(value1, value2, "float_mul").unwrap(); + ///let sub = builder.build_float_mul(value1, value2, "float_mul").unwrap(); /// - /// builder.build_return(Some(&sub)).unwrap(); + ///builder.build_return(Some(&sub)).unwrap(); ///``` // SubType: (&self, lhs: &FloatValue, rhs: &FloatValue, name: &str) -> FloatValue { pub fn build_float_mul>(&self, lhs: T, rhs: T, name: &str) -> Result { From b94013592fb9148e59fc8959364c2c924582b1cc Mon Sep 17 00:00:00 2001 From: Dan Kolsoi Date: Thu, 10 Oct 2024 00:52:44 -0400 Subject: [PATCH 3/7] Fixed spacing --- src/builder.rs | 128 ++++++++++++++++++++++++------------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 7bc735d8a1d..8aeadd6a8c4 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -2410,36 +2410,36 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - ///Creates integer subtraction given `lhs` and `rhs`. It returns either an `IntValue` or `BuilderError` - ///```rust,no_run - ///fn int_subtraction(lhs: i8, rhs: i8) -> i8 { - /// lhs-rhs - ///} + /// Creates integer subtraction given `lhs` and `rhs`. It returns either an `IntValue` or `BuilderError` + /// ```rust,no_run + /// fn int_subtraction(lhs: i8, rhs: i8) -> i8 { + /// lhs-rhs + /// } /// ``` /// # Example in inkwell: - ///The rust code above demonstrates how the example below could have been written if it was rust: - ///```rust,no_run - ///use inkwell::context::Context; + /// The rust code above demonstrates how the example below could have been written if it was rust: + /// ```rust,no_run + /// use inkwell::context::Context; /// /// // Setup - ///let context = Context::create(); - ///let module = context.create_module("my_module"); - ///let builder = context.create_builder(); - ///let i8_type = context.i8_type(); - ///let fn_type = i8_type.fn_type(&[i8_type.into(), i8_type.into()], false); + /// let context = Context::create(); + /// let module = context.create_module("my_module"); + /// let builder = context.create_builder(); + /// let i8_type = context.i8_type(); + /// let fn_type = i8_type.fn_type(&[i8_type.into(), i8_type.into()], false); /// /// // Function Definition - ///let function = module.add_function("int_subtraction", fn_type, None); - ///let value1 = function.get_first_param().unwrap().into_int_value(); - ///let value2 = function.get_nth_param(1).unwrap().into_int_value(); - ///let entry_block = context.append_basic_block(function, "entry"); + /// let function = module.add_function("int_subtraction", fn_type, None); + /// let value1 = function.get_first_param().unwrap().into_int_value(); + /// let value2 = function.get_nth_param(1).unwrap().into_int_value(); + /// let entry_block = context.append_basic_block(function, "entry"); /// - ///builder.position_at_end(entry_block); + /// builder.position_at_end(entry_block); /// - ///let sub = builder.build_int_sub(value1, value2, "int_subtract").unwrap(); + /// let sub = builder.build_int_sub(value1, value2, "int_subtract").unwrap(); /// - ///builder.build_return(Some(&sub)).unwrap(); - ///``` + /// builder.build_return(Some(&sub)).unwrap(); + /// ``` // SubType: (&self, lhs: &IntValue, rhs: &IntValue, name: &str) -> IntValue { pub fn build_int_sub>(&self, lhs: T, rhs: T, name: &str) -> Result { if self.positioned.get() != PositionState::Set { @@ -2473,36 +2473,36 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - ///Creates float subtraction given `lhs` and `rhs` as FloatValue. It returns either an `FloatValue` or `BuilderError` - ///```rust,no_run - ///fn float_subtraction(lhs: f16, rhs: f16) -> f16 { - /// lhs-rhs - ///} + /// Creates float subtraction given `lhs` and `rhs` as FloatValue. It returns either an `FloatValue` or `BuilderError` + /// ```rust,no_run + /// fn float_subtraction(lhs: f16, rhs: f16) -> f16 { + /// lhs-rhs + /// } /// ``` /// # Example in inkwell: - ///The rust code above demonstrates how the example below could have been written if it was rust: - ///```rust,no_run - ///use inkwell::context::Context; + /// The rust code above demonstrates how the example below could have been written if it was rust: + /// ```rust,no_run + /// use inkwell::context::Context; /// /// // Setup - ///let context = Context::create(); - ///let module = context.create_module("my_module"); - ///let builder = context.create_builder(); - ///let f16_type = context.f16_type(); - ///let fn_type = f16_type.fn_type(&[f16_type.into(), f16_type.into()], false); + /// let context = Context::create(); + /// let module = context.create_module("my_module"); + /// let builder = context.create_builder(); + /// let f16_type = context.f16_type(); + /// let fn_type = f16_type.fn_type(&[f16_type.into(), f16_type.into()], false); /// /// // Function Definition - ///let function = module.add_function("float_subtraction", fn_type, None); - ///let value = function.get_first_param().unwrap().into_float_value(); - ///let value2 = function.get_nth_param(1).unwrap().into_float_value(); - ///let entry_block = context.append_basic_block(function, "entry"); + /// let function = module.add_function("float_subtraction", fn_type, None); + /// let value = function.get_first_param().unwrap().into_float_value(); + /// let value2 = function.get_nth_param(1).unwrap().into_float_value(); + /// let entry_block = context.append_basic_block(function, "entry"); /// - ///builder.position_at_end(entry_block); + /// builder.position_at_end(entry_block); /// - ///let sub = builder.build_float_sub(value1, value2, "float_subtract").unwrap(); + /// let sub = builder.build_float_sub(value1, value2, "float_subtract").unwrap(); /// - ///builder.build_return(Some(&sub)).unwrap(); - ///``` + /// builder.build_return(Some(&sub)).unwrap(); + /// ``` // SubType: (&self, lhs: &FloatValue, rhs: &FloatValue, name: &str) -> FloatValue { pub fn build_float_sub>(&self, lhs: T, rhs: T, name: &str) -> Result { if self.positioned.get() != PositionState::Set { @@ -2513,37 +2513,37 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - ///Creates int multiplication given `lhs` and `rhs` as IntValue. It returns either an - ///`IntValue` or `BuilderError` - ///```rust,no_run - ///fn int_mul(lhs: i8, rhs: i8) -> i8 { - /// lhs*rhs - ///} + /// Creates int multiplication given `lhs` and `rhs` as IntValue. It returns either an + /// `IntValue` or `BuilderError` + /// ```rust,no_run + /// fn int_mul(lhs: i8, rhs: i8) -> i8 { + /// lhs*rhs + /// } /// ``` /// # Example in inkwell: - ///The rust code above demonstrates how the example below could have been written if it was rust: - ///```rust,no_run - ///use inkwell::context::Context; + /// The rust code above demonstrates how the example below could have been written if it was rust: + /// ```rust,no_run + /// use inkwell::context::Context; /// /// // Setup - ///let context = Context::create(); - ///let module = context.create_module("my_module"); - ///let builder = context.create_builder(); - ///let i8_type = context.i8_type(); - ///let fn_type = i8_type.fn_type(&[i8_type.into(), i8_type.into()], false); + /// let context = Context::create(); + /// let module = context.create_module("my_module"); + /// let builder = context.create_builder(); + /// let i8_type = context.i8_type(); + /// let fn_type = i8_type.fn_type(&[i8_type.into(), i8_type.into()], false); /// /// // Function Definition - ///let function = module.add_function("float_subtraction", fn_type, None); - ///let value = function.get_first_param().unwrap().into_int_value(); - ///let value2 = function.get_nth_param(1).unwrap().into_int_value(); - ///let entry_block = context.append_basic_block(function, "entry"); + /// let function = module.add_function("float_subtraction", fn_type, None); + /// let value = function.get_first_param().unwrap().into_int_value(); + /// let value2 = function.get_nth_param(1).unwrap().into_int_value(); + /// let entry_block = context.append_basic_block(function, "entry"); /// - ///builder.position_at_end(entry_block); + /// builder.position_at_end(entry_block); /// - ///let mul = builder.build_int_mul(value1, value2, "int_multiplication").unwrap(); + /// let mul = builder.build_int_mul(value1, value2, "int_multiplication").unwrap(); /// - ///builder.build_return(Some(&mul)).unwrap(); - ///``` + /// builder.build_return(Some(&mul)).unwrap(); + /// ``` // SubType: (&self, lhs: &IntValue, rhs: &IntValue, name: &str) -> IntValue { pub fn build_int_mul>(&self, lhs: T, rhs: T, name: &str) -> Result { if self.positioned.get() != PositionState::Set { From ba684e2476e31fa602aea4259aa73e8985e208f4 Mon Sep 17 00:00:00 2001 From: Dan Kolsoi Date: Thu, 10 Oct 2024 00:54:02 -0400 Subject: [PATCH 4/7] Fixed spacing --- src/builder.rs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 8aeadd6a8c4..a81f6505017 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -2578,37 +2578,37 @@ impl<'ctx> Builder<'ctx> { unsafe { Ok(T::new(value)) } } - ///Creates float multiplication + /// Creates float multiplication /// given `lhs` and `rhs` as FloatValue. It returns either an `FloatValue` or `BuilderError` - ///```rust,no_run - ///fn float_subtraction(lhs: f16, rhs: f16) -> f16{ - /// lhs*rhs + /// ```rust,no_run + /// fn float_subtraction(lhs: f16, rhs: f16) -> f16{ + /// lhs*rhs /// } /// ``` /// # Example in inkwell: - ///The rust code above demonstrates how the example below could have been written if it was rust: - ///```rust,no_run - ///use inkwell::context::Context; + /// The rust code above demonstrates how the example below could have been written if it was rust: + /// ```rust,no_run + /// use inkwell::context::Context; /// /// // Setup - ///let context = Context::create(); - ///let module = context.create_module("my_module"); - ///let builder = context.create_builder(); - ///let f16_type = context.f16_type(); - ///let fn_type = f16_type.fn_type(&[f16_type.into(), f16_type.into()], false); + /// let context = Context::create(); + /// let module = context.create_module("my_module"); + /// let builder = context.create_builder(); + /// let f16_type = context.f16_type(); + /// let fn_type = f16_type.fn_type(&[f16_type.into(), f16_type.into()], false); /// /// // Function Definition - ///let function = module.add_function("float_subtraction", fn_type, None); - ///let value = function.get_first_param().unwrap().into_float_value(); - ///let value2 = function.get_nth_param(1).unwrap().into_float_value(); - ///let entry_block = context.append_basic_block(function, "entry"); + /// let function = module.add_function("float_subtraction", fn_type, None); + /// let value = function.get_first_param().unwrap().into_float_value(); + /// let value2 = function.get_nth_param(1).unwrap().into_float_value(); + /// let entry_block = context.append_basic_block(function, "entry"); /// - ///builder.position_at_end(entry_block); + /// builder.position_at_end(entry_block); /// - ///let sub = builder.build_float_mul(value1, value2, "float_mul").unwrap(); + /// let sub = builder.build_float_mul(value1, value2, "float_mul").unwrap(); /// - ///builder.build_return(Some(&sub)).unwrap(); - ///``` + /// builder.build_return(Some(&sub)).unwrap(); + /// ``` // SubType: (&self, lhs: &FloatValue, rhs: &FloatValue, name: &str) -> FloatValue { pub fn build_float_mul>(&self, lhs: T, rhs: T, name: &str) -> Result { if self.positioned.get() != PositionState::Set { From 49b80b12f1c2fa571eec4e663aef896e15a35126 Mon Sep 17 00:00:00 2001 From: Dan Kolsoi Date: Thu, 10 Oct 2024 00:55:00 -0400 Subject: [PATCH 5/7] Update builder.rs --- src/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/builder.rs b/src/builder.rs index a81f6505017..6108f692b7d 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -2581,7 +2581,7 @@ impl<'ctx> Builder<'ctx> { /// Creates float multiplication /// given `lhs` and `rhs` as FloatValue. It returns either an `FloatValue` or `BuilderError` /// ```rust,no_run - /// fn float_subtraction(lhs: f16, rhs: f16) -> f16{ + /// fn float_subtraction(lhs: f16, rhs: f16) -> f16 { /// lhs*rhs /// } /// ``` From c48900f89c1776bf60f9d6e004aa79f84e0a116c Mon Sep 17 00:00:00 2001 From: Dan Kolsoi Date: Thu, 10 Oct 2024 00:58:46 -0400 Subject: [PATCH 6/7] Fixed typos --- src/builder.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index a10012f85b5..839fca968c9 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -2613,7 +2613,7 @@ impl<'ctx> Builder<'ctx> { /// /// // Function Definition /// let function = module.add_function("float_subtraction", fn_type, None); - /// let value = function.get_first_param().unwrap().into_float_value(); + /// let value1 = function.get_first_param().unwrap().into_float_value(); /// let value2 = function.get_nth_param(1).unwrap().into_float_value(); /// let entry_block = context.append_basic_block(function, "entry"); /// @@ -2654,7 +2654,7 @@ impl<'ctx> Builder<'ctx> { /// /// // Function Definition /// let function = module.add_function("float_subtraction", fn_type, None); - /// let value = function.get_first_param().unwrap().into_int_value(); + /// let value1 = function.get_first_param().unwrap().into_int_value(); /// let value2 = function.get_nth_param(1).unwrap().into_int_value(); /// let entry_block = context.append_basic_block(function, "entry"); /// From 3ef4e0705bf8b535dbaf8d32a2e4bcb158004edb Mon Sep 17 00:00:00 2001 From: Dan Kolsoi Date: Thu, 10 Oct 2024 01:02:46 -0400 Subject: [PATCH 7/7] Typo --- src/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/builder.rs b/src/builder.rs index 92a3b7cf520..68b2e56b747 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -2719,7 +2719,7 @@ impl<'ctx> Builder<'ctx> { /// /// // Function Definition /// let function = module.add_function("float_subtraction", fn_type, None); - /// let value = function.get_first_param().unwrap().into_float_value(); + /// let value1 = function.get_first_param().unwrap().into_float_value(); /// let value2 = function.get_nth_param(1).unwrap().into_float_value(); /// let entry_block = context.append_basic_block(function, "entry"); ///