mardi 10 avril 2018

How do I bind types into my Scala Interpreter?

I am trying to bind values into an interpreter with types from an external library.

This is how I am currently declaring my interpreter:

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)

However when I execute my code I get this error at runtime:

<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]
                                                               ^
...

I'm also trying to include an Object I've declared to the scope of the interpreter, and I'm not sure how I would do that. Any help would be appreciated!





Aucun commentaire:

Enregistrer un commentaire