summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/FunctionConstructor.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
commit41386e9cb918eed93b3f13648cbef387e371e451 (patch)
treea97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/runtime/FunctionConstructor.cpp
parente15dd966d523731101f70ccf768bba12435a0208 (diff)
downloadWebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/runtime/FunctionConstructor.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/FunctionConstructor.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/Source/JavaScriptCore/runtime/FunctionConstructor.cpp b/Source/JavaScriptCore/runtime/FunctionConstructor.cpp
index dbe42fa5f..53de63271 100644
--- a/Source/JavaScriptCore/runtime/FunctionConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/FunctionConstructor.cpp
@@ -29,7 +29,7 @@
#include "JSString.h"
#include "Lexer.h"
#include "Nodes.h"
-#include "JSCInlines.h"
+#include "Operations.h"
#include "Parser.h"
#include <wtf/text/StringBuilder.h>
@@ -37,7 +37,7 @@ namespace JSC {
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(FunctionConstructor);
-const ClassInfo FunctionConstructor::s_info = { "Function", &Base::s_info, 0, CREATE_METHOD_TABLE(FunctionConstructor) };
+const ClassInfo FunctionConstructor::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(FunctionConstructor) };
FunctionConstructor::FunctionConstructor(VM& vm, Structure* structure)
: InternalFunction(vm, structure)
@@ -86,37 +86,33 @@ JSObject* constructFunction(ExecState* exec, JSGlobalObject* globalObject, const
return constructFunctionSkippingEvalEnabledCheck(exec, globalObject, args, functionName, sourceURL, position);
}
-JSObject* constructFunctionSkippingEvalEnabledCheck(
- ExecState* exec, JSGlobalObject* globalObject, const ArgList& args,
- const Identifier& functionName, const String& sourceURL,
- const TextPosition& position, int overrideLineNumber)
+JSObject* constructFunctionSkippingEvalEnabledCheck(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args, const Identifier& functionName, const String& sourceURL, const TextPosition& position)
{
- // How we stringify functions is sometimes important for web compatibility.
- // See https://bugs.webkit.org/show_bug.cgi?id=24350.
+ // Functions need to have a space following the opening { due to for web compatibility
+ // see https://bugs.webkit.org/show_bug.cgi?id=24350
+ // We also need \n before the closing } to handle // comments at the end of the last line
String program;
if (args.isEmpty())
- program = makeString("{function ", functionName.string(), "() {\n\n}}");
+ program = ASCIILiteral("(function() {\n})");
else if (args.size() == 1)
- program = makeString("{function ", functionName.string(), "() {\n", args.at(0).toString(exec)->value(exec), "\n}}");
+ program = makeString("(function() {", args.at(0).toString(exec)->value(exec), "\n})");
else {
StringBuilder builder;
- builder.appendLiteral("{function ");
- builder.append(functionName.string());
- builder.append('(');
- builder.append(args.at(0).toString(exec)->view(exec));
+ builder.appendLiteral("(function(");
+ builder.append(args.at(0).toString(exec)->value(exec));
for (size_t i = 1; i < args.size() - 1; i++) {
- builder.appendLiteral(", ");
- builder.append(args.at(i).toString(exec)->view(exec));
+ builder.append(',');
+ builder.append(args.at(i).toString(exec)->value(exec));
}
- builder.appendLiteral(") {\n");
- builder.append(args.at(args.size() - 1).toString(exec)->view(exec));
- builder.appendLiteral("\n}}");
+ builder.appendLiteral(") {");
+ builder.append(args.at(args.size() - 1).toString(exec)->value(exec));
+ builder.appendLiteral("\n})");
program = builder.toString();
}
SourceCode source = makeSource(program, sourceURL, position);
- JSObject* exception = nullptr;
- FunctionExecutable* function = FunctionExecutable::fromGlobalCode(functionName, *exec, source, exception, overrideLineNumber);
+ JSObject* exception = 0;
+ FunctionExecutable* function = FunctionExecutable::fromGlobalCode(functionName, exec, exec->vmEntryGlobalObject()->debugger(), source, &exception);
if (!function) {
ASSERT(exception);
return exec->vm().throwException(exec, exception);