Commit 2ce2a7f8 authored by weinig@apple.com's avatar weinig@apple.com

JavaScriptCore:

2008-06-28  Sam Weinig  <sam@webkit.org>

        Rubber-stamped by Oliver Hunt.

        Splits FunctionConstructor out of FunctionPrototype.h/cpp
        Splits NumberConstructor and NumberPrototype out of NumberObject.h/cpp
        Rename object_object.h/cpp to ObjectPrototype.h/cpp and split out ObjectConstructor.

        * API/JSCallbackConstructor.cpp:
        * API/JSClassRef.cpp:
        * API/JSObjectRef.cpp:
        * DerivedSources.make:
        * GNUmakefile.am:
        * JavaScriptCore.pri:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * JavaScriptCoreSources.bkl:
        * VM/Machine.cpp:
        * kjs/AllInOneFile.cpp:
        * kjs/ArrayConstructor.cpp:
        * kjs/ArrayConstructor.h:
        * kjs/FunctionConstructor.cpp: Copied from JavaScriptCore/kjs/FunctionPrototype.cpp.
        * kjs/FunctionConstructor.h: Copied from JavaScriptCore/kjs/FunctionPrototype.h.
        * kjs/FunctionPrototype.cpp:
        * kjs/FunctionPrototype.h:
        * kjs/JSFunction.cpp:
        * kjs/JSGlobalObject.cpp:
        * kjs/JSImmediate.cpp:
        * kjs/MathObject.h:
        * kjs/NumberConstructor.cpp: Copied from JavaScriptCore/kjs/NumberObject.cpp.
        * kjs/NumberConstructor.h: Copied from JavaScriptCore/kjs/NumberObject.h.
        * kjs/NumberObject.cpp:
        * kjs/NumberObject.h:
        * kjs/NumberPrototype.cpp: Copied from JavaScriptCore/kjs/NumberObject.cpp.
        * kjs/NumberPrototype.h: Copied from JavaScriptCore/kjs/NumberObject.h.
        * kjs/ObjectConstructor.cpp: Copied from JavaScriptCore/kjs/object_object.cpp.
        * kjs/ObjectConstructor.h: Copied from JavaScriptCore/kjs/object_object.h.
        * kjs/ObjectPrototype.cpp: Copied from JavaScriptCore/kjs/object_object.cpp.
        * kjs/ObjectPrototype.h: Copied from JavaScriptCore/kjs/object_object.h.
        * kjs/RegExpObject.h:
        * kjs/Shell.cpp:
        * kjs/error_object.h:
        * kjs/internal.cpp:
        * kjs/nodes.cpp:
        * kjs/object_object.cpp: Removed.
        * kjs/object_object.h: Removed.
        * kjs/string_object.h:

WebCore:

2008-06-28  Sam Weinig  <sam@webkit.org>

        Rubber-stamped by Oliver Hunt.

        Update includes after remaming object_object.h to ObjectPrototype.h and
        splitting FunctionConstructor out of FunctionPrototype.h

        * ForwardingHeaders/kjs/FunctionConstructor.h: Added.
        * ForwardingHeaders/kjs/ObjectPrototype.h: Copied from WebCore/ForwardingHeaders/kjs/object_object.h.
        * ForwardingHeaders/kjs/object_object.h: Removed.
        * bindings/js/JSEventListener.cpp:
        * bindings/scripts/CodeGeneratorJS.pm:
        * bridge/qt/qt_instance.cpp:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34854 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ef1d58db
