Simplified file structure

This commit is contained in:
2024-08-07 19:39:10 +02:00
parent 1b13539b22
commit 66569446b1
219 changed files with 453 additions and 457 deletions

28
src/scope/Variable.go Normal file
View 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--
}