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.
20 lines
364 B
Go
20 lines
364 B
Go
package nested2
|
|
|
|
// Unused shouldn't produce any code if unused.
|
|
var Unused = 21
|
|
|
|
// Argument is an argument used from external package to call nested1.f.
|
|
var Argument = 22
|
|
|
|
// A has the same name as nested1.A.
|
|
var A = 23
|
|
|
|
// B should produce call to f and be DROPped if unused.
|
|
var B = f()
|
|
|
|
// Unique has unique name.
|
|
var Unique = 24
|
|
|
|
func f() int {
|
|
return 25
|
|
}
|