add graphql

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-06-11 20:45:45 +03:00
parent 55fa1ee403
commit 6d17a74ffb
16 changed files with 8494 additions and 48 deletions

32
graphql/callstack.go Normal file
View File

@@ -0,0 +1,32 @@
package generator
type Callstack interface {
Push(entry interface{})
Pop(entry interface{})
Has(entry interface{}) bool
}
func NewCallstack() Callstack {
return &callstack{stack: make(map[interface{}]int), index: 0}
}
type callstack struct {
stack map[interface{}]int
sorted []string
index int
}
func (c *callstack) Pop(entry interface{}) {
delete(c.stack, entry)
c.index--
}
func (c *callstack) Push(entry interface{}) {
c.stack[entry] = c.index
c.index++
}
func (c *callstack) Has(entry interface{}) bool {
_, ok := c.stack[entry]
return ok
}