diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp b/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp index d5e728c2c..288f05453 100644 --- a/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp +++ b/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2008, 2016 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 @@ -22,64 +22,74 @@ #include "NativeErrorConstructor.h" #include "ErrorInstance.h" +#include "Interpreter.h" #include "JSFunction.h" #include "JSString.h" #include "NativeErrorPrototype.h" -#include "Operations.h" +#include "JSCInlines.h" namespace JSC { STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(NativeErrorConstructor); -const ClassInfo NativeErrorConstructor::s_info = { "Function", &InternalFunction::s_info, 0, 0, CREATE_METHOD_TABLE(NativeErrorConstructor) }; +const ClassInfo NativeErrorConstructor::s_info = { "Function", &InternalFunction::s_info, 0, CREATE_METHOD_TABLE(NativeErrorConstructor) }; NativeErrorConstructor::NativeErrorConstructor(VM& vm, Structure* structure) : InternalFunction(vm, structure) { } +void NativeErrorConstructor::finishCreation(VM& vm, JSGlobalObject* globalObject, Structure* prototypeStructure, const String& name) +{ + Base::finishCreation(vm, name); + ASSERT(inherits(vm, info())); + + NativeErrorPrototype* prototype = NativeErrorPrototype::create(vm, prototypeStructure, name, this); + + putDirect(vm, vm.propertyNames->length, jsNumber(1), DontEnum | ReadOnly); + putDirect(vm, vm.propertyNames->prototype, prototype, DontDelete | ReadOnly | DontEnum); + m_errorStructure.set(vm, this, ErrorInstance::createStructure(vm, globalObject, prototype)); + ASSERT(m_errorStructure); + ASSERT(m_errorStructure->isObject()); +} + void NativeErrorConstructor::visitChildren(JSCell* cell, SlotVisitor& visitor) { NativeErrorConstructor* thisObject = jsCast<NativeErrorConstructor*>(cell); ASSERT_GC_OBJECT_INHERITS(thisObject, info()); - COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag); - ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren()); - - InternalFunction::visitChildren(thisObject, visitor); - visitor.append(&thisObject->m_errorStructure); + Base::visitChildren(thisObject, visitor); + visitor.append(thisObject->m_errorStructure); } EncodedJSValue JSC_HOST_CALL Interpreter::constructWithNativeErrorConstructor(ExecState* exec) { + VM& vm = exec->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); JSValue message = exec->argument(0); - Structure* errorStructure = static_cast<NativeErrorConstructor*>(exec->callee())->errorStructure(); + Structure* errorStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), jsCast<NativeErrorConstructor*>(exec->jsCallee())->errorStructure()); + RETURN_IF_EXCEPTION(scope, encodedJSValue()); ASSERT(errorStructure); - Vector<StackFrame> stackTrace; - exec->vm().interpreter->getStackTrace(stackTrace, std::numeric_limits<size_t>::max()); - stackTrace.remove(0); - return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, stackTrace)); + scope.release(); + return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, nullptr, TypeNothing, false)); } ConstructType NativeErrorConstructor::getConstructData(JSCell*, ConstructData& constructData) { constructData.native.function = Interpreter::constructWithNativeErrorConstructor; - return ConstructTypeHost; + return ConstructType::Host; } EncodedJSValue JSC_HOST_CALL Interpreter::callNativeErrorConstructor(ExecState* exec) { JSValue message = exec->argument(0); - Structure* errorStructure = static_cast<NativeErrorConstructor*>(exec->callee())->errorStructure(); - Vector<StackFrame> stackTrace; - exec->vm().interpreter->getStackTrace(stackTrace, std::numeric_limits<size_t>::max()); - stackTrace.remove(0); - return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, stackTrace)); + Structure* errorStructure = static_cast<NativeErrorConstructor*>(exec->jsCallee())->errorStructure(); + return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, nullptr, TypeNothing, false)); } CallType NativeErrorConstructor::getCallData(JSCell*, CallData& callData) { callData.native.function = Interpreter::callNativeErrorConstructor; - return CallTypeHost; + return CallType::Host; } } // namespace JSC |