mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-04 23:56:30 +00:00
43 lines
865 B
Go
43 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)
|
||
|
}
|