package core import ( "git.akyoto.dev/cli/q/src/build/cpu" "git.akyoto.dev/cli/q/src/build/expression" ) // Variable represents a named register. type Variable struct { Value *expression.Expression Name string Register cpu.Register Alive int } // 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().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().variables { if v.Register == register { return v } } return nil }