Skip to content

Commit

Permalink
Refactored nullable libfuncs to use the BlockExt trait (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Jun 6, 2024
1 parent 2c08c9e commit 67f42fb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/libfuncs/nullable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! Like a Box but it can be null.

use super::LibfuncHelper;
use crate::block_ext::BlockExt;
use crate::{error::Result, metadata::MetadataStorage};
use cairo_lang_sierra::{
extensions::{
Expand Down Expand Up @@ -98,11 +99,10 @@ fn build_match_nullable<'ctx, 'this>(
) -> Result<()> {
let arg = entry.argument(0)?.into();

let op =
entry.append_operation(ods::llvm::mlir_zero(context, pointer(context, 0), location).into());
let nullptr = op.result(0)?.into();
let nullptr = entry
.append_op_result(ods::llvm::mlir_zero(context, pointer(context, 0), location).into())?;

let op = entry.append_operation(
let is_null_ptr = entry.append_op_result(
OperationBuilder::new("llvm.icmp", location)
.add_operands(&[arg, nullptr])
.add_attributes(&[(
Expand All @@ -111,9 +111,7 @@ fn build_match_nullable<'ctx, 'this>(
)])
.add_results(&[IntegerType::new(context, 1).into()])
.build()?,
);

let is_null_ptr = op.result(0)?.into();
)?;

let block_is_null = helper.append_block(Block::new(&[]));
let block_is_not_null = helper.append_block(Block::new(&[]));
Expand Down

0 comments on commit 67f42fb

Please sign in to comment.