我正在尝试将值绑定到具有来自外部库的类型的解释器中。
这就是我目前声明我的解释器的方式:
val interpreter = new IMain({
val settings = new Settings
settings.usejavacp.value = true
settings.deprecation.value = true
settings.embeddedDefaults[IMessage]
settings.embeddedDefaults[IChannel]
settings.embeddedDefaults[IGuild]
settings.embeddedDefaults[IUser]
settings
})
// Variable bindings
interpreter.bind("message", "IMessage", event.getMessage)
interpreter.bind("guild", "IGuild", event.getGuild)
interpreter.bind("user", "IUser", event.getAuthor)
interpreter.bind("channel", "IChannel", event.getChannel)
interpreter.interpret(code)
但是,当我执行我的代码时,我在运行时收到此错误:
<console>:5: error: not found: type IMessage
var value: IMessage = _
^
<console>:6: error: not found: type IMessage
def set(x: _root_.scala.Any) = value = x.asInstanceOf[IMessage]
^
<console>:5: error: not found: type IGuild
var value: IGuild = _
^
<console>:6: error: not found: type IGuild
def set(x: _root_.scala.Any) = value = x.asInstanceOf[IGuild]
^
...
我还试图将我声明的对象包含在解释器的范围内,但我不确定我会如何做到这一点。任何帮助,将不胜感激!