mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
style: 自动格式化
This commit is contained in:
@@ -149,7 +149,10 @@ impl Compiler {
|
||||
}
|
||||
// Check if target is a captured cell
|
||||
if ctx.scopes.symbols.lookup_is_captured(name) {
|
||||
let cell_idx = ctx.scopes.cell_registry.iter()
|
||||
let cell_idx = ctx
|
||||
.scopes
|
||||
.cell_registry
|
||||
.iter()
|
||||
.find(|(n, _)| n == name)
|
||||
.map(|(_, idx)| *idx)
|
||||
.unwrap_or(0);
|
||||
|
||||
@@ -70,7 +70,10 @@ impl Compiler {
|
||||
|
||||
// Check if the owner's binding is captured (cell access)
|
||||
if ctx.scopes.symbols.lookup_is_captured(name) {
|
||||
let cell_idx = ctx.scopes.cell_registry.iter()
|
||||
let cell_idx = ctx
|
||||
.scopes
|
||||
.cell_registry
|
||||
.iter()
|
||||
.find(|(n, _)| n == name)
|
||||
.map(|(_, idx)| *idx)
|
||||
.unwrap_or(0);
|
||||
|
||||
@@ -163,7 +163,9 @@ impl Vm {
|
||||
if cell_ptr.is_null() {
|
||||
return Ok(());
|
||||
}
|
||||
unsafe { (*cell_ptr).value = src_val; }
|
||||
unsafe {
|
||||
(*cell_ptr).value = src_val;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -197,7 +199,9 @@ impl Vm {
|
||||
if uv_idx < upvals.len() {
|
||||
let cell = upvals[uv_idx];
|
||||
if !cell.is_null() {
|
||||
unsafe { (*cell).value = src_val; }
|
||||
unsafe {
|
||||
(*cell).value = src_val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ fn closure_nested_decl_reads_outer_var() {
|
||||
|
||||
#[test]
|
||||
fn closure_counter_escape() {
|
||||
let result = eval("function counter(){ var n=0; return function(){ return ++n; }; } var c=counter(); c(); c()").unwrap();
|
||||
let result =
|
||||
eval("function counter(){ var n=0; return function(){ return ++n; }; } var c=counter(); c(); c()").unwrap();
|
||||
assert_eq!(result.as_int(), 2);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user