Improved separation of concerns
This commit is contained in:
@ -31,10 +31,10 @@ func (f *Function) CompileCall(root *expression.Expression) error {
|
||||
}
|
||||
|
||||
parameters := root.Children[1:]
|
||||
registers := f.cpu.Input[:len(parameters)]
|
||||
registers := f.CPU.Input[:len(parameters)]
|
||||
|
||||
if isSyscall {
|
||||
registers = f.cpu.Syscall[:len(parameters)]
|
||||
registers = f.CPU.Syscall[:len(parameters)]
|
||||
}
|
||||
|
||||
err := f.ExpressionsToRegisters(parameters, registers)
|
||||
@ -43,10 +43,10 @@ func (f *Function) CompileCall(root *expression.Expression) error {
|
||||
return err
|
||||
}
|
||||
|
||||
f.SaveRegister(f.cpu.Output[0])
|
||||
f.SaveRegister(f.CPU.Output[0])
|
||||
|
||||
// Push
|
||||
for _, register := range f.cpu.General {
|
||||
for _, register := range f.CPU.General {
|
||||
if f.CurrentScope().IsUsed(register) {
|
||||
f.Register(asm.PUSH, register)
|
||||
}
|
||||
@ -60,7 +60,7 @@ func (f *Function) CompileCall(root *expression.Expression) error {
|
||||
}
|
||||
|
||||
for _, register := range registers {
|
||||
if register == f.cpu.Output[0] && root.Parent != nil {
|
||||
if register == f.CPU.Output[0] && root.Parent != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -68,8 +68,8 @@ func (f *Function) CompileCall(root *expression.Expression) error {
|
||||
}
|
||||
|
||||
// Pop
|
||||
for i := len(f.cpu.General) - 1; i >= 0; i-- {
|
||||
register := f.cpu.General[i]
|
||||
for i := len(f.CPU.General) - 1; i >= 0; i-- {
|
||||
register := f.CPU.General[i]
|
||||
|
||||
if f.CurrentScope().IsUsed(register) {
|
||||
f.Register(asm.POP, register)
|
||||
|
Reference in New Issue
Block a user