Implemented loads with register offsets
This commit is contained in:
parent
c86766bd33
commit
144810c6c8
13 changed files with 320 additions and 145 deletions
27
src/core/CallToRegister.go
Normal file
27
src/core/CallToRegister.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"git.akyoto.dev/cli/q/src/asm"
|
||||
"git.akyoto.dev/cli/q/src/cpu"
|
||||
"git.akyoto.dev/cli/q/src/expression"
|
||||
"git.akyoto.dev/cli/q/src/types"
|
||||
)
|
||||
|
||||
// CallToRegister moves the result of a function call into the given register.
|
||||
func (f *Function) CallToRegister(node *expression.Expression, register cpu.Register) (types.Type, error) {
|
||||
types, err := f.CompileCall(node)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if register != f.CPU.Output[0] {
|
||||
f.RegisterRegister(asm.MOVE, register, f.CPU.Output[0])
|
||||
}
|
||||
|
||||
if len(types) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return types[0], err
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue