mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 13:45:08 +00:00
LibJS: Move most of Interpreter into VM
This patch moves the exception state, call stack and scope stack from Interpreter to VM. I'm doing this to help myself discover what the split between Interpreter and VM should be, by shuffling things around and seeing what falls where. With these changes, we no longer have a persistent lexical environment for the current global object on the Interpreter's call stack. Instead, we push/pop that environment on Interpreter::run() enter/exit. Since it should only be used to find the global "this", and not for variable storage (that goes directly into the global object instead!), I had to insert some short-circuiting when walking the environment parent chain during variable lookup. Note that this is a "stepping stone" commit, not a final design.
This commit is contained in:
parent
838d9fa251
commit
6861c619c6
48 changed files with 765 additions and 726 deletions
|
@ -87,12 +87,12 @@ void SheetGlobalObject::initialize()
|
|||
JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::parse_cell_name)
|
||||
{
|
||||
if (interpreter.argument_count() != 1) {
|
||||
interpreter.throw_exception<JS::TypeError>("Expected exactly one argument to parse_cell_name()");
|
||||
interpreter.vm().throw_exception<JS::TypeError>(global_object, "Expected exactly one argument to parse_cell_name()");
|
||||
return {};
|
||||
}
|
||||
auto name_value = interpreter.argument(0);
|
||||
if (!name_value.is_string()) {
|
||||
interpreter.throw_exception<JS::TypeError>("Expected a String argument to parse_cell_name()");
|
||||
interpreter.vm().throw_exception<JS::TypeError>(global_object, "Expected a String argument to parse_cell_name()");
|
||||
return {};
|
||||
}
|
||||
auto position = Sheet::parse_cell_name(name_value.as_string().string());
|
||||
|
@ -125,12 +125,12 @@ void WorkbookObject::initialize(JS::GlobalObject& global_object)
|
|||
JS_DEFINE_NATIVE_FUNCTION(WorkbookObject::sheet)
|
||||
{
|
||||
if (interpreter.argument_count() != 1) {
|
||||
interpreter.throw_exception<JS::TypeError>("Expected exactly one argument to sheet()");
|
||||
interpreter.vm().throw_exception<JS::TypeError>(global_object, "Expected exactly one argument to sheet()");
|
||||
return {};
|
||||
}
|
||||
auto name_value = interpreter.argument(0);
|
||||
if (!name_value.is_string() && !name_value.is_number()) {
|
||||
interpreter.throw_exception<JS::TypeError>("Expected a String or Number argument to sheet()");
|
||||
interpreter.vm().throw_exception<JS::TypeError>(global_object, "Expected a String or Number argument to sheet()");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ JS_DEFINE_NATIVE_FUNCTION(WorkbookObject::sheet)
|
|||
return {};
|
||||
|
||||
if (!this_object->inherits("WorkbookObject")) {
|
||||
interpreter.throw_exception<JS::TypeError>(JS::ErrorType::NotA, "WorkbookObject");
|
||||
interpreter.vm().throw_exception<JS::TypeError>(global_object, JS::ErrorType::NotA, "WorkbookObject");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue