1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

implement missing builtin _noscan fns/methods for array and map, so that cgen can work more uniformly

This commit is contained in:
Delyan Angelov 2023-07-15 17:15:43 +03:00
parent ec0402e63b
commit 400dececc9
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 117 additions and 0 deletions

View File

@ -5,18 +5,92 @@
module builtin
// this is needed in `string.v`
[inline]
fn __new_array_noscan(mylen int, cap int, elm_size int) array {
return __new_array(mylen, cap, elm_size)
}
[inline]
fn __new_array_with_default_noscan(mylen int, cap int, elm_size int, val voidptr) array {
return __new_array_with_default(mylen, cap, elm_size, val)
}
[inline]
fn __new_array_with_multi_default_noscan(mylen int, cap int, elm_size int, val voidptr) array {
return __new_array_with_multi_default(mylen, cap, elm_size, val)
}
[inline]
fn __new_array_with_array_default_noscan(mylen int, cap int, elm_size int, val array, depth int) array {
return __new_array_with_array_default(mylen, cap, elm_size, val, depth)
}
[inline]
fn new_array_from_c_array_noscan(len int, cap int, elm_size int, c_array voidptr) array {
return new_array_from_c_array(len, cap, elm_size, c_array)
}
[inline]
fn (a array) repeat_to_depth_noscan(count int, depth int) array {
return unsafe { a.repeat_to_depth(count, depth) }
}
[inline]
fn (mut a array) insert_noscan(i int, val voidptr) {
a.insert(i, val)
}
[inline]
fn (mut a array) insert_many_noscan(i int, val voidptr, size int) {
unsafe { a.insert_many(i, val, size) }
}
[inline]
fn (mut a array) prepend_noscan(val voidptr) {
a.prepend_noscan(val)
}
[inline]
fn (mut a array) prepend_many_noscan(val voidptr, size int) {
unsafe { a.prepend_many_noscan(val, size) }
}
[inline]
fn (mut a array) pop_noscan() voidptr {
return a.pop()
}
[inline]
fn (a array) clone_static_to_depth_noscan(depth int) array {
return unsafe { a.clone_static_to_depth(depth) }
}
[inline]
fn (a &array) clone_to_depth_noscan(depth int) array {
return unsafe { a.clone_to_depth(depth) }
}
[inline]
fn (mut a array) push_noscan(val voidptr) {
a.push(val)
}
[inline]
fn (mut a array) push_many_noscan(val voidptr, size int) {
unsafe { a.push_many(val, size) }
}
[inline]
fn (a array) reverse_noscan() array {
return a.reverse()
}
[inline]
fn (mut a array) grow_cap_noscan(amount int) {
a.grow_cap(amount)
}
[inline]
fn (mut a array) grow_len_noscan(amount int) {
unsafe { a.grow_len(amount) }
}

View File

@ -0,0 +1,43 @@
module builtin
// Dummy placeholder for functions from map_d_gcboehm_opt.v
// These functions will be called by cgen, for maps that have keys and values
// of primitive types, that do not require GC scanning, like ints, bools etc.
[inline]
fn new_dense_array_noscan(key_bytes int, key_noscan bool, value_bytes int, value_noscan bool) DenseArray {
return new_dense_array(key_bytes, value_bytes)
}
[inline]
fn new_map_noscan_key(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn) map {
return new_map(key_bytes, value_bytes, hash_fn, key_eq_fn, clone_fn, free_fn)
}
[inline]
fn new_map_noscan_value(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn) map {
return new_map(key_bytes, value_bytes, hash_fn, key_eq_fn, clone_fn, free_fn)
}
[inline]
fn new_map_noscan_key_value(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn) map {
return new_map(key_bytes, value_bytes, hash_fn, key_eq_fn, clone_fn, free_fn)
}
[inline]
fn new_map_init_noscan_key(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn, n int, key_bytes int, value_bytes int, keys voidptr, values voidptr) map {
return new_map_init(hash_fn, key_eq_fn, clone_fn, free_fn, n, key_bytes, value_bytes,
keys, values)
}
[inline]
fn new_map_init_noscan_value(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn, n int, key_bytes int, value_bytes int, keys voidptr, values voidptr) map {
return new_map_init(hash_fn, key_eq_fn, clone_fn, free_fn, n, key_bytes, value_bytes,
keys, values)
}
[inline]
fn new_map_init_noscan_key_value(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn, n int, key_bytes int, value_bytes int, keys voidptr, values voidptr) map {
return new_map_init(hash_fn, key_eq_fn, clone_fn, free_fn, n, key_bytes, value_bytes,
keys, values)
}