hscript icon indicating copy to clipboard operation
hscript copied to clipboard

Add steppable/interruptible interpreter

Open 6J7KZg2f opened this issue 5 years ago • 6 comments

This pull is for a variation on Interp; IterativeInterp.

It makes it possible to step through hscript blocks of arbitrary complexity in discrete steps while maintaining variables and so on. There is theoretically no hscript expression that will cause this interpreter to hang.

Use cases include time sharing between multiple scripts, splitting a script over multiple frames, implementing script containing endless loops on single-threaded targets, and debugging scripts by stepping over each expression (nearly) one at a time.

See IterativeREADME.md for usage details.

6J7KZg2f avatar Apr 24 '19 05:04 6J7KZg2f

This in general needs a pretty major code review, if anyone would be keen to give one. There are some cases already where it should fail (array instantiation is something I haven't looked into a great deal yet, for example). The majority of the effort was spent on EFunction/ECall.

~It also does not in any way support hscriptPos at this point. I need to get my head around how to work with ExprDefs.~

6J7KZg2f avatar Apr 24 '19 05:04 6J7KZg2f

With the latest updates, this is now compatible with the hscriptPos flag. There are some situations, however, where PosInfo will become inaccurate at runtime for certain expressions.

6J7KZg2f avatar May 07 '19 05:05 6J7KZg2f

What's the situation with this? I have a use for this kind of thing as I'm currently working around it in a kinda annoyingly hacky way by wrapping expression after they come out of parsing in my own "execution stack closure list" and running those one by one. An interpreter that could be halted/yielded from the outside, would fix this issue. :)

muchitto avatar May 05 '20 11:05 muchitto

That's interesting, but I have not much time to review it atm.

Le mar. 5 mai 2020 à 13:32, muchitto [email protected] a écrit :

What's the situation with this? I have a use for this kind of thing as I'm currently working around it in a kinda annoyingly hacky way by wrapping expression after they come out of parsing in my own "execution stack closure list" and running those one by one. An interpreter that could be halted/yielded from the outside, would fix this issue. :)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HaxeFoundation/hscript/pull/79#issuecomment-624000997, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZXQA5OERTD45AKTDMYUDRP72NLANCNFSM4HIASISA .

ncannasse avatar May 05 '20 11:05 ncannasse

What's the situation with this? I have a use for this kind of thing as I'm currently working around it in a kinda annoyingly hacky way by wrapping expression after they come out of parsing in my own "execution stack closure list" and running those one by one. An interpreter that could be halted/yielded from the outside, would fix this issue. :)

I use it in production for https://talosfray.TV with no issues as far as I can tell, so using it from my fork is an option if you're desperate.

6J7KZg2f avatar May 08 '20 16:05 6J7KZg2f

I would also have a use for this.

mundusnine avatar Aug 18 '20 21:08 mundusnine