Changeset 254418 in webkit


Ignore:
Timestamp:
Jan 12, 2020 5:18:45 PM (4 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Consistently use "var" in builtin JS
https://bugs.webkit.org/show_bug.cgi?id=206157

Reviewed by Mark Lam.

let / const requires additional bytecode to make it Empty initialized for now.
For builtin JS, we would like to keep it as efficient and compact as we can
so we should use var consistently.

  • builtins/ArrayPrototype.js:

(sort.stringComparator):
(sort.compactSparse):
(sort.compactSlow):
(sort.compact):
(sort.merge):
(sort.mergeSort):
(sort.bucketSort):
(sort.comparatorSort):
(sort.stringSort):
(sort):
(globalPrivate.concatSlowPath):
(concat):

  • builtins/FunctionPrototype.js:

(call):
(overriddenName.string_appeared_here.symbolHasInstance):

  • builtins/GlobalOperations.js:

(globalPrivate.copyDataProperties):
(globalPrivate.copyDataPropertiesNoExclusions):

  • builtins/IteratorHelpers.js:

(performIteration):

  • builtins/ModuleLoader.js:

(async loadModule):
(async loadAndEvaluateModule):
(async requestImportModule):
(dependencyKeysIfEvaluated):

  • builtins/ObjectConstructor.js:

(fromEntries):

  • builtins/PromisePrototype.js:

(finally):
(valueThunk):
(globalPrivate.getThenFinally):
(thrower):
(globalPrivate.getCatchFinally):
(const.valueThunk): Deleted.
(const.thrower): Deleted.

  • builtins/RegExpPrototype.js:

(globalPrivate.advanceStringIndex):
(globalPrivate.regExpExec):
(globalPrivate.hasObservableSideEffectsForRegExpMatch):
(globalPrivate.matchSlow):
(overriddenName.string_appeared_here.match):
(overriddenName.string_appeared_here.matchAll):
(getSubstitution):
(overriddenName.string_appeared_here.replace):
(overriddenName.string_appeared_here.search):
(globalPrivate.hasObservableSideEffectsForRegExpSplit):
(overriddenName.string_appeared_here.split):
(intrinsic.RegExpTestIntrinsic.test):

  • builtins/RegExpStringIteratorPrototype.js:

(next):

  • builtins/StringPrototype.js:

(match):
(matchAll):
(globalPrivate.hasObservableSideEffectsForStringReplace):
(intrinsic.StringPrototypeReplaceIntrinsic.replace):
(globalPrivate.createHTML):

  • builtins/TypedArrayConstructor.js:

(of):
(from):

  • builtins/TypedArrayPrototype.js:

(globalPrivate.typedArraySpeciesConstructor):
(globalPrivate.typedArrayClampArgumentToStartOrEnd):
(fill):
(find):
(subarray):

Location:
trunk/Source/JavaScriptCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r254416 r254418  
     12020-01-12  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Consistently use "var" in builtin JS
     4        https://bugs.webkit.org/show_bug.cgi?id=206157
     5
     6        Reviewed by Mark Lam.
     7
     8        let / const requires additional bytecode to make it Empty initialized for now.
     9        For builtin JS, we would like to keep it as efficient and compact as we can
     10        so we should use `var` consistently.
     11
     12        * builtins/ArrayPrototype.js:
     13        (sort.stringComparator):
     14        (sort.compactSparse):
     15        (sort.compactSlow):
     16        (sort.compact):
     17        (sort.merge):
     18        (sort.mergeSort):
     19        (sort.bucketSort):
     20        (sort.comparatorSort):
     21        (sort.stringSort):
     22        (sort):
     23        (globalPrivate.concatSlowPath):
     24        (concat):
     25        * builtins/FunctionPrototype.js:
     26        (call):
     27        (overriddenName.string_appeared_here.symbolHasInstance):
     28        * builtins/GlobalOperations.js:
     29        (globalPrivate.copyDataProperties):
     30        (globalPrivate.copyDataPropertiesNoExclusions):
     31        * builtins/IteratorHelpers.js:
     32        (performIteration):
     33        * builtins/ModuleLoader.js:
     34        (async loadModule):
     35        (async loadAndEvaluateModule):
     36        (async requestImportModule):
     37        (dependencyKeysIfEvaluated):
     38        * builtins/ObjectConstructor.js:
     39        (fromEntries):
     40        * builtins/PromisePrototype.js:
     41        (finally):
     42        (valueThunk):
     43        (globalPrivate.getThenFinally):
     44        (thrower):
     45        (globalPrivate.getCatchFinally):
     46        (const.valueThunk): Deleted.
     47        (const.thrower): Deleted.
     48        * builtins/RegExpPrototype.js:
     49        (globalPrivate.advanceStringIndex):
     50        (globalPrivate.regExpExec):
     51        (globalPrivate.hasObservableSideEffectsForRegExpMatch):
     52        (globalPrivate.matchSlow):
     53        (overriddenName.string_appeared_here.match):
     54        (overriddenName.string_appeared_here.matchAll):
     55        (getSubstitution):
     56        (overriddenName.string_appeared_here.replace):
     57        (overriddenName.string_appeared_here.search):
     58        (globalPrivate.hasObservableSideEffectsForRegExpSplit):
     59        (overriddenName.string_appeared_here.split):
     60        (intrinsic.RegExpTestIntrinsic.test):
     61        * builtins/RegExpStringIteratorPrototype.js:
     62        (next):
     63        * builtins/StringPrototype.js:
     64        (match):
     65        (matchAll):
     66        (globalPrivate.hasObservableSideEffectsForStringReplace):
     67        (intrinsic.StringPrototypeReplaceIntrinsic.replace):
     68        (globalPrivate.createHTML):
     69        * builtins/TypedArrayConstructor.js:
     70        (of):
     71        (from):
     72        * builtins/TypedArrayPrototype.js:
     73        (globalPrivate.typedArraySpeciesConstructor):
     74        (globalPrivate.typedArrayClampArgumentToStartOrEnd):
     75        (fill):
     76        (find):
     77        (subarray):
     78
    1792020-01-12  Yusuke Suzuki  <ysuzuki@apple.com>
    280
  • trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js

    r254252 r254418  
    318318    function stringComparator(a, b)
    319319    {
    320         let aString = a.string;
    321         let bString = b.string;
    322 
    323         let aLength = aString.length;
    324         let bLength = bString.length;
    325         let length = min(aLength, bLength);
    326 
    327         for (let i = 0; i < length; ++i) {
    328             let aCharCode = aString.@charCodeAt(i);
    329             let bCharCode = bString.@charCodeAt(i);
     320        var aString = a.string;
     321        var bString = b.string;
     322
     323        var aLength = aString.length;
     324        var bLength = bString.length;
     325        var length = min(aLength, bLength);
     326
     327        for (var i = 0; i < length; ++i) {
     328            var aCharCode = aString.@charCodeAt(i);
     329            var bCharCode = bString.@charCodeAt(i);
    330330
    331331            if (aCharCode == bCharCode)
     
    341341    function compactSparse(array, dst, src, length)
    342342    {
    343         let values = [ ];
    344         let seen = { };
    345         let valueCount = 0;
    346         let undefinedCount = 0;
     343        var values = [ ];
     344        var seen = { };
     345        var valueCount = 0;
     346        var undefinedCount = 0;
    347347
    348348        // Clean up after the in-progress non-sparse compaction that failed.
    349         for (let i = dst; i < src; ++i)
     349        for (var i = dst; i < src; ++i)
    350350            delete array[i];
    351351
    352         for (let object = array; object; object = @Object.@getPrototypeOf(object)) {
    353             let propertyNames = @Object.@getOwnPropertyNames(object);
    354             for (let i = 0; i < propertyNames.length; ++i) {
    355                 let index = propertyNames[i];
     352        for (var object = array; object; object = @Object.@getPrototypeOf(object)) {
     353            var propertyNames = @Object.@getOwnPropertyNames(object);
     354            for (var i = 0; i < propertyNames.length; ++i) {
     355                var index = propertyNames[i];
    356356                if (index < length) { // Exclude non-numeric properties and properties past length.
    357357                    if (seen[index]) // Exclude duplicates.
     
    359359                    seen[index] = 1;
    360360
    361                     let value = array[index];
     361                    var value = array[index];
    362362                    delete array[index];
    363363
     
    372372        }
    373373
    374         for (let i = valueCount; i < valueCount + undefinedCount; ++i)
     374        for (var i = valueCount; i < valueCount + undefinedCount; ++i)
    375375            array[i] = @undefined;
    376376
     
    380380    function compactSlow(array, length)
    381381    {
    382         let holeCount = 0;
    383 
    384         let dst = 0;
    385         let src = 0;
     382        var holeCount = 0;
     383
     384        var dst = 0;
     385        var src = 0;
    386386        for (; src < length; ++src) {
    387387            if (!(src in array)) {
     
    392392            }
    393393
    394             let value = array[src];
     394            var value = array[src];
    395395            if (value === @undefined)
    396396                continue;
     
    399399        }
    400400
    401         let valueCount = dst;
    402         let undefinedCount = length - valueCount - holeCount;
    403 
    404         for (let i = valueCount; i < valueCount + undefinedCount; ++i)
     401        var valueCount = dst;
     402        var undefinedCount = length - valueCount - holeCount;
     403
     404        for (var i = valueCount; i < valueCount + undefinedCount; ++i)
    405405            array[i] = @undefined;
    406406
    407         for (let i = valueCount + undefinedCount; i < length; ++i)
     407        for (var i = valueCount + undefinedCount; i < length; ++i)
    408408            delete array[i];
    409409
     
    414414    function compact(array, length)
    415415    {
    416         for (let i = 0; i < array.length; ++i) {
     416        for (var i = 0; i < array.length; ++i) {
    417417            if (array[i] === @undefined)
    418418                return compactSlow(array, length);
     
    424424    function merge(dst, src, srcIndex, srcEnd, width, comparator)
    425425    {
    426         let left = srcIndex;
    427         let leftEnd = min(left + width, srcEnd);
    428         let right = leftEnd;
    429         let rightEnd = min(right + width, srcEnd);
    430 
    431         for (let dstIndex = left; dstIndex < rightEnd; ++dstIndex) {
     426        var left = srcIndex;
     427        var leftEnd = min(left + width, srcEnd);
     428        var right = leftEnd;
     429        var rightEnd = min(right + width, srcEnd);
     430
     431        for (var dstIndex = left; dstIndex < rightEnd; ++dstIndex) {
    432432            if (right < rightEnd) {
    433433                if (left >= leftEnd) {
     
    436436                }
    437437
    438                 let comparisonResult = comparator(src[right], src[left]);
     438                var comparisonResult = comparator(src[right], src[left]);
    439439                if ((typeof comparisonResult === "boolean" && !comparisonResult) || comparisonResult < 0) {
    440440                    dst[dstIndex] = src[right++];
     
    450450    function mergeSort(array, valueCount, comparator)
    451451    {
    452         let buffer = [ ];
     452        var buffer = [ ];
    453453        buffer.length = valueCount;
    454454
    455         let dst = buffer;
    456         let src = array;
    457         for (let width = 1; width < valueCount; width *= 2) {
    458             for (let srcIndex = 0; srcIndex < valueCount; srcIndex += 2 * width)
     455        var dst = buffer;
     456        var src = array;
     457        for (var width = 1; width < valueCount; width *= 2) {
     458            for (var srcIndex = 0; srcIndex < valueCount; srcIndex += 2 * width)
    459459                merge(dst, src, srcIndex, valueCount, width, comparator);
    460460
    461             let tmp = src;
     461            var tmp = src;
    462462            src = dst;
    463463            dst = tmp;
     
    465465
    466466        if (src != array) {
    467             for(let i = 0; i < valueCount; i++)
     467            for(var i = 0; i < valueCount; i++)
    468468                array[i] = src[i];
    469469        }
     
    474474        if (bucket.length < 32 || depth > 32) {
    475475            mergeSort(bucket, bucket.length, stringComparator);
    476             for (let i = 0; i < bucket.length; ++i)
     476            for (var i = 0; i < bucket.length; ++i)
    477477                array[dst++] = bucket[i].value;
    478478            return dst;
    479479        }
    480480
    481         let buckets = [ ];
    482         for (let i = 0; i < bucket.length; ++i) {
    483             let entry = bucket[i];
    484             let string = entry.string;
     481        var buckets = [ ];
     482        for (var i = 0; i < bucket.length; ++i) {
     483            var entry = bucket[i];
     484            var string = entry.string;
    485485            if (string.length == depth) {
    486486                array[dst++] = entry.value;
     
    488488            }
    489489
    490             let c = string.@charCodeAt(depth);
     490            var c = string.@charCodeAt(depth);
    491491            if (!buckets[c])
    492492                buckets[c] = [ ];
     
    494494        }
    495495
    496         for (let i = 0; i < buckets.length; ++i) {
     496        for (var i = 0; i < buckets.length; ++i) {
    497497            if (!buckets[i])
    498498                continue;
     
    505505    function comparatorSort(array, length, comparator)
    506506    {
    507         let valueCount = compact(array, length);
     507        var valueCount = compact(array, length);
    508508        mergeSort(array, valueCount, comparator);
    509509    }
     
    511511    function stringSort(array, length)
    512512    {
    513         let valueCount = compact(array, length);
    514 
    515         let strings = @newArrayWithSize(valueCount);
    516         for (let i = 0; i < valueCount; ++i)
     513        var valueCount = compact(array, length);
     514
     515        var strings = @newArrayWithSize(valueCount);
     516        for (var i = 0; i < valueCount; ++i)
    517517            strings[i] = { string: @toString(array[i]), value: array[i] };
    518518
     
    520520    }
    521521
    522     let sortFunction;
     522    var sortFunction;
    523523    if (typeof comparator == "function")
    524524        sortFunction = comparatorSort;
     
    528528        @throwTypeError("Array.prototype.sort requires the comparsion function be a function or undefined");
    529529
    530     let array = @toObject(this, "Array.prototype.sort requires that |this| not be null or undefined");
    531 
    532     let length = @toLength(array.length);
     530    var array = @toObject(this, "Array.prototype.sort requires that |this| not be null or undefined");
     531
     532    var length = @toLength(array.length);
    533533
    534534    // For compatibility with Firefox and Chrome, do nothing observable
     
    556556
    557557    do {
    558         let spreadable = @isObject(currentElement) && currentElement.@isConcatSpreadableSymbol;
     558        var spreadable = @isObject(currentElement) && currentElement.@isConcatSpreadableSymbol;
    559559        if ((spreadable === @undefined && @isArray(currentElement)) || spreadable) {
    560             let length = @toLength(currentElement.length);
     560            var length = @toLength(currentElement.length);
    561561            if (length + resultIndex > @MAX_ARRAY_INDEX)
    562562                @throwRangeError("Length exceeded the maximum array length");
     
    592592        && (!@isObject(first) || (!@isProxyObject(first) && first.@isConcatSpreadableSymbol === @undefined))) {
    593593
    594         let result = @concatMemcpy(this, first);
     594        var result = @concatMemcpy(this, first);
    595595        if (result !== null)
    596596            return result;
  • trunk/Source/JavaScriptCore/builtins/FunctionPrototype.js

    r253867 r254418  
    2828    "use strict";
    2929
    30     let argumentValues = [];
     30    var argumentValues = [];
    3131    // Start from 1 to ignore thisArgument
    32     for (let i = 1; i < arguments.length; i++)
     32    for (var i = 1; i < arguments.length; i++)
    3333        @putByValDirect(argumentValues, i-1, arguments[i]);
    3434
     
    5454        return @hasInstanceBoundFunction(this, value);
    5555
    56     let target = this.prototype;
     56    var target = this.prototype;
    5757    return @instanceOf(value, target);
    5858}
  • trunk/Source/JavaScriptCore/builtins/GlobalOperations.js

    r242382 r254418  
    9696        return target;
    9797
    98     let from = @toObject(source);
    99     let keys = @ownKeys(from);
    100     let keysLength = keys.length;
    101     for (let i = 0; i < keysLength; i++) {
    102         let nextKey = keys[i];
     98    var from = @toObject(source);
     99    var keys = @ownKeys(from);
     100    var keysLength = keys.length;
     101    for (var i = 0; i < keysLength; i++) {
     102        var nextKey = keys[i];
    103103        if (!excludedSet.@has(nextKey)) {
    104104            if (@propertyIsEnumerable(from, nextKey)) {
    105                 let propValue = from[nextKey];
     105                var propValue = from[nextKey];
    106106                @defineEnumerableWritableConfigurableDataProperty(target, nextKey, propValue);
    107107            }
     
    123123        return target;
    124124
    125     let from = @toObject(source);
    126     let keys = @ownKeys(from);
    127     let keysLength = keys.length;
    128     for (let i = 0; i < keysLength; i++) {
    129         let nextKey = keys[i];
     125    var from = @toObject(source);
     126    var keys = @ownKeys(from);
     127    var keysLength = keys.length;
     128    for (var i = 0; i < keysLength; i++) {
     129        var nextKey = keys[i];
    130130        if (@propertyIsEnumerable(from, nextKey)) {
    131             let propValue = from[nextKey];
     131            var propValue = from[nextKey];
    132132            @defineEnumerableWritableConfigurableDataProperty(target, nextKey, propValue);
    133133        }
  • trunk/Source/JavaScriptCore/builtins/IteratorHelpers.js

    r222421 r254418  
    3131    // https://tc39.github.io/ecma262/#sec-runtime-semantics-arrayaccumulation
    3232
    33     let result = [];
     33    var result = [];
    3434
    35     let iterator = iterable.@iteratorSymbol();
    36     let next = iterator.next;
    37     let item;
    38     let index = 0;
     35    var iterator = iterable.@iteratorSymbol();
     36    var next = iterator.next;
     37    var item;
     38    var index = 0;
    3939    while (true) {
    4040        item = next.@call(iterator);
  • trunk/Source/JavaScriptCore/builtins/ModuleLoader.js

    r249509 r254418  
    339339    // Take the name and resolve it to the unique identifier for the resource location.
    340340    // For example, take the "jquery" and return the URL for the resource.
    341     let key = await this.resolve(moduleName, @undefined, fetcher);
    342     let entry = await this.requestSatisfy(this.ensureRegistered(key), parameters, fetcher, new @Set);
     341    var key = await this.resolve(moduleName, @undefined, fetcher);
     342    var entry = await this.requestSatisfy(this.ensureRegistered(key), parameters, fetcher, new @Set);
    343343    return entry.key;
    344344}
     
    360360    "use strict";
    361361
    362     let key = await this.loadModule(moduleName, parameters, fetcher);
     362    var key = await this.loadModule(moduleName, parameters, fetcher);
    363363    return await this.linkAndEvaluateModule(key, fetcher);
    364364}
     
    368368    "use strict";
    369369
    370     let entry = await this.requestSatisfy(this.ensureRegistered(key), parameters, fetcher, new @Set);
     370    var entry = await this.requestSatisfy(this.ensureRegistered(key), parameters, fetcher, new @Set);
    371371    this.linkAndEvaluateModule(entry.key, fetcher);
    372372    return this.getModuleNamespaceObject(entry.module);
     
    377377    "use strict";
    378378
    379     let entry = this.registry.@get(key);
     379    var entry = this.registry.@get(key);
    380380    if (!entry || !entry.evaluated)
    381381        return null;
    382382
    383     let dependencies = entry.dependencies;
    384     let length = dependencies.length;
    385     let result = new @Array(length);
    386     for (let i = 0; i < length; ++i)
     383    var dependencies = entry.dependencies;
     384    var length = dependencies.length;
     385    var result = new @Array(length);
     386    for (var i = 0; i < length; ++i)
    387387        result[i] = dependencies[i].key;
    388388
  • trunk/Source/JavaScriptCore/builtins/ObjectConstructor.js

    r241644 r254418  
    4646    "use strict";
    4747
    48     let object = {};
     48    var object = {};
    4949
    50     for (let entry of iterable) {
     50    for (var entry of iterable) {
    5151        if (!@isObject(entry))
    5252            @throwTypeError("Object.fromEntries requires the first iterable parameter yields objects");
    53         let key = entry[0];
    54         let value = entry[1];
     53        var key = entry[0];
     54        var value = entry[1];
    5555        @putByValDirect(object, key, value);
    5656    }
  • trunk/Source/JavaScriptCore/builtins/PromisePrototype.js

    r249509 r254418  
    8080        @throwTypeError("|this| is not an object");
    8181
    82     const constructor = @speciesConstructor(this, @Promise);
     82    var constructor = @speciesConstructor(this, @Promise);
    8383
    8484    @assert(@isConstructor(constructor));
    8585
    86     let thenFinally;
    87     let catchFinally;
     86    var thenFinally;
     87    var catchFinally;
    8888
    8989    if (typeof onFinally !== "function") {
     
    106106    {
    107107        @assert(typeof onFinally === "function");
    108         const result = onFinally();
     108        var result = onFinally();
    109109
    110110        @assert(@isConstructor(constructor));
    111         const resultCapability = @newPromiseCapability(constructor);
     111        var resultCapability = @newPromiseCapability(constructor);
    112112
    113113        resultCapability.@resolve.@call(@undefined, result);
    114114
    115         const promise = resultCapability.@promise;
    116         const valueThunk = function () { return value; };
     115        var promise = resultCapability.@promise;
     116        var valueThunk = function () { return value; };
    117117
    118118        return promise.then(valueThunk);
     
    128128    {
    129129        @assert(typeof onFinally === "function");
    130         const result = onFinally();
     130        var result = onFinally();
    131131
    132132        @assert(@isConstructor(constructor));
    133         const resultCapability = @newPromiseCapability(constructor);
     133        var resultCapability = @newPromiseCapability(constructor);
    134134
    135135        resultCapability.@resolve.@call(@undefined, result);
    136136
    137         const promise = resultCapability.@promise;
    138         const thrower = function () { throw reason; };
     137        var promise = resultCapability.@promise;
     138        var thrower = function () { throw reason; };
    139139
    140140        return promise.then(thrower);
  • trunk/Source/JavaScriptCore/builtins/RegExpPrototype.js

    r254195 r254418  
    4949        return index + 1;
    5050
    51     let first = string.@charCodeAt(index);
     51    var first = string.@charCodeAt(index);
    5252    if (first < 0xD800 || first > 0xDBFF)
    5353        return index + 1;
    5454
    55     let second = string.@charCodeAt(index + 1);
     55    var second = string.@charCodeAt(index + 1);
    5656    if (second < 0xDC00 || second > 0xDFFF)
    5757        return index + 1;
     
    6565    "use strict";
    6666
    67     let exec = regexp.exec;
    68     let builtinExec = @regExpBuiltinExec;
     67    var exec = regexp.exec;
     68    var builtinExec = @regExpBuiltinExec;
    6969    if (exec !== builtinExec && typeof exec === "function") {
    70         let result = exec.@call(regexp, str);
     70        var result = exec.@call(regexp, str);
    7171        if (result !== null && !@isObject(result))
    7272            @throwTypeError("The result of a RegExp exec must be null or an object");
     
    8585
    8686    // This is accessed by the RegExpExec internal function.
    87     let regexpExec = @tryGetById(regexp, "exec");
     87    var regexpExec = @tryGetById(regexp, "exec");
    8888    if (regexpExec !== @regExpBuiltinExec)
    8989        return true;
    9090
    91     let regexpGlobal = @tryGetById(regexp, "global");
     91    var regexpGlobal = @tryGetById(regexp, "global");
    9292    if (regexpGlobal !== @regExpProtoGlobalGetter)
    9393        return true;
    94     let regexpUnicode = @tryGetById(regexp, "unicode");
     94    var regexpUnicode = @tryGetById(regexp, "unicode");
    9595    if (regexpUnicode !== @regExpProtoUnicodeGetter)
    9696        return true;
     
    107107        return @regExpExec(regexp, str);
    108108   
    109     let unicode = regexp.unicode;
     109    var unicode = regexp.unicode;
    110110    regexp.lastIndex = 0;
    111     let resultList = [];
     111    var resultList = [];
    112112
    113113    // FIXME: It would be great to implement a solution similar to what we do in
    114114    // RegExpObject::matchGlobal(). It's not clear if this is possible, since this loop has
    115115    // effects. https://bugs.webkit.org/show_bug.cgi?id=158145
    116     const maximumReasonableMatchSize = 100000000;
     116    var maximumReasonableMatchSize = 100000000;
    117117
    118118    while (true) {
    119         let result = @regExpExec(regexp, str);
     119        var result = @regExpExec(regexp, str);
    120120       
    121121        if (result === null) {
     
    128128            @throwOutOfMemoryError();
    129129
    130         let resultString = @toString(result[0]);
     130        var resultString = @toString(result[0]);
    131131
    132132        if (!resultString.length)
     
    145145        @throwTypeError("RegExp.prototype.@@match requires that |this| be an Object");
    146146
    147     let str = @toString(strArg);
     147    var str = @toString(strArg);
    148148
    149149    // Check for observable side effects and call the fast path if there aren't any.
     
    158158    "use strict";
    159159
    160     let regExp = this;
     160    var regExp = this;
    161161    if (!@isObject(regExp))
    162162        @throwTypeError("RegExp.prototype.@@matchAll requires |this| to be an Object");
    163163
    164     let string = @toString(strArg);
    165     let Matcher = @speciesConstructor(regExp, @RegExp);
    166 
    167     let flags = @toString(regExp.flags);
    168     let matcher = new Matcher(regExp, flags);
     164    var string = @toString(strArg);
     165    var Matcher = @speciesConstructor(regExp, @RegExp);
     166
     167    var flags = @toString(regExp.flags);
     168    var matcher = new Matcher(regExp, flags);
    169169    matcher.lastIndex = @toLength(regExp.lastIndex);
    170170
    171     let global = @stringIncludesInternal.@call(flags, "g");
    172     let fullUnicode = @stringIncludesInternal.@call(flags, "u");
     171    var global = @stringIncludesInternal.@call(flags, "g");
     172    var fullUnicode = @stringIncludesInternal.@call(flags, "u");
    173173
    174174    return new @RegExpStringIterator(matcher, string, global, fullUnicode);
     
    184184        "use strict";
    185185
    186         let matchLength = matched.length;
    187         let stringLength = str.length;
    188         let tailPos = position + matchLength;
    189         let m = captures.length;
    190         let replacementLength = replacement.length;
    191         let result = "";
    192         let lastStart = 0;
    193 
    194         for (let start = 0; start = replacement.indexOf("$", lastStart), start !== -1; lastStart = start) {
     186        var matchLength = matched.length;
     187        var stringLength = str.length;
     188        var tailPos = position + matchLength;
     189        var m = captures.length;
     190        var replacementLength = replacement.length;
     191        var result = "";
     192        var lastStart = 0;
     193
     194        for (var start = 0; start = replacement.indexOf("$", lastStart), start !== -1; lastStart = start) {
    195195            if (start - lastStart > 0)
    196196                result = result + replacement.substring(lastStart, start);
    197197            start++;
    198             let ch = replacement.charAt(start);
     198            var ch = replacement.charAt(start);
    199199            if (ch === "")
    200200                result = result + "$";
     
    222222                case "<":
    223223                    if (namedCaptures !== @undefined) {
    224                         let groupNameStartIndex = start + 1;
    225                         let groupNameEndIndex = replacement.indexOf(">", groupNameStartIndex);
     224                        var groupNameStartIndex = start + 1;
     225                        var groupNameEndIndex = replacement.indexOf(">", groupNameStartIndex);
    226226                        if (groupNameEndIndex !== -1) {
    227                             let groupName = replacement.substring(groupNameStartIndex, groupNameEndIndex);
    228                             let capture = namedCaptures[groupName];
     227                            var groupName = replacement.substring(groupNameStartIndex, groupNameEndIndex);
     228                            var capture = namedCaptures[groupName];
    229229                            if (capture !== @undefined)
    230230                                result = result + @toString(capture);
     
    239239                    break;
    240240                default:
    241                     let chCode = ch.charCodeAt(0);
     241                    var chCode = ch.charCodeAt(0);
    242242                    if (chCode >= 0x30 && chCode <= 0x39) {
    243                         let originalStart = start - 1;
     243                        var originalStart = start - 1;
    244244                        start++;
    245245
    246                         let n = chCode - 0x30;
     246                        var n = chCode - 0x30;
    247247                        if (n > m) {
    248248                            result = result + replacement.substring(originalStart, start);
     
    251251
    252252                        if (start < replacementLength) {
    253                             let nextChCode = replacement.charCodeAt(start);
     253                            var nextChCode = replacement.charCodeAt(start);
    254254                            if (nextChCode >= 0x30 && nextChCode <= 0x39) {
    255                                 let nn = 10 * n + nextChCode - 0x30;
     255                                var nn = 10 * n + nextChCode - 0x30;
    256256                                if (nn <= m) {
    257257                                    n = nn;
     
    266266                        }
    267267
    268                         let capture = captures[n - 1];
     268                        var capture = captures[n - 1];
    269269                        if (capture !== @undefined)
    270270                            result = result + capture;
     
    282282        @throwTypeError("RegExp.prototype.@@replace requires that |this| be an Object");
    283283
    284     let regexp = this;
    285 
    286     let str = @toString(strArg);
    287     let stringLength = str.length;
    288     let functionalReplace = typeof replace === 'function';
     284    var regexp = this;
     285
     286    var str = @toString(strArg);
     287    var stringLength = str.length;
     288    var functionalReplace = typeof replace === 'function';
    289289
    290290    if (!functionalReplace)
    291291        replace = @toString(replace);
    292292
    293     let global = regexp.global;
    294     let unicode = false;
     293    var global = regexp.global;
     294    var unicode = false;
    295295
    296296    if (global) {
     
    299299    }
    300300
    301     let resultList = [];
    302     let result;
    303     let done = false;
     301    var resultList = [];
     302    var result;
     303    var done = false;
    304304    while (!done) {
    305305        result = @regExpExec(regexp, str);
     
    312312                done = true;
    313313            else {
    314                 let matchStr = @toString(result[0]);
     314                var matchStr = @toString(result[0]);
    315315
    316316                if (!matchStr.length)
     
    320320    }
    321321
    322     let accumulatedResult = "";
    323     let nextSourcePosition = 0;
    324     let lastPosition = 0;
    325 
    326     for (let i = 0, resultListLength = resultList.length; i < resultListLength; ++i) {
    327         let result = resultList[i];
    328         let nCaptures = result.length - 1;
     322    var accumulatedResult = "";
     323    var nextSourcePosition = 0;
     324    var lastPosition = 0;
     325
     326    for (var i = 0, resultListLength = resultList.length; i < resultListLength; ++i) {
     327        var result = resultList[i];
     328        var nCaptures = result.length - 1;
    329329        if (nCaptures < 0)
    330330            nCaptures = 0;
    331         let matched = @toString(result[0]);
    332         let matchLength = matched.length;
    333         let position = result.index;
     331        var matched = @toString(result[0]);
     332        var matchLength = matched.length;
     333        var position = result.index;
    334334        position = (position > stringLength) ? stringLength : position;
    335335        position = (position < 0) ? 0 : position;
    336336
    337         let captures = [];
    338         for (let n = 1; n <= nCaptures; n++) {
    339             let capN = result[n];
     337        var captures = [];
     338        for (var n = 1; n <= nCaptures; n++) {
     339            var capN = result[n];
    340340            if (capN !== @undefined)
    341341                capN = @toString(capN);
     
    343343        }
    344344
    345         let replacement;
    346         let namedCaptures = result.groups;
     345        var replacement;
     346        var namedCaptures = result.groups;
    347347
    348348        if (functionalReplace) {
    349             let replacerArgs = [ matched ].concat(captures);
     349            var replacerArgs = [ matched ].concat(captures);
    350350            replacerArgs.@push(position);
    351351            replacerArgs.@push(str);
     
    354354                replacerArgs.@push(namedCaptures);
    355355
    356             let replValue = replace.@apply(@undefined, replacerArgs);
     356            var replValue = replace.@apply(@undefined, replacerArgs);
    357357            replacement = @toString(replValue);
    358358        } else {
     
    382382    "use strict";
    383383
    384     let regexp = this;
     384    var regexp = this;
    385385
    386386    // Check for observable side effects and call the fast path if there aren't any.
     
    396396
    397397    // 3. Let S be ? ToString(string).
    398     let str = @toString(strArg)
     398    var str = @toString(strArg)
    399399
    400400    // 4. Let previousLastIndex be ? Get(rx, "lastIndex").
    401     let previousLastIndex = regexp.lastIndex;
     401    var previousLastIndex = regexp.lastIndex;
    402402
    403403    // 5.If SameValue(previousLastIndex, 0) is false, then
     
    408408
    409409    // 6. Let result be ? RegExpExec(rx, S).
    410     let result = @regExpExec(regexp, str);
     410    var result = @regExpExec(regexp, str);
    411411
    412412    // 7. Let currentLastIndex be ? Get(rx, "lastIndex").
     
    434434
    435435    // This is accessed by the RegExpExec internal function.
    436     let regexpExec = @tryGetById(regexp, "exec");
     436    var regexpExec = @tryGetById(regexp, "exec");
    437437    if (regexpExec !== @regExpBuiltinExec)
    438438        return true;
    439439   
    440440    // This is accessed by step 5 below.
    441     let regexpFlags = @tryGetById(regexp, "flags");
     441    var regexpFlags = @tryGetById(regexp, "flags");
    442442    if (regexpFlags !== @regExpProtoFlagsGetter)
    443443        return true;
    444444   
    445445    // These are accessed by the builtin flags getter.
    446     let regexpGlobal = @tryGetById(regexp, "global");
     446    var regexpGlobal = @tryGetById(regexp, "global");
    447447    if (regexpGlobal !== @regExpProtoGlobalGetter)
    448448        return true;
    449     let regexpIgnoreCase = @tryGetById(regexp, "ignoreCase");
     449    var regexpIgnoreCase = @tryGetById(regexp, "ignoreCase");
    450450    if (regexpIgnoreCase !== @regExpProtoIgnoreCaseGetter)
    451451        return true;
    452     let regexpMultiline = @tryGetById(regexp, "multiline");
     452    var regexpMultiline = @tryGetById(regexp, "multiline");
    453453    if (regexpMultiline !== @regExpProtoMultilineGetter)
    454454        return true;
    455     let regexpSticky = @tryGetById(regexp, "sticky");
     455    var regexpSticky = @tryGetById(regexp, "sticky");
    456456    if (regexpSticky !== @regExpProtoStickyGetter)
    457457        return true;
    458     let regexpUnicode = @tryGetById(regexp, "unicode");
     458    var regexpUnicode = @tryGetById(regexp, "unicode");
    459459    if (regexpUnicode !== @regExpProtoUnicodeGetter)
    460460        return true;
    461461   
    462462    // This is accessed by the RegExp species constructor.
    463     let regexpSource = @tryGetById(regexp, "source");
     463    var regexpSource = @tryGetById(regexp, "source");
    464464    if (regexpSource !== @regExpProtoSourceGetter)
    465465        return true;
     
    478478    if (!@isObject(this))
    479479        @throwTypeError("RegExp.prototype.@@split requires that |this| be an Object");
    480     let regexp = this;
     480    var regexp = this;
    481481
    482482    // 3. Let S be ? ToString(string).
    483     let str = @toString(string);
     483    var str = @toString(string);
    484484
    485485    // 4. Let C be ? SpeciesConstructor(rx, %RegExp%).
    486     let speciesConstructor = @speciesConstructor(regexp, @RegExp);
     486    var speciesConstructor = @speciesConstructor(regexp, @RegExp);
    487487
    488488    if (speciesConstructor === @RegExp && !@hasObservableSideEffectsForRegExpSplit(regexp))
     
    490490
    491491    // 5. Let flags be ? ToString(? Get(rx, "flags")).
    492     let flags = @toString(regexp.flags);
    493 
    494     // 6. If flags contains "u", let unicodeMatching be true.
     492    var flags = @toString(regexp.flags);
     493
     494    // 6. If flags contains "u", var unicodeMatching be true.
    495495    // 7. Else, let unicodeMatching be false.
    496     let unicodeMatching = @stringIncludesInternal.@call(flags, "u");
    497     // 8. If flags contains "y", let newFlags be flags.
     496    var unicodeMatching = @stringIncludesInternal.@call(flags, "u");
     497    // 8. If flags contains "y", var newFlags be flags.
    498498    // 9. Else, let newFlags be the string that is the concatenation of flags and "y".
    499     let newFlags = @stringIncludesInternal.@call(flags, "y") ? flags : flags + "y";
     499    var newFlags = @stringIncludesInternal.@call(flags, "y") ? flags : flags + "y";
    500500
    501501    // 10. Let splitter be ? Construct(C, « rx, newFlags »).
    502     let splitter = new speciesConstructor(regexp, newFlags);
     502    var splitter = new speciesConstructor(regexp, newFlags);
    503503
    504504    // We need to check again for RegExp subclasses that will fail the speciesConstructor test
     
    509509    // 11. Let A be ArrayCreate(0).
    510510    // 12. Let lengthA be 0.
    511     let result = [];
    512 
    513     // 13. If limit is undefined, let lim be 2^32-1; else let lim be ? ToUint32(limit).
     511    var result = [];
     512
     513    // 13. If limit is undefined, let lim be 2^32-1; else var lim be ? ToUint32(limit).
    514514    limit = (limit === @undefined) ? 0xffffffff : limit >>> 0;
    515515
     
    519519
    520520    // 14. [Defered from above] Let size be the number of elements in S.
    521     let size = str.length;
     521    var size = str.length;
    522522
    523523    // 17. If size = 0, then
    524524    if (!size) {
    525525        // a. Let z be ? RegExpExec(splitter, S).
    526         let z = @regExpExec(splitter, str);
     526        var z = @regExpExec(splitter, str);
    527527        // b. If z is not null, return A.
    528528        if (z != null)
     
    535535
    536536    // 15. [Defered from above] Let p be 0.
    537     let position = 0;
     537    var position = 0;
    538538    // 18. Let q be p.
    539     let matchPosition = 0;
     539    var matchPosition = 0;
    540540
    541541    // 19. Repeat, while q < size
     
    544544        splitter.lastIndex = matchPosition;
    545545        // b. Let z be ? RegExpExec(splitter, S).
    546         let matches = @regExpExec(splitter, str);
     546        var matches = @regExpExec(splitter, str);
    547547        // c. If z is null, let q be AdvanceStringIndex(S, q, unicodeMatching).
    548548        if (matches === null)
     
    551551        else {
    552552            // i. Let e be ? ToLength(? Get(splitter, "lastIndex")).
    553             let endPosition = @toLength(splitter.lastIndex);
     553            var endPosition = @toLength(splitter.lastIndex);
    554554            // ii. Let e be min(e, size).
    555555            endPosition = (endPosition <= size) ? endPosition : size;
     
    560560            else {
    561561                // 1. Let T be a String value equal to the substring of S consisting of the elements at indices p (inclusive) through q (exclusive).
    562                 let subStr = @stringSubstrInternal.@call(str, position, matchPosition - position);
     562                var subStr = @stringSubstrInternal.@call(str, position, matchPosition - position);
    563563                // 2. Perform ! CreateDataProperty(A, ! ToString(lengthA), T).
    564564                // 3. Let lengthA be lengthA + 1.
     
    572572                // 6. Let numberOfCaptures be ? ToLength(? Get(z, "length")).
    573573                // 7. Let numberOfCaptures be max(numberOfCaptures-1, 0).
    574                 let numberOfCaptures = matches.length > 1 ? matches.length - 1 : 0;
     574                var numberOfCaptures = matches.length > 1 ? matches.length - 1 : 0;
    575575
    576576                // 8. Let i be 1.
    577                 let i = 1;
     577                var i = 1;
    578578                // 9. Repeat, while i <= numberOfCaptures,
    579579                while (i <= numberOfCaptures) {
    580580                    // a. Let nextCapture be ? Get(z, ! ToString(i)).
    581                     let nextCapture = matches[i];
     581                    var nextCapture = matches[i];
    582582                    // b. Perform ! CreateDataProperty(A, ! ToString(lengthA), nextCapture).
    583583                    // d. Let lengthA be lengthA + 1.
     
    595595    }
    596596    // 20. Let T be a String value equal to the substring of S consisting of the elements at indices p (inclusive) through size (exclusive).
    597     let remainingStr = @stringSubstrInternal.@call(str, position, size);
     597    var remainingStr = @stringSubstrInternal.@call(str, position, size);
    598598    // 21. Perform ! CreateDataProperty(A, ! ToString(lengthA), T).
    599599    @putByValDirect(result, result.length, remainingStr);
     
    608608    "use strict";
    609609
    610     let regexp = this;
     610    var regexp = this;
    611611
    612612    // Check for observable side effects and call the fast path if there aren't any.
     
    622622
    623623    // 3. Let string be ? ToString(S).
    624     let str = @toString(strArg);
     624    var str = @toString(strArg);
    625625
    626626    // 4. Let match be ? RegExpExec(R, string).
    627     let match = @regExpExec(regexp, str);
     627    var match = @regExpExec(regexp, str);
    628628
    629629    // 5. If match is not null, return true; else return false.
  • trunk/Source/JavaScriptCore/builtins/RegExpStringIteratorPrototype.js

    r246567 r254418  
    3131        @throwTypeError("%RegExpStringIteratorPrototype%.next requires |this| to be an Object");
    3232
    33     let done = @getByIdDirectPrivate(this, "regExpStringIteratorDone");
     33    var done = @getByIdDirectPrivate(this, "regExpStringIteratorDone");
    3434    if (done === @undefined)
    3535        @throwTypeError("%RegExpStringIteratorPrototype%.next requires |this| to be an RegExp String Iterator instance");
     
    3838        return { value: @undefined, done: true };
    3939
    40     let regExp = @getByIdDirectPrivate(this, "regExpStringIteratorRegExp");
    41     let string = @getByIdDirectPrivate(this, "regExpStringIteratorString");
    42     let global = @getByIdDirectPrivate(this, "regExpStringIteratorGlobal");
    43     let fullUnicode = @getByIdDirectPrivate(this, "regExpStringIteratorUnicode");
    44     let match = @regExpExec(regExp, string);
     40    var regExp = @getByIdDirectPrivate(this, "regExpStringIteratorRegExp");
     41    var string = @getByIdDirectPrivate(this, "regExpStringIteratorString");
     42    var global = @getByIdDirectPrivate(this, "regExpStringIteratorGlobal");
     43    var fullUnicode = @getByIdDirectPrivate(this, "regExpStringIteratorUnicode");
     44    var match = @regExpExec(regExp, string);
    4545    if (match === null) {
    4646        @putByIdDirectPrivate(this, "regExpStringIteratorDone", true);
     
    4949
    5050    if (global) {
    51         let matchStr = @toString(match[0]);
     51        var matchStr = @toString(match[0]);
    5252        if (matchStr === "") {
    53             let thisIndex = @toLength(regExp.lastIndex);
     53            var thisIndex = @toLength(regExp.lastIndex);
    5454            regExp.lastIndex = @advanceStringIndex(string, thisIndex, fullUnicode);
    5555        }
  • trunk/Source/JavaScriptCore/builtins/StringPrototype.js

    r252754 r254418  
    3939    }
    4040
    41     let thisString = @toString(this);
    42     let createdRegExp = @regExpCreate(regexp, @undefined);
     41    var thisString = @toString(this);
     42    var createdRegExp = @regExpCreate(regexp, @undefined);
    4343    return createdRegExp.@matchSymbol(thisString);
    4444}
     
    5555            @throwTypeError("String.prototype.matchAll argument must not be a non-global regular expression");
    5656
    57         let matcher = arg.@matchAllSymbol;
     57        var matcher = arg.@matchAllSymbol;
    5858        if (!@isUndefinedOrNull(matcher))
    5959            return matcher.@call(arg, this);
    6060    }
    6161
    62     let string = @toString(this);
    63     let regExp = @regExpCreate(arg, "g");
     62    var string = @toString(this);
     63    var regExp = @regExpCreate(arg, "g");
    6464    return regExp.@matchAllSymbol(string);
    6565}
     
    223223        return true;
    224224   
    225     let regexpExec = @tryGetById(regexp, "exec");
     225    var regexpExec = @tryGetById(regexp, "exec");
    226226    if (regexpExec !== @regExpBuiltinExec)
    227227        return true;
    228228
    229     let regexpGlobal = @tryGetById(regexp, "global");
     229    var regexpGlobal = @tryGetById(regexp, "global");
    230230    if (regexpGlobal !== @regExpProtoGlobalGetter)
    231231        return true;
    232232
    233     let regexpUnicode = @tryGetById(regexp, "unicode");
     233    var regexpUnicode = @tryGetById(regexp, "unicode");
    234234    if (regexpUnicode !== @regExpProtoUnicodeGetter)
    235235        return true;
     
    247247
    248248    if (search != null) {
    249         let replacer = search.@replaceSymbol;
    250         if (replacer !== @undefined) {
    251             if (!@hasObservableSideEffectsForStringReplace(search, replacer))
    252                 return @toString(this).@replaceUsingRegExp(search, replace);
    253             return replacer.@call(search, this, replace);
    254         }
    255     }
    256 
    257     let thisString = @toString(this);
    258     let searchString = @toString(search);
    259     return thisString.@replaceUsingStringSearch(searchString, replace);
    260 }
    261 
    262 function replaceAll(search, replace)
    263 {
    264     "use strict";
    265 
    266     if (@isUndefinedOrNull(this))
    267         @throwTypeError("String.prototype.replaceAll requires |this| not to be null nor undefined");
    268 
    269     if (search != null) {
    270         if (@isRegExp(search) && !@stringIncludesInternal.@call(@toString(search.flags), "g"))
    271             @throwTypeError("String.prototype.replaceAll argument must not be a non-global regular expression");
    272 
    273249        var replacer = search.@replaceSymbol;
    274250        if (replacer !== @undefined) {
     
    281257    var thisString = @toString(this);
    282258    var searchString = @toString(search);
     259    return thisString.@replaceUsingStringSearch(searchString, replace);
     260}
     261
     262function replaceAll(search, replace)
     263{
     264    "use strict";
     265
     266    if (@isUndefinedOrNull(this))
     267        @throwTypeError("String.prototype.replaceAll requires |this| not to be null nor undefined");
     268
     269    if (search != null) {
     270        if (@isRegExp(search) && !@stringIncludesInternal.@call(@toString(search.flags), "g"))
     271            @throwTypeError("String.prototype.replaceAll argument must not be a non-global regular expression");
     272
     273        var replacer = search.@replaceSymbol;
     274        if (replacer !== @undefined) {
     275            if (!@hasObservableSideEffectsForStringReplace(search, replacer))
     276                return @toString(this).@replaceUsingRegExp(search, replace);
     277            return replacer.@call(search, this, replace);
     278        }
     279    }
     280
     281    var thisString = @toString(this);
     282    var searchString = @toString(search);
    283283    return thisString.@replaceAllUsingStringSearch(searchString, replace);
    284284}
     
    347347    if (@isUndefinedOrNull(string))
    348348        @throwTypeError(`${func} requires that |this| not be null or undefined`);
    349     let S = @toString(string);
    350     let p1 = "<" + tag;
     349    var S = @toString(string);
     350    var p1 = "<" + tag;
    351351    if (attribute) {
    352         let V = @toString(value);
    353         let escapedV = V.@replaceUsingRegExp(/"/g, '&quot;');
     352        var V = @toString(value);
     353        var escapedV = V.@replaceUsingRegExp(/"/g, '&quot;');
    354354        p1 = p1 + " " + @toString(attribute) + '="' + escapedV + '"'
    355355    }
    356     let p2 = p1 + ">"
    357     let p3 = p2 + S;
    358     let p4 = p3 + "</" + tag + ">";
     356    var p2 = p1 + ">"
     357    var p3 = p2 + S;
     358    var p4 = p3 + "</" + tag + ">";
    359359    return p4;
    360360}
  • trunk/Source/JavaScriptCore/builtins/TypedArrayConstructor.js

    r230376 r254418  
    3232{
    3333    "use strict";
    34     let len = arguments.length;
    35     let constructFunction = @getByIdDirectPrivate(this, "allocateTypedArray");
     34    var len = arguments.length;
     35    var constructFunction = @getByIdDirectPrivate(this, "allocateTypedArray");
    3636    if (constructFunction === @undefined)
    3737        @throwTypeError("TypedArray.of requires its this argument to subclass a TypedArray constructor");
    3838
    39     let result = constructFunction(len);
     39    var result = constructFunction(len);
    4040
    41     for (let i = 0; i < len; i++)
     41    for (var i = 0; i < len; i++)
    4242        result[i] = arguments[i];
    4343
     
    4949    "use strict";
    5050
    51     let mapFn = @argument(1);
     51    var mapFn = @argument(1);
    5252
    53     let thisArg;
     53    var thisArg;
    5454
    5555    if (mapFn !== @undefined) {
     
    6060    }
    6161
    62     let arrayLike = @toObject(items, "TypedArray.from requires an array-like object - not null or undefined");
     62    var arrayLike = @toObject(items, "TypedArray.from requires an array-like object - not null or undefined");
    6363
    64     let iteratorMethod = items.@iteratorSymbol;
     64    var iteratorMethod = items.@iteratorSymbol;
    6565    if (iteratorMethod != null) {
    6666        if (typeof iteratorMethod !== "function")
    6767            @throwTypeError("TypedArray.from requires that the property of the first argument, items[Symbol.iterator], when exists, be a function");
    6868
    69         let accumulator = [];
     69        var accumulator = [];
    7070
    71         let k = 0;
    72         let iterator = iteratorMethod.@call(items);
     71        var k = 0;
     72        var iterator = iteratorMethod.@call(items);
    7373
    7474        // Since for-of loop once more looks up the @@iterator property of a given iterable,
    7575        // it could be observable if the user defines a getter for @@iterator.
    7676        // To avoid this situation, we define a wrapper object that @@iterator just returns a given iterator.
    77         let wrapper = {};
     77        var wrapper = {};
    7878        wrapper.@iteratorSymbol = function() { return iterator; }
    7979
    80         for (let value of wrapper) {
     80        for (var value of wrapper) {
    8181            if (mapFn)
    8282                @putByValDirect(accumulator, k, thisArg === @undefined ? mapFn(value, k) : mapFn.@call(thisArg, value, k));
     
    8686        }
    8787
    88         let constructFunction = @getByIdDirectPrivate(this, "allocateTypedArray");
     88        var constructFunction = @getByIdDirectPrivate(this, "allocateTypedArray");
    8989        if (constructFunction === @undefined)
    9090            @throwTypeError("TypedArray.from requires its this argument subclass a TypedArray constructor");
    9191
    92         let result = constructFunction(k);
     92        var result = constructFunction(k);
    9393
    94         for (let i = 0; i < k; i++)
     94        for (var i = 0; i < k; i++)
    9595            result[i] = accumulator[i];
    9696
     
    9999    }
    100100
    101     let arrayLikeLength = @toLength(arrayLike.length);
     101    var arrayLikeLength = @toLength(arrayLike.length);
    102102
    103     let constructFunction = @getByIdDirectPrivate(this, "allocateTypedArray");
     103    var constructFunction = @getByIdDirectPrivate(this, "allocateTypedArray");
    104104    if (constructFunction === @undefined)
    105105        @throwTypeError("this does not subclass a TypedArray constructor");
    106106
    107     let result = constructFunction(arrayLikeLength);
     107    var result = constructFunction(arrayLikeLength);
    108108
    109     let k = 0;
     109    var k = 0;
    110110    while (k < arrayLikeLength) {
    111         let value = arrayLike[k];
     111        var value = arrayLike[k];
    112112        if (mapFn)
    113113            result[k] = thisArg === @undefined ? mapFn(value, k) : mapFn.@call(thisArg, value, k);
  • trunk/Source/JavaScriptCore/builtins/TypedArrayPrototype.js

    r254252 r254418  
    3636{
    3737    "use strict";
    38     let constructor = value.constructor;
     38    var constructor = value.constructor;
    3939    if (constructor === @undefined)
    4040        return @typedArrayGetOriginalConstructor(value);
     
    6161        return undefinedValue;
    6262
    63     let int = @toInteger(value);
     63    var int = @toInteger(value);
    6464    if (int < 0) {
    6565        int += length;
     
    9090    "use strict";
    9191
    92     let length = @typedArrayLength(this);
    93 
    94     let start = @argument(1);
    95     let end = @argument(2);
     92    var length = @typedArrayLength(this);
     93
     94    var start = @argument(1);
     95    var end = @argument(2);
    9696
    9797    start = @typedArrayClampArgumentToStartOrEnd(start, length, 0);
    9898    end = @typedArrayClampArgumentToStartOrEnd(end, length, length);
    9999
    100     for (let i = start; i < end; i++)
     100    for (var i = start; i < end; i++)
    101101        this[i] = value;
    102102    return this;
     
    113113
    114114    for (var i = 0; i < length; i++) {
    115         let elem = this[i];
     115        var elem = this[i];
    116116        if (callback.@call(thisArg, elem, i, this))
    117117            return elem;
     
    239239        @throwTypeError("|this| should be a typed array view");
    240240
    241     let start = @toInteger(begin);
    242     let finish;
     241    var start = @toInteger(begin);
     242    var finish;
    243243    if (end !== @undefined)
    244244        finish = @toInteger(end);
    245245
    246     let constructor = @typedArraySpeciesConstructor(this);
     246    var constructor = @typedArraySpeciesConstructor(this);
    247247
    248248    return @typedArraySubarrayCreate.@call(this, start, finish, constructor);
Note: See TracChangeset for help on using the changeset viewer.