fix: 修复 switch case 标签冲突与大 switch 寄存器回绕
This commit is contained in:
@@ -45,7 +45,7 @@ pub(crate) enum Label {
|
||||
ForInStart(u32),
|
||||
ForInEnd(u32),
|
||||
SwitchEnd(u32),
|
||||
SwitchCase(u32),
|
||||
SwitchCase(u32, u32),
|
||||
CatchBody(u32),
|
||||
FinallyBody(u32),
|
||||
TryEnd(u32),
|
||||
@@ -111,6 +111,14 @@ impl CompileCtx {
|
||||
self.label_counter = 0;
|
||||
}
|
||||
|
||||
pub(crate) fn reg_checkpoint(&self) -> u8 {
|
||||
self.next_reg
|
||||
}
|
||||
|
||||
pub(crate) fn restore_reg_checkpoint(&mut self, checkpoint: u8) {
|
||||
self.next_reg = checkpoint;
|
||||
}
|
||||
|
||||
pub(crate) fn add_constant(&mut self, c: Constant) -> u16 {
|
||||
if let Some(idx) = self.constants.iter().position(|x| x == &c) {
|
||||
return idx as u16;
|
||||
|
||||
Reference in New Issue
Block a user