Moved AST generation to its own package

This commit is contained in:
Eduard Urbach 2024-07-01 15:05:15 +02:00
parent 8453273d73
commit 2d045759f2
Signed by: eduard
GPG key ID: 49226B848C78F6C8
8 changed files with 172 additions and 171 deletions

View file

@ -77,6 +77,24 @@ func (f *Function) useVariable(variable *Variable) {
}
}
// identifierExists returns true if the identifier has been defined.
func (f *Function) identifierExists(name string) bool {
_, exists := f.variables[name]
if exists {
return true
}
_, exists = f.definitions[name]
if exists {
return true
}
_, exists = f.functions[name]
return exists
}
func (f *Function) storeVariableInRegister(name string, value *expression.Expression, uses int) error {
reg, exists := f.cpu.FindFree(f.cpu.General)