Moved register state to scopes

This commit is contained in:
2024-07-16 15:30:28 +02:00
parent d1ccd60139
commit d6d018c5c5
22 changed files with 230 additions and 129 deletions

View File

@ -15,12 +15,12 @@ type Variable struct {
// Variable returns the variable with the given name or `nil` if it doesn't exist.
func (s *state) Variable(name string) *Variable {
return s.Scope()[name]
return s.Scope().variables[name]
}
// VariableInRegister returns the variable that occupies the given register or `nil` if none occupy the register.
func (s *state) VariableInRegister(register cpu.Register) *Variable {
for _, v := range s.Scope() {
for _, v := range s.Scope().variables {
if v.Register == register {
return v
}