0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 02:02:38 +01:00

ircd::js: Use a script object in the task (more flexible than function).

This commit is contained in:
Jason Volk 2016-11-01 04:34:20 -07:00
parent f54c4215b4
commit 333b0dca5a
2 changed files with 3 additions and 4 deletions

View file

@ -30,7 +30,7 @@ struct task
{
uint64_t pid;
struct global global; // global / this / root scope object
heap_function main; // main generator wrapper function
heap_script main; // main generator wrapper script
struct generator generator; // generator state
private:

View file

@ -175,11 +175,10 @@ try
// TODO: options
JS::CompileOptions opts(*cx);
JS::AutoObjectVector stack(*cx);
// The function must be compiled in this scope and returned as a heap_function
// before the compartment destructs.
return heap_function { stack, opts, "main", {}, source };
return heap_script { opts, source };
}()}
,generator{[this]
{
@ -190,7 +189,7 @@ try
// The run() closure provides safety for entering the JS engine.
value state(run([this]
{
return this->main(this->global);
return this->main();
}));
// Construct the generator object here on the stack while in a compartment. The