forked from M-Labs/nac3
f
This commit is contained in:
parent
0a2dfab9a1
commit
100e441a44
@ -329,10 +329,36 @@ pub fn list_slice_assignment<'ctx, 'a>(
|
|||||||
// index in bound and positive should be done
|
// index in bound and positive should be done
|
||||||
// assert if dest.step == 1 then len(src) <= len(dest) else len(src) == len(dest), and
|
// assert if dest.step == 1 then len(src) <= len(dest) else len(src) == len(dest), and
|
||||||
// throw exception if not satisfied
|
// throw exception if not satisfied
|
||||||
|
let src_end = ctx.builder
|
||||||
|
.build_select(
|
||||||
|
ctx.builder.build_int_compare(
|
||||||
|
inkwell::IntPredicate::SLT,
|
||||||
|
src_idx.2,
|
||||||
|
zero,
|
||||||
|
"is_neg",
|
||||||
|
),
|
||||||
|
ctx.builder.build_int_sub(src_idx.1, one, "e_min_one"),
|
||||||
|
ctx.builder.build_int_add(src_idx.1, one, "e_add_one"),
|
||||||
|
"final_e",
|
||||||
|
)
|
||||||
|
.into_int_value();
|
||||||
|
let dest_end = ctx.builder
|
||||||
|
.build_select(
|
||||||
|
ctx.builder.build_int_compare(
|
||||||
|
inkwell::IntPredicate::SLT,
|
||||||
|
dest_idx.2,
|
||||||
|
zero,
|
||||||
|
"is_neg",
|
||||||
|
),
|
||||||
|
ctx.builder.build_int_sub(dest_idx.1, one, "e_min_one"),
|
||||||
|
ctx.builder.build_int_add(dest_idx.1, one, "e_add_one"),
|
||||||
|
"final_e",
|
||||||
|
)
|
||||||
|
.into_int_value();
|
||||||
let src_slice_len =
|
let src_slice_len =
|
||||||
calculate_len_for_slice_range(generator, ctx, src_idx.0, src_idx.1, src_idx.2);
|
calculate_len_for_slice_range(generator, ctx, src_idx.0, src_end, src_idx.2);
|
||||||
let dest_slice_len =
|
let dest_slice_len =
|
||||||
calculate_len_for_slice_range(generator, ctx, dest_idx.0, dest_idx.1, dest_idx.2);
|
calculate_len_for_slice_range(generator, ctx, dest_idx.0, dest_end, dest_idx.2);
|
||||||
let src_eq_dest = ctx.builder.build_int_compare(
|
let src_eq_dest = ctx.builder.build_int_compare(
|
||||||
IntPredicate::EQ,
|
IntPredicate::EQ,
|
||||||
src_slice_len,
|
src_slice_len,
|
||||||
@ -357,7 +383,7 @@ pub fn list_slice_assignment<'ctx, 'a>(
|
|||||||
generator,
|
generator,
|
||||||
cond,
|
cond,
|
||||||
"0:ValueError",
|
"0:ValueError",
|
||||||
"attempt to assign sequence of size {0}, to slice of size {1} with step size {2}",
|
"attempt to assign sequence of size {0} to slice of size {1} with step size {2}",
|
||||||
[Some(src_slice_len), Some(dest_slice_len), Some(dest_idx.2)],
|
[Some(src_slice_len), Some(dest_slice_len), Some(dest_idx.2)],
|
||||||
ctx.current_loc,
|
ctx.current_loc,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user