Implemented definitions

This commit is contained in:
Eduard Urbach 2024-06-30 12:28:43 +02:00
parent aba9cf2412
commit ef7deb30b7
Signed by: eduard
GPG key ID: 49226B848C78F6C8
6 changed files with 70 additions and 14 deletions

View file

@ -190,6 +190,16 @@ func (f *Function) TokenToRegister(t token.Token, register cpu.Register) error {
switch t.Kind {
case token.Identifier:
name := t.Text()
constant, exists := f.definitions[name]
if exists {
if config.Verbose {
f.Logf("constant %s = %s", constant.Name, constant.Value)
}
return f.ExpressionToRegister(constant.Value, register)
}
variable, exists := f.variables[name]
if !exists {