Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687package dll
import ( "iter" "slices")
// List is a slice of DLLs.type List struct { libs []Library}
// All returns an iterator over all libraries.func (list *List) All() iter.Seq[Library] { return func(yield func(Library) bool) { for _, lib := range list.libs { if !yield(lib) { return } } }}
// Append adds a function for the given DLL if it doesn't exist yet.func (list *List) Append(dllName string, funcName string) { for i, dll := range list.libs { if dll.Name != dllName { continue }
if slices.Contains(dll.Functions, funcName) { return }
list.libs[i].Functions = append(list.libs[i].Functions, funcName) return }
list.libs = append(list.libs, Library{Name: dllName, Functions: []string{funcName}})}
// Contains returns true if the library exists.func (list *List) Contains(dllName string) bool { for _, dll := range list.libs { if dll.Name == dllName { return true } }
return false}
// Count returns the number of libraries.func (list *List) Count() int { return len(list.libs)}
// Count returns the number of functions.func (list *List) CountFunctions() int { count := 0
for _, dll := range list.libs { count += len(dll.Functions) }
return count}
// Index returns the position of the given function name.func (list *List) Index(dllName string, funcName string) int { index := 0
for _, dll := range list.libs { if dll.Name != dllName { index += len(dll.Functions) + 1 continue }
for i, fn := range dll.Functions { if fn == funcName { return index + i } } }
return -1}