Custom internal Runner example?

I have a custom language plugin and I would like to add an ability to run and debug the code written in this language - however, there's no command line or external tool for this, at the end of the day it's just a matter of calling a Java method, e.g. String response = MyLanguage.runScript(script); So my question is, how do I go about implementing an internal runner? All examples I could find start and control the external OS processes. Can anyone recommend any good example of an internal runner?


Folks, pardon my annoyance, I'm still trying to figure this one out. So again the idea is to have an in-memory process running in a separate thread, as opposed to starting an external process in OS, e.g. 


Now I have a bunch of classes, `MyLanguageProcessHandler`, `MyLanguageDebugProcess extends XDebugProcess`, `MyLanguageProgramRunner`, `MyLanguageRunProfileState`, but I guess I still don't fully understand the relationship between them. Which class is supposed to run the above mentioned code? How is it invoked? And how do I pass the output to the debug console?