Commit 95f6b726 authored by yangguo's avatar yangguo Committed by Commit bot

Wrap harmony implementations in functions.

R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/1100673002

Cr-Commit-Position: refs/heads/master@{#27955}
parent 998e9416
......@@ -258,10 +258,10 @@ class AstValue : public ZoneObject {
F(next, "next") \
F(proto, "__proto__") \
F(prototype, "prototype") \
F(reflect_apply, "ReflectApply") \
F(reflect_construct, "ReflectConstruct") \
F(spread_arguments, "SpreadArguments") \
F(spread_iterable, "SpreadIterable") \
F(reflect_apply, "$reflectApply") \
F(reflect_construct, "$reflectConstruct") \
F(spread_arguments, "$spreadArguments") \
F(spread_iterable, "$spreadIterable") \
F(this, "this") \
F(throw_iterator_result_not_an_object, "ThrowIteratorResultNotAnObject") \
F(to_string, "ToString") \
......
......@@ -1727,14 +1727,12 @@ void Genesis::InitializeGlobal_harmony_reflect() {
Handle<JSObject> builtins(native_context()->builtins());
// Install references to functions of the Reflect object
if (FLAG_harmony_reflect || FLAG_harmony_spreadcalls) {
Handle<JSFunction> apply =
InstallFunction(builtins, "ReflectApply", JS_OBJECT_TYPE,
JSObject::kHeaderSize, MaybeHandle<JSObject>(),
Builtins::kReflectApply);
Handle<JSFunction> construct =
InstallFunction(builtins, "ReflectConstruct", JS_OBJECT_TYPE,
JSObject::kHeaderSize, MaybeHandle<JSObject>(),
Builtins::kReflectConstruct);
Handle<JSFunction> apply = InstallFunction(
builtins, "$reflectApply", JS_OBJECT_TYPE, JSObject::kHeaderSize,
MaybeHandle<JSObject>(), Builtins::kReflectApply);
Handle<JSFunction> construct = InstallFunction(
builtins, "$reflectConstruct", JS_OBJECT_TYPE, JSObject::kHeaderSize,
MaybeHandle<JSObject>(), Builtins::kReflectConstruct);
if (FLAG_vector_ics) {
// Apply embeds an IC, so we need a type vector of size 1 in the shared
// function info.
......
......@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function() {
'use strict';
// This file relies on the fact that the following declaration has been made
// in runtime.js:
// var $Array = global.Array;
%CheckIsBootstrapping();
var GlobalArray = global.Array;
// -------------------------------------------------------------------
......@@ -47,15 +49,11 @@ function ArrayIncludes(searchElement, fromIndex) {
// -------------------------------------------------------------------
function HarmonyArrayIncludesExtendArrayPrototype() {
%CheckIsBootstrapping();
%FunctionSetLength(ArrayIncludes, 1);
%FunctionSetLength(ArrayIncludes, 1);
// Set up the non-enumerable functions on the Array prototype object.
InstallFunctions($Array.prototype, DONT_ENUM, [
"includes", ArrayIncludes
]);
}
// Set up the non-enumerable functions on the Array prototype object.
InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"includes", ArrayIncludes
]);
HarmonyArrayIncludesExtendArrayPrototype();
})();
......@@ -2,11 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function() {
'use strict';
// This file relies on the fact that the following declaration has been made
// in runtime.js:
// var $Array = global.Array;
%CheckIsBootstrapping();
var GlobalArray = global.Array;
var GlobalSymbol = global.Symbol;
// -------------------------------------------------------------------
......@@ -208,34 +211,24 @@ function ArrayOf() {
// -------------------------------------------------------------------
function HarmonyArrayExtendSymbolPrototype() {
%CheckIsBootstrapping();
InstallConstants(global.Symbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"isConcatSpreadable", symbolIsConcatSpreadable
]);
}
InstallConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"isConcatSpreadable", symbolIsConcatSpreadable
]);
HarmonyArrayExtendSymbolPrototype();
%FunctionSetLength(ArrayFrom, 1);
function HarmonyArrayExtendArrayPrototype() {
%CheckIsBootstrapping();
// Set up non-enumerable functions on the Array object.
InstallFunctions(GlobalArray, DONT_ENUM, [
"from", ArrayFrom,
"of", ArrayOf
]);
%FunctionSetLength(ArrayFrom, 1);
// Set up non-enumerable functions on the Array object.
InstallFunctions($Array, DONT_ENUM, [
"from", ArrayFrom,
"of", ArrayOf
]);
// Set up the non-enumerable functions on the Array prototype object.
InstallFunctions($Array.prototype, DONT_ENUM, [
"find", ArrayFind,
"findIndex", ArrayFindIndex,
"fill", ArrayFill
]);
}
// Set up the non-enumerable functions on the Array prototype object.
InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
"find", ArrayFind,
"findIndex", ArrayFindIndex,
"fill", ArrayFill
]);
HarmonyArrayExtendArrayPrototype();
})();
......@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function() {
'use strict';
var $Reflect = global.Reflect;
%CheckIsBootstrapping();
function SetUpReflect() {
%CheckIsBootstrapping();
var GlobalReflect = global.Reflect;
InstallFunctions($Reflect, DONT_ENUM, [
"apply", ReflectApply,
"construct", ReflectConstruct
]);
}
InstallFunctions(GlobalReflect, DONT_ENUM, [
"apply", $reflectApply,
"construct", $reflectConstruct
]);
SetUpReflect();
})();
......@@ -2,9 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function() {
'use strict';
var $RegExp = global.RegExp;
%CheckIsBootstrapping();
var GlobalRegExp = global.RegExp;
// -------------------------------------------------------------------
......@@ -24,12 +28,8 @@ function RegExpGetFlags() {
return result;
}
function ExtendRegExpPrototype() {
%CheckIsBootstrapping();
%DefineAccessorPropertyUnchecked($RegExp.prototype, 'flags', RegExpGetFlags,
null, DONT_ENUM);
%SetNativeFlag(RegExpGetFlags);
}
%DefineAccessorPropertyUnchecked(GlobalRegExp.prototype, 'flags',
RegExpGetFlags, null, DONT_ENUM);
%SetNativeFlag(RegExpGetFlags);
ExtendRegExpPrototype();
})();
......@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var $spreadArguments;
var $spreadIterable;
(function() {
'use strict';
function SpreadArguments() {
......@@ -31,3 +36,8 @@ function SpreadIterable(collection) {
}
return args;
}
$spreadArguments = SpreadArguments;
$spreadIterable = SpreadIterable;
})();
......@@ -2,15 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function() {
"use strict";
function HarmonyToStringExtendSymbolPrototype() {
%CheckIsBootstrapping();
%CheckIsBootstrapping();
var GlobalSymbol = global.Symbol;
InstallConstants(global.Symbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"toStringTag", symbolToStringTag
]);
}
InstallConstants(GlobalSymbol, [
// TODO(dslomov, caitp): Move to symbol.js when shipping
"toStringTag", symbolToStringTag
]);
HarmonyToStringExtendSymbolPrototype();
})();
......@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function() {
"use strict";
// This file relies on the fact that the following declaration has been made
// in runtime.js:
// var $Array = global.Array;
%CheckIsBootstrapping();
// -------------------------------------------------------------------
......@@ -72,10 +72,7 @@ endmacro
TYPED_ARRAYS(TYPED_ARRAY_HARMONY_ADDITIONS)
function HarmonyTypedArrayExtendPrototypes() {
macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
%CheckIsBootstrapping();
// Set up non-enumerable functions on the object.
InstallFunctions(global.NAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [
"of", NAMEOf
......@@ -87,7 +84,6 @@ macro EXTEND_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
]);
endmacro
TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
}
TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
HarmonyTypedArrayExtendPrototypes();
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment