Simplified file structure
This commit is contained in:
parent
cacee7260a
commit
a466281307
219 changed files with 453 additions and 457 deletions
|
@ -1,30 +0,0 @@
|
|||
package scope
|
||||
|
||||
import (
|
||||
"git.akyoto.dev/cli/q/src/build/cpu"
|
||||
)
|
||||
|
||||
// Scope represents an independent code block.
|
||||
type Scope struct {
|
||||
Variables []*Variable
|
||||
Depth uint8
|
||||
InLoop bool
|
||||
cpu.State
|
||||
}
|
||||
|
||||
// AddVariable adds a new variable to the current scope.
|
||||
func (s *Scope) AddVariable(variable *Variable) {
|
||||
s.Variables = append(s.Variables, variable)
|
||||
s.Use(variable.Register)
|
||||
}
|
||||
|
||||
// VariableByName returns the variable with the given name or `nil` if it doesn't exist.
|
||||
func (s *Scope) VariableByName(name string) *Variable {
|
||||
for _, v := range s.Variables {
|
||||
if v.Name == name {
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue