summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/JSFunction.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
commit284837daa07b29d6a63a748544a90b1f5842ac5c (patch)
treeecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/JavaScriptCore/runtime/JSFunction.cpp
parent2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff)
downloadqtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSFunction.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/JSFunction.cpp60
1 files changed, 29 insertions, 31 deletions
diff --git a/Source/JavaScriptCore/runtime/JSFunction.cpp b/Source/JavaScriptCore/runtime/JSFunction.cpp
index 0a65deee2..e5cb8cf38 100644
--- a/Source/JavaScriptCore/runtime/JSFunction.cpp
+++ b/Source/JavaScriptCore/runtime/JSFunction.cpp
@@ -38,7 +38,6 @@
#include "ObjectPrototype.h"
#include "Parser.h"
#include "PropertyNameArray.h"
-#include "ScopeChainMark.h"
using namespace WTF;
using namespace Unicode;
@@ -59,7 +58,7 @@ bool JSFunction::isHostFunctionNonInline() const
return isHostFunction();
}
-JSFunction* JSFunction::create(ExecState* exec, JSGlobalObject* globalObject, int length, const UString& name, NativeFunction nativeFunction, Intrinsic intrinsic, NativeFunction nativeConstructor)
+JSFunction* JSFunction::create(ExecState* exec, JSGlobalObject* globalObject, int length, const String& name, NativeFunction nativeFunction, Intrinsic intrinsic, NativeFunction nativeConstructor)
{
NativeExecutable* executable;
#if !ENABLE(JIT)
@@ -81,38 +80,38 @@ JSFunction* JSFunction::create(ExecState* exec, JSGlobalObject* globalObject, in
JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
: Base(exec->globalData(), structure)
, m_executable()
- , m_scopeChain(exec->globalData(), this, globalObject->globalScopeChain())
+ , m_scope(exec->globalData(), this, globalObject)
{
}
-JSFunction::JSFunction(ExecState* exec, FunctionExecutable* executable, ScopeChainNode* scopeChainNode)
- : Base(exec->globalData(), scopeChainNode->globalObject->functionStructure())
+JSFunction::JSFunction(ExecState* exec, FunctionExecutable* executable, JSScope* scope)
+ : Base(exec->globalData(), scope->globalObject()->functionStructure())
, m_executable(exec->globalData(), this, executable)
- , m_scopeChain(exec->globalData(), this, scopeChainNode)
+ , m_scope(exec->globalData(), this, scope)
{
}
-void JSFunction::finishCreation(ExecState* exec, NativeExecutable* executable, int length, const UString& name)
+void JSFunction::finishCreation(ExecState* exec, NativeExecutable* executable, int length, const String& name)
{
Base::finishCreation(exec->globalData());
ASSERT(inherits(&s_info));
m_executable.set(exec->globalData(), this, executable);
- putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name), DontDelete | ReadOnly | DontEnum);
+ putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name), DontDelete | ReadOnly | DontEnum);
putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(length), DontDelete | ReadOnly | DontEnum);
}
-void JSFunction::finishCreation(ExecState* exec, FunctionExecutable* executable, ScopeChainNode* scopeChainNode)
+void JSFunction::finishCreation(ExecState* exec, FunctionExecutable* executable, JSScope* scope)
{
JSGlobalData& globalData = exec->globalData();
Base::finishCreation(globalData);
ASSERT(inherits(&s_info));
// Switching the structure here is only safe if we currently have the function structure!
- ASSERT(structure() == scopeChainNode->globalObject->functionStructure());
+ ASSERT(structure() == scope->globalObject()->functionStructure());
setStructureAndReallocateStorageIfNecessary(
globalData,
- scopeChainNode->globalObject->namedFunctionStructure());
- putDirectOffset(globalData, scopeChainNode->globalObject->functionNameOffset(), executable->nameValue());
+ scope->globalObject()->namedFunctionStructure());
+ putDirectOffset(globalData, scope->globalObject()->functionNameOffset(), executable->nameValue());
}
Structure* JSFunction::cacheInheritorID(ExecState* exec)
@@ -125,33 +124,33 @@ Structure* JSFunction::cacheInheritorID(ExecState* exec)
return m_cachedInheritorID.get();
}
-const UString& JSFunction::name(ExecState* exec)
+const String& JSFunction::name(ExecState* exec)
{
return asString(getDirect(exec->globalData(), exec->globalData().propertyNames->name))->tryGetValue();
}
-const UString JSFunction::displayName(ExecState* exec)
+const String JSFunction::displayName(ExecState* exec)
{
JSValue displayName = getDirect(exec->globalData(), exec->globalData().propertyNames->displayName);
if (displayName && isJSString(displayName))
return asString(displayName)->tryGetValue();
- return UString();
+ return String();
}
-const UString JSFunction::calculatedDisplayName(ExecState* exec)
+const String JSFunction::calculatedDisplayName(ExecState* exec)
{
- const UString explicitName = displayName(exec);
+ const String explicitName = displayName(exec);
if (!explicitName.isEmpty())
return explicitName;
- const UString actualName = name(exec);
+ const String actualName = name(exec);
if (!actualName.isEmpty() || isHostFunction())
return actualName;
- return jsExecutable()->inferredName().ustring();
+ return jsExecutable()->inferredName().string();
}
const SourceCode* JSFunction::sourceCode() const
@@ -169,9 +168,8 @@ void JSFunction::visitChildren(JSCell* cell, SlotVisitor& visitor)
ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
Base::visitChildren(thisObject, visitor);
- visitor.append(&thisObject->m_scopeChain);
- if (thisObject->m_executable)
- visitor.append(&thisObject->m_executable);
+ visitor.append(&thisObject->m_scope);
+ visitor.append(&thisObject->m_executable);
}
CallType JSFunction::getCallData(JSCell* cell, CallData& callData)
@@ -182,7 +180,7 @@ CallType JSFunction::getCallData(JSCell* cell, CallData& callData)
return CallTypeHost;
}
callData.js.functionExecutable = thisObject->jsExecutable();
- callData.js.scopeChain = thisObject->scope();
+ callData.js.scope = thisObject->scope();
return CallTypeJS;
}
@@ -205,7 +203,7 @@ JSValue JSFunction::callerGetter(ExecState* exec, JSValue slotBase, PropertyName
JSFunction* function = jsCast<JSFunction*>(caller);
if (function->isHostFunction() || !function->jsExecutable()->isStrictMode())
return caller;
- return throwTypeError(exec, "Function.caller used to retrieve strict caller");
+ return throwTypeError(exec, ASCIILiteral("Function.caller used to retrieve strict caller"));
}
JSValue JSFunction::lengthGetter(ExecState*, JSValue slotBase, PropertyName)
@@ -416,27 +414,27 @@ bool JSFunction::defineOwnProperty(JSObject* object, ExecState* exec, PropertyNa
if (descriptor.configurablePresent() && descriptor.configurable()) {
if (throwException)
- throwError(exec, createTypeError(exec, "Attempting to configurable attribute of unconfigurable property."));
+ throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
return false;
}
if (descriptor.enumerablePresent() && descriptor.enumerable()) {
if (throwException)
- throwError(exec, createTypeError(exec, "Attempting to change enumerable attribute of unconfigurable property."));
+ throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
return false;
}
if (descriptor.isAccessorDescriptor()) {
if (throwException)
- throwError(exec, createTypeError(exec, "Attempting to change access mechanism for an unconfigurable property."));
+ throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
return false;
}
if (descriptor.writablePresent() && descriptor.writable()) {
if (throwException)
- throwError(exec, createTypeError(exec, "Attempting to change writable attribute of unconfigurable property."));
+ throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
return false;
}
if (!valueCheck) {
if (throwException)
- throwError(exec, createTypeError(exec, "Attempting to change value of a readonly property."));
+ throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
return false;
}
return true;
@@ -451,12 +449,12 @@ ConstructType JSFunction::getConstructData(JSCell* cell, ConstructData& construc
return ConstructTypeHost;
}
constructData.js.functionExecutable = thisObject->jsExecutable();
- constructData.js.scopeChain = thisObject->scope();
+ constructData.js.scope = thisObject->scope();
return ConstructTypeJS;
}
-UString getCalculatedDisplayName(CallFrame* callFrame, JSObject* object)
+String getCalculatedDisplayName(CallFrame* callFrame, JSObject* object)
{
if (JSFunction* function = jsDynamicCast<JSFunction*>(object))
return function->calculatedDisplayName(callFrame);