cgen: create enclosing block on C side for V `lock` blocks (#8538)
parent
2424e2cb02
commit
cee00a3551
|
@ -3448,7 +3448,9 @@ fn (mut g Gen) lock_expr(node ast.LockExpr) {
|
|||
g.writeln('\t\tsync__RwMutex_lock((sync__RwMutex*)_arr_$mtxs[$mtxs]);')
|
||||
g.writeln('}')
|
||||
}
|
||||
g.writeln('/*lock*/ {')
|
||||
g.stmts(node.stmts)
|
||||
g.writeln('}')
|
||||
if node.lockeds.len == 0 {
|
||||
// this should not happen
|
||||
} else if node.lockeds.len == 1 {
|
||||
|
@ -3465,7 +3467,7 @@ fn (mut g Gen) lock_expr(node ast.LockExpr) {
|
|||
g.writeln('\t\tsync__RwMutex_runlock((sync__RwMutex*)_arr_$mtxs[$mtxs]);')
|
||||
g.writeln('\telse')
|
||||
g.writeln('\t\tsync__RwMutex_unlock((sync__RwMutex*)_arr_$mtxs[$mtxs]);')
|
||||
g.writeln('}')
|
||||
g.write('}')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,12 +48,12 @@ fn test_shared_as_value() {
|
|||
assert v == 35
|
||||
}
|
||||
rlock m {
|
||||
w := m_val(m)
|
||||
assert w == -3.125
|
||||
u := m_val(m)
|
||||
assert u == -3.125
|
||||
}
|
||||
lock a {
|
||||
x := a_val(a)
|
||||
assert x == 4
|
||||
u := a_val(a)
|
||||
assert u == 4
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue