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

25
src/core/Evaluate.go Normal file
View File

@ -0,0 +1,25 @@
package core
import (
"git.akyoto.dev/cli/q/src/cpu"
"git.akyoto.dev/cli/q/src/expression"
"git.akyoto.dev/cli/q/src/token"
"git.akyoto.dev/cli/q/src/types"
)
// Evaluate evaluates an expression and returns a register that contains the value of the expression.
func (f *Function) Evaluate(expr *expression.Expression) (types.Type, cpu.Register, error) {
if expr.Token.Kind == token.Identifier {
name := expr.Token.Text(f.File.Bytes)
variable := f.VariableByName(name)
if variable.Alive == 1 {
f.UseVariable(variable)
return variable.Type, variable.Register, nil
}
}
tmp := f.NewRegister()
typ, err := f.ExpressionToRegister(expr, tmp)
return typ, tmp, err
}