Implemented basic support for function pointers

This commit is contained in:
2025-01-30 16:33:20 +01:00
parent a2d80b0c21
commit 162824ec1c
8 changed files with 166 additions and 15 deletions

View File

@ -0,0 +1,33 @@
package core
import (
"math"
"git.akyoto.dev/cli/q/src/asm"
"git.akyoto.dev/cli/q/src/errors"
"git.akyoto.dev/cli/q/src/expression"
)
// CompileMemoryStore ...
func (f *Function) CompileMemoryStore(root *expression.Expression) error {
parameters := root.Children[1:]
name := parameters[0].Token.Text(f.File.Bytes)
numBytes, _ := f.Number(parameters[1].Token)
value := parameters[2]
variable := f.VariableByName(name)
if variable == nil {
return errors.New(&errors.UnknownIdentifier{Name: name}, f.File, parameters[0].Token.Position)
}
defer f.UseVariable(variable)
memory := asm.Memory{
Base: variable.Register,
OffsetRegister: math.MaxUint8,
Length: byte(numBytes),
}
_, err := f.ExpressionToMemory(value, memory)
return err
}