mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
778fe2cde0
commit
ce26d5bc5c
@ -345,10 +345,15 @@ fn (mut g Gen) gen_array_map(node ast.CallExpr) {
|
||||
}
|
||||
left_type := if node.left_type.has_flag(.shared_f) {
|
||||
node.left_type.clear_flag(.shared_f).deref()
|
||||
} else if node.left_type.is_ptr() {
|
||||
node.left_type.deref()
|
||||
} else {
|
||||
node.left_type
|
||||
}
|
||||
g.write('${g.typ(left_type)} ${tmp}_orig = ')
|
||||
if !node.left_type.has_flag(.shared_f) && node.left_type.is_ptr() {
|
||||
g.write('*')
|
||||
}
|
||||
g.expr(node.left)
|
||||
if node.left_type.has_flag(.shared_f) {
|
||||
g.write('->val')
|
||||
|
3
vlib/v/gen/c/testdata/mutable_receiver_type_mapping.out
vendored
Normal file
3
vlib/v/gen/c/testdata/mutable_receiver_type_mapping.out
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[1, 0, 0]
|
||||
[0, 1, 0]
|
||||
[0, 0, 1]
|
18
vlib/v/gen/c/testdata/mutable_receiver_type_mapping.vv
vendored
Normal file
18
vlib/v/gen/c/testdata/mutable_receiver_type_mapping.vv
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
fn (mut a [][]f32) str() string {
|
||||
return a.map(it.str()).join('\n')
|
||||
}
|
||||
|
||||
fn identity(n int) [][]f32 {
|
||||
mut res := [][]f32{len: n, init: []f32{len: n, init: 0.0}}
|
||||
for i in 0 .. n {
|
||||
res[i][i] = 1.0
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
fn main() {
|
||||
a := identity(3)
|
||||
|
||||
println(a)
|
||||
}
|
Loading…
Reference in New Issue
Block a user