Improved variable lifetime tracking
This commit is contained in:
parent
1510f88165
commit
b8c011d742
17 changed files with 114 additions and 31 deletions
|
@ -260,7 +260,18 @@ func scanFile(path string, functions chan<- *Function) error {
|
|||
if len(tokens) == 1 {
|
||||
name := tokens[0].Text()
|
||||
register := x64.CallRegisters[len(function.variables)]
|
||||
variable := &Variable{Name: name, Register: register}
|
||||
uses := countIdentifier(function.Body, name)
|
||||
|
||||
if uses == 0 {
|
||||
return errors.New(&errors.UnusedVariable{Name: name}, file, tokens[0].Position)
|
||||
}
|
||||
|
||||
variable := &Variable{
|
||||
Name: name,
|
||||
Register: register,
|
||||
Alive: uses,
|
||||
}
|
||||
|
||||
function.addVariable(variable)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue