CCF icon indicating copy to clipboard operation
CCF copied to clipboard

[WIP] Cleanup `js::core::Context`, move to an extension model

Open eddyashton opened this issue 1 year ago • 1 comments

Goal is for js::core::Context to be a pure interpreter (ie - we don't insert anything that QuickJS doesn't), and a vaguely readable interface. This PR works towards the latter by shuffling methods around, removing a few unused/unnecessary overloads, and the former by introducing an Extension pattern rather than populate_global_XXX methods on the Context.

A goal of this extension pattern is the removal of the messy globals object on Context - previously lots of inserted calls relied on the globals.tx object inserted to support the ccf.kv functions. Now they explicitly use the state in their own extension, including a Tx* where necessary. This should also simplify cleanup, as its a case of deleting extensions rather than invalidating global values.

eddyashton avatar May 02 '24 16:05 eddyashton

TODO before merging:

  • [x] Rename IExtension
  • [x] Rename the extensions for less Ccf repetition
  • [x] Manually verify what we expose in each execution context hasn't changed, see if that can be automated. (EDIT: Manually verified that we insert exactly the same globals, but with a bunch of hacks and manually string mangling. Will punt on automating this for now.

eddyashton avatar May 16 '24 16:05 eddyashton