Tuple by value (#172) #174

Merged
sb10q merged 1 commits from tuple_by_value into master 2024-08-17 17:37:19 +08:00
1 changed files with 52 additions and 53 deletions

View File

@ -90,7 +90,8 @@ pub fn gen_assign<'ctx, 'a, G: CodeGenerator>(
target: &Expr<Option<Type>>, target: &Expr<Option<Type>>,
value: ValueEnum<'ctx>, value: ValueEnum<'ctx>,
) { ) {
if let ExprKind::Tuple { elts, .. } = &target.node { match &target.node {
ExprKind::Tuple { elts, .. } => {
if let BasicValueEnum::StructValue(v) = value.to_basic_value_enum(ctx, generator) { if let BasicValueEnum::StructValue(v) = value.to_basic_value_enum(ctx, generator) {
for (i, elt) in elts.iter().enumerate() { for (i, elt) in elts.iter().enumerate() {
let v = ctx let v = ctx
@ -102,8 +103,7 @@ pub fn gen_assign<'ctx, 'a, G: CodeGenerator>(
} else { } else {
unreachable!() unreachable!()
} }
} else { }
match &target.node {
ExprKind::Subscript { value: ls, slice, .. } ExprKind::Subscript { value: ls, slice, .. }
if matches!(&slice.node, ExprKind::Slice { .. }) => if matches!(&slice.node, ExprKind::Slice { .. }) =>
{ {
@ -151,7 +151,6 @@ pub fn gen_assign<'ctx, 'a, G: CodeGenerator>(
} }
} }
} }
}
pub fn gen_for<'ctx, 'a, G: CodeGenerator>( pub fn gen_for<'ctx, 'a, G: CodeGenerator>(
generator: &mut G, generator: &mut G,