mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-30 05:08:56 +00:00
LibJS: Use the same StringPrototype globally
To make sure that everyone has the same instance of StringPrototype, hang a global prototype off of the Interpreter that can be fetched when constructing new StringObjects.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <LibJS/Heap.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/PrimitiveString.h>
|
||||
#include <LibJS/StringObject.h>
|
||||
#include <LibJS/StringPrototype.h>
|
||||
@@ -35,7 +36,7 @@ namespace JS {
|
||||
StringObject::StringObject(PrimitiveString* string)
|
||||
: m_string(string)
|
||||
{
|
||||
set_prototype(heap().allocate<StringPrototype>());
|
||||
set_prototype(interpreter().string_prototype());
|
||||
put("length", Value(static_cast<i32>(m_string->string().length())));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user