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:
parent
f54c4215b4
commit
333b0dca5a
2 changed files with 3 additions and 4 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue