mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-02 21:49:25 +00:00
30 lines
405 B
Go
30 lines
405 B
Go
|
package analyzer
|
||
|
|
||
|
import (
|
||
|
"go/ast"
|
||
|
)
|
||
|
|
||
|
type funcTypeStack []*ast.FuncType
|
||
|
|
||
|
func (s *funcTypeStack) Push(f *ast.FuncType) {
|
||
|
*s = append(*s, f)
|
||
|
}
|
||
|
|
||
|
func (s *funcTypeStack) Pop() *ast.FuncType {
|
||
|
if len(*s) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
last := len(*s) - 1
|
||
|
f := (*s)[last]
|
||
|
*s = (*s)[:last]
|
||
|
return f
|
||
|
}
|
||
|
|
||
|
func (s *funcTypeStack) Top() *ast.FuncType {
|
||
|
if len(*s) == 0 {
|
||
|
return nil
|
||
|
}
|
||
|
return (*s)[len(*s)-1]
|
||
|
}
|