Simplified identifier lookup
This commit is contained in:
parent
e962ac379c
commit
e439516059
5 changed files with 34 additions and 31 deletions
25
src/core/Identifier.go
Normal file
25
src/core/Identifier.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/scope"
|
||||
)
|
||||
|
||||
// Identifier looks up an identifier which can be a variable or a function.
|
||||
func (f *Function) Identifier(name string) (*scope.Variable, *Function) {
|
||||
variable := f.VariableByName(name)
|
||||
|
||||
if variable != nil {
|
||||
return variable, nil
|
||||
}
|
||||
|
||||
uniqueName := fmt.Sprintf("%s.%s", f.Package, name)
|
||||
function, exists := f.Functions[uniqueName]
|
||||
|
||||
if exists {
|
||||
return nil, function
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue