2021-09-02 21:26:40 +00:00
|
|
|
package vm
|
|
|
|
|
2023-10-20 16:27:20 +00:00
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
|
|
|
"github.com/ethereum/go-ethereum/plugins"
|
|
|
|
)
|
|
|
|
|
2021-09-02 21:26:40 +00:00
|
|
|
func (st *Stack) Len() int {
|
|
|
|
return len(st.data)
|
|
|
|
}
|
2023-10-20 16:27:20 +00:00
|
|
|
|
|
|
|
func PluginOpCodeSelect(pl *plugins.PluginLoader, jt *JumpTable) *JumpTable {
|
|
|
|
var opCodes []int
|
|
|
|
fnList := pl.Lookup("OpCodeSelect", func(item interface{}) bool {
|
|
|
|
_, ok := item.(func() []int)
|
|
|
|
return ok
|
|
|
|
})
|
|
|
|
for _, fni := range fnList {
|
|
|
|
if fn, ok := fni.(func() []int); ok {
|
|
|
|
opCodes = append(opCodes, fn()...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(opCodes) > 0 {
|
|
|
|
jt = copyJumpTable(jt)
|
|
|
|
}
|
|
|
|
for _, idx := range opCodes {
|
|
|
|
(*jt)[idx] = nil
|
|
|
|
}
|
|
|
|
return jt
|
|
|
|
}
|
|
|
|
|
|
|
|
func pluginOpCodeSelect(jt *JumpTable) *JumpTable {
|
|
|
|
if plugins.DefaultPluginLoader == nil {
|
|
|
|
log.Warn("Attempting PluginOpCodeSelect, but default PluginLoader has not been initialized")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return PluginOpCodeSelect(plugins.DefaultPluginLoader, jt)
|
|
|
|
}
|
|
|
|
|