style: 自动格式化
This commit is contained in:
@@ -121,10 +121,10 @@ impl Compiler {
|
||||
ctx.projected_pc += 1; // STORE_VAR (value from FOR_IN_NEXT)
|
||||
}
|
||||
}
|
||||
oxide_parser::ForStatementLeft::AssignmentTargetIdentifier(_) => {
|
||||
ctx.alloc_reg(); // key register
|
||||
ctx.projected_pc += 1; // STORE_VAR
|
||||
}
|
||||
oxide_parser::ForStatementLeft::AssignmentTargetIdentifier(_) => {
|
||||
ctx.alloc_reg(); // key register
|
||||
ctx.projected_pc += 1; // STORE_VAR
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +306,9 @@ impl Compiler {
|
||||
let break_label = if let Some(sw_label) = ctx.current_switch() {
|
||||
*sw_label
|
||||
} else {
|
||||
let (bl, _) = ctx.current_loop().ok_or("break outside switch or loop".to_string())?;
|
||||
let (bl, _) = ctx
|
||||
.current_loop()
|
||||
.ok_or("break outside switch or loop".to_string())?;
|
||||
*bl
|
||||
};
|
||||
let break_pos = ctx.resolve_label(break_label)?;
|
||||
|
||||
@@ -204,7 +204,10 @@ fn compile_do_while_emits_body_before_test() {
|
||||
#[test]
|
||||
fn compile_do_while_break() {
|
||||
let module = compile_source("do { break; } while (true)");
|
||||
assert!(!module.bytecode.is_empty(), "do-while with break should compile");
|
||||
assert!(
|
||||
!module.bytecode.is_empty(),
|
||||
"do-while with break should compile"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -251,7 +254,10 @@ fn compile_for_in_let_decl() {
|
||||
fn compile_switch_emits_jmp_if_true() {
|
||||
let module = compile_source("var x=0; switch(x){case 1:1;case 2:2;}");
|
||||
assert!(
|
||||
module.bytecode.iter().any(|&i| opcode::opcode(i) == OpCode::JMP_IF_TRUE),
|
||||
module
|
||||
.bytecode
|
||||
.iter()
|
||||
.any(|&i| opcode::opcode(i) == OpCode::JMP_IF_TRUE),
|
||||
"switch should emit JMP_IF_TRUE"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user