NullSetterFunction.cpp [plain text]
#include "config.h"
#include "NullSetterFunction.h"
#include "Error.h"
#include "JSCInlines.h"
#include "JSCJSValueInlines.h"
#include "StackVisitor.h"
namespace JSC {
const ClassInfo NullSetterFunction::s_info = { "Function", &Base::s_info, 0, CREATE_METHOD_TABLE(NullSetterFunction) };
class GetCallerStrictnessFunctor {
public:
GetCallerStrictnessFunctor()
: m_iterations(0)
, m_callerIsStrict(false)
{
}
StackVisitor::Status operator()(StackVisitor& visitor)
{
++m_iterations;
if (m_iterations < 2)
return StackVisitor::Continue;
CodeBlock* codeBlock = visitor->codeBlock();
m_callerIsStrict = codeBlock && codeBlock->isStrictMode();
return StackVisitor::Done;
}
bool callerIsStrict() const { return m_callerIsStrict; }
private:
int m_iterations;
bool m_callerIsStrict;
};
static bool callerIsStrict(ExecState* exec)
{
GetCallerStrictnessFunctor iter;
exec->iterate(iter);
return iter.callerIsStrict();
}
static EncodedJSValue JSC_HOST_CALL callReturnUndefined(ExecState* exec)
{
if (callerIsStrict(exec))
return JSValue::encode(throwTypeError(exec, ASCIILiteral("Setting a property that has only a getter")));
return JSValue::encode(jsUndefined());
}
CallType NullSetterFunction::getCallData(JSCell*, CallData& callData)
{
callData.native.function = callReturnUndefined;
return CallTypeHost;
}
ConstructType NullSetterFunction::getConstructData(JSCell*, ConstructData&)
{
return ConstructTypeNone;
}
}