[ES6] Add Reflect namespace and add Reflect.deleteProperty
https://bugs.webkit.org/show_bug.cgi?id=147287
Reviewed by Sam Weinig.
This patch just creates the namespace for ES6 Reflect APIs.
And add template files to implement the actual code.
Not to keep the JS generated properties C array empty,
we added one small method, Reflect.deleteProperty in this patch.
* CMakeLists.txt:
* DerivedSources.make:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* builtins/ReflectObject.js: Added.
(deleteProperty):
* runtime/CommonIdentifiers.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/ReflectObject.cpp: Added.
(JSC::ReflectObject::ReflectObject):
(JSC::ReflectObject::finishCreation):
(JSC::ReflectObject::getOwnPropertySlot):
* runtime/ReflectObject.h: Added.
(JSC::ReflectObject::create):
(JSC::ReflectObject::createStructure):
* tests/stress/reflect-delete-property.js: Added.
(shouldBe):
(shouldThrow):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@187401 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/builtins/ReflectObject.js b/Source/JavaScriptCore/builtins/ReflectObject.js
new file mode 100644
index 0000000..15013ac
--- /dev/null
+++ b/Source/JavaScriptCore/builtins/ReflectObject.js
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+function deleteProperty(target, propertyKey)
+{
+ // Intentionally keep the code the sloppy mode to suppress the TypeError
+ // raised by the delete operator under the strict mode.
+
+ if (!@isObject(target))
+ throw new @TypeError("Reflect.deleteProperty requires the first argument be a object");
+
+ return delete target[propertyKey];
+}
+