diff options
| author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
|---|---|---|
| committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
| commit | 41386e9cb918eed93b3f13648cbef387e371e451 (patch) | |
| tree | a97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/builtins | |
| parent | e15dd966d523731101f70ccf768bba12435a0208 (diff) | |
| download | WebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz | |
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/builtins')
16 files changed, 0 insertions, 1913 deletions
diff --git a/Source/JavaScriptCore/builtins/Array.prototype.js b/Source/JavaScriptCore/builtins/Array.prototype.js deleted file mode 100644 index af46dd8fe..000000000 --- a/Source/JavaScriptCore/builtins/Array.prototype.js +++ /dev/null @@ -1,644 +0,0 @@ -/* - * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. - * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>. - * - * 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 reduce(callback /*, initialValue */) -{ - "use strict"; - if (this === null) - throw new @TypeError("Array.prototype.reduce requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.reduce requires that |this| not be undefined"); - - var array = @Object(this); - var length = @toLength(array.length); - - if (typeof callback !== "function") - throw new @TypeError("Array.prototype.reduce callback must be a function"); - - if (length === 0 && arguments.length < 2) - throw new @TypeError("reduce of empty array with no initial value"); - - var accumulator, k = 0; - if (arguments.length > 1) - accumulator = arguments[1]; - else { - while (k < length && !(k in array)) - k += 1; - if (k >= length) - throw new @TypeError("reduce of empty array with no initial value"); - accumulator = array[k++]; - } - - while (k < length) { - if (k in array) - accumulator = callback.@call(undefined, accumulator, array[k], k, array); - k += 1; - } - return accumulator; -} - -function reduceRight(callback /*, initialValue */) -{ - "use strict"; - if (this === null) - throw new @TypeError("Array.prototype.reduceRight requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.reduceRight requires that |this| not be undefined"); - - var array = @Object(this); - var length = @toLength(array.length); - - if (typeof callback !== "function") - throw new @TypeError("Array.prototype.reduceRight callback must be a function"); - - if (length === 0 && arguments.length < 2) - throw new @TypeError("reduceRight of empty array with no initial value"); - - var accumulator, k = length - 1; - if (arguments.length > 1) - accumulator = arguments[1]; - else { - while (k >= 0 && !(k in array)) - k -= 1; - if (k < 0) - throw new @TypeError("reduceRight of empty array with no initial value"); - accumulator = array[k--]; - } - - while (k >= 0) { - if (k in array) - accumulator = callback.@call(undefined, accumulator, array[k], k, array); - k -= 1; - } - return accumulator; -} - -function every(callback /*, thisArg */) { - "use strict"; - if (this === null) - throw new @TypeError("Array.prototype.every requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.every requires that |this| not be undefined"); - - var array = @Object(this); - var length = @toLength(array.length); - - if (typeof callback !== "function") - throw new @TypeError("Array.prototype.every callback must be a function"); - - var thisArg = arguments.length > 1 ? arguments[1] : undefined; - - for (var i = 0; i < length; i++) { - if (!(i in array)) - continue; - if (!callback.@call(thisArg, array[i], i, array)) - return false; - } - - return true; -} - -function forEach(callback /*, thisArg */) { - "use strict"; - if (this === null) - throw new @TypeError("Array.prototype.forEach requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.forEach requires that |this| not be undefined"); - - var array = @Object(this); - var length = @toLength(array.length); - - if (typeof callback !== "function") - throw new @TypeError("Array.prototype.forEach callback must be a function"); - - var thisArg = arguments.length > 1 ? arguments[1] : undefined; - - for (var i = 0; i < length; i++) { - if (i in array) - callback.@call(thisArg, array[i], i, array); - } -} - -function filter(callback /*, thisArg */) { - "use strict"; - if (this === null) - throw new @TypeError("Array.prototype.filter requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.filter requires that |this| not be undefined"); - - var array = @Object(this); - var length = @toLength(array.length); - - if (typeof callback !== "function") - throw new @TypeError("Array.prototype.filter callback must be a function"); - - var thisArg = arguments.length > 1 ? arguments[1] : undefined; - var result = []; - var nextIndex = 0; - for (var i = 0; i < length; i++) { - if (!(i in array)) - continue; - var current = array[i] - if (callback.@call(thisArg, current, i, array)) { - @putByValDirect(result, nextIndex, current); - ++nextIndex; - } - } - return result; -} - -function map(callback /*, thisArg */) { - "use strict"; - if (this === null) - throw new @TypeError("Array.prototype.map requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.map requires that |this| not be undefined"); - - var array = @Object(this); - var length = @toLength(array.length); - - if (typeof callback !== "function") - throw new @TypeError("Array.prototype.map callback must be a function"); - - var thisArg = arguments.length > 1 ? arguments[1] : undefined; - var result = []; - result.length = length; - var nextIndex = 0; - for (var i = 0; i < length; i++) { - if (!(i in array)) - continue; - var mappedValue = callback.@call(thisArg, array[i], i, array); - @putByValDirect(result, i, mappedValue); - } - return result; -} - -function some(callback /*, thisArg */) { - "use strict"; - if (this === null) - throw new @TypeError("Array.prototype.some requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.some requires that |this| not be undefined"); - - var array = @Object(this); - var length = @toLength(array.length); - - if (typeof callback !== "function") - throw new @TypeError("Array.prototype.some callback must be a function"); - - var thisArg = arguments.length > 1 ? arguments[1] : undefined; - for (var i = 0; i < length; i++) { - if (!(i in array)) - continue; - if (callback.@call(thisArg, array[i], i, array)) - return true; - } - return false; -} - -function fill(value /* [, start [, end]] */) -{ - "use strict"; - if (this === null) - throw new @TypeError("Array.prototype.fill requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.fill requires that |this| not be undefined"); - var O = @Object(this); - var len = @toLength(O.length); - var relativeStart = 0; - if (arguments.length > 1 && arguments[1] !== undefined) - relativeStart = arguments[1] | 0; - var k = 0; - if (relativeStart < 0) { - k = len + relativeStart; - if (k < 0) - k = 0; - } else { - k = relativeStart; - if (k > len) - k = len; - } - var relativeEnd = len; - if (arguments.length > 2 && arguments[2] !== undefined) - relativeEnd = arguments[2] | 0; - var final = 0; - if (relativeEnd < 0) { - final = len + relativeEnd; - if (final < 0) - final = 0; - } else { - final = relativeEnd; - if (final > len) - final = len; - } - for (; k < final; k++) - O[k] = value; - return O; -} - -function find(callback /*, thisArg */) { - "use strict"; - if (this === null) - throw new @TypeError("Array.prototype.find requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.find requires that |this| not be undefined"); - - var array = @Object(this); - var length = @toLength(array.length); - - if (typeof callback !== "function") - throw new @TypeError("Array.prototype.find callback must be a function"); - - var thisArg = arguments.length > 1 ? arguments[1] : undefined; - for (var i = 0; i < length; i++) { - var kValue = array[i]; - if (callback.@call(thisArg, kValue, i, array)) - return kValue; - } - return undefined; -} - -function findIndex(callback /*, thisArg */) { - "use strict"; - if (this === null) - throw new @TypeError("Array.prototype.findIndex requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.findIndex requires that |this| not be undefined"); - - var array = @Object(this); - var length = @toLength(array.length); - - if (typeof callback !== "function") - throw new @TypeError("Array.prototype.findIndex callback must be a function"); - - var thisArg = arguments.length > 1 ? arguments[1] : undefined; - for (var i = 0; i < length; i++) { - if (callback.@call(thisArg, array[i], i, array)) - return i; - } - return -1; -} - -function includes(searchElement /*, fromIndex*/) { - "use strict"; - if (this === null) - throw new @TypeError("Array.prototype.includes requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.includes requires that |this| not be undefined"); - - var array = @Object(this); - var length = @toLength(array.length); - - if (length === 0) - return false; - - var fromIndex = 0; - if (arguments.length > 1 && arguments[1] !== undefined) - fromIndex = arguments[1] | 0; - - var index; - if (fromIndex >= 0) - index = fromIndex; - else - index = length + fromIndex; - - if (index < 0) - index = 0; - - var currentElement; - for (; index < length; ++index) { - currentElement = array[index]; - // Use SameValueZero comparison, rather than just StrictEquals. - if (searchElement === currentElement || (searchElement !== searchElement && currentElement !== currentElement)) - return true; - } - return false; -} - -function sort(comparator) -{ - "use strict"; - - function min(a, b) - { - return a < b ? a : b; - } - - function stringComparator(a, b) - { - var aString = a.string; - var bString = b.string; - - var aLength = aString.length; - var bLength = bString.length; - var length = min(aLength, bLength); - - for (var i = 0; i < length; ++i) { - var aCharCode = aString.@charCodeAt(i); - var bCharCode = bString.@charCodeAt(i); - - if (aCharCode == bCharCode) - continue; - - return aCharCode - bCharCode; - } - - return aLength - bLength; - } - - // Move undefineds and holes to the end of a sparse array. Result is [values..., undefineds..., holes...]. - function compactSparse(array, dst, src, length) - { - var values = [ ]; - var seen = { }; - var valueCount = 0; - var undefinedCount = 0; - - // Clean up after the in-progress non-sparse compaction that failed. - for (var i = dst; i < src; ++i) - delete array[i]; - - for (var object = array; object; object = @Object.@getPrototypeOf(object)) { - var propertyNames = @Object.@getOwnPropertyNames(object); - for (var i = 0; i < propertyNames.length; ++i) { - var index = propertyNames[i]; - if (index < length) { // Exclude non-numeric properties and properties past length. - if (seen[index]) // Exclude duplicates. - continue; - seen[index] = 1; - - var value = array[index]; - delete array[index]; - - if (value === undefined) { - ++undefinedCount; - continue; - } - - array[valueCount++] = value; - } - } - } - - for (var i = valueCount; i < valueCount + undefinedCount; ++i) - array[i] = undefined; - - return valueCount; - } - - function compactSlow(array, length) - { - var holeCount = 0; - - for (var dst = 0, src = 0; src < length; ++src) { - if (!(src in array)) { - ++holeCount; - if (holeCount < 256) - continue; - return compactSparse(array, dst, src, length); - } - - var value = array[src]; - if (value === undefined) - continue; - - array[dst++] = value; - } - - var valueCount = dst; - var undefinedCount = length - valueCount - holeCount; - - for (var i = valueCount; i < valueCount + undefinedCount; ++i) - array[i] = undefined; - - for (var i = valueCount + undefinedCount; i < length; ++i) - delete array[i]; - - return valueCount; - } - - // Move undefineds and holes to the end of an array. Result is [values..., undefineds..., holes...]. - function compact(array, length) - { - for (var i = 0; i < array.length; ++i) { - if (array[i] === undefined) - return compactSlow(array, length); - } - - return length; - } - - function merge(dst, src, srcIndex, srcEnd, width, comparator) - { - var left = srcIndex; - var leftEnd = min(left + width, srcEnd); - var right = leftEnd; - var rightEnd = min(right + width, srcEnd); - - for (var dstIndex = left; dstIndex < rightEnd; ++dstIndex) { - if (right < rightEnd) { - if (left >= leftEnd || comparator(src[right], src[left]) < 0) { - dst[dstIndex] = src[right++]; - continue; - } - } - - dst[dstIndex] = src[left++]; - } - } - - function mergeSort(array, valueCount, comparator) - { - var buffer = [ ]; - buffer.length = valueCount; - - var dst = buffer; - var src = array; - for (var width = 1; width < valueCount; width *= 2) { - for (var srcIndex = 0; srcIndex < valueCount; srcIndex += 2 * width) - merge(dst, src, srcIndex, valueCount, width, comparator); - - var tmp = src; - src = dst; - dst = tmp; - } - - if (src != array) { - for(var i = 0; i < valueCount; i++) - array[i] = src[i]; - } - } - - function bucketSort(array, dst, bucket, depth) - { - if (bucket.length < 32 || depth > 32) { - mergeSort(bucket, bucket.length, stringComparator); - for (var i = 0; i < bucket.length; ++i) - array[dst++] = bucket[i].value; - return dst; - } - - var buckets = [ ]; - for (var i = 0; i < bucket.length; ++i) { - var entry = bucket[i]; - var string = entry.string; - if (string.length == depth) { - array[dst++] = entry.value; - continue; - } - - var c = string.@charCodeAt(depth); - if (!buckets[c]) - buckets[c] = [ ]; - buckets[c][buckets[c].length] = entry; - } - - for (var i = 0; i < buckets.length; ++i) { - if (!buckets[i]) - continue; - dst = bucketSort(array, dst, buckets[i], depth + 1); - } - - return dst; - } - - function comparatorSort(array, comparator) - { - var length = array.length >>> 0; - - // For compatibility with Firefox and Chrome, do nothing observable - // to the target array if it has 0 or 1 sortable properties. - if (length < 2) - return; - - var valueCount = compact(array, length); - mergeSort(array, valueCount, comparator); - } - - function stringSort(array) - { - var length = array.length >>> 0; - - // For compatibility with Firefox and Chrome, do nothing observable - // to the target array if it has 0 or 1 sortable properties. - if (length < 2) - return; - - var valueCount = compact(array, length); - - var strings = new @Array(valueCount); - for (var i = 0; i < valueCount; ++i) - strings[i] = { string: @toString(array[i]), value: array[i] }; - - bucketSort(array, 0, strings, 0); - } - - if (this === null) - throw new @TypeError("Array.prototype.sort requires that |this| not be null"); - - if (this === undefined) - throw new @TypeError("Array.prototype.sort requires that |this| not be undefined"); - - if (typeof this == "string") - throw new @TypeError("Attempted to assign to readonly property."); - - var array = @Object(this); - - if (typeof comparator == "function") - comparatorSort(array, comparator); - else - stringSort(array); - - return array; -} - -function copyWithin(target, start /*, end */) -{ - "use strict"; - - function maxWithPositives(a, b) - { - return (a < b) ? b : a; - } - - function minWithMaybeNegativeZeroAndPositive(maybeNegativeZero, positive) - { - return (maybeNegativeZero < positive) ? maybeNegativeZero : positive; - } - - if (this === null || this === undefined) - throw new @TypeError("Array.copyWithin requires that |this| not be null or undefined"); - var thisObject = @Object(this); - - var length = @toLength(thisObject.length); - - var relativeTarget = @toInteger(target); - var to = (relativeTarget < 0) ? maxWithPositives(length + relativeTarget, 0) : minWithMaybeNegativeZeroAndPositive(relativeTarget, length); - - var relativeStart = @toInteger(start); - var from = (relativeStart < 0) ? maxWithPositives(length + relativeStart, 0) : minWithMaybeNegativeZeroAndPositive(relativeStart, length); - - var relativeEnd; - if (arguments.length >= 3) { - var end = arguments[2]; - if (end === undefined) - relativeEnd = length; - else - relativeEnd = @toInteger(end); - } else - relativeEnd = length; - - var finalValue = (relativeEnd < 0) ? maxWithPositives(length + relativeEnd, 0) : minWithMaybeNegativeZeroAndPositive(relativeEnd, length); - - var count = minWithMaybeNegativeZeroAndPositive(finalValue - from, length - to); - - var direction = 1; - if (from < to && to < from + count) { - direction = -1; - from = from + count - 1; - to = to + count - 1; - } - - for (var i = 0; i < count; ++i, from += direction, to += direction) { - if (from in thisObject) - thisObject[to] = thisObject[from]; - else - delete thisObject[to]; - } - - return thisObject; -} diff --git a/Source/JavaScriptCore/builtins/ArrayConstructor.js b/Source/JavaScriptCore/builtins/ArrayConstructor.js deleted file mode 100644 index 5a551f739..000000000 --- a/Source/JavaScriptCore/builtins/ArrayConstructor.js +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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 of(/* items... */) -{ - "use strict"; - - var length = arguments.length; - // TODO: Need isConstructor(this) instead of typeof "function" check. - var array = typeof this === 'function' ? new this(length) : new @Array(length); - for (var k = 0; k < length; ++k) - @putByValDirect(array, k, arguments[k]); - array.length = length; - return array; -} - -function from(items /*, mapFn, thisArg */) { - "use strict"; - - var thisObj = this; - - var mapFn = arguments.length > 1 ? arguments[1] : undefined; - - var thisArg; - - if (mapFn !== undefined) { - if (typeof mapFn !== "function") - throw new @TypeError("Array.from requires that the second argument, when provided, be a function"); - - if (arguments.length > 2) - thisArg = arguments[2]; - } - - if (items == null) - throw new @TypeError("Array.from requires an array-like object - not null or undefined"); - - var iteratorMethod = items[@symbolIterator]; - if (iteratorMethod != null) { - if (typeof iteratorMethod !== "function") - throw new @TypeError("Array.from requires that the property of the first argument, items[Symbol.iterator], when exists, be a function"); - - // TODO: Need isConstructor(thisObj) instead of typeof "function" check. - var result = (typeof thisObj === "function") ? @Object(new thisObj()) : []; - - var k = 0; - var iterator = iteratorMethod.@call(items); - - // Since for-of loop once more looks up the @@iterator property of a given iterable, - // it could be observable if the user defines a getter for @@iterator. - // To avoid this situation, we define a wrapper object that @@iterator just returns a given iterator. - var wrapper = { - [@symbolIterator]() { - return iterator; - } - }; - - for (var value of wrapper) { - if (mapFn) - @putByValDirect(result, k, thisArg === undefined ? mapFn(value, k) : mapFn.@call(thisArg, value, k)); - else - @putByValDirect(result, k, value); - k += 1; - } - - result.length = k; - return result; - } - - var arrayLike = @Object(items); - var arrayLikeLength = @toLength(arrayLike.length); - - // TODO: Need isConstructor(thisObj) instead of typeof "function" check. - var result = (typeof thisObj === "function") ? @Object(new thisObj(arrayLikeLength)) : new @Array(arrayLikeLength); - - var k = 0; - while (k < arrayLikeLength) { - var value = arrayLike[k]; - if (mapFn) - @putByValDirect(result, k, thisArg === undefined ? mapFn(value, k) : mapFn.@call(thisArg, value, k)); - else - @putByValDirect(result, k, value); - k += 1; - } - - result.length = arrayLikeLength; - return result; -} diff --git a/Source/JavaScriptCore/builtins/ArrayIterator.prototype.js b/Source/JavaScriptCore/builtins/ArrayIterator.prototype.js deleted file mode 100644 index 82df528c9..000000000 --- a/Source/JavaScriptCore/builtins/ArrayIterator.prototype.js +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>. - * - * 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 next() { - "use strict"; - - if (this == null) - throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| not be null or undefined"); - - var itemKind = this.@arrayIterationKind; - if (itemKind === undefined) - throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| be an Array Iterator instance"); - - var done = true; - var value = undefined; - - var array = this.@iteratedObject; - if (array !== undefined) { - var index = this.@arrayIteratorNextIndex; - var length = array.length >>> 0; - if (index >= length) { - this.@iteratedObject = undefined; - } else { - this.@arrayIteratorNextIndex = index + 1; - done = false; - if (itemKind === @arrayIterationKindKey) { - value = index; - } else if (itemKind === @arrayIterationKindValue) { - value = array[index]; - } else { - value = [ index, array[index] ]; - } - } - } - - return {done, value}; -} diff --git a/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp b/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp deleted file mode 100644 index 9370e7e1f..000000000 --- a/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - - -#include "config.h" -#include "BuiltinExecutables.h" - -#include "BuiltinNames.h" -#include "Executable.h" -#include "JSCInlines.h" -#include "Parser.h" -#include <wtf/NeverDestroyed.h> - -namespace JSC { - -BuiltinExecutables::BuiltinExecutables(VM& vm) - : m_vm(vm) -#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(makeSource(StringImpl::createFromLiteral(s_##name, length))) - JSC_FOREACH_BUILTIN(INITIALIZE_BUILTIN_SOURCE_MEMBERS) -#undef EXPOSE_BUILTIN_STRINGS -{ -} - -UnlinkedFunctionExecutable* BuiltinExecutables::createDefaultConstructor(ConstructorKind constructorKind, const Identifier& name) -{ - static NeverDestroyed<const String> baseConstructorCode(ASCIILiteral("(function () { })")); - static NeverDestroyed<const String> derivedConstructorCode(ASCIILiteral("(function () { super(...arguments); })")); - - switch (constructorKind) { - case ConstructorKind::None: - break; - case ConstructorKind::Base: - return createExecutableInternal(makeSource(baseConstructorCode), name, constructorKind, ConstructAbility::CanConstruct); - case ConstructorKind::Derived: - return createExecutableInternal(makeSource(derivedConstructorCode), name, constructorKind, ConstructAbility::CanConstruct); - } - ASSERT_NOT_REACHED(); - return nullptr; -} - -UnlinkedFunctionExecutable* BuiltinExecutables::createExecutableInternal(const SourceCode& source, const Identifier& name, ConstructorKind constructorKind, ConstructAbility constructAbility) -{ - JSTextPosition positionBeforeLastNewline; - ParserError error; - bool isParsingDefaultConstructor = constructorKind != ConstructorKind::None; - JSParserBuiltinMode builtinMode = isParsingDefaultConstructor ? JSParserBuiltinMode::NotBuiltin : JSParserBuiltinMode::Builtin; - UnlinkedFunctionKind kind = isParsingDefaultConstructor ? UnlinkedNormalFunction : UnlinkedBuiltinFunction; - RefPtr<SourceProvider> sourceOverride = isParsingDefaultConstructor ? source.provider() : nullptr; - std::unique_ptr<ProgramNode> program = parse<ProgramNode>( - &m_vm, source, Identifier(), builtinMode, - JSParserStrictMode::NotStrict, SourceParseMode::ProgramMode, error, - &positionBeforeLastNewline, constructorKind); - - if (!program) { - dataLog("Fatal error compiling builtin function '", name.string(), "': ", error.message()); - CRASH(); - } - - StatementNode* exprStatement = program->singleStatement(); - RELEASE_ASSERT(exprStatement); - RELEASE_ASSERT(exprStatement->isExprStatement()); - ExpressionNode* funcExpr = static_cast<ExprStatementNode*>(exprStatement)->expr(); - RELEASE_ASSERT(funcExpr); - RELEASE_ASSERT(funcExpr->isFuncExprNode()); - FunctionMetadataNode* metadata = static_cast<FuncExprNode*>(funcExpr)->metadata(); - RELEASE_ASSERT(!program->hasCapturedVariables()); - - metadata->setEndPosition(positionBeforeLastNewline); - RELEASE_ASSERT(metadata); - RELEASE_ASSERT(metadata->ident().isNull()); - - // This function assumes an input string that would result in a single anonymous function expression. - metadata->setEndPosition(positionBeforeLastNewline); - RELEASE_ASSERT(metadata); - for (const auto& closedVariable : program->closedVariables()) { - if (closedVariable == m_vm.propertyNames->arguments.impl()) - continue; - - if (closedVariable == m_vm.propertyNames->undefinedKeyword.impl()) - continue; - } - metadata->overrideName(name); - VariableEnvironment dummyTDZVariables; - UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&m_vm, source, metadata, kind, constructAbility, dummyTDZVariables, WTF::move(sourceOverride)); - functionExecutable->m_nameValue.set(m_vm, functionExecutable, jsString(&m_vm, name.string())); - return functionExecutable; -} - -void BuiltinExecutables::finalize(Handle<Unknown>, void* context) -{ - static_cast<Weak<UnlinkedFunctionExecutable>*>(context)->clear(); -} - -#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, length) \ -UnlinkedFunctionExecutable* BuiltinExecutables::name##Executable() \ -{\ - if (!m_##name##Executable)\ - m_##name##Executable = Weak<UnlinkedFunctionExecutable>(createBuiltinExecutable(m_##name##Source, m_vm.propertyNames->builtinNames().functionName##PublicName(), s_##name##ConstructAbility), this, &m_##name##Executable);\ - return m_##name##Executable.get();\ -} -JSC_FOREACH_BUILTIN(DEFINE_BUILTIN_EXECUTABLES) -#undef EXPOSE_BUILTIN_SOURCES - -} diff --git a/Source/JavaScriptCore/builtins/BuiltinExecutables.h b/Source/JavaScriptCore/builtins/BuiltinExecutables.h deleted file mode 100644 index 4e432225f..000000000 --- a/Source/JavaScriptCore/builtins/BuiltinExecutables.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -#ifndef BuiltinExecutables_h -#define BuiltinExecutables_h - -#include "JSCBuiltins.h" -#include "ParserModes.h" -#include "SourceCode.h" -#include "Weak.h" -#include "WeakHandleOwner.h" - -namespace JSC { - -class UnlinkedFunctionExecutable; -class Identifier; -class VM; - -class BuiltinExecutables final: private WeakHandleOwner { - WTF_MAKE_FAST_ALLOCATED; -public: - explicit BuiltinExecutables(VM&); - -#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, length) \ -UnlinkedFunctionExecutable* name##Executable(); \ -const SourceCode& name##Source() { return m_##name##Source; } - - JSC_FOREACH_BUILTIN(EXPOSE_BUILTIN_EXECUTABLES) -#undef EXPOSE_BUILTIN_SOURCES - - UnlinkedFunctionExecutable* createDefaultConstructor(ConstructorKind, const Identifier& name); - -private: - void finalize(Handle<Unknown>, void* context) override; - - VM& m_vm; - - UnlinkedFunctionExecutable* createBuiltinExecutable(const SourceCode& code, const Identifier& name, ConstructAbility constructAbility) - { - return createExecutableInternal(code, name, ConstructorKind::None, constructAbility); - } - UnlinkedFunctionExecutable* createExecutableInternal(const SourceCode&, const Identifier&, ConstructorKind, ConstructAbility); - -#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, length)\ - SourceCode m_##name##Source; \ - Weak<UnlinkedFunctionExecutable> m_##name##Executable; - JSC_FOREACH_BUILTIN(DECLARE_BUILTIN_SOURCE_MEMBERS) -#undef DECLARE_BUILTIN_SOURCE_MEMBERS -}; - -} - -#endif diff --git a/Source/JavaScriptCore/builtins/BuiltinNames.h b/Source/JavaScriptCore/builtins/BuiltinNames.h deleted file mode 100644 index ce044479f..000000000 --- a/Source/JavaScriptCore/builtins/BuiltinNames.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -#ifndef BuiltinNames_h -#define BuiltinNames_h - -#include "CommonIdentifiers.h" -#include "JSCBuiltins.h" - -namespace JSC { - -#define INITIALISE_BUILTIN_NAMES(name) , m_##name(Identifier::fromString(vm, #name)), m_##name##PrivateName(Identifier::fromUid(PrivateName(PrivateName::Description, ASCIILiteral("PrivateSymbol." #name)))) -#define DECLARE_BUILTIN_NAMES(name) const Identifier m_##name; const Identifier m_##name##PrivateName; -#define DECLARE_BUILTIN_IDENTIFIER_ACCESSOR(name) \ - const Identifier& name##PublicName() const { return m_##name; } \ - const Identifier& name##PrivateName() const { return m_##name##PrivateName; } - -#define INITIALISE_BUILTIN_SYMBOLS(name) INITIALISE_BUILTIN_NAMES(name), m_##name##Symbol(Identifier::fromUid(PrivateName(PrivateName::Description, ASCIILiteral("Symbol." #name)))) -#define DECLARE_BUILTIN_SYMBOLS(name) DECLARE_BUILTIN_NAMES(name) const Identifier m_##name##Symbol; -#define DECLARE_BUILTIN_SYMBOL_ACCESSOR(name) \ - DECLARE_BUILTIN_IDENTIFIER_ACCESSOR(name) \ - const Identifier& name##Symbol() const { return m_##name##Symbol; } - -#define INITIALISE_PRIVATE_TO_PUBLIC_ENTRY(name) m_privateToPublicMap.add(m_##name##PrivateName.impl(), &m_##name); -#define INITIALISE_PUBLIC_TO_PRIVATE_ENTRY(name) m_publicToPrivateMap.add(m_##name.impl(), &m_##name##PrivateName); - -class BuiltinNames { - WTF_MAKE_NONCOPYABLE(BuiltinNames); WTF_MAKE_FAST_ALLOCATED; - -public: - BuiltinNames(VM* vm, CommonIdentifiers* commonIdentifiers) - : m_emptyIdentifier(commonIdentifiers->emptyIdentifier) - JSC_FOREACH_BUILTIN_FUNCTION_NAME(INITIALISE_BUILTIN_NAMES) - JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALISE_BUILTIN_NAMES) - JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(INITIALISE_BUILTIN_SYMBOLS) - { - JSC_FOREACH_BUILTIN_FUNCTION_NAME(INITIALISE_PRIVATE_TO_PUBLIC_ENTRY) - JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALISE_PRIVATE_TO_PUBLIC_ENTRY) - JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(INITIALISE_PRIVATE_TO_PUBLIC_ENTRY) - JSC_FOREACH_BUILTIN_FUNCTION_NAME(INITIALISE_PUBLIC_TO_PRIVATE_ENTRY) - JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALISE_PUBLIC_TO_PRIVATE_ENTRY) - JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(INITIALISE_PUBLIC_TO_PRIVATE_ENTRY) - } - - bool isPrivateName(SymbolImpl& uid) const; - bool isPrivateName(UniquedStringImpl& uid) const; - bool isPrivateName(const Identifier&) const; - const Identifier* getPrivateName(const Identifier&) const; - const Identifier& getPublicName(const Identifier&) const; - - JSC_FOREACH_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) - JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) - JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(DECLARE_BUILTIN_SYMBOL_ACCESSOR) - -private: - Identifier m_emptyIdentifier; - JSC_FOREACH_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES) - JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_NAMES) - JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(DECLARE_BUILTIN_SYMBOLS) - typedef HashMap<RefPtr<UniquedStringImpl>, const Identifier*, IdentifierRepHash> BuiltinNamesMap; - BuiltinNamesMap m_publicToPrivateMap; - BuiltinNamesMap m_privateToPublicMap; -}; - -#undef DECLARE_BUILTIN_NAMES -#undef INITIALISE_BUILTIN_NAMES -#undef DECLARE_BUILTIN_IDENTIFIER_ACCESSOR -#undef DECLARE_BUILTIN_SYMBOLS -#undef INITIALISE_BUILTIN_SYMBOLS -#undef DECLARE_BUILTIN_SYMBOL_ACCESSOR - -inline bool BuiltinNames::isPrivateName(SymbolImpl& uid) const -{ - return m_privateToPublicMap.contains(&uid); -} - -inline bool BuiltinNames::isPrivateName(UniquedStringImpl& uid) const -{ - if (!uid.isSymbol()) - return false; - return m_privateToPublicMap.contains(&uid); -} - -inline bool BuiltinNames::isPrivateName(const Identifier& ident) const -{ - if (ident.isNull()) - return false; - return isPrivateName(*ident.impl()); -} - -inline const Identifier* BuiltinNames::getPrivateName(const Identifier& ident) const -{ - auto iter = m_publicToPrivateMap.find(ident.impl()); - if (iter != m_publicToPrivateMap.end()) - return iter->value; - return 0; -} - -inline const Identifier& BuiltinNames::getPublicName(const Identifier& ident) const -{ - auto iter = m_privateToPublicMap.find(ident.impl()); - if (iter != m_privateToPublicMap.end()) - return *iter->value; - return m_emptyIdentifier; -} - - -} - -#endif diff --git a/Source/JavaScriptCore/builtins/Function.prototype.js b/Source/JavaScriptCore/builtins/Function.prototype.js deleted file mode 100644 index 2b7540b0c..000000000 --- a/Source/JavaScriptCore/builtins/Function.prototype.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2014 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 call(thisArgument) { - "use strict"; - return this.@call(...arguments); -} - -function apply(thisValue, argumentValues) { - "use strict"; - return this.@apply(thisValue, argumentValues); -} diff --git a/Source/JavaScriptCore/builtins/GlobalObject.js b/Source/JavaScriptCore/builtins/GlobalObject.js deleted file mode 100644 index 6adadefbd..000000000 --- a/Source/JavaScriptCore/builtins/GlobalObject.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>. - * - * 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 toInteger(target) -{ - "use strict"; - - var numberValue = @Number(target); - - // isNaN(numberValue) - if (numberValue !== numberValue) - return 0; - - if (numberValue === 0 || !@isFinite(numberValue)) - return numberValue; - - return (numberValue > 0 ? 1 : -1) * @floor(@abs(numberValue)); -} - -function toLength(target) -{ - "use strict"; - - var maxSafeInteger = 0x1FFFFFFFFFFFFF; - var length = @toInteger(target); - // originally Math.min(Math.max(length, 0), maxSafeInteger)); - return length > 0 ? (length < maxSafeInteger ? length : maxSafeInteger) : 0; -} - -function isObject(object) -{ - "use strict"; - - return (object !== null && typeof object === "object") || typeof object === "function"; -} diff --git a/Source/JavaScriptCore/builtins/Iterator.prototype.js b/Source/JavaScriptCore/builtins/Iterator.prototype.js deleted file mode 100644 index 1e9b98c84..000000000 --- a/Source/JavaScriptCore/builtins/Iterator.prototype.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>. - * - * 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 symbolIterator() -{ - 'use strict'; - return this; -} diff --git a/Source/JavaScriptCore/builtins/ObjectConstructor.js b/Source/JavaScriptCore/builtins/ObjectConstructor.js deleted file mode 100644 index 6b7ac1996..000000000 --- a/Source/JavaScriptCore/builtins/ObjectConstructor.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2015 Jordan Harband. 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 assign(target/*[*/, /*...*/sources/*] */) { - "use strict"; - - if (target == null) - throw new @TypeError("can't convert " + target + " to object"); - - var objTarget = @Object(target); - for (var s = 1, argumentsLength = arguments.length; s < argumentsLength; ++s) { - var nextSource = arguments[s]; - if (nextSource != null) { - var from = @Object(nextSource); - var keys = @ownEnumerablePropertyKeys(from); - for (var i = 0, keysLength = keys.length; i < keysLength; ++i) { - var nextKey = keys[i]; - objTarget[nextKey] = from[nextKey]; - } - } - } - return objTarget; -} diff --git a/Source/JavaScriptCore/builtins/Operations.Promise.js b/Source/JavaScriptCore/builtins/Operations.Promise.js deleted file mode 100644 index 80c57ab0b..000000000 --- a/Source/JavaScriptCore/builtins/Operations.Promise.js +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>. - * - * 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 isPromise(promise) -{ - "use strict"; - - return @isObject(promise) && !!promise.@promiseState; -} - -function newPromiseReaction(capability, handler) -{ - "use strict"; - - return { - @capabilities: capability, - @handler: handler - }; -} - -function newPromiseDeferred() -{ - "use strict"; - - return @newPromiseCapability(@Promise); -} - -function newPromiseCapability(constructor) -{ - "use strict"; - - // FIXME: Check isConstructor(constructor). - if (typeof constructor !== "function") - throw new @TypeError("promise capability requires a constructor function"); - - var promiseCapability = { - @promise: undefined, - @resolve: undefined, - @reject: undefined - }; - - function executor(resolve, reject) - { - if (promiseCapability.@resolve !== undefined) - throw new @TypeError("resolve function is already set"); - if (promiseCapability.@reject !== undefined) - throw new @TypeError("reject function is already set"); - - promiseCapability.@resolve = resolve; - promiseCapability.@reject = reject; - } - - var promise = new constructor(executor); - - if (typeof promiseCapability.@resolve !== "function") - throw new @TypeError("executor did not take a resolve function"); - - if (typeof promiseCapability.@reject !== "function") - throw new @TypeError("executor did not take a reject function"); - - promiseCapability.@promise = promise; - - return promiseCapability; -} - -function triggerPromiseReactions(reactions, argument) -{ - "use strict"; - - for (var index = 0, length = reactions.length; index < length; ++index) - @enqueueJob(@promiseReactionJob, [reactions[index], argument]); -} - -function rejectPromise(promise, reason) -{ - "use strict"; - - var reactions = promise.@promiseRejectReactions; - promise.@promiseResult = reason; - promise.@promiseFulfillReactions = undefined; - promise.@promiseRejectReactions = undefined; - promise.@promiseState = @promiseRejected; - @triggerPromiseReactions(reactions, reason); -} - -function fulfillPromise(promise, value) -{ - "use strict"; - - var reactions = promise.@promiseFulfillReactions; - promise.@promiseResult = value; - promise.@promiseFulfillReactions = undefined; - promise.@promiseRejectReactions = undefined; - promise.@promiseState = @promiseFulfilled; - @triggerPromiseReactions(reactions, value); -} - -function createResolvingFunctions(promise) -{ - "use strict"; - - var alreadyResolved = false; - - var resolve = function (resolution) { - if (alreadyResolved) - return undefined; - alreadyResolved = true; - - if (resolution === promise) - return @rejectPromise(promise, new @TypeError("Resolve a promise with itself")); - - if (!@isObject(resolution)) - return @fulfillPromise(promise, resolution); - - var then; - try { - then = resolution.then; - } catch (error) { - return @rejectPromise(promise, error); - } - - if (typeof then !== 'function') - return @fulfillPromise(promise, resolution); - - @enqueueJob(@promiseResolveThenableJob, [promise, resolution, then]); - - return undefined; - }; - - var reject = function (reason) { - if (alreadyResolved) - return undefined; - alreadyResolved = true; - - return @rejectPromise(promise, reason); - }; - - return { - @resolve: resolve, - @reject: reject - }; -} - -function promiseReactionJob(reaction, argument) -{ - "use strict"; - - var promiseCapability = reaction.@capabilities; - - var result; - try { - result = reaction.@handler.@call(undefined, argument); - } catch (error) { - return promiseCapability.@reject.@call(undefined, error); - } - - return promiseCapability.@resolve.@call(undefined, result); -} - -function promiseResolveThenableJob(promiseToResolve, thenable, then) -{ - "use strict"; - - var resolvingFunctions = @createResolvingFunctions(promiseToResolve); - - try { - return then.@call(thenable, resolvingFunctions.@resolve, resolvingFunctions.@reject); - } catch (error) { - return resolvingFunctions.@reject.@call(undefined, error); - } -} - -function initializePromise(executor) -{ - "use strict"; - - if (typeof executor !== 'function') - throw new @TypeError("Promise constructor takes a function argument"); - - this.@promiseState = @promisePending; - this.@promiseFulfillReactions = []; - this.@promiseRejectReactions = []; - - var resolvingFunctions = @createResolvingFunctions(this); - try { - executor(resolvingFunctions.@resolve, resolvingFunctions.@reject); - } catch (error) { - return resolvingFunctions.@reject.@call(undefined, error); - } - - return this; -} diff --git a/Source/JavaScriptCore/builtins/Promise.prototype.js b/Source/JavaScriptCore/builtins/Promise.prototype.js deleted file mode 100644 index 8563df0d9..000000000 --- a/Source/JavaScriptCore/builtins/Promise.prototype.js +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2014 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. AND ITS CONTRIBUTORS ``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 ITS 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 catch(onRejected) -{ - "use strict"; - - return this.then(undefined, onRejected); -} - -function then(onFulfilled, onRejected) -{ - "use strict"; - - if (!@isPromise(this)) - throw new @TypeError("|this| is not a object"); - - // FIXME: Fix this code when @@species well-known symbol is landed. - // https://bugs.webkit.org/show_bug.cgi?id=146624 - var constructor = this.constructor; - - var resultCapability = @newPromiseCapability(constructor); - - if (typeof onFulfilled !== "function") - onFulfilled = function (argument) { return argument; }; - - if (typeof onRejected !== "function") - onRejected = function (argument) { throw argument; }; - - var fulfillReaction = @newPromiseReaction(resultCapability, onFulfilled); - var rejectReaction = @newPromiseReaction(resultCapability, onRejected); - - var state = this.@promiseState; - - if (state === @promisePending) { - @putByValDirect(this.@promiseFulfillReactions, this.@promiseFulfillReactions.length, fulfillReaction) - @putByValDirect(this.@promiseRejectReactions, this.@promiseRejectReactions.length, rejectReaction) - } else if (state === @promiseFulfilled) - @enqueueJob(@promiseReactionJob, [fulfillReaction, this.@promiseResult]); - else if (state === @promiseRejected) - @enqueueJob(@promiseReactionJob, [rejectReaction, this.@promiseResult]); - - return resultCapability.@promise; -} diff --git a/Source/JavaScriptCore/builtins/PromiseConstructor.js b/Source/JavaScriptCore/builtins/PromiseConstructor.js deleted file mode 100644 index 1f83b47f7..000000000 --- a/Source/JavaScriptCore/builtins/PromiseConstructor.js +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>. - * - * 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 all(iterable) -{ - "use strict"; - - if (!@isObject(this)) - throw new TypeError("|this| is not a object"); - - // FIXME: Fix this code when @@species well-known symbol is landed. - // https://bugs.webkit.org/show_bug.cgi?id=146624 - var constructor = this; - - var promiseCapability = @newPromiseCapability(constructor); - - var values = []; - var index = 0; - var remainingElementsCount = 1; - - function newResolveElement(index) - { - var alreadyCalled = false; - return function (argument) - { - if (alreadyCalled) - return undefined; - alreadyCalled = true; - - @putByValDirect(values, index, argument); - - --remainingElementsCount; - if (remainingElementsCount === 0) - return promiseCapability.@resolve.@call(undefined, values); - - return undefined; - } - } - - try { - for (var value of iterable) { - @putByValDirect(values, index, undefined); - var nextPromise = constructor.resolve(value); - var resolveElement = newResolveElement(index); - ++remainingElementsCount; - nextPromise.then(resolveElement, promiseCapability.@reject); - ++index; - } - - --remainingElementsCount; - if (remainingElementsCount === 0) - promiseCapability.@resolve.@call(undefined, values); - } catch (error) { - promiseCapability.@reject.@call(undefined, error); - } - - return promiseCapability.@promise; -} - -function race(iterable) -{ - "use strict"; - - if (!@isObject(this)) - throw new TypeError("|this| is not a object"); - - // FIXME: Fix this code when @@species well-known symbol is landed. - // https://bugs.webkit.org/show_bug.cgi?id=146624 - var constructor = this; - - var promiseCapability = @newPromiseCapability(constructor); - - try { - for (var value of iterable) { - var nextPromise = constructor.resolve(value); - nextPromise.then(promiseCapability.@resolve, promiseCapability.@reject); - } - } catch (error) { - promiseCapability.@reject.@call(undefined, error); - } - - return promiseCapability.@promise; -} - -function reject(reason) -{ - "use strict"; - - if (!@isObject(this)) - throw new TypeError("|this| is not a object"); - - var promiseCapability = @newPromiseCapability(this); - - promiseCapability.@reject.@call(undefined, reason); - - return promiseCapability.@promise; -} - -function resolve(value) -{ - "use strict"; - - if (!@isObject(this)) - throw new TypeError("|this| is not a object"); - - if (@isPromise(value)) { - var valueConstructor = value.constructor; - if (valueConstructor === this) - return value; - } - - var promiseCapability = @newPromiseCapability(this); - - promiseCapability.@resolve.@call(undefined, value); - - return promiseCapability.@promise; -} diff --git a/Source/JavaScriptCore/builtins/ReflectObject.js b/Source/JavaScriptCore/builtins/ReflectObject.js deleted file mode 100644 index 69c982850..000000000 --- a/Source/JavaScriptCore/builtins/ReflectObject.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -// http://www.ecma-international.org/ecma-262/6.0/#sec-reflect.apply -function apply(target, thisArgument, argumentsList) -{ - "use strict"; - - if (typeof target !== "function") - throw new @TypeError("Reflect.apply requires the first argument be a function"); - - if (!@isObject(argumentsList)) - throw new @TypeError("Reflect.apply requires the third argument be an object"); - - return target.@apply(thisArgument, argumentsList); -} - -// http://www.ecma-international.org/ecma-262/6.0/#sec-reflect.deleteproperty -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 an object"); - - return delete target[propertyKey]; -} - -// http://www.ecma-international.org/ecma-262/6.0/#sec-reflect.has -function has(target, propertyKey) -{ - "use strict"; - - if (!@isObject(target)) - throw new @TypeError("Reflect.has requires the first argument be an object"); - - return propertyKey in target; -} diff --git a/Source/JavaScriptCore/builtins/StringConstructor.js b/Source/JavaScriptCore/builtins/StringConstructor.js deleted file mode 100644 index f8cd16b12..000000000 --- a/Source/JavaScriptCore/builtins/StringConstructor.js +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>. - * - * 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 raw(template) { - "use strict"; - - if (template === null || template === undefined) - throw new @TypeError("String.raw requires template not be null or undefined"); - var cookedSegments = @Object(template); - - var rawValue = cookedSegments.raw; - if (rawValue === null || rawValue === undefined) - throw new @TypeError("String.raw requires template.raw not be null or undefined"); - var rawSegments = @Object(rawValue); - - var numberOfSubstitutions = arguments.length - 1; - - var segmentCount = @toLength(rawSegments.length); - - if (segmentCount <= 0) - return ''; - - var stringElements = ''; - for (var i = 0; ; ++i) { - var segment = @toString(rawSegments[i]); - stringElements += segment; - - if ((i + 1) === segmentCount) - return stringElements; - - if (i < numberOfSubstitutions) { - var substitutionIndexInArguments = i + 1; - var next = @toString(arguments[substitutionIndexInArguments]); - stringElements += next; - } - } -} diff --git a/Source/JavaScriptCore/builtins/StringIterator.prototype.js b/Source/JavaScriptCore/builtins/StringIterator.prototype.js deleted file mode 100644 index 8810c7dc1..000000000 --- a/Source/JavaScriptCore/builtins/StringIterator.prototype.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>. - * - * 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 next() { - "use strict"; - - if (this == null) - throw new @TypeError("%StringIteratorPrototype%.next requires that |this| not be null or undefined"); - - var position = this.@stringIteratorNextIndex; - if (position === undefined) - throw new @TypeError("%StringIteratorPrototype%.next requires that |this| be a String Iterator instance"); - - var done = true; - var value = undefined; - - var string = this.@iteratedString; - if (string !== undefined) { - var length = string.length >>> 0; - if (position >= length) { - this.@iteratedString = undefined; - } else { - done = false; - - var first = string.@charCodeAt(position); - if (first < 0xD800 || first > 0xDBFF || position + 1 === length) - value = string[position]; - else { - var second = string.@charCodeAt(position + 1); - if (second < 0xDC00 || second > 0xDFFF) - value = string[position]; - else - value = string[position] + string[position + 1]; - } - - this.@stringIteratorNextIndex = position + value.length; - } - } - - return {done, value}; -} |
