Skip to content

Commit

Permalink
Rename MapInstance to JsMap (#1601)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma authored Jul 30, 2023
1 parent c52ff7f commit 5c19933
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
11 changes: 2 additions & 9 deletions Jint/Native/Map/MapInstance.cs → Jint/Native/Map/JsMap.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using Jint.Native.Object;
using Jint.Runtime;
using Jint.Runtime.Descriptors;

namespace Jint.Native.Map;

internal sealed class MapInstance : ObjectInstance
internal sealed class JsMap : ObjectInstance
{
private readonly Realm _realm;
internal readonly OrderedDictionary<JsValue, JsValue> _map;

public MapInstance(Engine engine, Realm realm) : base(engine)
public JsMap(Engine engine, Realm realm) : base(engine)
{
_realm = realm;
_map = new OrderedDictionary<JsValue, JsValue>(SameValueZeroComparer.Instance);
Expand Down Expand Up @@ -101,10 +100,4 @@ internal ObjectInstance Values()
{
return _realm.Intrinsics.MapIteratorPrototype.ConstructValueIterator(this);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal uint GetSize()
{
return (uint) _map.Count;
}
}
4 changes: 2 additions & 2 deletions Jint/Native/Map/MapConstructor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override ObjectInstance Construct(JsValue[] arguments, JsValue newTarget)
var map = OrdinaryCreateFromConstructor(
newTarget,
static intrinsics => intrinsics.Map.PrototypeObject,
static (Engine engine, Realm realm, object? _) => new MapInstance(engine, realm));
static (Engine engine, Realm realm, object? _) => new JsMap(engine, realm));

if (arguments.Length > 0 && !arguments[0].IsNullOrUndefined())
{
Expand All @@ -84,7 +84,7 @@ private JsValue GroupBy(JsValue thisObject, JsValue[] arguments)
var items = arguments.At(0);
var callbackfn = arguments.At(1);
var grouping = GroupByHelper.GroupBy(_engine, _realm, items, callbackfn, mapMode: true);
var map = (MapInstance) Construct(_realm.Intrinsics.Map);
var map = (JsMap) Construct(_realm.Intrinsics.Map);
foreach (var pair in grouping)
{
map.MapSet(pair.Key, pair.Value);
Expand Down
8 changes: 4 additions & 4 deletions Jint/Native/Map/MapIteratorPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected override void Initialize()
SetSymbols(symbols);
}

internal IteratorInstance ConstructEntryIterator(MapInstance map)
internal IteratorInstance ConstructEntryIterator(JsMap map)
{
var instance = new MapIterator(Engine, map)
{
Expand All @@ -45,7 +45,7 @@ internal IteratorInstance ConstructEntryIterator(MapInstance map)
return instance;
}

internal IteratorInstance ConstructKeyIterator(MapInstance map)
internal IteratorInstance ConstructKeyIterator(JsMap map)
{
var instance = new IteratorInstance.EnumerableIterator(Engine, map._map.Keys)
{
Expand All @@ -55,7 +55,7 @@ internal IteratorInstance ConstructKeyIterator(MapInstance map)
return instance;
}

internal IteratorInstance ConstructValueIterator(MapInstance map)
internal IteratorInstance ConstructValueIterator(JsMap map)
{
var instance = new IteratorInstance.EnumerableIterator(Engine, map._map.Values)
{
Expand All @@ -71,7 +71,7 @@ private sealed class MapIterator : IteratorInstance

private int _position;

public MapIterator(Engine engine, MapInstance map) : base(engine)
public MapIterator(Engine engine, JsMap map) : base(engine)
{
_map = map._map;
_position = 0;
Expand Down
4 changes: 2 additions & 2 deletions Jint/Native/Map/MapPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ private ObjectInstance Values(JsValue thisObject, JsValue[] arguments)
return map.Values();
}

private MapInstance AssertMapInstance(JsValue thisObject)
private JsMap AssertMapInstance(JsValue thisObject)
{
if (thisObject is MapInstance map)
if (thisObject is JsMap map)
{
return map;
}
Expand Down

0 comments on commit 5c19933

Please sign in to comment.