summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibJS/Runtime/ArrayConstructor.cpp1
-rw-r--r--Libraries/LibJS/Runtime/BooleanConstructor.cpp1
-rw-r--r--Libraries/LibJS/Runtime/DateConstructor.cpp1
-rw-r--r--Libraries/LibJS/Runtime/ErrorConstructor.cpp1
-rw-r--r--Libraries/LibJS/Runtime/FunctionConstructor.cpp1
-rw-r--r--Libraries/LibJS/Runtime/FunctionPrototype.cpp6
-rw-r--r--Libraries/LibJS/Runtime/NativeFunction.cpp5
-rw-r--r--Libraries/LibJS/Runtime/NativeFunction.h1
-rw-r--r--Libraries/LibJS/Runtime/NumberConstructor.cpp1
-rw-r--r--Libraries/LibJS/Runtime/ObjectConstructor.cpp1
-rw-r--r--Libraries/LibJS/Runtime/StringConstructor.cpp1
-rw-r--r--Libraries/LibJS/Tests/Function.prototype.toString.js4
-rw-r--r--Libraries/LibJS/Tests/function-TypeError.js2
13 files changed, 22 insertions, 4 deletions
diff --git a/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Libraries/LibJS/Runtime/ArrayConstructor.cpp
index 6be1953fff..bfaaccd05f 100644
--- a/Libraries/LibJS/Runtime/ArrayConstructor.cpp
+++ b/Libraries/LibJS/Runtime/ArrayConstructor.cpp
@@ -34,6 +34,7 @@
namespace JS {
ArrayConstructor::ArrayConstructor()
+ : NativeFunction("Array")
{
put("prototype", interpreter().array_prototype());
put("length", Value(1));
diff --git a/Libraries/LibJS/Runtime/BooleanConstructor.cpp b/Libraries/LibJS/Runtime/BooleanConstructor.cpp
index c8254abd66..3f5d54a68a 100644
--- a/Libraries/LibJS/Runtime/BooleanConstructor.cpp
+++ b/Libraries/LibJS/Runtime/BooleanConstructor.cpp
@@ -33,6 +33,7 @@
namespace JS {
BooleanConstructor::BooleanConstructor()
+ : NativeFunction("Boolean")
{
put("prototype", Value(interpreter().boolean_prototype()));
put("length", Value(1));
diff --git a/Libraries/LibJS/Runtime/DateConstructor.cpp b/Libraries/LibJS/Runtime/DateConstructor.cpp
index 407c95d38d..9f825a6b96 100644
--- a/Libraries/LibJS/Runtime/DateConstructor.cpp
+++ b/Libraries/LibJS/Runtime/DateConstructor.cpp
@@ -34,6 +34,7 @@
namespace JS {
DateConstructor::DateConstructor()
+ : NativeFunction("Date")
{
put("prototype", interpreter().date_prototype());
put("length", Value(7));
diff --git a/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Libraries/LibJS/Runtime/ErrorConstructor.cpp
index b62018fe02..082d3d3944 100644
--- a/Libraries/LibJS/Runtime/ErrorConstructor.cpp
+++ b/Libraries/LibJS/Runtime/ErrorConstructor.cpp
@@ -31,6 +31,7 @@
namespace JS {
ErrorConstructor::ErrorConstructor()
+ : NativeFunction("Error")
{
put("prototype", interpreter().error_prototype());
put("length", Value(1));
diff --git a/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Libraries/LibJS/Runtime/FunctionConstructor.cpp
index 6a005f8324..fc93e3d13c 100644
--- a/Libraries/LibJS/Runtime/FunctionConstructor.cpp
+++ b/Libraries/LibJS/Runtime/FunctionConstructor.cpp
@@ -35,6 +35,7 @@
namespace JS {
FunctionConstructor::FunctionConstructor()
+ : NativeFunction("Function")
{
put("prototype", interpreter().function_prototype());
put("length", Value(1));
diff --git a/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Libraries/LibJS/Runtime/FunctionPrototype.cpp
index 33f36335af..62e6c60068 100644
--- a/Libraries/LibJS/Runtime/FunctionPrototype.cpp
+++ b/Libraries/LibJS/Runtime/FunctionPrototype.cpp
@@ -122,7 +122,11 @@ Value FunctionPrototype::to_string(Interpreter& interpreter)
// function_body = body.to_source();
function_body = " ???";
}
- auto function_source = String::format("function %s(%s) {\n%s\n}", function_name.characters(), function_parameters.characters(), function_body.characters());
+
+ auto function_source = String::format("function %s(%s) {\n%s\n}",
+ function_name.is_null() ? "" : function_name.characters(),
+ function_parameters.characters(),
+ function_body.characters());
return js_string(interpreter, function_source);
}
diff --git a/Libraries/LibJS/Runtime/NativeFunction.cpp b/Libraries/LibJS/Runtime/NativeFunction.cpp
index e50988105c..aadf7d8060 100644
--- a/Libraries/LibJS/Runtime/NativeFunction.cpp
+++ b/Libraries/LibJS/Runtime/NativeFunction.cpp
@@ -36,6 +36,11 @@ NativeFunction::NativeFunction(const FlyString& name, AK::Function<Value(Interpr
{
}
+NativeFunction::NativeFunction(const FlyString& name)
+ : m_name(name)
+{
+}
+
NativeFunction::~NativeFunction()
{
}
diff --git a/Libraries/LibJS/Runtime/NativeFunction.h b/Libraries/LibJS/Runtime/NativeFunction.h
index 8495cb7cb8..d79fb38b04 100644
--- a/Libraries/LibJS/Runtime/NativeFunction.h
+++ b/Libraries/LibJS/Runtime/NativeFunction.h
@@ -43,6 +43,7 @@ public:
virtual bool has_constructor() const { return false; }
protected:
+ NativeFunction(const FlyString& name);
NativeFunction() {}
private:
diff --git a/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Libraries/LibJS/Runtime/NumberConstructor.cpp
index 817a4858b0..4a5c9fc80c 100644
--- a/Libraries/LibJS/Runtime/NumberConstructor.cpp
+++ b/Libraries/LibJS/Runtime/NumberConstructor.cpp
@@ -37,6 +37,7 @@
namespace JS {
NumberConstructor::NumberConstructor()
+ : NativeFunction("Number")
{
put_native_function("isSafeInteger", is_safe_integer, 1);
diff --git a/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Libraries/LibJS/Runtime/ObjectConstructor.cpp
index ad00184707..21bd5c18b3 100644
--- a/Libraries/LibJS/Runtime/ObjectConstructor.cpp
+++ b/Libraries/LibJS/Runtime/ObjectConstructor.cpp
@@ -35,6 +35,7 @@
namespace JS {
ObjectConstructor::ObjectConstructor()
+ : NativeFunction("Object")
{
put("prototype", interpreter().object_prototype());
diff --git a/Libraries/LibJS/Runtime/StringConstructor.cpp b/Libraries/LibJS/Runtime/StringConstructor.cpp
index 5001e6ba8b..f28c89b307 100644
--- a/Libraries/LibJS/Runtime/StringConstructor.cpp
+++ b/Libraries/LibJS/Runtime/StringConstructor.cpp
@@ -33,6 +33,7 @@
namespace JS {
StringConstructor::StringConstructor()
+ : NativeFunction("String")
{
put("prototype", interpreter().string_prototype());
put("length", Value(1));
diff --git a/Libraries/LibJS/Tests/Function.prototype.toString.js b/Libraries/LibJS/Tests/Function.prototype.toString.js
index 0d52bc7940..231a49458d 100644
--- a/Libraries/LibJS/Tests/Function.prototype.toString.js
+++ b/Libraries/LibJS/Tests/Function.prototype.toString.js
@@ -10,8 +10,8 @@ try {
}
return bar + 42;
}).toString() === "function (foo, bar, baz) {\n ???\n}");
- assert(console.log.toString() === "function () {\n [NativeFunction]\n}");
- assert(Function.toString() === "function () {\n [FunctionConstructor]\n}");
+ assert(console.log.toString() === "function log() {\n [NativeFunction]\n}");
+ assert(Function.toString() === "function Function() {\n [FunctionConstructor]\n}");
console.log("PASS");
} catch (e) {
diff --git a/Libraries/LibJS/Tests/function-TypeError.js b/Libraries/LibJS/Tests/function-TypeError.js
index 2909c802e3..2d411c2221 100644
--- a/Libraries/LibJS/Tests/function-TypeError.js
+++ b/Libraries/LibJS/Tests/function-TypeError.js
@@ -41,7 +41,7 @@ try {
new isNaN();
} catch(e) {
assert(e.name === "TypeError");
- assert(e.message === "function () {\n [NativeFunction]\n} is not a constructor");
+ assert(e.message === "function isNaN() {\n [NativeFunction]\n} is not a constructor");
}
console.log("PASS");