Removed unused variables from scopes
This commit is contained in:
parent
d6d018c5c5
commit
1825a72f8c
@ -27,11 +27,17 @@ func (s *state) pushScope(body ast.AST) {
|
|||||||
scope.variables = make(map[string]*Variable, len(lastScope.variables))
|
scope.variables = make(map[string]*Variable, len(lastScope.variables))
|
||||||
|
|
||||||
for k, v := range lastScope.variables {
|
for k, v := range lastScope.variables {
|
||||||
|
count := ast.Count(body, token.Identifier, v.Name)
|
||||||
|
|
||||||
|
if count == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
scope.variables[k] = &Variable{
|
scope.variables[k] = &Variable{
|
||||||
Value: v.Value,
|
Value: v.Value,
|
||||||
Name: v.Name,
|
Name: v.Name,
|
||||||
Register: v.Register,
|
Register: v.Register,
|
||||||
Alive: ast.Count(body, token.Identifier, v.Name),
|
Alive: count,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user