Skip to content

Commit

Permalink
Internalize some members (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma authored Feb 23, 2023
1 parent 695825c commit c2bc38e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/Esprima/Ast/ArrayPattern.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.CompilerServices;
using Esprima.Utils;

namespace Esprima.Ast;

Expand Down
1 change: 0 additions & 1 deletion src/Esprima/Ast/ExportDefaultDeclaration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.CompilerServices;
using Esprima.Utils;

namespace Esprima.Ast;

Expand Down
15 changes: 7 additions & 8 deletions src/Esprima/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static partial class Character

// https://tc39.github.io/ecma262/#sec-line-terminators

public static bool IsLineTerminator(char ch)
internal static bool IsLineTerminator(char ch)
{
return ch == 10
|| ch == 13
Expand All @@ -31,29 +31,29 @@ public static bool IsLineTerminator(char ch)

// https://tc39.github.io/ecma262/#sec-white-space

public static bool IsWhiteSpace(char ch)
internal static bool IsWhiteSpace(char ch)
{
return (_characterData[ch] & (byte) CharacterMask.WhiteSpace) != 0;
}

// https://tc39.github.io/ecma262/#sec-names-and-keywords

public static bool IsIdentifierStart(char ch)
internal static bool IsIdentifierStart(char ch)
{
return (_characterData[ch] & (byte) CharacterMask.IdentifierStart) != 0;
}

public static bool IsIdentifierStart(string s, int index)
internal static bool IsIdentifierStart(string s, int index)
{
return IsIdentifierStartUnicodeCategory(CharUnicodeInfo.GetUnicodeCategory(s, index));
}

public static bool IsIdentifierPart(char ch)
internal static bool IsIdentifierPart(char ch)
{
return (_characterData[ch] & (byte) CharacterMask.IdentifierPart) != 0;
}

public static bool IsIdentifierPart(string s, int index)
internal static bool IsIdentifierPart(string s, int index)
{
return IsIdentifierPartUnicodeCategory(CharUnicodeInfo.GetUnicodeCategory(s, index));
}
Expand All @@ -72,12 +72,11 @@ public static bool IsIdentifierPart(string s, int index)

public static bool IsOctalDigit(char cp) => IsInRange(cp, '0', '7');

public static string FromCodePoint(int cp) => char.ConvertFromUtf32(cp);
internal static string FromCodePoint(int cp) => char.ConvertFromUtf32(cp);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool IsInRange(char c, char min, char max) => c - (uint) min <= max - (uint) min;


internal static bool IsIdentifierStartUnicodeCategory(UnicodeCategory cat)
{
return IsLetterChar(cat) || cat is UnicodeCategory.ModifierLetter or UnicodeCategory.NonSpacingMark;
Expand Down
2 changes: 1 addition & 1 deletion src/Esprima/Messages.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Esprima;

// Error messages should be identical to V8.
public static class Messages
internal static class Messages
{
public const string ArgumentsNotAllowedInClassField = "'arguments' is not allowed in class field initializer or static initialization block";
public const string AsyncFunctionInSingleStatementContext = "Async functions can only be declared at the top level or inside a block.";
Expand Down
3 changes: 1 addition & 2 deletions src/Esprima/Utils/AstToJsonConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections;
using System.Globalization;
using System.Numerics;
using System.Reflection;
Expand Down

0 comments on commit c2bc38e

Please sign in to comment.