Reduced token size

This commit is contained in:
2024-07-21 14:35:06 +02:00
parent ca36d34cb9
commit 04ba68a075
47 changed files with 543 additions and 764 deletions

View File

@ -15,7 +15,7 @@ import (
func (f *Function) TokenToRegister(t token.Token, register cpu.Register) error {
switch t.Kind {
case token.Identifier:
name := t.Text()
name := t.Text(f.File.Bytes)
variable := f.VariableByName(name)
if variable == nil {
@ -27,7 +27,7 @@ func (f *Function) TokenToRegister(t token.Token, register cpu.Register) error {
return nil
case token.Number:
value := t.Text()
value := t.Text(f.File.Bytes)
n, err := strconv.Atoi(value)
if err != nil {
@ -40,7 +40,7 @@ func (f *Function) TokenToRegister(t token.Token, register cpu.Register) error {
case token.String:
f.count.data++
label := fmt.Sprintf("%s_data_%d", f.Name, f.count.data)
value := t.Bytes[1 : len(t.Bytes)-1]
value := t.Bytes(f.File.Bytes)[1 : t.Length-1]
f.Assembler.SetData(label, value)
f.RegisterLabel(asm.MOVE, register, label)
return nil