forked from TrueCloudLab/neoneo-go
800321db06
So that (*codegen).Visit is able to omit code generation for these unused global vars. The most tricky part is to detect unused global variables, it is done in several steps: 1. Collect the set of named used/unused global vars. 2. Collect the set of globally declared expressions that contain function calls. 3. Pick up global vars from the set made at step 2. 4. Traverse used functions and puck up those global vars that are used from these functions. 5. Rename all globals that are presented in the set made at step 1 but are not presented in the set made on step 3 or step 4.
18 lines
407 B
Go
18 lines
407 B
Go
package nested3
|
|
|
|
// Argument is used as a function argument.
|
|
var Argument = 34
|
|
|
|
// Anna is used to check struct-related usage analyzer logic (calls to methods
|
|
// and fields).
|
|
var Anna = Person{Age: 24}
|
|
|
|
// Person is an auxiliary structure containing simple field.
|
|
type Person struct {
|
|
Age int
|
|
}
|
|
|
|
// GetAge is used to check method calls inside usage analyzer.
|
|
func (p Person) GetAge() int {
|
|
return p.Age
|
|
}
|