Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Young <[email protected]>
  • Loading branch information
seanyoung committed Sep 26, 2023
1 parent 9c974b3 commit c5e81da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
21 changes: 6 additions & 15 deletions src/emit/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,23 +893,14 @@ impl<'a> Binary<'a> {
self.module.get_struct_type("struct.vector").unwrap().into()
}
Type::Array(base_ty, dims) => {
let mut aty = self.llvm_field_ty(base_ty, ns);

for dim in dims {
match dim {
ArrayLength::Fixed(d) => {
aty = aty.array_type(d.to_u32().unwrap()).into();
}
dims.iter()
.fold(self.llvm_field_ty(base_ty, ns), |aty, dim| match dim {
ArrayLength::Fixed(d) => aty.array_type(d.to_u32().unwrap()).into(),
ArrayLength::Dynamic => {
aty = self.module.get_struct_type("struct.vector").unwrap().into();
}
ArrayLength::AnyFixed => {
unreachable!()
self.module.get_struct_type("struct.vector").unwrap().into()
}
}
}

aty
ArrayLength::AnyFixed => unreachable!(),
})
}
Type::Struct(StructType::SolParameters) => self
.module
Expand Down
16 changes: 8 additions & 8 deletions src/emit/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,7 @@ pub(super) fn expression_to_slice<'a, T: TargetRuntime<'a> + ?Sized>(
bin.builder.build_store(output_len, len);
}

return (output, llvm_length);
(output, llvm_length)
}
Expression::AllocDynamicBytes {
initializer: Some(initializer),
Expand All @@ -2195,16 +2195,16 @@ pub(super) fn expression_to_slice<'a, T: TargetRuntime<'a> + ?Sized>(
let ptr = bin.emit_global_string("slice_constant", initializer, true);
let len = i64_const!(initializer.len() as u64);

return (ptr, len);
(ptr, len)
}
_ => (),
}

let from = e.ty();
_ => {
let from = e.ty();

let val = expression(target, bin, e, vartab, function, ns);
let val = expression(target, bin, e, vartab, function, ns);

basic_value_to_slice(bin, val, &from, to, function, ns)
basic_value_to_slice(bin, val, &from, to, function, ns)
}
}
}

/// Convert basic enum value to a slice. This function calls itself recursively
Expand Down

0 comments on commit c5e81da

Please sign in to comment.