Removed unused variables from scopes

This commit is contained in:
Eduard Urbach 2024-07-16 15:39:32 +02:00
parent 545c8dd4f6
commit 43a6e85929
Signed by: eduard
GPG key ID: 49226B848C78F6C8

View file

@ -27,11 +27,17 @@ func (s *state) pushScope(body ast.AST) {
scope.variables = make(map[string]*Variable, len(lastScope.variables))
for k, v := range lastScope.variables {
count := ast.Count(body, token.Identifier, v.Name)
if count == 0 {
continue
}
scope.variables[k] = &Variable{
Value: v.Value,
Name: v.Name,
Register: v.Register,
Alive: ast.Count(body, token.Identifier, v.Name),
Alive: count,
}
}
} else {