Removed unused variables from scopes

This commit is contained in:
Eduard Urbach 2024-07-16 15:39:32 +02:00
parent d6d018c5c5
commit 1825a72f8c
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0

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 {