mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 03:01:12 +08:00
fix: 降低函数体寄存器压力
This commit is contained in:
@@ -101,6 +101,13 @@ impl SymbolTable {
|
||||
Err(format!("Identifier '{name}' is not defined"))
|
||||
}
|
||||
|
||||
pub fn lookup_any(&self, name: &str) -> Option<u8> {
|
||||
self.scopes
|
||||
.iter()
|
||||
.rev()
|
||||
.find_map(|scope| scope.bindings.get(name).map(|binding| binding.reg))
|
||||
}
|
||||
|
||||
pub fn lookup_or_global(&mut self, name: &str, reg_for_new: u8) -> u8 {
|
||||
for scope in self.scopes.iter().rev() {
|
||||
if let Some(b) = scope.bindings.get(name) {
|
||||
|
||||
Reference in New Issue
Block a user