mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 22:15:08 +00:00
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
5 changed files with 12 additions and 12 deletions
|
@ -58,13 +58,13 @@ Value RegExpConstructor::construct(Function&)
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
if (!vm.argument_count())
|
if (!vm.argument_count())
|
||||||
return RegExpObject::create(global_object(), "(?:)", "");
|
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())
|
if (vm.exception())
|
||||||
return {};
|
return {};
|
||||||
auto flags = vm.argument_count() > 1 ? vm.argument(1).to_string(global_object()) : "";
|
auto flags = vm.argument_count() > 1 ? vm.argument(1).to_string(global_object()) : "";
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return {};
|
return {};
|
||||||
return RegExpObject::create(global_object(), contents, flags);
|
return RegExpObject::create(global_object(), pattern, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,14 +33,14 @@
|
||||||
|
|
||||||
namespace JS {
|
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)
|
: Object(prototype)
|
||||||
, m_content(content)
|
, m_pattern(pattern)
|
||||||
, m_flags(flags)
|
, m_flags(flags)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,18 +35,18 @@ class RegExpObject : public Object {
|
||||||
JS_OBJECT(RegExpObject, Object);
|
JS_OBJECT(RegExpObject, Object);
|
||||||
|
|
||||||
public:
|
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;
|
virtual ~RegExpObject() override;
|
||||||
|
|
||||||
const String& content() const { return m_content; }
|
const String& pattern() const { return m_pattern; }
|
||||||
const String& flags() const { return m_flags; }
|
const String& flags() const { return m_flags; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool is_regexp_object() const override { return true; }
|
virtual bool is_regexp_object() const override { return true; }
|
||||||
|
|
||||||
String m_content;
|
String m_pattern;
|
||||||
String m_flags;
|
String m_flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::to_string)
|
||||||
auto* regexp_object = regexp_object_from(vm, global_object);
|
auto* regexp_object = regexp_object_from(vm, global_object);
|
||||||
if (!regexp_object)
|
if (!regexp_object)
|
||||||
return {};
|
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*>&)
|
static void print_regexp(const JS::Object& object, HashTable<JS::Object*>&)
|
||||||
{
|
{
|
||||||
auto& regexp = static_cast<const JS::RegExpObject&>(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)
|
static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue