Simplified file structure
This commit is contained in:
28
src/scope/Variable.go
Normal file
28
src/scope/Variable.go
Normal file
@ -0,0 +1,28 @@
|
||||
package scope
|
||||
|
||||
import (
|
||||
"git.akyoto.dev/cli/q/src/cpu"
|
||||
"git.akyoto.dev/cli/q/src/types"
|
||||
)
|
||||
|
||||
// Variable represents a named register.
|
||||
type Variable struct {
|
||||
Name string
|
||||
Type types.Type
|
||||
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--
|
||||
}
|
Reference in New Issue
Block a user