q/src/build/scope/Variable.go

26 lines
460 B
Go

package scope
import (
"git.akyoto.dev/cli/q/src/build/cpu"
)
// Variable represents a named register.
type Variable struct {
Name string
Alive uint8
Register cpu.Register
}
// IsAlive returns true if the variable is still alive.
func (v *Variable) IsAlive() bool {
return v.Alive > 0
}
// Use reduces the lifetime counter by one.
func (v *Variable) Use() {
if v.Alive == 0 {
panic("incorrect number of variable use calls")
}
v.Alive--
}