woodpecker/vendor/github.com/quasilyte/go-ruleguard/ruleguard/quasigo/env.go
Lukas c28f7cb29f
Add golangci-lint (#502)
Initial part of #435
2021-11-14 21:01:54 +01:00

42 lines
865 B
Go

package quasigo
type funcKey struct {
qualifier string
name string
}
func (k funcKey) String() string {
if k.qualifier != "" {
return k.qualifier + "." + k.name
}
return k.name
}
type nativeFunc struct {
mappedFunc func(*ValueStack)
name string // Needed for the readable disasm
}
func newEnv() *Env {
return &Env{
nameToNativeFuncID: make(map[funcKey]uint16),
nameToFuncID: make(map[funcKey]uint16),
debug: newDebugInfo(),
}
}
func (env *Env) addNativeFunc(key funcKey, f func(*ValueStack)) {
id := len(env.nativeFuncs)
env.nativeFuncs = append(env.nativeFuncs, nativeFunc{
mappedFunc: f,
name: key.String(),
})
env.nameToNativeFuncID[key] = uint16(id)
}
func (env *Env) addFunc(key funcKey, f *Func) {
id := len(env.userFuncs)
env.userFuncs = append(env.userFuncs, f)
env.nameToFuncID[key] = uint16(id)
}