LibJS: Add JSON.stringify function to the intrinsics

This is needed for some Web APIs.
This commit is contained in:
Linus Groh 2022-09-25 19:17:24 +01:00
parent b42b950688
commit 4e536eaf98
Notes: sideshowbarker 2024-07-17 06:36:51 +09:00
2 changed files with 4 additions and 0 deletions

View File

@ -310,6 +310,7 @@ void Intrinsics::initialize_intrinsics(Realm& realm)
m_array_prototype_values_function = &m_array_prototype->get_without_side_effects(vm.names.values).as_function();
m_date_constructor_now_function = &m_date_constructor->get_without_side_effects(vm.names.now).as_function();
m_json_parse_function = &m_json_object->get_without_side_effects(vm.names.parse).as_function();
m_json_stringify_function = &m_json_object->get_without_side_effects(vm.names.stringify).as_function();
m_object_prototype_to_string_function = &m_object_prototype->get_without_side_effects(vm.names.toString).as_function();
}
@ -327,6 +328,7 @@ void Intrinsics::visit_edges(Visitor& visitor)
visitor.visit(m_date_constructor_now_function);
visitor.visit(m_eval_function);
visitor.visit(m_json_parse_function);
visitor.visit(m_json_stringify_function);
visitor.visit(m_object_prototype_to_string_function);
visitor.visit(m_throw_type_error_function);

View File

@ -55,6 +55,7 @@ public:
FunctionObject* array_prototype_values_function() const { return m_array_prototype_values_function; }
FunctionObject* date_constructor_now_function() const { return m_date_constructor_now_function; }
FunctionObject* json_parse_function() const { return m_json_parse_function; }
FunctionObject* json_stringify_function() const { return m_json_stringify_function; }
FunctionObject* object_prototype_to_string_function() const { return m_object_prototype_to_string_function; }
FunctionObject* throw_type_error_function() const { return m_throw_type_error_function; }
@ -149,6 +150,7 @@ private:
FunctionObject* m_array_prototype_values_function { nullptr };
FunctionObject* m_date_constructor_now_function { nullptr };
FunctionObject* m_json_parse_function { nullptr };
FunctionObject* m_json_stringify_function { nullptr };
FunctionObject* m_object_prototype_to_string_function { nullptr };
FunctionObject* m_throw_type_error_function { nullptr };