var $Map = global.Map;
-// Used by harmony-templates.js
-var $MapGet;
-var $MapSet;
-
-
(function() {
+%CheckIsBootstrapping();
+
function HashToEntry(table, hash, numBuckets) {
var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets);
}
-// -------------------------------------------------------------------
+%SetCode($Set, SetConstructor);
+%FunctionSetPrototype($Set, new $Object());
+%AddNamedProperty($Set.prototype, "constructor", $Set, DONT_ENUM);
+%AddNamedProperty(
+ $Set.prototype, symbolToStringTag, "Set", DONT_ENUM | READ_ONLY);
-function SetUpSet() {
- %CheckIsBootstrapping();
-
- %SetCode($Set, SetConstructor);
- %FunctionSetPrototype($Set, new $Object());
- %AddNamedProperty($Set.prototype, "constructor", $Set, DONT_ENUM);
- %AddNamedProperty(
- $Set.prototype, symbolToStringTag, "Set", DONT_ENUM | READ_ONLY);
-
- %FunctionSetLength(SetForEach, 1);
-
- // Set up the non-enumerable functions on the Set prototype object.
- InstallGetter($Set.prototype, "size", SetGetSize);
- InstallFunctions($Set.prototype, DONT_ENUM, $Array(
- "add", SetAdd,
- "has", SetHas,
- "delete", SetDelete,
- "clear", SetClearJS,
- "forEach", SetForEach
- ));
-}
+%FunctionSetLength(SetForEach, 1);
-SetUpSet();
+// Set up the non-enumerable functions on the Set prototype object.
+InstallGetter($Set.prototype, "size", SetGetSize);
+InstallFunctions($Set.prototype, DONT_ENUM, $Array(
+ "add", SetAdd,
+ "has", SetHas,
+ "delete", SetDelete,
+ "clear", SetClearJS,
+ "forEach", SetForEach
+));
// -------------------------------------------------------------------
}
-// -------------------------------------------------------------------
-
-function SetUpMap() {
- %CheckIsBootstrapping();
-
- %SetCode($Map, MapConstructor);
- %FunctionSetPrototype($Map, new $Object());
- %AddNamedProperty($Map.prototype, "constructor", $Map, DONT_ENUM);
- %AddNamedProperty(
- $Map.prototype, symbolToStringTag, "Map", DONT_ENUM | READ_ONLY);
-
- %FunctionSetLength(MapForEach, 1);
-
- // Set up the non-enumerable functions on the Map prototype object.
- InstallGetter($Map.prototype, "size", MapGetSize);
- InstallFunctions($Map.prototype, DONT_ENUM, $Array(
- "get", MapGet,
- "set", MapSet,
- "has", MapHas,
- "delete", MapDelete,
- "clear", MapClearJS,
- "forEach", MapForEach
- ));
-
- $MapGet = MapGet;
- $MapSet = MapSet;
-}
-
-SetUpMap();
+%SetCode($Map, MapConstructor);
+%FunctionSetPrototype($Map, new $Object());
+%AddNamedProperty($Map.prototype, "constructor", $Map, DONT_ENUM);
+%AddNamedProperty(
+ $Map.prototype, symbolToStringTag, "Map", DONT_ENUM | READ_ONLY);
+
+%FunctionSetLength(MapForEach, 1);
+
+// Set up the non-enumerable functions on the Map prototype object.
+InstallGetter($Map.prototype, "size", MapGetSize);
+InstallFunctions($Map.prototype, DONT_ENUM, $Array(
+ "get", MapGet,
+ "set", MapSet,
+ "has", MapHas,
+ "delete", MapDelete,
+ "clear", MapClearJS,
+ "forEach", MapForEach
+));
})();
"use strict";
+// Called from a desugaring in the parser.
+var GetTemplateCallSite;
+
+(function() {
+
+%CheckIsBootstrapping();
+
var callSiteCache = new $Map;
+var mapGetFn = $Map.prototype.get;
+var mapSetFn = $Map.prototype.set;
+
function SameCallSiteElements(rawStrings, other) {
var length = rawStrings.length;
function GetCachedCallSite(siteObj, hash) {
- var obj = %_CallFunction(callSiteCache, hash, $MapGet);
+ var obj = %_CallFunction(callSiteCache, hash, mapGetFn);
if (IS_UNDEFINED(obj)) return;
function SetCachedCallSite(siteObj, hash) {
- var obj = %_CallFunction(callSiteCache, hash, $MapGet);
+ var obj = %_CallFunction(callSiteCache, hash, mapGetFn);
var array;
if (IS_UNDEFINED(obj)) {
array = new InternalArray(1);
array[0] = siteObj;
- %_CallFunction(callSiteCache, hash, array, $MapSet);
+ %_CallFunction(callSiteCache, hash, array, mapSetFn);
} else {
obj.push(siteObj);
}
}
-function GetTemplateCallSite(siteObj, rawStrings, hash) {
+GetTemplateCallSite = function(siteObj, rawStrings, hash) {
var cached = GetCachedCallSite(rawStrings, hash);
if (!IS_UNDEFINED(cached)) return cached;
return SetCachedCallSite(%ObjectFreeze(siteObj), hash);
}
+
+})();