Removed unused variables from scopes
This commit is contained in:
parent
545c8dd4f6
commit
43a6e85929
1 changed files with 7 additions and 1 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue