Skip to content

Commit

Permalink
Rename variables (#595)
Browse files Browse the repository at this point in the history
* Rename variables

* Rename variable in comment
  • Loading branch information
JulianGCalderon authored May 14, 2024
1 parent e89d38a commit 60796b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn compile_func(
metadata,
)
.collect::<Result<Vec<_>, _>>()?;
let mut ret_types = extract_types(
let mut return_types = extract_types(
context,
module,
&function.signature.ret_types,
Expand All @@ -186,9 +186,9 @@ fn compile_func(
}
}

// Extract memory-allocated return types from ret_types and insert them in arg_types as a
// Extract memory-allocated return types from return_types and insert them in arg_types as a
// pointer.
let return_types = function
let return_type_infos = function
.signature
.ret_types
.iter()
Expand All @@ -205,15 +205,15 @@ fn compile_func(
// None => Doesn't return anything.
// Some(false) => Has a complex return type.
// Some(true) => Has a manual return type which is in `arg_types[0]`.
let has_return_ptr = if return_types.len() > 1 {
let has_return_ptr = if return_type_infos.len() > 1 {
Some(false)
} else if return_types
} else if return_type_infos
.first()
.is_some_and(|(_, type_info)| type_info.is_memory_allocated(registry))
{
assert_eq!(ret_types.len(), 1);
assert_eq!(return_types.len(), 1);

ret_types.remove(0);
return_types.remove(0);
arg_types.insert(0, llvm::r#type::opaque_pointer(context));

Some(true)
Expand Down Expand Up @@ -576,7 +576,7 @@ fn compile_func(

// Store the return value in the return pointer, if there's one.
if let Some(true) = has_return_ptr {
let (_ret_type_id, ret_type_info) = return_types[0];
let (_ret_type_id, ret_type_info) = return_type_infos[0];
let ret_layout = ret_type_info.layout(registry)?;

let ptr = values.remove(0);
Expand Down Expand Up @@ -658,7 +658,7 @@ fn compile_func(
module.body().append_operation(func::func(
context,
StringAttribute::new(context, &function_name),
TypeAttribute::new(FunctionType::new(context, &arg_types, &ret_types).into()),
TypeAttribute::new(FunctionType::new(context, &arg_types, &return_types).into()),
region,
&[
(
Expand Down

0 comments on commit 60796b9

Please sign in to comment.