mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-03 15:16:29 +00:00
c28f7cb29f
Initial part of #435
42 lines
865 B
Go
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)
|
|
}
|