mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
implement incrementing by a variable number
This commit is contained in:
parent
99058e7203
commit
946ce9c292
1 changed files with 7 additions and 7 deletions
|
@ -101,7 +101,7 @@ impl<'ctx> PointerToRefcount<'ctx> {
|
||||||
env.builder.build_store(self.value, refcount);
|
env.builder.build_store(self.value, refcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn increment<'a, 'env>(&self, env: &Env<'a, 'ctx, 'env>) {
|
fn increment<'a, 'env>(&self, amount: u64, env: &Env<'a, 'ctx, 'env>) {
|
||||||
let refcount = self.get_refcount(env);
|
let refcount = self.get_refcount(env);
|
||||||
let builder = env.builder;
|
let builder = env.builder;
|
||||||
let refcount_type = ptr_int(env.context, env.ptr_bytes);
|
let refcount_type = ptr_int(env.context, env.ptr_bytes);
|
||||||
|
@ -114,7 +114,7 @@ impl<'ctx> PointerToRefcount<'ctx> {
|
||||||
);
|
);
|
||||||
let incremented = builder.build_int_add(
|
let incremented = builder.build_int_add(
|
||||||
refcount,
|
refcount,
|
||||||
refcount_type.const_int(1_u64, false),
|
refcount_type.const_int(amount, false),
|
||||||
"increment_refcount",
|
"increment_refcount",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -703,7 +703,7 @@ fn build_inc_list_help<'a, 'ctx, 'env>(
|
||||||
builder.position_at_end(increment_block);
|
builder.position_at_end(increment_block);
|
||||||
|
|
||||||
let refcount_ptr = PointerToRefcount::from_list_wrapper(env, original_wrapper);
|
let refcount_ptr = PointerToRefcount::from_list_wrapper(env, original_wrapper);
|
||||||
refcount_ptr.increment(env);
|
refcount_ptr.increment(1, env);
|
||||||
|
|
||||||
builder.build_unconditional_branch(cont_block);
|
builder.build_unconditional_branch(cont_block);
|
||||||
|
|
||||||
|
@ -943,7 +943,7 @@ fn build_inc_str_help<'a, 'ctx, 'env>(
|
||||||
builder.position_at_end(decrement_block);
|
builder.position_at_end(decrement_block);
|
||||||
|
|
||||||
let refcount_ptr = PointerToRefcount::from_list_wrapper(env, str_wrapper);
|
let refcount_ptr = PointerToRefcount::from_list_wrapper(env, str_wrapper);
|
||||||
refcount_ptr.increment(env);
|
refcount_ptr.increment(1, env);
|
||||||
|
|
||||||
builder.build_unconditional_branch(cont_block);
|
builder.build_unconditional_branch(cont_block);
|
||||||
|
|
||||||
|
@ -1389,9 +1389,9 @@ fn build_rec_union_help<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
// increment/decrement the cons-cell itself
|
// increment/decrement the cons-cell itself
|
||||||
match mode {
|
match mode {
|
||||||
Mode::Inc(_) => {
|
Mode::Inc(inc_amount) => {
|
||||||
let refcount_ptr = PointerToRefcount::from_ptr_to_data(env, value_ptr);
|
let refcount_ptr = PointerToRefcount::from_ptr_to_data(env, value_ptr);
|
||||||
refcount_ptr.increment(env);
|
refcount_ptr.increment(inc_amount, env);
|
||||||
}
|
}
|
||||||
Mode::Dec => {
|
Mode::Dec => {
|
||||||
let refcount_ptr = PointerToRefcount::from_ptr_to_data(env, value_ptr);
|
let refcount_ptr = PointerToRefcount::from_ptr_to_data(env, value_ptr);
|
||||||
|
@ -1751,7 +1751,7 @@ pub fn build_inc_union_help<'a, 'ctx, 'env>(
|
||||||
// TODO do this decrement before the recursive call?
|
// TODO do this decrement before the recursive call?
|
||||||
// Then the recursive call is potentially TCE'd
|
// Then the recursive call is potentially TCE'd
|
||||||
let refcount_ptr = PointerToRefcount::from_ptr_to_data(env, recursive_field_ptr);
|
let refcount_ptr = PointerToRefcount::from_ptr_to_data(env, recursive_field_ptr);
|
||||||
refcount_ptr.increment(env);
|
refcount_ptr.increment(1, env);
|
||||||
} else if field_layout.contains_refcounted() {
|
} else if field_layout.contains_refcounted() {
|
||||||
let field_ptr = env
|
let field_ptr = env
|
||||||
.builder
|
.builder
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue