Skip to content

Commit 20fbc2a

Browse files
committed
Merge branch 'main' into feat-class-relaxed-field-declaration-rhs
2 parents 9fe5a1f + df931b6 commit 20fbc2a

File tree

10 files changed

+356
-651
lines changed

10 files changed

+356
-651
lines changed

src/WattleScript.Interpreter/DataStructs/LinkedListArrayIndex.cs

Lines changed: 0 additions & 127 deletions
This file was deleted.

src/WattleScript.Interpreter/DataStructs/LinkedListIndex.cs

Lines changed: 0 additions & 120 deletions
This file was deleted.

src/WattleScript.Interpreter/DataStructs/Slice.cs

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,22 @@ namespace WattleScript.Interpreter.DataStructs
99
/// Provides facility to create a "sliced" view over an existing IList<typeparamref name="T"/>
1010
/// </summary>
1111
/// <typeparam name="T">The type of the items contained in the collection</typeparam>
12-
internal class Slice<T> : IEnumerable<T>, IList<T>
12+
internal class Slice<T> : IList<T>
1313
{
1414
IList<T> m_SourceList;
1515
int m_From, m_Length;
16-
bool m_Reversed;
1716

1817
/// <summary>
1918
/// Initializes a new instance of the <see cref="Slice{T}"/> class.
2019
/// </summary>
2120
/// <param name="list">The list to apply the Slice view on</param>
2221
/// <param name="from">From which index</param>
2322
/// <param name="length">The length of the slice</param>
24-
/// <param name="reversed">if set to <c>true</c> the view is in reversed order.</param>
25-
public Slice(IList<T> list, int from, int length, bool reversed)
23+
public Slice(IList<T> list, int from, int length)
2624
{
2725
m_SourceList = list;
2826
m_From = from;
2927
m_Length = length;
30-
m_Reversed = reversed;
3128
}
3229

3330
/// <summary>
@@ -37,60 +34,36 @@ public Slice(IList<T> list, int from, int length, bool reversed)
3734
/// <returns></returns>
3835
public T this[int index]
3936
{
40-
get
41-
{
42-
return m_SourceList[CalcRealIndex(index)];
43-
}
44-
set
45-
{
46-
m_SourceList[CalcRealIndex(index)] = value;
47-
}
37+
get => m_SourceList[CalcRealIndex(index)];
38+
set => m_SourceList[CalcRealIndex(index)] = value;
4839
}
4940

5041
/// <summary>
5142
/// Gets the index from which the slice starts
5243
/// </summary>
53-
public int From
54-
{
55-
get { return m_From; }
56-
}
44+
public int From => m_From;
5745

5846
/// <summary>
5947
/// Gets the number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />.
6048
/// </summary>
6149
/// <returns>The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />.</returns>
62-
public int Count
63-
{
64-
get { return m_Length; }
65-
}
66-
50+
public int Count => m_Length;
51+
6752
/// <summary>
68-
/// Gets a value indicating whether this <see cref="Slice{T}"/> operates in a reversed direction.
53+
/// Gets a value indicating whether the <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only.
6954
/// </summary>
70-
/// <value>
71-
/// <c>true</c> if this <see cref="Slice{T}"/> operates in a reversed direction; otherwise, <c>false</c>.
72-
/// </value>
73-
public bool Reversed
74-
{
75-
get { return m_Reversed; }
76-
}
77-
55+
/// <returns>true if the <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only; otherwise, false.</returns>
56+
public bool IsReadOnly => true;
57+
7858
/// <summary>
7959
/// Calculates the real index in the underlying collection
8060
/// </summary>
8161
private int CalcRealIndex(int index)
8262
{
8363
if (index < 0 || index >= m_Length)
84-
throw new ArgumentOutOfRangeException("index");
85-
86-
if (m_Reversed)
87-
{
88-
return m_From + m_Length - index - 1;
89-
}
90-
else
91-
{
92-
return m_From + index;
93-
}
64+
throw new ArgumentOutOfRangeException(nameof(index));
65+
66+
return m_From + index;
9467
}
9568

9669
/// <summary>
@@ -224,15 +197,6 @@ public void CopyTo(T[] array, int arrayIndex)
224197
array[i + arrayIndex] = this[i];
225198
}
226199

227-
/// <summary>
228-
/// Gets a value indicating whether the <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only.
229-
/// </summary>
230-
/// <returns>true if the <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only; otherwise, false.</returns>
231-
public bool IsReadOnly
232-
{
233-
get { return true; }
234-
}
235-
236200
/// <summary>
237201
/// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1" />.
238202
/// </summary>

src/WattleScript.Interpreter/DataTypes/CallbackArguments.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,13 @@ public string AsStringUsingMeta(ScriptExecutionContext executionContext, int arg
221221
/// <returns></returns>
222222
public CallbackArguments SkipMethodCall()
223223
{
224-
if (this.IsMethodCall)
224+
if (IsMethodCall)
225225
{
226-
Slice<DynValue> slice = new Slice<DynValue>(m_Args, 1, m_Args.Count - 1, false);
226+
Slice<DynValue> slice = new Slice<DynValue>(m_Args, 1, m_Args.Count - 1);
227227
return new CallbackArguments(slice, m_implicitThis, false);
228228
}
229-
else return this;
229+
230+
return this;
230231
}
231232
}
232233
}

0 commit comments

Comments
 (0)