Implemented dependency tracking

This commit is contained in:
2025-03-03 12:14:53 +01:00
parent 08660ad845
commit 751614e7c0
12 changed files with 75 additions and 69 deletions

View File

@ -42,7 +42,8 @@ func (f *Function) EvaluateDot(expr *expression.Expression) (eval.Value, error)
return value, nil
}
constant, isConst := f.All.Constants[f.Package+"."+leftText+"."+rightText]
label := fmt.Sprintf("%s.%s", leftText, rightText)
constant, isConst := f.All.Constants[f.Package+"."+label]
if isConst {
number, err := ToNumber(constant.Token, constant.File)
@ -73,10 +74,18 @@ func (f *Function) EvaluateDot(expr *expression.Expression) (eval.Value, error)
}
}
value := &eval.Label{
Typ: types.AnyPointer,
Label: fmt.Sprintf("%s.%s", leftText, rightText),
function, exists := f.All.Functions[label]
if exists {
f.Dependencies = append(f.Dependencies, function)
value := &eval.Label{
Typ: types.AnyPointer,
Label: label,
}
return value, nil
}
return value, nil
return nil, errors.New(&errors.UnknownIdentifier{Name: label}, f.File, left.Token.Position)
}