......@@ -29,7 +29,7 @@
#include "APICast.h"
#include <kjs/JSGlobalObject.h>
#include <kjs/object_object.h>
#include <kjs/ObjectPrototype.h>
#include <wtf/Vector.h>
namespace KJS {
......
......@@ -30,10 +30,10 @@
#include "APICast.h"
#include "JSCallbackObject.h"
#include "JSObjectRef.h"
#include <kjs/InitializeThreading.h>
#include <kjs/JSGlobalObject.h>
#include <kjs/ObjectPrototype.h>
#include <kjs/identifier.h>
#include <kjs/InitializeThreading.h>
#include <kjs/object_object.h>
using namespace KJS;
......
......@@ -28,19 +28,19 @@
#include "JSObjectRef.h"
#include "APICast.h"
#include "FunctionConstructor.h"
#include "JSCallbackConstructor.h"
#include "JSCallbackFunction.h"
#include "JSCallbackObject.h"
#include "JSClassRef.h"
#include "JSFunction.h"
#include "JSGlobalObject.h"
#include "JSObject.h"
#include "JSString.h"
#include "JSValueRef.h"
#include "ObjectPrototype.h"
#include "PropertyNameArray.h"
#include "JSFunction.h"
#include "FunctionPrototype.h"
#include "identifier.h"
#include "JSString.h"
#include "JSObject.h"
#include "object_object.h"
#include <wtf/Platform.h>
using namespace KJS;
......
2008-06-28 Sam Weinig <sam@webkit.org>
Rubber-stamped by Oliver Hunt.
Splits FunctionConstructor out of FunctionPrototype.h/cpp
Splits NumberConstructor and NumberPrototype out of NumberObject.h/cpp
Rename object_object.h/cpp to ObjectPrototype.h/cpp and split out ObjectConstructor.
* API/JSCallbackConstructor.cpp:
* API/JSClassRef.cpp:
* API/JSObjectRef.cpp:
* DerivedSources.make:
* GNUmakefile.am:
* JavaScriptCore.pri:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* JavaScriptCoreSources.bkl:
* VM/Machine.cpp:
* kjs/AllInOneFile.cpp:
* kjs/ArrayConstructor.cpp:
* kjs/ArrayConstructor.h:
* kjs/FunctionConstructor.cpp: Copied from JavaScriptCore/kjs/FunctionPrototype.cpp.
* kjs/FunctionConstructor.h: Copied from JavaScriptCore/kjs/FunctionPrototype.h.
* kjs/FunctionPrototype.cpp:
* kjs/FunctionPrototype.h:
* kjs/JSFunction.cpp:
* kjs/JSGlobalObject.cpp:
* kjs/JSImmediate.cpp:
* kjs/MathObject.h:
* kjs/NumberConstructor.cpp: Copied from JavaScriptCore/kjs/NumberObject.cpp.
* kjs/NumberConstructor.h: Copied from JavaScriptCore/kjs/NumberObject.h.
* kjs/NumberObject.cpp:
* kjs/NumberObject.h:
* kjs/NumberPrototype.cpp: Copied from JavaScriptCore/kjs/NumberObject.cpp.
* kjs/NumberPrototype.h: Copied from JavaScriptCore/kjs/NumberObject.h.
* kjs/ObjectConstructor.cpp: Copied from JavaScriptCore/kjs/object_object.cpp.
* kjs/ObjectConstructor.h: Copied from JavaScriptCore/kjs/object_object.h.
* kjs/ObjectPrototype.cpp: Copied from JavaScriptCore/kjs/object_object.cpp.
* kjs/ObjectPrototype.h: Copied from JavaScriptCore/kjs/object_object.h.
* kjs/RegExpObject.h:
* kjs/Shell.cpp:
* kjs/error_object.h:
* kjs/internal.cpp:
* kjs/nodes.cpp:
* kjs/object_object.cpp: Removed.
* kjs/object_object.h: Removed.
* kjs/string_object.h:
2008-06-28 Darin Adler <darin@apple.com>
Reviewed by Oliver.
......
......@@ -39,7 +39,7 @@ all : \
grammar.cpp \
lexer.lut.h \
MathObject.lut.h \
NumberObject.lut.h \
NumberConstructor.lut.h \
RegExpObject.lut.h \
string_object.lut.h \
$(JavaScriptCore)/docs/bytecode.html \
......
......@@ -21,7 +21,7 @@ javascriptcore_built_nosources += \
JavaScriptCore/kjs/ArrayPrototype.lut.h \
JavaScriptCore/kjs/date_object.lut.h \
JavaScriptCore/kjs/MathObject.lut.h \
JavaScriptCore/kjs/NumberObject.lut.h \
JavaScriptCore/kjs/NumberConstructor.lut.h \
JavaScriptCore/kjs/RegExpObject.lut.h \
JavaScriptCore/kjs/string_object.lut.h \
JavaScriptCore/pcre/chartables.c \
......@@ -96,6 +96,7 @@ javascriptcore_sources += \
JavaScriptCore/kjs/dtoa.cpp \
JavaScriptCore/kjs/error_object.cpp \
JavaScriptCore/kjs/JSFunction.cpp \
JavaScriptCore/kjs/FunctionConstructor.cpp \
JavaScriptCore/kjs/FunctionPrototype.cpp \
JavaScriptCore/kjs/identifier.cpp \
JavaScriptCore/kjs/internal.cpp \
......@@ -106,10 +107,13 @@ javascriptcore_sources += \
JavaScriptCore/kjs/MathObject.cpp \
JavaScriptCore/kjs/nodes.cpp \
JavaScriptCore/kjs/nodes2string.cpp \
JavaScriptCore/kjs/NumberConstructor.cpp \
JavaScriptCore/kjs/NumberObject.cpp \
JavaScriptCore/kjs/NumberPrototype.cpp \
JavaScriptCore/kjs/JSObject.cpp \
JavaScriptCore/kjs/JSGlobalObject.cpp \
JavaScriptCore/kjs/object_object.cpp \
JavaScriptCore/kjs/ObjectConstructor.cpp \
JavaScriptCore/kjs/ObjectPrototype.cpp \
JavaScriptCore/kjs/operations.cpp \
JavaScriptCore/kjs/PropertyMap.cpp \
JavaScriptCore/kjs/PropertySlot.cpp \
......@@ -208,7 +212,7 @@ CLEANFILES += \
JavaScriptCore/kjs/ArrayPrototype.lut.h \
JavaScriptCore/kjs/date_object.lut.h \
JavaScriptCore/kjs/MathObject.lut.h \
JavaScriptCore/kjs/NumberObject.lut.h \
JavaScriptCore/kjs/NumberConstructor.lut.h \
JavaScriptCore/kjs/RegExpObject.lut.h \
JavaScriptCore/kjs/string_object.lut.h \
JavaScriptCore/pcre/chartables.c \
......
......@@ -15,7 +15,7 @@ include(pcre/pcre.pri)
LUT_FILES += \
kjs/date_object.cpp \
kjs/NumberObject.cpp \
kjs/NumberConstructor.cpp \
kjs/string_object.cpp \
kjs/ArrayPrototype.cpp \
kjs/MathObject.cpp \
......@@ -80,6 +80,7 @@ SOURCES += \
kjs/dtoa.cpp \
kjs/error_object.cpp \
kjs/ExecState.cpp \
kjs/FunctionConstructor.cpp \
kjs/FunctionPrototype.cpp \
kjs/identifier.cpp \
kjs/internal.cpp \
......@@ -93,9 +94,12 @@ SOURCES += \
kjs/MathObject.cpp \
kjs/nodes.cpp \
kjs/nodes2string.cpp \
kjs/NumberConstructor.cpp \
kjs/NumberObject.cpp \
kjs/NumberPrototype.cpp \
kjs/JSObject.cpp \
kjs/object_object.cpp \
kjs/ObjectConstructor.cpp \
kjs/ObjectPrototype.cpp \
kjs/operations.cpp \
kjs/Parser.cpp \
kjs/PropertyMap.cpp \
......
......@@ -380,6 +380,14 @@
RelativePath="..\..\kjs\ExecState.h"
>
</File>
<File
RelativePath="..\..\kjs\FunctionConstructor.cpp"
>
</File>
<File
RelativePath="..\..\kjs\FunctionConstructor.h"
>
</File>
<File
RelativePath="..\..\kjs\FunctionPrototype.cpp"
>
......@@ -552,6 +560,14 @@
RelativePath="..\..\kjs\NodeInfo.h"
>
</File>
<File
RelativePath="..\..\kjs\NumberConstructor.cpp"
>
</File>
<File
RelativePath="..\..\kjs\NumberConstructor.h"
>
</File>
<File
RelativePath="..\..\kjs\NumberObject.cpp"
>
......@@ -561,11 +577,27 @@
>
</File>
<File
RelativePath="..\..\kjs\object_object.cpp"
RelativePath="..\..\kjs\NumberPrototype.cpp"
>
</File>
<File
RelativePath="..\..\kjs\NumberPrototype.h"
>
</File>
<File
RelativePath="..\..\kjs\ObjectConstructor.cpp"
>
</File>
<File
RelativePath="..\..\kjs\ObjectConstructor.h"
>
</File>
<File
RelativePath="..\..\kjs\ObjectPrototype.cpp"
>
</File>
<File
RelativePath="..\..\kjs\object_object.h"
RelativePath="..\..\kjs\ObjectPrototype.h"
>
</File>
<File
......@@ -725,7 +757,7 @@
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\NumberObject.lut.h"
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\NumberConstructor.lut.h"
>
</File>
<File
......
......@@ -59,6 +59,7 @@ Source files for JSCore.
kjs/error_object.cpp
kjs/ExecState.cpp
kjs/JSFunction.cpp
kjs/FunctionConstructor.cpp
kjs/FunctionPrototype.cpp
kjs/identifier.cpp
kjs/InitializeThreading.cpp
......@@ -78,9 +79,12 @@ Source files for JSCore.
kjs/MathObject.cpp
kjs/nodes.cpp
kjs/nodes2string.cpp
kjs/NumberConstructor.cpp
kjs/NumberObject.cpp
kjs/NumberPrototype.cpp
kjs/JSObject.cpp
kjs/object_object.cpp
kjs/ObjectConstructor.cpp
kjs/ObjectPrototype.cpp
kjs/operations.cpp
kjs/Parser.cpp
kjs/PropertyMap.cpp
......
......@@ -40,12 +40,12 @@
#include "JSLock.h"
#include "JSPropertyNameIterator.h"
#include "JSString.h"
#include "ObjectPrototype.h"
#include "Parser.h"
#include "Profiler.h"
#include "RegExpObject.h"
#include "Register.h"
#include "debugger.h"
#include "object_object.h"
#include "operations.h"
#include <stdio.h>
......
......@@ -43,6 +43,7 @@
#include "DateMath.cpp"
#include "dtoa.cpp"
#include "error_object.cpp"
#include "FunctionConstructor.cpp"
#include "FunctionPrototype.cpp"
#include "grammar.cpp"
#include "identifier.cpp"
......@@ -57,10 +58,13 @@
#include "MathObject.cpp"
#include "nodes.cpp"
#include "nodes2string.cpp"
#include "NumberConstructor.cpp"
#include "NumberObject.cpp"
#include "NumberPrototype.cpp"
#include "JSObject.cpp"
#include "JSGlobalObject.cpp"
#include "object_object.cpp"
#include "ObjectConstructor.cpp"
#include "ObjectPrototype.cpp"
#include "operations.cpp"
#include "Parser.cpp"
#include "PropertyMap.cpp"
......@@ -72,6 +76,7 @@
#include "string_object.cpp"
#include "ustring.cpp"
#include "JSValue.cpp"
#include "JSVariableObject.cpp"
#include "wtf/FastMalloc.cpp"
#include "wtf/TCSystemAlloc.cpp"
#include "VM/CodeGenerator.cpp"
......
......@@ -25,6 +25,7 @@
#include "ArrayConstructor.h"
#include "ArrayPrototype.h"
#include "FunctionPrototype.h"
#include "JSArray.h"
#include "error_object.h"
#include "lookup.h"
......
......@@ -21,11 +21,12 @@
#ifndef ArrayConstructor_h
#define ArrayConstructor_h
#include "FunctionPrototype.h"
#include "JSFunction.h"
namespace KJS {
class ArrayPrototype;
class FunctionPrototype;
class ArrayConstructor : public InternalFunction {
public:
......
/*
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "config.h"
#include "FunctionConstructor.h"
#include "FunctionPrototype.h"
#include "JSFunction.h"
#include "JSGlobalObject.h"
#include "JSString.h"
#include "Parser.h"
#include "debugger.h"
#include "lexer.h"
#include "nodes.h"
namespace KJS {
FunctionConstructor::FunctionConstructor(ExecState* exec, FunctionPrototype* functionPrototype)
: InternalFunction(functionPrototype, Identifier(exec, functionPrototype->classInfo()->className))
{
putDirect(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);
// Number of arguments for constructor
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum);
}
static JSObject* constructWithFunctionConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
return constructFunction(exec, args);
}
ConstructType FunctionConstructor::getConstructData(ConstructData& constructData)
{
constructData.native.function = constructWithFunctionConstructor;
return ConstructTypeNative;
}
static JSValue* callFunctionConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return constructFunction(exec, args);
}
// ECMA 15.3.1 The Function Constructor Called as a Function
CallType FunctionConstructor::getCallData(CallData& callData)
{
callData.native.function = callFunctionConstructor;
return CallTypeNative;
}
// ECMA 15.3.2 The Function Constructor
JSObject* constructFunction(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber)
{
UString p("");
UString body;
int argsSize = args.size();
if (argsSize == 0)
body = "";
else if (argsSize == 1)
body = args[0]->toString(exec);
else {
p = args[0]->toString(exec);
for (int k = 1; k < argsSize - 1; k++)
p += "," + args[k]->toString(exec);
body = args[argsSize - 1]->toString(exec);
}
// parse the source code
int sourceId;
int errLine;
UString errMsg;
RefPtr<SourceProvider> source = UStringSourceProvider::create(body);
RefPtr<FunctionBodyNode> functionBody = exec->parser()->parse<FunctionBodyNode>(exec, sourceURL, lineNumber, source, &sourceId, &errLine, &errMsg);
// No program node == syntax error - throw a syntax error
if (!functionBody)
// We can't return a Completion(Throw) here, so just set the exception
// and return it
return throwError(exec, SyntaxError, errMsg, errLine, sourceId, sourceURL);
functionBody->setSource(SourceRange(source, 0, source->length()));
ScopeChain scopeChain(exec->lexicalGlobalObject(), exec->globalThisValue());
JSFunction* function = new (exec) JSFunction(exec, functionName, functionBody.get(), scopeChain.node());
// parse parameter list. throw syntax error on illegal identifiers
int len = p.size();
const UChar* c = p.data();
int i = 0, params = 0;
UString param;
while (i < len) {
while (*c == ' ' && i < len)
c++, i++;
if (Lexer::isIdentStart(c[0])) { // else error
param = UString(c, 1);
c++, i++;
while (i < len && (Lexer::isIdentPart(c[0]))) {
param.append(*c);
c++, i++;
}
while (i < len && *c == ' ')
c++, i++;
if (i == len) {
functionBody->parameters().append(Identifier(exec, param));
params++;
break;
} else if (*c == ',') {
functionBody->parameters().append(Identifier(exec, param));
params++;
c++, i++;
continue;
} // else error
}
return throwError(exec, SyntaxError, "Syntax error in parameter list");
}
JSObject* prototype = constructEmptyObject(exec);
prototype->putDirect(exec->propertyNames().constructor, function, DontEnum);
function->putDirect(exec->propertyNames().prototype, prototype, DontDelete);
return function;
}
// ECMA 15.3.2 The Function Constructor
JSObject* constructFunction(ExecState* exec, const ArgList& args)
{
return constructFunction(exec, args, Identifier(exec, "anonymous"), UString(), 1);
}
} // namespace KJS
// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef FunctionConstructor_h
#define FunctionConstructor_h
#include "JSFunction.h"
namespace KJS {
class FunctionPrototype;
/**
* @internal
*
* The initial value of the the global variable's "Function" property
*/
class FunctionConstructor : public InternalFunction {
public:
FunctionConstructor(ExecState*, FunctionPrototype*);
private:
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallData(CallData&);
};
JSObject* constructFunction(ExecState*, const ArgList&, const Identifier& functionName, const UString& sourceURL, int lineNumber);
JSObject* constructFunction(ExecState*, const ArgList&);
} // namespace KJS
#endif // FunctionConstructor_h
......@@ -21,23 +21,10 @@
#include "config.h"
#include "FunctionPrototype.h"
#include "JSGlobalObject.h"
#include "Parser.h"
#include "debugger.h"
#include "JSArray.h"
#include "JSFunction.h"
#include "JSString.h"
#include "lexer.h"
#include "nodes.h"
#include "JSObject.h"
#include <stdio.h>
#include <string.h>
#include <wtf/Assertions.h>
namespace KJS {
// ------------------------------ FunctionPrototype -------------------------
static JSValue* functionProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* functionProtoFuncApply(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* functionProtoFuncCall(ExecState*, JSObject*, JSValue*, const ArgList&);
......@@ -133,116 +120,4 @@ JSValue* functionProtoFuncCall(ExecState* exec, JSObject*, JSValue* thisValue, c
return call(exec, thisValue, callType, callData, callThis, argsTail);
}
// ------------------------------ FunctionConstructor ----------------------------
FunctionConstructor::FunctionConstructor(ExecState* exec, FunctionPrototype* functionPrototype)
: InternalFunction(functionPrototype, Identifier(exec, functionPrototype->classInfo()->className))
{
putDirect(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);
// Number of arguments for constructor
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum);
}
static JSObject* constructWithFunctionConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
return constructFunction(exec, args);
}
ConstructType FunctionConstructor::getConstructData(ConstructData& constructData)
{
constructData.native.function = constructWithFunctionConstructor;
return ConstructTypeNative;
}
static JSValue* callFunctionConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return constructFunction(exec, args);
}
// ECMA 15.3.1 The Function Constructor Called as a Function
CallType FunctionConstructor::getCallData(CallData& callData)
{
callData.native.function = callFunctionConstructor;
return CallTypeNative;
}
// ECMA 15.3.2 The Function Constructor
JSObject* constructFunction(ExecState* exec, const ArgList& args, const Identifier& functionName, const UString& sourceURL, int lineNumber)
{
UString p("");
UString body;
int argsSize = args.size();
if (argsSize == 0)
body = "";
else if (argsSize == 1)
body = args[0]->toString(exec);
else {
p = args[0]->toString(exec);
for (int k = 1; k < argsSize - 1; k++)
p += "," + args[k]->toString(exec);
body = args[argsSize - 1]->toString(exec);
}
// parse the source code
int sourceId;
int errLine;
UString errMsg;
RefPtr<SourceProvider> source = UStringSourceProvider::create(body);
RefPtr<FunctionBodyNode> functionBody = exec->parser()->parse<FunctionBodyNode>(exec, sourceURL, lineNumber, source, &sourceId, &errLine, &errMsg);
// No program node == syntax error - throw a syntax error
if (!functionBody)
// We can't return a Completion(Throw) here, so just set the exception
// and return it
return throwError(exec, SyntaxError, errMsg, errLine, sourceId, sourceURL);