Added scope package
This commit is contained in:
20
src/build/core/storeVariableInRegister.go
Normal file
20
src/build/core/storeVariableInRegister.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user