Skip to content

Commit

Permalink
Fix stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
azteca1998 committed Sep 30, 2024
1 parent 256b625 commit 2476ac8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/libfuncs/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub fn build<'ctx, 'this>(
helper,
metadata,
&info.signature.param_signatures[0].ty,
entry.argument(0)?.into(),
)?;

entry.append_operation(helper.br(0, &[], location));
Expand Down
33 changes: 17 additions & 16 deletions src/types/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,27 +485,28 @@ pub fn build<'ctx>(

#[allow(clippy::too_many_arguments)]
fn snapshot_take<'ctx, 'this>(
context: &'ctx Context,
registry: &ProgramRegistry<CoreType, CoreLibfunc>,
entry: &'this Block<'ctx>,
location: Location<'ctx>,
helper: &LibfuncHelper<'ctx, 'this>,
metadata: &mut MetadataStorage,
info: WithSelf<EnumConcreteType>,
src_value: Value<'ctx, 'this>,
_context: &'ctx Context,
_registry: &ProgramRegistry<CoreType, CoreLibfunc>,
_entry: &'this Block<'ctx>,
_location: Location<'ctx>,
_helper: &LibfuncHelper<'ctx, 'this>,
_metadata: &mut MetadataStorage,
_info: WithSelf<EnumConcreteType>,
_src_value: Value<'ctx, 'this>,
) -> Result<(&'this Block<'ctx>, Value<'ctx, 'this>)> {
todo!()
}

#[allow(clippy::too_many_arguments)]
pub(crate) fn build_drop<'ctx, 'this>(
context: &'ctx Context,
registry: &ProgramRegistry<CoreType, CoreLibfunc>,
entry: &'this Block<'ctx>,
location: Location<'ctx>,
helper: &LibfuncHelper<'ctx, 'this>,
metadata: &mut MetadataStorage,
info: WithSelf<EnumConcreteType>,
value: Value<'ctx, 'this>,
_context: &'ctx Context,
_registry: &ProgramRegistry<CoreType, CoreLibfunc>,
_entry: &'this Block<'ctx>,
_location: Location<'ctx>,
_helper: &LibfuncHelper<'ctx, 'this>,
_metadata: &mut MetadataStorage,
_info: WithSelf<EnumConcreteType>,
_value: Value<'ctx, 'this>,
) -> Result<()> {
todo!()
}
Expand Down
10 changes: 5 additions & 5 deletions src/types/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ fn snapshot_take<'ctx, 'this>(
let self_ty = registry.build_type(context, helper, registry, metadata, info.self_ty)?;
let mut value = entry.append_op_result(llvm::undef(self_ty, location))?;

// The following unwrap is unreachable because we've already check that at least one of the
// struct's members have a custom clone implementation before registering this function.
let snapshot_clones_meta = metadata.get::<SnapshotClonesMeta>().unwrap();
for (member_idx, member_id) in info.members.iter().enumerate() {
let member_ty = registry.build_type(context, helper, registry, metadata, member_id)?;
let member_val =
entry.extract_value(context, location, src_value, member_ty, member_idx)?;

// The following unwrap is unreachable because we've already check that at least one of the
// struct's members have a custom clone implementation before registering this function.
let snapshot_clones_meta = metadata.get::<SnapshotClonesMeta>().unwrap();

let cloned_member_val;
(entry, cloned_member_val) = match snapshot_clones_meta.wrap_invoke(member_id) {
Some(clone_fn) => clone_fn(
Expand All @@ -125,6 +126,7 @@ fn snapshot_take<'ctx, 'this>(
Ok((entry, value))
}

#[allow(clippy::too_many_arguments)]
pub(crate) fn build_drop<'ctx, 'this>(
context: &'ctx Context,
registry: &ProgramRegistry<CoreType, CoreLibfunc>,
Expand All @@ -135,8 +137,6 @@ pub(crate) fn build_drop<'ctx, 'this>(
info: WithSelf<StructConcreteType>,
value: Value<'ctx, 'this>,
) -> Result<()> {
let value = entry.argument(0)?.into();

// Since we don't currently have a way to check if a type should implement drop or not we just
// call `build_drop` for every member. The canonicalization pass should remove unnecessary
// `extractvalue` operations.
Expand Down

0 comments on commit 2476ac8

Please sign in to comment.