Added scope package

This commit is contained in:
2024-07-20 23:20:23 +02:00
parent 263c0cfb8b
commit 43cdac5572
37 changed files with 416 additions and 371 deletions

View File

@ -0,0 +1,20 @@
package core
import (
"git.akyoto.dev/cli/q/src/build/expression"
"git.akyoto.dev/cli/q/src/build/scope"
)
func (f *Function) storeVariableInRegister(name string, value *expression.Expression, uses int) error {
reg := f.CurrentScope().MustFindFree(f.cpu.General)
f.CurrentScope().Reserve(reg)
err := f.ExpressionToRegister(value, reg)
f.AddVariable(&scope.Variable{
Name: name,
Register: reg,
Alive: uses,
})
return err
}