Commit cb1fec85 authored by Hugo Moreau's avatar Hugo Moreau

global: adding accessor only once

Getter and Setter were added twice.

 * transform/global.go : Here.
parent 77a8448d
Pipeline #26397 failed with stage
in 1 minute and 49 seconds
......@@ -247,6 +247,9 @@ func (t *Global) Pre(meta *Meta, v *Visitor) bool {
continue
}
funcident := t.createArg(lhs.Name+"_set", "func(int)", ident)
if findFuncIdent(t.Funcs, funcident.Name) {
return true
}
t.Funcs = append(t.Funcs, t.createFunc(lhs, funcident))
}
}
......@@ -262,6 +265,9 @@ func (t *Global) Pre(meta *Meta, v *Visitor) bool {
return true
}
funcident := t.createArg(node.Name+"_get", "func() int", ident)
if findFuncIdent(t.Funcs, funcident.Name) {
return true
}
t.Funcs = append(t.Funcs, t.createFunc(node, funcident))
}
}
......@@ -298,3 +304,15 @@ func findIdent(a *ast.Field, x string) bool {
}
return false
}
func findFuncIdent(a []*ast.FuncDecl, x string) bool {
if a == nil {
return false
}
for _, val := range a {
if x == val.Name.Name {
return true
}
}
return false
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment