Separated compiler into its own package
This commit is contained in:
@ -9,28 +9,28 @@ import (
|
||||
)
|
||||
|
||||
func (f *Function) AddLabel(label string) {
|
||||
f.assembler.Label(asm.LABEL, label)
|
||||
f.Assembler.Label(asm.LABEL, label)
|
||||
f.postInstruction()
|
||||
}
|
||||
|
||||
func (f *Function) Call(label string) {
|
||||
f.assembler.Call(label)
|
||||
f.Assembler.Call(label)
|
||||
f.Scope().Use(f.cpu.Output[0])
|
||||
f.postInstruction()
|
||||
}
|
||||
|
||||
func (f *Function) Comment(format string, args ...any) {
|
||||
f.assembler.Comment(fmt.Sprintf(format, args...))
|
||||
f.Assembler.Comment(fmt.Sprintf(format, args...))
|
||||
f.postInstruction()
|
||||
}
|
||||
|
||||
func (f *Function) Jump(mnemonic asm.Mnemonic, label string) {
|
||||
f.assembler.Label(mnemonic, label)
|
||||
f.Assembler.Label(mnemonic, label)
|
||||
f.postInstruction()
|
||||
}
|
||||
|
||||
func (f *Function) Register(mnemonic asm.Mnemonic, a cpu.Register) {
|
||||
f.assembler.Register(mnemonic, a)
|
||||
f.Assembler.Register(mnemonic, a)
|
||||
|
||||
if mnemonic == asm.POP {
|
||||
f.Scope().Use(a)
|
||||
@ -44,7 +44,7 @@ func (f *Function) RegisterNumber(mnemonic asm.Mnemonic, a cpu.Register, b int)
|
||||
f.SaveRegister(a)
|
||||
}
|
||||
|
||||
f.assembler.RegisterNumber(mnemonic, a, b)
|
||||
f.Assembler.RegisterNumber(mnemonic, a, b)
|
||||
|
||||
if mnemonic == asm.MOVE {
|
||||
f.Scope().Use(a)
|
||||
@ -58,7 +58,7 @@ func (f *Function) RegisterLabel(mnemonic asm.Mnemonic, register cpu.Register, l
|
||||
f.SaveRegister(register)
|
||||
}
|
||||
|
||||
f.assembler.RegisterLabel(mnemonic, register, label)
|
||||
f.Assembler.RegisterLabel(mnemonic, register, label)
|
||||
|
||||
if mnemonic == asm.MOVE {
|
||||
f.Scope().Use(register)
|
||||
@ -76,7 +76,7 @@ func (f *Function) RegisterRegister(mnemonic asm.Mnemonic, a cpu.Register, b cpu
|
||||
f.SaveRegister(a)
|
||||
}
|
||||
|
||||
f.assembler.RegisterRegister(mnemonic, a, b)
|
||||
f.Assembler.RegisterRegister(mnemonic, a, b)
|
||||
|
||||
if mnemonic == asm.MOVE {
|
||||
f.Scope().Use(a)
|
||||
@ -86,12 +86,12 @@ func (f *Function) RegisterRegister(mnemonic asm.Mnemonic, a cpu.Register, b cpu
|
||||
}
|
||||
|
||||
func (f *Function) Return() {
|
||||
f.assembler.Return()
|
||||
f.Assembler.Return()
|
||||
f.postInstruction()
|
||||
}
|
||||
|
||||
func (f *Function) Syscall() {
|
||||
f.assembler.Syscall()
|
||||
f.Assembler.Syscall()
|
||||
f.Scope().Use(f.cpu.Output[0])
|
||||
f.postInstruction()
|
||||
}
|
||||
|
Reference in New Issue
Block a user