LibJS+js: Rename RegExp.{content => pattern}
The spec talks about it as 'pattern', so let's use that instead.
This commit is contained in:
parent
3db8ced4c7
commit
3200ff5f4f
Notes:
sideshowbarker
2024-07-19 01:14:44 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/3200ff5f4f4 Pull-request: https://github.com/SerenityOS/serenity/pull/4103 Reviewed-by: https://github.com/linusg ✅
5 changed files with 12 additions and 12 deletions
|
@ -58,13 +58,13 @@ Value RegExpConstructor::construct(Function&)
|
|||
auto& vm = this->vm();
|
||||
if (!vm.argument_count())
|
||||
return RegExpObject::create(global_object(), "(?:)", "");
|
||||
auto contents = vm.argument(0).to_string(global_object());
|
||||
auto pattern = vm.argument(0).to_string(global_object());
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto flags = vm.argument_count() > 1 ? vm.argument(1).to_string(global_object()) : "";
|
||||
if (vm.exception())
|
||||
return {};
|
||||
return RegExpObject::create(global_object(), contents, flags);
|
||||
return RegExpObject::create(global_object(), pattern, flags);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,14 +33,14 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
RegExpObject* RegExpObject::create(GlobalObject& global_object, String content, String flags)
|
||||
RegExpObject* RegExpObject::create(GlobalObject& global_object, String pattern, String flags)
|
||||
{
|
||||
return global_object.heap().allocate<RegExpObject>(global_object, content, flags, *global_object.regexp_prototype());
|
||||
return global_object.heap().allocate<RegExpObject>(global_object, pattern, flags, *global_object.regexp_prototype());
|
||||
}
|
||||
|
||||
RegExpObject::RegExpObject(String content, String flags, Object& prototype)
|
||||
RegExpObject::RegExpObject(String pattern, String flags, Object& prototype)
|
||||
: Object(prototype)
|
||||
, m_content(content)
|
||||
, m_pattern(pattern)
|
||||
, m_flags(flags)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -35,18 +35,18 @@ class RegExpObject : public Object {
|
|||
JS_OBJECT(RegExpObject, Object);
|
||||
|
||||
public:
|
||||
static RegExpObject* create(GlobalObject&, String content, String flags);
|
||||
static RegExpObject* create(GlobalObject&, String pattern, String flags);
|
||||
|
||||
RegExpObject(String content, String flags, Object& prototype);
|
||||
RegExpObject(String pattern, String flags, Object& prototype);
|
||||
virtual ~RegExpObject() override;
|
||||
|
||||
const String& content() const { return m_content; }
|
||||
const String& pattern() const { return m_pattern; }
|
||||
const String& flags() const { return m_flags; }
|
||||
|
||||
private:
|
||||
virtual bool is_regexp_object() const override { return true; }
|
||||
|
||||
String m_content;
|
||||
String m_pattern;
|
||||
String m_flags;
|
||||
};
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::to_string)
|
|||
auto* regexp_object = regexp_object_from(vm, global_object);
|
||||
if (!regexp_object)
|
||||
return {};
|
||||
return js_string(vm, String::formatted("/{}/{}", regexp_object->content(), regexp_object->flags()));
|
||||
return js_string(vm, String::formatted("/{}/{}", regexp_object->pattern(), regexp_object->flags()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ static void print_error(const JS::Object& object, HashTable<JS::Object*>&)
|
|||
static void print_regexp(const JS::Object& object, HashTable<JS::Object*>&)
|
||||
{
|
||||
auto& regexp = static_cast<const JS::RegExpObject&>(object);
|
||||
out("\033[34;1m/{}/{}\033[0m", regexp.content(), regexp.flags());
|
||||
out("\033[34;1m/{}/{}\033[0m", regexp.pattern(), regexp.flags());
|
||||
}
|
||||
|
||||
static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects)
|
||||
|
|
Loading…
Add table
Reference in a new issue