Cue/hegemon — pull request #1 by stefanp (2013-04-13 07:03:48+00:00)
Title: Script options (version, optimization level, execution observer)

Note: this is not ready yet! Just creating this pull request to get early feedback.

The goal is to let callers specify the javascript version, optimization level they need, as well as letting them register an optional 'execution observer' - a simple delegate called from the interpreter or the generated code - which can be used, for example, to kill long running scripts.

Highlights:
- Move some formerly global, static things from Script to ScriptCache.
- Introduce a ScriptOptions class and the corresponding builder to hold these new configurable options.
- Add a ScriptCache constructor that takes ScriptOptions, and a Script constructor that takes a ScriptCache
- Provide a ready-to-use execution observer that'll throw a java.lang.Error to kill scripts that have been running for too long.
- Remove Script.STATIC_VALUES (which does not appear to be really necessary for our own codebase, and smells like trouble).

TODO:
- The legacy Script constructor creates a ScriptCache - maybe this is wrong? In any case, make sure we're backwards compatible and de-uglify if possible.
- Maybe rename ScriptCache to ScriptLoader to clarify its role as the parent for a set of scripts with the same options.
- Reintroduce STATIC_VALUES if needed (ideally per loader?)