| Index: src/collection.js | 
| diff --git a/src/collection.js b/src/collection.js | 
| index 9054187a12d0372ef1e028569a197059579f26ba..f2b481b8e73e4b85bb08a73636865e1806de3ccc 100644 | 
| --- a/src/collection.js | 
| +++ b/src/collection.js | 
| @@ -113,8 +113,29 @@ function SetClear() { | 
| throw MakeTypeError('incompatible_method_receiver', | 
| ['Set.prototype.clear', this]); | 
| } | 
| -  // Replace the internal table with a new empty table. | 
| -  %SetInitialize(this); | 
| +  %SetClear(this); | 
| +} | 
| + | 
| + | 
| +function SetForEach(f, receiver) { | 
| +  if (!IS_SET(this)) { | 
| +    throw MakeTypeError('incompatible_method_receiver', | 
| +                        ['Set.prototype.forEach', this]); | 
| +  } | 
| + | 
| +  if (!IS_SPEC_FUNCTION(f)) { | 
| +    throw MakeTypeError('called_non_callable', [f]); | 
| +  } | 
| + | 
| +  var iterator = %SetCreateIterator(this, ITERATOR_KIND_VALUES); | 
| +  var entry; | 
| +  try { | 
| +    while (!(entry = %SetIteratorNext(iterator)).done) { | 
| +      %_CallFunction(receiver, entry.value, entry.value, this, f); | 
| +    } | 
| +  } finally { | 
| +    %SetIteratorClose(iterator); | 
| +  } | 
| } | 
|  | 
|  | 
| @@ -127,13 +148,16 @@ function SetUpSet() { | 
| %FunctionSetPrototype($Set, new $Object()); | 
| %SetProperty($Set.prototype, "constructor", $Set, DONT_ENUM); | 
|  | 
| +  %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", SetClear | 
| +    "clear", SetClear, | 
| +    "forEach", SetForEach | 
| )); | 
| } | 
|  | 
| @@ -202,8 +226,29 @@ function MapClear() { | 
| throw MakeTypeError('incompatible_method_receiver', | 
| ['Map.prototype.clear', this]); | 
| } | 
| -  // Replace the internal table with a new empty table. | 
| -  %MapInitialize(this); | 
| +  %MapClear(this); | 
| +} | 
| + | 
| + | 
| +function MapForEach(f, receiver) { | 
| +  if (!IS_MAP(this)) { | 
| +    throw MakeTypeError('incompatible_method_receiver', | 
| +                        ['Map.prototype.forEach', this]); | 
| +  } | 
| + | 
| +  if (!IS_SPEC_FUNCTION(f)) { | 
| +    throw MakeTypeError('called_non_callable', [f]); | 
| +  } | 
| + | 
| +  var iterator = %MapCreateIterator(this, ITERATOR_KIND_ENTRIES); | 
| +  var entry; | 
| +  try { | 
| +    while (!(entry = %MapIteratorNext(iterator)).done) { | 
| +      %_CallFunction(receiver, entry.value[1], entry.value[0], this, f); | 
| +    } | 
| +  } finally { | 
| +    %MapIteratorClose(iterator); | 
| +  } | 
| } | 
|  | 
|  | 
| @@ -216,6 +261,8 @@ function SetUpMap() { | 
| %FunctionSetPrototype($Map, new $Object()); | 
| %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM); | 
|  | 
| +  %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( | 
| @@ -223,7 +270,8 @@ function SetUpMap() { | 
| "set", MapSet, | 
| "has", MapHas, | 
| "delete", MapDelete, | 
| -    "clear", MapClear | 
| +    "clear", MapClear, | 
| +    "forEach", MapForEach | 
| )); | 
| } | 
|  | 
|  |