Only allocate register for capture if original name is a register

This commit is contained in:
Andrew Morris
2023-03-24 14:32:12 +11:00
parent 57a95798cd
commit 5931d8a8f9

View File

@@ -273,14 +273,18 @@ impl ScopeAnalysis {
if inserted {
let key = (captor_id.clone(), name_id.clone());
// This is just self.allocate_reg, but we can't borrow all of self right now
let reg = self
.reg_allocators
.entry(captor_id.clone())
.or_insert_with(|| RegAllocator::default())
.allocate(&name.sym);
if let Value::Register(_) = name.value {
// This is just self.allocate_reg, but we can't borrow all of self right now
let reg = self
.reg_allocators
.entry(captor_id.clone())
.or_insert_with(|| RegAllocator::default())
.allocate(&name.sym);
self.capture_values.insert(key, Value::Register(reg));
self.capture_values.insert(key, Value::Register(reg));
} else {
self.capture_values.insert(key, name.value.clone());
}
}
name.captures.push(Capture {