Browse Source

Use global usings and aliases for Esprima namespaces and types (#1824)

* Use global usings for Esprima namespaces and Nodes
* alias operators
* add SourceLocation alias
* cleanup Directory.Build.props
Marko Lahma 1 năm trước cách đây
mục cha
commit
aca8fb3d62
100 tập tin đã thay đổi với 260 bổ sung362 xóa
  1. 1 0
      .gitignore
  2. 30 0
      Directory.Build.props
  3. 0 1
      Jint.Benchmark/DromaeoBenchmark.cs
  4. 0 2
      Jint.Benchmark/EngineComparisonBenchmark.cs
  5. 0 2
      Jint.Benchmark/EngineConstructionBenchmark.cs
  6. 6 0
      Jint.Benchmark/Jint.Benchmark.csproj
  7. 0 1
      Jint.Benchmark/ObjectAccessBenchmark.cs
  8. 0 1
      Jint.Benchmark/ShadowRealmBenchmark.cs
  9. 0 1
      Jint.Benchmark/SingleScriptBenchmark.cs
  10. 0 1
      Jint.Repl/Program.cs
  11. 0 2
      Jint.Tests.CommonScripts/ConcurrencyTest.cs
  12. 2 0
      Jint.Tests.PublicInterface/ModuleLoaderTests.cs
  13. 0 1
      Jint.Tests.PublicInterface/RavenApiUsageTests.cs
  14. 0 2
      Jint.Tests.Test262/State.cs
  15. 1 2
      Jint.Tests.Test262/Test262Test.cs
  16. 4 6
      Jint.Tests/Parser/JavascriptParserTests.cs
  17. 1 3
      Jint.Tests/Runtime/Debugger/CallStackTests.cs
  18. 1 2
      Jint.Tests/Runtime/Debugger/EvaluateTests.cs
  19. 2 4
      Jint.Tests/Runtime/Debugger/StepFlowTests.cs
  20. 1 2
      Jint.Tests/Runtime/Debugger/TestHelpers.cs
  21. 0 1
      Jint.Tests/Runtime/EngineTests.ScriptPreparation.cs
  22. 0 2
      Jint.Tests/Runtime/EngineTests.cs
  23. 0 1
      Jint.Tests/Runtime/ErrorTests.cs
  24. 2 0
      Jint.Tests/Runtime/ModuleTests.cs
  25. 0 32
      Jint/Directory.Build.props
  26. 10 12
      Jint/Engine.Ast.cs
  27. 3 3
      Jint/Engine.Modules.cs
  28. 1 3
      Jint/Engine.cs
  29. 22 25
      Jint/EsprimaExtensions.cs
  30. 11 12
      Jint/HoistingScope.cs
  31. 0 1
      Jint/JsValueExtensions.cs
  32. 2 5
      Jint/Native/Function/ClassDefinition.cs
  33. 2 5
      Jint/Native/Function/EvalFunction.cs
  34. 0 1
      Jint/Native/Function/Function.cs
  35. 0 2
      Jint/Native/Function/FunctionInstance.Dynamic.cs
  36. 0 1
      Jint/Native/Function/ScriptFunction.cs
  37. 3 4
      Jint/Native/Generator/GeneratorInstance.cs
  38. 0 1
      Jint/Native/Global/GlobalObject.cs
  39. 0 1
      Jint/Native/JsRegExp.cs
  40. 0 1
      Jint/Native/JsTypedArray.cs
  41. 0 1
      Jint/Native/Json/JsonParser.cs
  42. 0 1
      Jint/Native/PrivateName.cs
  43. 0 1
      Jint/Native/RegExp/RegExpConstructor.cs
  44. 0 3
      Jint/Native/ShadowRealm/ShadowRealm.cs
  45. 1 3
      Jint/Runtime/CallStack/CallStackElement.cs
  46. 2 4
      Jint/Runtime/CallStack/JintCallStack.cs
  47. 1 3
      Jint/Runtime/Completion.cs
  48. 3 5
      Jint/Runtime/Debugger/CallFrame.cs
  49. 1 2
      Jint/Runtime/Debugger/DebugCallStack.cs
  50. 5 7
      Jint/Runtime/Debugger/DebugHandler.cs
  51. 4 6
      Jint/Runtime/Debugger/DebugInformation.cs
  52. 1 2
      Jint/Runtime/Environments/FunctionEnvironment.cs
  53. 1 1
      Jint/Runtime/Environments/ModuleEnvironment.cs
  54. 0 1
      Jint/Runtime/Environments/PrivateEnvironment.cs
  55. 2 4
      Jint/Runtime/ExceptionHelper.cs
  56. 1 0
      Jint/Runtime/Host.cs
  57. 2 3
      Jint/Runtime/IScriptOrModule.Extensions.cs
  58. 1 0
      Jint/Runtime/Interop/DefaultTypeConverter.cs
  59. 0 1
      Jint/Runtime/Interpreter/EvaluationContext.cs
  60. 0 1
      Jint/Runtime/Interpreter/Expressions/BindingPatternAssignmentExpression.cs
  61. 1 2
      Jint/Runtime/Interpreter/Expressions/JintArrayExpression.cs
  62. 0 1
      Jint/Runtime/Interpreter/Expressions/JintArrowFunctionExpression.cs
  63. 33 32
      Jint/Runtime/Interpreter/Expressions/JintAssignmentExpression.cs
  64. 0 1
      Jint/Runtime/Interpreter/Expressions/JintAwaitExpression.cs
  65. 45 44
      Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs
  66. 3 4
      Jint/Runtime/Interpreter/Expressions/JintCallExpression.cs
  67. 0 1
      Jint/Runtime/Interpreter/Expressions/JintClassExpression.cs
  68. 0 2
      Jint/Runtime/Interpreter/Expressions/JintConditionalExpression.cs
  69. 0 1
      Jint/Runtime/Interpreter/Expressions/JintConstantExpression.cs
  70. 28 29
      Jint/Runtime/Interpreter/Expressions/JintExpression.cs
  71. 0 1
      Jint/Runtime/Interpreter/Expressions/JintFunctionExpression.cs
  72. 0 1
      Jint/Runtime/Interpreter/Expressions/JintIdentifierExpression.cs
  73. 0 1
      Jint/Runtime/Interpreter/Expressions/JintImportExpression.cs
  74. 0 2
      Jint/Runtime/Interpreter/Expressions/JintLiteralExpression.cs
  75. 0 1
      Jint/Runtime/Interpreter/Expressions/JintLogicalAndExpression.cs
  76. 0 1
      Jint/Runtime/Interpreter/Expressions/JintLogicalOrExpression.cs
  77. 1 2
      Jint/Runtime/Interpreter/Expressions/JintMemberExpression.cs
  78. 0 1
      Jint/Runtime/Interpreter/Expressions/JintMetaPropertyExpression.cs
  79. 1 2
      Jint/Runtime/Interpreter/Expressions/JintNewExpression.cs
  80. 0 1
      Jint/Runtime/Interpreter/Expressions/JintObjectExpression.cs
  81. 0 2
      Jint/Runtime/Interpreter/Expressions/JintPrivateIdentifierExpression.cs
  82. 0 1
      Jint/Runtime/Interpreter/Expressions/JintSequenceExpression.cs
  83. 0 1
      Jint/Runtime/Interpreter/Expressions/JintSpreadExpression.cs
  84. 0 1
      Jint/Runtime/Interpreter/Expressions/JintSuperExpression.cs
  85. 0 1
      Jint/Runtime/Interpreter/Expressions/JintTaggedTemplateExpression.cs
  86. 0 1
      Jint/Runtime/Interpreter/Expressions/JintTemplateLiteralExpression.cs
  87. 0 1
      Jint/Runtime/Interpreter/Expressions/JintThisExpression.cs
  88. 11 10
      Jint/Runtime/Interpreter/Expressions/JintUnaryExpression.cs
  89. 0 1
      Jint/Runtime/Interpreter/Expressions/JintUpdateExpression.cs
  90. 0 1
      Jint/Runtime/Interpreter/Expressions/JintYieldExpression.cs
  91. 0 1
      Jint/Runtime/Interpreter/Expressions/NullishCoalescingExpression.cs
  92. 7 8
      Jint/Runtime/Interpreter/JintFunctionDefinition.cs
  93. 0 1
      Jint/Runtime/Interpreter/JintStatementList.cs
  94. 0 1
      Jint/Runtime/Interpreter/Statements/ConstantReturnStatement.cs
  95. 0 1
      Jint/Runtime/Interpreter/Statements/JintBlockStatement.cs
  96. 0 1
      Jint/Runtime/Interpreter/Statements/JintBreakStatement.cs
  97. 0 1
      Jint/Runtime/Interpreter/Statements/JintClassDeclarationStatement.cs
  98. 0 1
      Jint/Runtime/Interpreter/Statements/JintContinueStatement.cs
  99. 0 1
      Jint/Runtime/Interpreter/Statements/JintDebuggerStatement.cs
  100. 0 1
      Jint/Runtime/Interpreter/Statements/JintDoWhileStatement.cs

+ 1 - 0
.gitignore

@@ -165,3 +165,4 @@ BenchmarkDotNet.Artifacts*
 
 # generated code
 Jint.Tests.Test262/Generated
+/artifacts

+ 30 - 0
Directory.Build.props

@@ -1,7 +1,37 @@
 <Project>
 
   <PropertyGroup>
+
+    <Copyright>Sebastien Ros</Copyright>
+    <Authors>Sebastien Ros</Authors>
+
+    <Description>Javascript interpreter for .NET.</Description>
+    <PackageTags>javascript, interpreter, es5, es2015, es6, ecmascript, interop</PackageTags>
+    <PackageProjectUrl>https://github.com/sebastienros/jint</PackageProjectUrl>
+    <PackageLicenseExpression>BSD-2-Clause</PackageLicenseExpression>
+
+    <BuildNumber Condition="'$(BuildNumber)' == ''">0</BuildNumber>
+    <VersionPrefix>3.0.1</VersionPrefix>
+    <VersionSuffix>beta-$(BuildNumber)</VersionSuffix>
+    <FileVersion>$(VersionPrefix).$(BuildNumber)</FileVersion>
+
+    <PublishRepositoryUrl>true</PublishRepositoryUrl>
+    <EmbedUntrackedSources>true</EmbedUntrackedSources>
+    <IncludeSymbols>true</IncludeSymbols>
+    <DebugType>portable</DebugType>
+    <SymbolPackageFormat>snupkg</SymbolPackageFormat>
+
+    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <UseArtifactsOutput>true</UseArtifactsOutput>
+
   </PropertyGroup>
 
+  <ItemGroup>
+    <Using Include="Esprima" />
+    <Using Include="Esprima.Ast" />
+    <Using Include="Esprima.Utils" />
+    <Using Include="Esprima.Location" Alias="SourceLocation" />
+    <Using Include="Esprima.Ast.Nodes" Alias="NodeType" />
+  </ItemGroup>
+
 </Project>

+ 0 - 1
Jint.Benchmark/DromaeoBenchmark.cs

@@ -1,5 +1,4 @@
 using BenchmarkDotNet.Attributes;
-using Esprima.Ast;
 
 namespace Jint.Benchmark;
 

+ 0 - 2
Jint.Benchmark/EngineComparisonBenchmark.cs

@@ -1,8 +1,6 @@
 using BenchmarkDotNet.Attributes;
 using BenchmarkDotNet.Configs;
 using BenchmarkDotNet.Order;
-using Esprima;
-using Esprima.Ast;
 
 namespace Jint.Benchmark;
 

+ 0 - 2
Jint.Benchmark/EngineConstructionBenchmark.cs

@@ -1,6 +1,4 @@
 using BenchmarkDotNet.Attributes;
-using Esprima;
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Benchmark;

+ 6 - 0
Jint.Benchmark/Jint.Benchmark.csproj

@@ -10,6 +10,8 @@
     <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
     <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
     <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
+    <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
+    <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
     <AssemblyOriginatorKeyFile>..\Jint\Jint.snk</AssemblyOriginatorKeyFile>
     <SignAssembly>true</SignAssembly>
     <LangVersion>latest</LangVersion>
@@ -29,4 +31,8 @@
     <PackageReference Include="NiL.JS" />
     <PackageReference Include="YantraJS.Core" />
   </ItemGroup>
+  <ItemGroup>
+    <Using Include="Esprima" />
+    <Using Include="Esprima.Ast" />
+  </ItemGroup>
 </Project>

+ 0 - 1
Jint.Benchmark/ObjectAccessBenchmark.cs

@@ -1,5 +1,4 @@
 using BenchmarkDotNet.Attributes;
-using Esprima.Ast;
 
 namespace Jint.Benchmark;
 

+ 0 - 1
Jint.Benchmark/ShadowRealmBenchmark.cs

@@ -1,5 +1,4 @@
 using BenchmarkDotNet.Attributes;
-using Esprima.Ast;
 
 namespace Jint.Benchmark;
 

+ 0 - 1
Jint.Benchmark/SingleScriptBenchmark.cs

@@ -1,5 +1,4 @@
 using BenchmarkDotNet.Attributes;
-using Esprima.Ast;
 
 namespace Jint.Benchmark;
 

+ 0 - 1
Jint.Repl/Program.cs

@@ -1,5 +1,4 @@
 using System.Reflection;
-using Esprima;
 using Jint;
 using Jint.Native;
 using Jint.Native.Json;

+ 0 - 2
Jint.Tests.CommonScripts/ConcurrencyTest.cs

@@ -1,5 +1,3 @@
-using Esprima;
-
 namespace Jint.Tests.CommonScripts;
 
 [Parallelizable(ParallelScope.Fixtures)]

+ 2 - 0
Jint.Tests.PublicInterface/ModuleLoaderTests.cs

@@ -3,6 +3,8 @@ using Jint.Native;
 using Jint.Native.Json;
 using Jint.Runtime.Modules;
 
+using Module = Jint.Runtime.Modules.Module;
+
 #nullable enable
 
 namespace Jint.Tests.PublicInterface;

+ 0 - 1
Jint.Tests.PublicInterface/RavenApiUsageTests.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Constraints;
 using Jint.Native;
 using Jint.Native.Function;

+ 0 - 2
Jint.Tests.Test262/State.cs

@@ -1,5 +1,3 @@
-using Esprima.Ast;
-
 namespace Jint.Tests.Test262;
 
 /// <summary>

+ 1 - 2
Jint.Tests.Test262/Test262Test.cs

@@ -1,5 +1,4 @@
-using Esprima;
-using Jint.Native;
+using Jint.Native;
 using Jint.Runtime;
 using Jint.Runtime.Descriptors;
 using Jint.Runtime.Interop;

+ 4 - 6
Jint.Tests/Parser/JavascriptParserTests.cs

@@ -1,6 +1,4 @@
-using Esprima;
-using Esprima.Ast;
-using Jint.Runtime;
+using Jint.Runtime;
 
 namespace Jint.Tests.Parser
 {
@@ -13,7 +11,7 @@ namespace Jint.Tests.Parser
             var body = program.Body;
 
             Assert.Single(body);
-            Assert.Equal(Nodes.ThisExpression, body.First().As<ExpressionStatement>().Expression.Type);
+            Assert.Equal(NodeType.ThisExpression, body.First().As<ExpressionStatement>().Expression.Type);
         }
 
         [Fact]
@@ -23,7 +21,7 @@ namespace Jint.Tests.Parser
             var body = program.Body;
 
             Assert.Single(body);
-            Assert.Equal(Nodes.Literal, body.First().As<ExpressionStatement>().Expression.Type);
+            Assert.Equal(NodeType.Literal, body.First().As<ExpressionStatement>().Expression.Type);
             Assert.Equal(null, body.First().As<ExpressionStatement>().Expression.As<Literal>().Value);
             Assert.Equal("null", body.First().As<ExpressionStatement>().Expression.As<Literal>().Raw);
         }
@@ -38,7 +36,7 @@ namespace Jint.Tests.Parser
             var body = program.Body;
 
             Assert.Single(body);
-            Assert.Equal(Nodes.Literal, body.First().As<ExpressionStatement>().Expression.Type);
+            Assert.Equal(NodeType.Literal, body.First().As<ExpressionStatement>().Expression.Type);
             Assert.Equal(42d, body.First().As<ExpressionStatement>().Expression.As<Literal>().Value);
             Assert.Equal("42", body.First().As<ExpressionStatement>().Expression.As<Literal>().Raw);
         }

+ 1 - 3
Jint.Tests/Runtime/Debugger/CallStackTests.cs

@@ -1,6 +1,4 @@
-using Esprima;
-using Esprima.Ast;
-using Jint.Runtime.Debugger;
+using Jint.Runtime.Debugger;
 
 namespace Jint.Tests.Runtime.Debugger
 {

+ 1 - 2
Jint.Tests/Runtime/Debugger/EvaluateTests.cs

@@ -1,5 +1,4 @@
-using Esprima;
-using Jint.Native;
+using Jint.Native;
 using Jint.Runtime;
 using Jint.Runtime.Debugger;
 

+ 2 - 4
Jint.Tests/Runtime/Debugger/StepFlowTests.cs

@@ -1,6 +1,4 @@
-using Esprima;
-using Esprima.Ast;
-using Jint.Runtime.Debugger;
+using Jint.Runtime.Debugger;
 
 namespace Jint.Tests.Runtime.Debugger
 {
@@ -271,7 +269,7 @@ let res = c();
             engine.Execute(script);
             return stepStatements;
 
-            void OutputPosition(Location location)
+            void OutputPosition(in SourceLocation location)
             {
                 var line = scriptLines[location.Start.Line - 1];
                 var withPositionIndicator = string.Concat(line.Substring(0, location.Start.Column), "»", line.Substring(location.Start.Column));

+ 1 - 2
Jint.Tests/Runtime/Debugger/TestHelpers.cs

@@ -1,5 +1,4 @@
-using Esprima.Ast;
-using Jint.Runtime.Debugger;
+using Jint.Runtime.Debugger;
 
 namespace Jint.Tests.Runtime.Debugger
 {

+ 0 - 1
Jint.Tests/Runtime/EngineTests.ScriptPreparation.cs

@@ -1,5 +1,4 @@
 using System.Text.RegularExpressions;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Runtime.Interpreter;
 using Jint.Runtime.Interpreter.Expressions;

+ 0 - 2
Jint.Tests/Runtime/EngineTests.cs

@@ -1,7 +1,5 @@
 using System.Globalization;
 using System.Reflection;
-using Esprima;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Array;
 using Jint.Native.Number;

+ 0 - 1
Jint.Tests/Runtime/ErrorTests.cs

@@ -1,5 +1,4 @@
 using System.Reflection;
-using Esprima;
 using Jint.Native;
 using Jint.Runtime;
 using Jint.Tests.Runtime.TestClasses;

+ 2 - 0
Jint.Tests/Runtime/ModuleTests.cs

@@ -2,6 +2,8 @@ using Jint.Native;
 using Jint.Runtime;
 using Jint.Runtime.Modules;
 
+using Module = Jint.Runtime.Modules.Module;
+
 namespace Jint.Tests.Runtime;
 
 public class ModuleTests

+ 0 - 32
Jint/Directory.Build.props

@@ -1,32 +0,0 @@
-<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-
-  <PropertyGroup>
-
-    <Copyright>Sebastien Ros</Copyright>
-    <Authors>Sebastien Ros</Authors>
-
-    <PackageId>Jint</PackageId>
-    <AssemblyTitle>Jint</AssemblyTitle>
-    <Description>Javascript interpreter for .NET.</Description>
-
-    <BuildNumber Condition="'$(BuildNumber)' == ''">0</BuildNumber>
-    <VersionPrefix>3.0.1</VersionPrefix>
-    <VersionSuffix>beta-$(BuildNumber)</VersionSuffix>
-    <FileVersion>$(VersionPrefix).$(BuildNumber)</FileVersion>
-
-    <PackageId>Jint</PackageId>
-    <PackageTags>javascript, interpreter, es5, es2015, es6, ecmascript, interop</PackageTags>
-    <PackageProjectUrl>https://github.com/sebastienros/jint</PackageProjectUrl>
-    <PackageLicenseExpression>BSD-2-Clause</PackageLicenseExpression>
-
-    <PublishRepositoryUrl>true</PublishRepositoryUrl>
-    <EmbedUntrackedSources>true</EmbedUntrackedSources>
-    <IncludeSymbols>true</IncludeSymbols>
-    <DebugType>portable</DebugType>
-    <SymbolPackageFormat>snupkg</SymbolPackageFormat>
-
-    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-
-  </PropertyGroup>
-
-</Project>

+ 10 - 12
Jint/Engine.Ast.cs

@@ -1,7 +1,5 @@
 using System.Runtime.InteropServices;
 using System.Text.RegularExpressions;
-using Esprima;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Runtime;
 using Jint.Runtime.Interpreter;
@@ -70,7 +68,7 @@ public partial class Engine
         {
             switch (node.Type)
             {
-                case Nodes.Identifier:
+                case NodeType.Identifier:
                     var identifier = (Identifier) node;
                     var name = identifier.Name;
 
@@ -82,7 +80,7 @@ public partial class Engine
                     node.AssociatedData = new JintIdentifierExpression(identifier, bindingName);
                     break;
 
-                case Nodes.Literal:
+                case NodeType.Literal:
                     var literal = (Literal) node;
 
                     var constantValue = JintLiteralExpression.ConvertToJsValue(literal);
@@ -114,26 +112,26 @@ public partial class Engine
 
                     break;
 
-                case Nodes.MemberExpression:
+                case NodeType.MemberExpression:
                     node.AssociatedData = JintMemberExpression.InitializeDeterminedProperty((MemberExpression) node, cache: true);
                     break;
 
-                case Nodes.ArrowFunctionExpression:
-                case Nodes.FunctionDeclaration:
-                case Nodes.FunctionExpression:
+                case NodeType.ArrowFunctionExpression:
+                case NodeType.FunctionDeclaration:
+                case NodeType.FunctionExpression:
                     var function = (IFunction) node;
                     node.AssociatedData = JintFunctionDefinition.BuildState(function);
                     break;
 
-                case Nodes.Program:
+                case NodeType.Program:
                     node.AssociatedData = new CachedHoistingScope((Program) node);
                     break;
 
-                case Nodes.UnaryExpression:
+                case NodeType.UnaryExpression:
                     node.AssociatedData = JintUnaryExpression.BuildConstantExpression((UnaryExpression) node);
                     break;
 
-                case Nodes.BinaryExpression:
+                case NodeType.BinaryExpression:
                     var binaryExpression = (BinaryExpression) node;
                     if (_options.FoldConstants
                         && binaryExpression.Operator != BinaryOperator.InstanceOf
@@ -161,7 +159,7 @@ public partial class Engine
 
                     break;
 
-                case Nodes.ReturnStatement:
+                case NodeType.ReturnStatement:
                     var returnStatement = (ReturnStatement) node;
                     if (returnStatement.Argument is Literal returnedLiteral)
                     {

+ 3 - 3
Jint/Engine.Modules.cs

@@ -1,10 +1,10 @@
-using Esprima;
-using Jint.Native;
+using Jint.Native;
 using Jint.Native.Object;
 using Jint.Native.Promise;
 using Jint.Runtime;
 using Jint.Runtime.Interpreter;
 using Jint.Runtime.Modules;
+using Module = Jint.Runtime.Modules.Module;
 
 namespace Jint;
 
@@ -172,7 +172,7 @@ public partial class Engine
             {
                 var location = module is CyclicModule cyclicModuleRecord
                     ? cyclicModuleRecord.AbnormalCompletionLocation
-                    : Location.From(new Position(), new Position());
+                    : SourceLocation.From(new Position(), new Position());
 
                 var node = EsprimaExtensions.CreateLocationNode(location);
                 ExceptionHelper.ThrowJavaScriptException(_engine, promise.Value, node.Location);

+ 1 - 3
Jint/Engine.cs

@@ -1,8 +1,6 @@
 using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
 using System.Runtime.CompilerServices;
-using Esprima;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Function;
 using Jint.Native.Generator;
@@ -531,7 +529,7 @@ namespace Jint
                 constraint.Check();
             }
 
-            if (_isDebugMode && statement != null && statement.Type != Nodes.BlockStatement)
+            if (_isDebugMode && statement != null && statement.Type != NodeType.BlockStatement)
             {
                 Debugger.OnStep(statement);
             }

+ 22 - 25
Jint/EsprimaExtensions.cs

@@ -1,7 +1,4 @@
 using System.Runtime.CompilerServices;
-using Esprima;
-using Esprima.Ast;
-using Esprima.Utils;
 using Jint.Native;
 using Jint.Native.Function;
 using Jint.Native.Object;
@@ -64,19 +61,19 @@ namespace Jint
         private static JsValue TryGetComputedPropertyKey<T>(T expression, Engine engine)
             where T : Expression
         {
-            if (expression.Type is Nodes.Identifier
-                or Nodes.CallExpression
-                or Nodes.BinaryExpression
-                or Nodes.UpdateExpression
-                or Nodes.AssignmentExpression
-                or Nodes.UnaryExpression
-                or Nodes.MemberExpression
-                or Nodes.LogicalExpression
-                or Nodes.ConditionalExpression
-                or Nodes.ArrowFunctionExpression
-                or Nodes.FunctionExpression
-                or Nodes.YieldExpression
-                or Nodes.TemplateLiteral)
+            if (expression.Type is NodeType.Identifier
+                or NodeType.CallExpression
+                or NodeType.BinaryExpression
+                or NodeType.UpdateExpression
+                or NodeType.AssignmentExpression
+                or NodeType.UnaryExpression
+                or NodeType.MemberExpression
+                or NodeType.LogicalExpression
+                or NodeType.ConditionalExpression
+                or NodeType.ArrowFunctionExpression
+                or NodeType.FunctionExpression
+                or NodeType.YieldExpression
+                or NodeType.TemplateLiteral)
             {
                 var context = engine._activeEvaluationContext;
                 return JintExpression.Build(expression).GetValue(context!);
@@ -90,9 +87,9 @@ namespace Jint
         {
             var type = node.Type;
             return type
-                is Nodes.FunctionExpression
-                or Nodes.ArrowFunctionExpression
-                or Nodes.ClassExpression;
+                is NodeType.FunctionExpression
+                or NodeType.ArrowFunctionExpression
+                or NodeType.ClassExpression;
         }
 
         /// <summary>
@@ -178,7 +175,7 @@ namespace Jint
 
         internal static void GetBoundNames(this Node? parameter, List<Key> target)
         {
-            if (parameter is null || parameter.Type == Nodes.Literal)
+            if (parameter is null || parameter.Type == NodeType.Literal)
             {
                 return;
             }
@@ -257,18 +254,18 @@ namespace Jint
         /// </summary>
         internal static void PrivateBoundIdentifiers(this Node parameter, HashSet<PrivateIdentifier> target)
         {
-            if (parameter.Type == Nodes.PrivateIdentifier)
+            if (parameter.Type == NodeType.PrivateIdentifier)
             {
                 target.Add((PrivateIdentifier) parameter);
             }
-            else if (parameter.Type is Nodes.AccessorProperty or Nodes.MethodDefinition or Nodes.PropertyDefinition)
+            else if (parameter.Type is NodeType.AccessorProperty or NodeType.MethodDefinition or NodeType.PropertyDefinition)
             {
                 if (((ClassProperty) parameter).Key is PrivateIdentifier privateKeyIdentifier)
                 {
                     target.Add(privateKeyIdentifier);
                 }
             }
-            else if (parameter.Type == Nodes.ClassBody)
+            else if (parameter.Type == NodeType.ClassBody)
             {
                 ref readonly var elements = ref ((ClassBody) parameter).Body;
                 for (var i = 0; i < elements.Count; i++)
@@ -476,7 +473,7 @@ namespace Jint
         /// <summary>
         /// Creates a dummy node that can be used when only location available and node is required.
         /// </summary>
-        internal static SyntaxElement CreateLocationNode(in Location location)
+        internal static SyntaxElement CreateLocationNode(in SourceLocation location)
         {
             return new MinimalSyntaxElement(location);
         }
@@ -492,7 +489,7 @@ namespace Jint
 
         private sealed class MinimalSyntaxElement : SyntaxElement
         {
-            public MinimalSyntaxElement(in Location location)
+            public MinimalSyntaxElement(in SourceLocation location)
             {
                 Location = location;
             }

+ 11 - 12
Jint/HoistingScope.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Runtime.Modules;
 using Module = Esprima.Ast.Module;
 
@@ -80,7 +79,7 @@ namespace Jint
             for (var i = 0; i < statementListItems.Count; i++)
             {
                 var node = statementListItems[i];
-                if (node.Type != Nodes.VariableDeclaration && node.Type != Nodes.FunctionDeclaration && node.Type != Nodes.ClassDeclaration)
+                if (node.Type != NodeType.VariableDeclaration && node.Type != NodeType.FunctionDeclaration && node.Type != NodeType.ClassDeclaration)
                 {
                     continue;
                 }
@@ -104,7 +103,7 @@ namespace Jint
             for (var i = 0; i < statementListItems.Count; i++)
             {
                 var node = statementListItems[i];
-                if (node.Type != Nodes.VariableDeclaration)
+                if (node.Type != NodeType.VariableDeclaration)
                 {
                     continue;
                 }
@@ -223,7 +222,7 @@ namespace Jint
                 foreach (var childNode in node.ChildNodes)
                 {
                     var childType = childNode.Type;
-                    if (childType == Nodes.VariableDeclaration)
+                    if (childType == NodeType.VariableDeclaration)
                     {
                         var variableDeclaration = (VariableDeclaration)childNode;
                         if (variableDeclaration.Kind == VariableDeclarationKind.Var)
@@ -262,24 +261,24 @@ namespace Jint
                             }
                         }
                     }
-                    else if (childType == Nodes.FunctionDeclaration)
+                    else if (childType == NodeType.FunctionDeclaration)
                     {
                         // function declarations are not hoisted if they are under block or case clauses
-                        if (parent is null || (node.Type != Nodes.BlockStatement && node.Type != Nodes.SwitchCase))
+                        if (parent is null || (node.Type != NodeType.BlockStatement && node.Type != NodeType.SwitchCase))
                         {
                             _functions ??= new List<FunctionDeclaration>();
                             _functions.Add((FunctionDeclaration)childNode);
                         }
                     }
-                    else if (childType == Nodes.ClassDeclaration && parent is null or Module)
+                    else if (childType == NodeType.ClassDeclaration && parent is null or Module)
                     {
                         _lexicalDeclarations ??= new List<Declaration>();
                         _lexicalDeclarations.Add((Declaration) childNode);
                     }
 
-                    if (childType != Nodes.FunctionDeclaration
-                        && childType != Nodes.ArrowFunctionExpression
-                        && childType != Nodes.FunctionExpression
+                    if (childType != NodeType.FunctionDeclaration
+                        && childType != NodeType.ArrowFunctionExpression
+                        && childType != NodeType.FunctionExpression
                         && !childNode.ChildNodes.IsEmpty())
                     {
                         Visit(childNode, node);
@@ -306,14 +305,14 @@ namespace Jint
             {
                 foreach (var childNode in node.ChildNodes)
                 {
-                    if (childNode.Type == Nodes.ImportDeclaration)
+                    if (childNode.Type == NodeType.ImportDeclaration)
                     {
                         _importEntries ??= [];
                         _requestedModules ??= [];
                         var import = (ImportDeclaration) childNode;
                         import.GetImportEntries(_importEntries, _requestedModules);
                     }
-                    else if (childNode.Type is Nodes.ExportAllDeclaration or Nodes.ExportDefaultDeclaration or Nodes.ExportNamedDeclaration)
+                    else if (childNode.Type is NodeType.ExportAllDeclaration or NodeType.ExportDefaultDeclaration or NodeType.ExportNamedDeclaration)
                     {
                         _exportEntries ??= [];
                         _requestedModules ??= [];

+ 0 - 1
Jint/JsValueExtensions.cs

@@ -1,7 +1,6 @@
 using System.Diagnostics.Contracts;
 using System.Numerics;
 using System.Runtime.CompilerServices;
-using Esprima;
 using Jint.Native;
 using Jint.Native.Function;
 using Jint.Native.Object;

+ 2 - 5
Jint/Native/Function/ClassDefinition.cs

@@ -1,6 +1,3 @@
-using Esprima;
-using Esprima.Ast;
-using Esprima.Utils;
 using Jint.Native.Object;
 using Jint.Runtime;
 using Jint.Runtime.Descriptors;
@@ -280,7 +277,7 @@ internal sealed class ClassDefinition
         private readonly NodeList<Node> _nodeList;
         private readonly BlockStatement _statement;
 
-        public ClassFieldFunction(Expression expression) : base(Nodes.ExpressionStatement)
+        public ClassFieldFunction(Expression expression) : base(NodeType.ExpressionStatement)
         {
             var nodeList = NodeList.Create<Statement>(new [] { new ReturnStatement(expression) });
             _statement = new BlockStatement(nodeList);
@@ -323,7 +320,7 @@ internal sealed class ClassDefinition
         private readonly BlockStatement _statement;
         private readonly NodeList<Node> _params;
 
-        public ClassStaticBlockFunction(StaticBlock staticBlock) : base(Nodes.StaticBlock)
+        public ClassStaticBlockFunction(StaticBlock staticBlock) : base(NodeType.StaticBlock)
         {
             _statement = new BlockStatement(staticBlock.Body);
             _params = new NodeList<Node>();

+ 2 - 5
Jint/Native/Function/EvalFunction.cs

@@ -1,6 +1,3 @@
-using Esprima;
-using Esprima.Ast;
-using Esprima.Utils;
 using Jint.Runtime;
 using Jint.Runtime.Descriptors;
 using Jint.Runtime.Environments;
@@ -214,13 +211,13 @@ public sealed class EvalFunction : Function
 
         protected override object? VisitMemberExpression(MemberExpression memberExpression)
         {
-            _containsSuperProperty |= memberExpression.Object.Type == Nodes.Super;
+            _containsSuperProperty |= memberExpression.Object.Type == NodeType.Super;
             return base.VisitMemberExpression(memberExpression);
         }
 
         protected override object? VisitCallExpression(CallExpression callExpression)
         {
-            _containsSuperCall |= callExpression.Callee.Type == Nodes.Super;
+            _containsSuperCall |= callExpression.Callee.Type == NodeType.Super;
             return base.VisitCallExpression(callExpression);
         }
     }

+ 0 - 1
Jint/Native/Function/Function.cs

@@ -1,6 +1,5 @@
 using System.Diagnostics;
 using System.Runtime.CompilerServices;
-using Esprima.Ast;
 using Jint.Native.Object;
 using Jint.Runtime;
 using Jint.Runtime.Descriptors;

+ 0 - 2
Jint/Native/Function/FunctionInstance.Dynamic.cs

@@ -1,5 +1,3 @@
-using Esprima;
-using Esprima.Ast;
 using Jint.Native.Object;
 using Jint.Runtime;
 using Jint.Runtime.Descriptors;

+ 0 - 1
Jint/Native/Function/ScriptFunction.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native.Object;
 using Jint.Runtime;
 using Jint.Runtime.Descriptors;

+ 3 - 4
Jint/Native/Generator/GeneratorInstance.cs

@@ -1,5 +1,4 @@
-using Esprima;
-using Jint.Native.Iterator;
+using Jint.Native.Iterator;
 using Jint.Native.Object;
 using Jint.Runtime;
 using Jint.Runtime.Environments;
@@ -79,7 +78,7 @@ internal sealed class GeneratorInstance : ObjectInstance
                 return new IteratorResult(_engine, abruptCompletion.Value, JsBoolean.True);
             }
 
-            ExceptionHelper.ThrowJavaScriptException(_engine, abruptCompletion.Value, new Location());
+            ExceptionHelper.ThrowJavaScriptException(_engine, abruptCompletion.Value, (SourceLocation) default);
         }
 
         var genContext = _generatorContext;
@@ -96,7 +95,7 @@ internal sealed class GeneratorInstance : ObjectInstance
 
         if (_error is not null)
         {
-            ExceptionHelper.ThrowJavaScriptException(_engine, _error, new Location());
+            ExceptionHelper.ThrowJavaScriptException(_engine, _error, (SourceLocation) default);
         }
 
         return ResumeExecution(genContext, new EvaluationContext(_engine));

+ 0 - 1
Jint/Native/Global/GlobalObject.cs

@@ -3,7 +3,6 @@ using System.Globalization;
 using System.Linq;
 using System.Runtime.CompilerServices;
 using System.Text;
-using Esprima;
 using Jint.Native.Object;
 using Jint.Native.String;
 using Jint.Runtime;

+ 0 - 1
Jint/Native/JsRegExp.cs

@@ -1,5 +1,4 @@
 using System.Text.RegularExpressions;
-using Esprima;
 using Jint.Native.Object;
 using Jint.Native.RegExp;
 using Jint.Runtime;

+ 0 - 1
Jint/Native/JsTypedArray.cs

@@ -1,6 +1,5 @@
 using System.Globalization;
 using System.Runtime.CompilerServices;
-using Esprima;
 using Jint.Native.ArrayBuffer;
 using Jint.Native.Number;
 using Jint.Native.Object;

+ 0 - 1
Jint/Native/Json/JsonParser.cs

@@ -4,7 +4,6 @@ using System.Globalization;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Text;
-using Esprima;
 using Jint.Runtime;
 
 namespace Jint.Native.Json

+ 0 - 1
Jint/Native/PrivateName.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Runtime;
 
 namespace Jint.Native;

+ 0 - 1
Jint/Native/RegExp/RegExpConstructor.cs

@@ -1,5 +1,4 @@
 using System.Text.RegularExpressions;
-using Esprima;
 using Jint.Collections;
 using Jint.Native.Function;
 using Jint.Native.Object;

+ 0 - 3
Jint/Native/ShadowRealm/ShadowRealm.cs

@@ -1,7 +1,4 @@
 using System.Diagnostics.CodeAnalysis;
-using Esprima;
-using Esprima.Ast;
-using Esprima.Utils;
 using Jint.Native.Object;
 using Jint.Native.Promise;
 using Jint.Runtime;

+ 1 - 3
Jint/Runtime/CallStack/CallStackElement.cs

@@ -1,5 +1,3 @@
-using Esprima;
-using Esprima.Ast;
 using Jint.Native.Function;
 using Jint.Runtime.Interpreter.Expressions;
 
@@ -21,7 +19,7 @@ namespace Jint.Runtime.CallStack
         public readonly JintExpression? Expression;
         public readonly CallStackExecutionContext CallingExecutionContext;
 
-        public Location Location
+        public SourceLocation Location
         {
             get
             {

+ 2 - 4
Jint/Runtime/CallStack/JintCallStack.cs

@@ -2,8 +2,6 @@ using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
 using System.Linq;
 using System.Text;
-using Esprima;
-using Esprima.Ast;
 using Jint.Collections;
 using Jint.Native.Function;
 using Jint.Runtime.Environments;
@@ -117,12 +115,12 @@ namespace Jint.Runtime.CallStack
             return string.Join("->", _stack.Select(static cse => cse.ToString()).Reverse());
         }
 
-        internal string BuildCallStackString(Location location, int excludeTop = 0)
+        internal string BuildCallStackString(SourceLocation location, int excludeTop = 0)
         {
             static void AppendLocation(
                 ref ValueStringBuilder sb,
                 string shortDescription,
-                in Location loc,
+                in SourceLocation loc,
                 in CallStackElement? element)
             {
                 sb.Append("   at");

+ 1 - 3
Jint/Runtime/Completion.cs

@@ -1,8 +1,6 @@
 using System.Diagnostics;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
-using Esprima;
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime;
@@ -38,7 +36,7 @@ public readonly struct Completion
 
     public readonly CompletionType Type;
     public readonly JsValue Value;
-    public ref readonly Location Location => ref _source.Location;
+    public ref readonly SourceLocation Location => ref _source.Location;
 
     public static ref readonly Completion Empty() => ref _emptyCompletion;
 

+ 3 - 5
Jint/Runtime/Debugger/CallFrame.cs

@@ -1,5 +1,3 @@
-using Esprima;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Runtime.CallStack;
 using Environment = Jint.Runtime.Environments.Environment;
@@ -15,7 +13,7 @@ namespace Jint.Runtime.Debugger
         internal CallFrame(
             CallStackElement? element,
             in CallStackExecutionContext context,
-            Location location,
+            in SourceLocation location,
             JsValue? returnValue)
         {
             _element = element;
@@ -38,12 +36,12 @@ namespace Jint.Runtime.Debugger
         /// Source location of function of this call frame.
         /// </summary>
         /// <remarks>For top level (global) call frames, as well as functions not defined in script, this will be null.</remarks>
-        public Location? FunctionLocation => (_element?.Function._functionDefinition?.Function as Node)?.Location;
+        public SourceLocation? FunctionLocation => (_element?.Function._functionDefinition?.Function as Node)?.Location;
 
         /// <summary>
         /// Currently executing source location in this call frame.
         /// </summary>
-        public Location Location { get; }
+        public SourceLocation Location { get; }
 
         /// <summary>
         /// The scope chain of this call frame.

+ 1 - 2
Jint/Runtime/Debugger/DebugCallStack.cs

@@ -1,5 +1,4 @@
 using System.Collections;
-using Esprima;
 using Jint.Native;
 using Jint.Runtime.CallStack;
 
@@ -9,7 +8,7 @@ namespace Jint.Runtime.Debugger
     {
         private readonly List<CallFrame> _stack;
 
-        internal DebugCallStack(Engine engine, Location location, JintCallStack callStack, JsValue? returnValue)
+        internal DebugCallStack(Engine engine, SourceLocation location, JintCallStack callStack, JsValue? returnValue)
         {
             _stack = new List<CallFrame>(callStack.Count + 1);
             var executionContext = new CallStackExecutionContext(engine.ExecutionContext);

+ 5 - 7
Jint/Runtime/Debugger/DebugHandler.cs

@@ -1,5 +1,3 @@
-using Esprima;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Runtime.Interpreter;
 
@@ -68,7 +66,7 @@ namespace Jint.Runtime.Debugger
         /// The location is available as long as DebugMode is enabled - i.e. even when not stepping
         /// or hitting a breakpoint.
         /// </remarks>
-        public Location? CurrentLocation { get; private set; }
+        public SourceLocation? CurrentLocation { get; private set; }
 
         /// <summary>
         /// Collection of active breakpoints for the engine.
@@ -170,14 +168,14 @@ namespace Jint.Runtime.Debugger
 
             var bodyLocation = functionBody.Location;
             var functionBodyEnd = bodyLocation.End;
-            var location = Location.From(functionBodyEnd, functionBodyEnd, bodyLocation.Source);
+            var location = SourceLocation.From(functionBodyEnd, functionBodyEnd, bodyLocation.Source);
 
             CheckBreakPointAndPause(node: null, location, returnValue);
         }
 
         private void CheckBreakPointAndPause(
             Node? node,
-            Location location,
+            in SourceLocation location,
             JsValue? returnValue = null)
         {
             CurrentLocation = location;
@@ -198,7 +196,7 @@ namespace Jint.Runtime.Debugger
             {
                 pauseType = PauseType.Break;
             }
-            else if (node?.Type == Nodes.DebuggerStatement &&
+            else if (node?.Type == NodeType.DebuggerStatement &&
                 _engine.Options.Debugger.StatementHandling == DebuggerStatementHandling.Script)
             {
                 pauseType = PauseType.DebuggerStatement;
@@ -216,7 +214,7 @@ namespace Jint.Runtime.Debugger
         private void Pause(
             PauseType type,
             Node? node,
-            Location location,
+            in SourceLocation location,
             JsValue? returnValue = null,
             BreakPoint? breakPoint = null)
         {

+ 4 - 6
Jint/Runtime/Debugger/DebugInformation.cs

@@ -1,13 +1,11 @@
-using Esprima;
-using Esprima.Ast;
-using Jint.Native;
+using Jint.Native;
 
 namespace Jint.Runtime.Debugger
 {
     public sealed class DebugInformation : EventArgs
     {
         private readonly Engine _engine;
-        private readonly Location _currentLocation;
+        private readonly SourceLocation _currentLocation;
         private readonly JsValue? _returnValue;
 
         private DebugCallStack? _callStack;
@@ -15,7 +13,7 @@ namespace Jint.Runtime.Debugger
         internal DebugInformation(
             Engine engine,
             Node? currentNode,
-            Location currentLocation,
+            in SourceLocation currentLocation,
             JsValue? returnValue,
             long currentMemoryUsage,
             PauseType pauseType,
@@ -57,7 +55,7 @@ namespace Jint.Runtime.Debugger
         /// The current source Location.
         /// For return points, this starts and ends at the end of the function body.
         /// </summary>
-        public Location Location => CurrentCallFrame.Location;
+        public SourceLocation Location => CurrentCallFrame.Location;
 
         /// <summary>
         /// Not implemented. Will always return 0.

+ 1 - 2
Jint/Runtime/Environments/FunctionEnvironment.cs

@@ -1,5 +1,4 @@
 using System.Runtime.CompilerServices;
-using Esprima.Ast;
 using Jint.Collections;
 using Jint.Native;
 using Jint.Native.Function;
@@ -261,7 +260,7 @@ namespace Jint.Runtime.Environments
 
                 array = _engine.Realm.Intrinsics.Array.ArrayCreate(0);
                 var max = arrayPattern.Elements.Count;
-                if (max > 0 && arrayPattern.Elements[max - 1]?.Type == Nodes.RestElement)
+                if (max > 0 && arrayPattern.Elements[max - 1]?.Type == NodeType.RestElement)
                 {
                     // need to consume all
                     max = int.MaxValue;

+ 1 - 1
Jint/Runtime/Environments/ModuleEnvironment.cs

@@ -1,7 +1,7 @@
 using System.Diagnostics.CodeAnalysis;
 using Jint.Collections;
 using Jint.Native;
-using Jint.Runtime.Modules;
+using Module = Jint.Runtime.Modules.Module;
 
 namespace Jint.Runtime.Environments;
 

+ 0 - 1
Jint/Runtime/Environments/PrivateEnvironment.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Environments;

+ 2 - 4
Jint/Runtime/ExceptionHelper.cs

@@ -1,8 +1,6 @@
 using System.Diagnostics.CodeAnalysis;
 using System.Reflection;
 using System.Runtime.ExceptionServices;
-using Esprima;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Error;
 using Jint.Runtime.CallStack;
@@ -24,7 +22,7 @@ namespace Jint.Runtime
         }
 
         [DoesNotReturn]
-        public static void ThrowSyntaxError(Realm realm, string message, Location location)
+        public static void ThrowSyntaxError(Realm realm, string message, in SourceLocation location)
         {
             throw new JavaScriptException(realm.Intrinsics.SyntaxError, message).SetJavaScriptLocation(location);
         }
@@ -148,7 +146,7 @@ namespace Jint.Runtime
         }
 
         [DoesNotReturn]
-        public static void ThrowJavaScriptException(Engine engine, JsValue value, in Location location)
+        public static void ThrowJavaScriptException(Engine engine, JsValue value, in SourceLocation location)
         {
             throw new JavaScriptException(value).SetJavaScriptCallstack(engine, location);
         }

+ 1 - 0
Jint/Runtime/Host.cs

@@ -6,6 +6,7 @@ using Jint.Runtime.Descriptors;
 using Jint.Runtime.Environments;
 using Jint.Runtime.Interop;
 using Jint.Runtime.Modules;
+using Module = Jint.Runtime.Modules.Module;
 
 namespace Jint.Runtime
 {

+ 2 - 3
Jint/Runtime/IScriptOrModule.Extensions.cs

@@ -1,11 +1,10 @@
-using Esprima;
-using Jint.Runtime.Modules;
+using Module = Jint.Runtime.Modules.Module;
 
 namespace Jint.Runtime;
 
 internal static class ScriptOrModuleExtensions
 {
-    public static Module AsModule(this IScriptOrModule? scriptOrModule, Engine engine, Location location)
+    public static Module AsModule(this IScriptOrModule? scriptOrModule, Engine engine, in SourceLocation location)
     {
         if (scriptOrModule is not Module module)
         {

+ 1 - 0
Jint/Runtime/Interop/DefaultTypeConverter.cs

@@ -9,6 +9,7 @@ using Jint.Native;
 using Jint.Native.Function;
 using Jint.Native.Object;
 using Jint.Runtime.Descriptors;
+using Expression = System.Linq.Expressions.Expression;
 
 #pragma warning disable IL2026
 #pragma warning disable IL2067

+ 0 - 1
Jint/Runtime/Interpreter/EvaluationContext.cs

@@ -1,5 +1,4 @@
 using System.Runtime.CompilerServices;
-using Esprima.Ast;
 
 namespace Jint.Runtime.Interpreter;
 

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/BindingPatternAssignmentExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Array;
 using Jint.Native.Function;

+ 1 - 2
Jint/Runtime/Interpreter/Expressions/JintArrayExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Iterator;
 
@@ -32,7 +31,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                 {
                     var expression = Build(expr);
                     expressions[n] = expression;
-                    _hasSpreads |= expr.Type == Nodes.SpreadElement;
+                    _hasSpreads |= expr.Type == NodeType.SpreadElement;
                 }
             }
 

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintArrowFunctionExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Function;
 

+ 33 - 32
Jint/Runtime/Interpreter/Expressions/JintAssignmentExpression.cs

@@ -1,9 +1,10 @@
 using System.Numerics;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Function;
 using Jint.Runtime.Environments;
+
 using Environment = Jint.Runtime.Environments.Environment;
+using Operator = Esprima.Ast.AssignmentOperator;
 
 namespace Jint.Runtime.Interpreter.Expressions
 {
@@ -13,7 +14,7 @@ namespace Jint.Runtime.Interpreter.Expressions
         private readonly JintIdentifierExpression? _leftIdentifier;
 
         private readonly JintExpression _right;
-        private readonly AssignmentOperator _operator;
+        private readonly Operator _operator;
 
         private JintAssignmentExpression(AssignmentExpression expression) : base(expression)
         {
@@ -26,7 +27,7 @@ namespace Jint.Runtime.Interpreter.Expressions
 
         internal static JintExpression Build(AssignmentExpression expression)
         {
-            if (expression.Operator == AssignmentOperator.Assign)
+            if (expression.Operator == Operator.Assign)
             {
                 if (expression.Left is BindingPattern)
                 {
@@ -79,7 +80,7 @@ namespace Jint.Runtime.Interpreter.Expressions
             {
                 switch (_operator)
                 {
-                    case AssignmentOperator.PlusAssign:
+                    case Operator.PlusAssign:
                     {
                         var rval = _right.GetValue(context);
                         if (AreIntegerOperands(originalLeftValue, rval))
@@ -114,7 +115,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         break;
                     }
 
-                    case AssignmentOperator.MinusAssign:
+                    case Operator.MinusAssign:
                     {
                         var rval = _right.GetValue(context);
                         if (AreIntegerOperands(originalLeftValue, rval))
@@ -133,7 +134,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         break;
                     }
 
-                    case AssignmentOperator.TimesAssign:
+                    case Operator.TimesAssign:
                     {
                         var rval = _right.GetValue(context);
                         if (AreIntegerOperands(originalLeftValue, rval))
@@ -156,14 +157,14 @@ namespace Jint.Runtime.Interpreter.Expressions
                         break;
                     }
 
-                    case AssignmentOperator.DivideAssign:
+                    case Operator.DivideAssign:
                     {
                         var rval = _right.GetValue(context);
                         newLeftValue = Divide(context, originalLeftValue, rval);
                         break;
                     }
 
-                    case AssignmentOperator.ModuloAssign:
+                    case Operator.ModuloAssign:
                     {
                         var rval = _right.GetValue(context);
                         if (originalLeftValue.IsUndefined() || rval.IsUndefined())
@@ -178,49 +179,49 @@ namespace Jint.Runtime.Interpreter.Expressions
                         break;
                     }
 
-                    case AssignmentOperator.BitwiseAndAssign:
+                    case Operator.BitwiseAndAssign:
                     {
                         var rval = _right.GetValue(context);
                         newLeftValue = TypeConverter.ToInt32(originalLeftValue) & TypeConverter.ToInt32(rval);
                         break;
                     }
 
-                    case AssignmentOperator.BitwiseOrAssign:
+                    case Operator.BitwiseOrAssign:
                     {
                         var rval = _right.GetValue(context);
                         newLeftValue = TypeConverter.ToInt32(originalLeftValue) | TypeConverter.ToInt32(rval);
                         break;
                     }
 
-                    case AssignmentOperator.BitwiseXorAssign:
+                    case Operator.BitwiseXorAssign:
                     {
                         var rval = _right.GetValue(context);
                         newLeftValue = TypeConverter.ToInt32(originalLeftValue) ^ TypeConverter.ToInt32(rval);
                         break;
                     }
 
-                    case AssignmentOperator.LeftShiftAssign:
+                    case Operator.LeftShiftAssign:
                     {
                         var rval = _right.GetValue(context);
                         newLeftValue = TypeConverter.ToInt32(originalLeftValue) << (int) (TypeConverter.ToUint32(rval) & 0x1F);
                         break;
                     }
 
-                    case AssignmentOperator.RightShiftAssign:
+                    case Operator.RightShiftAssign:
                     {
                         var rval = _right.GetValue(context);
                         newLeftValue = TypeConverter.ToInt32(originalLeftValue) >> (int) (TypeConverter.ToUint32(rval) & 0x1F);
                         break;
                     }
 
-                    case AssignmentOperator.UnsignedRightShiftAssign:
+                    case Operator.UnsignedRightShiftAssign:
                     {
                         var rval = _right.GetValue(context);
                         newLeftValue = (uint) TypeConverter.ToInt32(originalLeftValue) >> (int) (TypeConverter.ToUint32(rval) & 0x1F);
                         break;
                     }
 
-                    case AssignmentOperator.NullishAssign:
+                    case Operator.NullishAssign:
                     {
                         if (!originalLeftValue.IsNullOrUndefined())
                         {
@@ -232,7 +233,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         break;
                     }
 
-                    case AssignmentOperator.AndAssign:
+                    case Operator.AndAssign:
                     {
                         if (!TypeConverter.ToBoolean(originalLeftValue))
                         {
@@ -244,7 +245,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         break;
                     }
 
-                    case AssignmentOperator.OrAssign:
+                    case Operator.OrAssign:
                     {
                         if (TypeConverter.ToBoolean(originalLeftValue))
                         {
@@ -256,7 +257,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         break;
                     }
 
-                    case AssignmentOperator.ExponentiationAssign:
+                    case Operator.ExponentiationAssign:
                     {
                         var rval = _right.GetValue(context);
                         if (!originalLeftValue.IsBigInt() && !rval.IsBigInt())
@@ -297,41 +298,41 @@ namespace Jint.Runtime.Interpreter.Expressions
             string? operatorClrName = null;
             switch (_operator)
             {
-                case AssignmentOperator.PlusAssign:
+                case Operator.PlusAssign:
                     operatorClrName = "op_Addition";
                     break;
-                case AssignmentOperator.MinusAssign:
+                case Operator.MinusAssign:
                     operatorClrName = "op_Subtraction";
                     break;
-                case AssignmentOperator.TimesAssign:
+                case Operator.TimesAssign:
                     operatorClrName = "op_Multiply";
                     break;
-                case AssignmentOperator.DivideAssign:
+                case Operator.DivideAssign:
                     operatorClrName = "op_Division";
                     break;
-                case AssignmentOperator.ModuloAssign:
+                case Operator.ModuloAssign:
                     operatorClrName = "op_Modulus";
                     break;
-                case AssignmentOperator.BitwiseAndAssign:
+                case Operator.BitwiseAndAssign:
                     operatorClrName = "op_BitwiseAnd";
                     break;
-                case AssignmentOperator.BitwiseOrAssign:
+                case Operator.BitwiseOrAssign:
                     operatorClrName = "op_BitwiseOr";
                     break;
-                case AssignmentOperator.BitwiseXorAssign:
+                case Operator.BitwiseXorAssign:
                     operatorClrName = "op_ExclusiveOr";
                     break;
-                case AssignmentOperator.LeftShiftAssign:
+                case Operator.LeftShiftAssign:
                     operatorClrName = "op_LeftShift";
                     break;
-                case AssignmentOperator.RightShiftAssign:
+                case Operator.RightShiftAssign:
                     operatorClrName = "op_RightShift";
                     break;
-                case AssignmentOperator.UnsignedRightShiftAssign:
+                case Operator.UnsignedRightShiftAssign:
                     operatorClrName = "op_UnsignedRightShift";
                     break;
-                case AssignmentOperator.ExponentiationAssign:
-                case AssignmentOperator.Assign:
+                case Operator.ExponentiationAssign:
+                case Operator.Assign:
                 default:
                     break;
             }
@@ -352,7 +353,7 @@ namespace Jint.Runtime.Interpreter.Expressions
         private JsValue NamedEvaluation(EvaluationContext context, JintExpression expression)
         {
             var rval = expression.GetValue(context);
-            if (expression._expression.IsAnonymousFunctionDefinition() && _left._expression.Type == Nodes.Identifier)
+            if (expression._expression.IsAnonymousFunctionDefinition() && _left._expression.Type == NodeType.Identifier)
             {
                 ((Function) rval).SetFunctionName(((Identifier) _left._expression).Name);
             }

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintAwaitExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Expressions;

+ 45 - 44
Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs

@@ -4,13 +4,14 @@ using System.Linq;
 using System.Numerics;
 using System.Reflection;
 using System.Runtime.CompilerServices;
-using Esprima.Ast;
 using Jint.Extensions;
 using Jint.Native;
 using Jint.Native.Number;
 using Jint.Native.Object;
 using Jint.Runtime.Interop;
 
+using Operator = Esprima.Ast.BinaryOperator;
+
 namespace Jint.Runtime.Interpreter.Expressions
 {
     internal abstract class JintBinaryExpression : JintExpression
@@ -94,60 +95,60 @@ namespace Jint.Runtime.Interpreter.Expressions
             JintBinaryExpression? result = null;
             switch (expression.Operator)
             {
-                case BinaryOperator.StrictlyEqual:
+                case Operator.StrictlyEqual:
                     result = new StrictlyEqualBinaryExpression(expression);
                     break;
-                case BinaryOperator.StrictlyNotEqual:
+                case Operator.StrictlyNotEqual:
                     result = new StrictlyNotEqualBinaryExpression(expression);
                     break;
-                case BinaryOperator.Less:
+                case Operator.Less:
                     result = new LessBinaryExpression(expression);
                     break;
-                case BinaryOperator.Greater:
+                case Operator.Greater:
                     result = new GreaterBinaryExpression(expression);
                     break;
-                case BinaryOperator.Plus:
+                case Operator.Plus:
                     result = new PlusBinaryExpression(expression);
                     break;
-                case BinaryOperator.Minus:
+                case Operator.Minus:
                     result = new MinusBinaryExpression(expression);
                     break;
-                case BinaryOperator.Times:
+                case Operator.Times:
                     result = new TimesBinaryExpression(expression);
                     break;
-                case BinaryOperator.Divide:
+                case Operator.Divide:
                     result = new DivideBinaryExpression(expression);
                     break;
-                case BinaryOperator.Equal:
+                case Operator.Equal:
                     result = new EqualBinaryExpression(expression);
                     break;
-                case BinaryOperator.NotEqual:
+                case Operator.NotEqual:
                     result = new EqualBinaryExpression(expression, invert: true);
                     break;
-                case BinaryOperator.GreaterOrEqual:
+                case Operator.GreaterOrEqual:
                     result = new CompareBinaryExpression(expression, leftFirst: true);
                     break;
-                case BinaryOperator.LessOrEqual:
+                case Operator.LessOrEqual:
                     result = new CompareBinaryExpression(expression, leftFirst: false);
                     break;
-                case BinaryOperator.BitwiseAnd:
-                case BinaryOperator.BitwiseOr:
-                case BinaryOperator.BitwiseXor:
-                case BinaryOperator.LeftShift:
-                case BinaryOperator.RightShift:
-                case BinaryOperator.UnsignedRightShift:
+                case Operator.BitwiseAnd:
+                case Operator.BitwiseOr:
+                case Operator.BitwiseXor:
+                case Operator.LeftShift:
+                case Operator.RightShift:
+                case Operator.UnsignedRightShift:
                     result = new BitwiseBinaryExpression(expression);
                     break;
-                case BinaryOperator.InstanceOf:
+                case Operator.InstanceOf:
                     result = new InstanceOfBinaryExpression(expression);
                     break;
-                case BinaryOperator.Exponentiation:
+                case Operator.Exponentiation:
                     result = new ExponentiationBinaryExpression(expression);
                     break;
-                case BinaryOperator.Modulo:
+                case Operator.Modulo:
                     result = new ModuloBinaryExpression(expression);
                     break;
-                case BinaryOperator.In:
+                case Operator.In:
                     result = new InBinaryExpression(expression);
                     break;
                 default:
@@ -155,8 +156,8 @@ namespace Jint.Runtime.Interpreter.Expressions
                     break;
             }
 
-            if (expression.Operator != BinaryOperator.InstanceOf
-                && expression.Operator != BinaryOperator.In
+            if (expression.Operator != Operator.InstanceOf
+                && expression.Operator != Operator.In
                 && expression.Left is Literal leftLiteral
                 && expression.Right is Literal rightLiteral)
             {
@@ -769,18 +770,18 @@ namespace Jint.Runtime.Interpreter.Expressions
                 {
                     return _operator switch
                     {
-                        BinaryOperator.BitwiseAnd => "op_BitwiseAnd",
-                        BinaryOperator.BitwiseOr => "op_BitwiseOr",
-                        BinaryOperator.BitwiseXor => "op_ExclusiveOr",
-                        BinaryOperator.LeftShift => "op_LeftShift",
-                        BinaryOperator.RightShift => "op_RightShift",
-                        BinaryOperator.UnsignedRightShift => "op_UnsignedRightShift",
+                        Operator.BitwiseAnd => "op_BitwiseAnd",
+                        Operator.BitwiseOr => "op_BitwiseOr",
+                        Operator.BitwiseXor => "op_ExclusiveOr",
+                        Operator.LeftShift => "op_LeftShift",
+                        Operator.RightShift => "op_RightShift",
+                        Operator.UnsignedRightShift => "op_UnsignedRightShift",
                         _ => null
                     };
                 }
             }
 
-            private readonly BinaryOperator _operator;
+            private readonly Operator _operator;
 
             public BitwiseBinaryExpression(BinaryExpression expression) : base(expression)
             {
@@ -816,22 +817,22 @@ namespace Jint.Runtime.Interpreter.Expressions
                     JsValue? result = null;
                     switch (_operator)
                     {
-                        case BinaryOperator.BitwiseAnd:
+                        case Operator.BitwiseAnd:
                             result = JsNumber.Create(leftValue & rightValue);
                             break;
-                        case BinaryOperator.BitwiseOr:
+                        case Operator.BitwiseOr:
                             result = JsNumber.Create(leftValue | rightValue);
                             break;
-                        case BinaryOperator.BitwiseXor:
+                        case Operator.BitwiseXor:
                             result = JsNumber.Create(leftValue ^ rightValue);
                             break;
-                        case BinaryOperator.LeftShift:
+                        case Operator.LeftShift:
                             result = JsNumber.Create(leftValue << (int) ((uint) rightValue & 0x1F));
                             break;
-                        case BinaryOperator.RightShift:
+                        case Operator.RightShift:
                             result = JsNumber.Create(leftValue >> (int) ((uint) rightValue & 0x1F));
                             break;
-                        case BinaryOperator.UnsignedRightShift:
+                        case Operator.UnsignedRightShift:
                             result = JsNumber.Create((uint) leftValue >> (int) ((uint) rightValue & 0x1F));
                             break;
                         default:
@@ -849,7 +850,7 @@ namespace Jint.Runtime.Interpreter.Expressions
             {
                 switch (_operator)
                 {
-                    case BinaryOperator.BitwiseAnd:
+                    case Operator.BitwiseAnd:
                     {
                         if (!left.IsBigInt())
                         {
@@ -859,7 +860,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         return JsBigInt.Create(TypeConverter.ToBigInt(left) & TypeConverter.ToBigInt(right));
                     }
 
-                    case BinaryOperator.BitwiseOr:
+                    case Operator.BitwiseOr:
                     {
                         if (!left.IsBigInt())
                         {
@@ -868,7 +869,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         return JsBigInt.Create(TypeConverter.ToBigInt(left) | TypeConverter.ToBigInt(right));
                     }
 
-                    case BinaryOperator.BitwiseXor:
+                    case Operator.BitwiseXor:
                     {
                         if (!left.IsBigInt())
                         {
@@ -877,7 +878,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         return JsBigInt.Create(TypeConverter.ToBigInt(left) ^ TypeConverter.ToBigInt(right));
                     }
 
-                    case BinaryOperator.LeftShift:
+                    case Operator.LeftShift:
                     {
                         if (!left.IsBigInt())
                         {
@@ -886,7 +887,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         return JsBigInt.Create(TypeConverter.ToBigInt(left) << (int) TypeConverter.ToBigInt(right));
                     }
 
-                    case BinaryOperator.RightShift:
+                    case Operator.RightShift:
                     {
                         if (!left.IsBigInt())
                         {
@@ -895,7 +896,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         return JsBigInt.Create(TypeConverter.ToBigInt(left) >> (int) TypeConverter.ToBigInt(right));
                     }
 
-                    case BinaryOperator.UnsignedRightShift:
+                    case Operator.UnsignedRightShift:
                     {
                         if (!left.IsBigInt())
                         {

+ 3 - 4
Jint/Runtime/Interpreter/Expressions/JintCallExpression.cs

@@ -1,6 +1,5 @@
 using System.Diagnostics.CodeAnalysis;
 using System.Runtime.CompilerServices;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Function;
 using Jint.Native.Object;
@@ -41,7 +40,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                     return false;
                 }
 
-                return e.Type == Nodes.SpreadElement || e is AssignmentExpression { Right.Type: Nodes.SpreadElement };
+                return e.Type == NodeType.SpreadElement || e is AssignmentExpression { Right.Type: NodeType.SpreadElement };
             }
 
             var cacheable = true;
@@ -49,7 +48,7 @@ namespace Jint.Runtime.Interpreter.Expressions
             {
                 var expressionArgument = expressionArguments[i];
                 cachedArgumentsHolder.JintArguments[i] = Build(expressionArgument);
-                cacheable &= expressionArgument.Type == Nodes.Literal;
+                cacheable &= expressionArgument.Type == NodeType.Literal;
                 _hasSpreads |= CanSpread(expressionArgument);
                 if (expressionArgument is ArrayExpression ae)
                 {
@@ -90,7 +89,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                 return StackGuard.RunOnEmptyStack(EvaluateInternal, context);
             }
 
-            if (_calleeExpression._expression.Type == Nodes.Super)
+            if (_calleeExpression._expression.Type == NodeType.Super)
             {
                 return SuperCall(context);
             }

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintClassExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native.Function;
 
 namespace Jint.Runtime.Interpreter.Expressions

+ 0 - 2
Jint/Runtime/Interpreter/Expressions/JintConditionalExpression.cs

@@ -1,5 +1,3 @@
-using Esprima.Ast;
-
 namespace Jint.Runtime.Interpreter.Expressions
 {
     internal sealed class JintConditionalExpression : JintExpression

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintConstantExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Expressions;

+ 28 - 29
Jint/Runtime/Interpreter/Expressions/JintExpression.cs

@@ -1,6 +1,5 @@
 using System.Numerics;
 using System.Runtime.CompilerServices;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Iterator;
 using Jint.Native.Number;
@@ -97,42 +96,42 @@ namespace Jint.Runtime.Interpreter.Expressions
 
             var result = expression.Type switch
             {
-                Nodes.AssignmentExpression => JintAssignmentExpression.Build((AssignmentExpression) expression),
-                Nodes.ArrayExpression => JintArrayExpression.Build((ArrayExpression) expression),
-                Nodes.ArrowFunctionExpression => new JintArrowFunctionExpression((ArrowFunctionExpression) expression),
-                Nodes.BinaryExpression => JintBinaryExpression.Build((BinaryExpression) expression),
-                Nodes.CallExpression => new JintCallExpression((CallExpression) expression),
-                Nodes.ConditionalExpression => new JintConditionalExpression((ConditionalExpression) expression),
-                Nodes.FunctionExpression => new JintFunctionExpression((FunctionExpression) expression),
-                Nodes.Identifier => new JintIdentifierExpression((Identifier) expression),
-                Nodes.PrivateIdentifier => new JintPrivateIdentifierExpression((PrivateIdentifier) expression),
-                Nodes.Literal => JintLiteralExpression.Build((Literal) expression),
-                Nodes.LogicalExpression => ((BinaryExpression) expression).Operator switch
+                NodeType.AssignmentExpression => JintAssignmentExpression.Build((AssignmentExpression) expression),
+                NodeType.ArrayExpression => JintArrayExpression.Build((ArrayExpression) expression),
+                NodeType.ArrowFunctionExpression => new JintArrowFunctionExpression((ArrowFunctionExpression) expression),
+                NodeType.BinaryExpression => JintBinaryExpression.Build((BinaryExpression) expression),
+                NodeType.CallExpression => new JintCallExpression((CallExpression) expression),
+                NodeType.ConditionalExpression => new JintConditionalExpression((ConditionalExpression) expression),
+                NodeType.FunctionExpression => new JintFunctionExpression((FunctionExpression) expression),
+                NodeType.Identifier => new JintIdentifierExpression((Identifier) expression),
+                NodeType.PrivateIdentifier => new JintPrivateIdentifierExpression((PrivateIdentifier) expression),
+                NodeType.Literal => JintLiteralExpression.Build((Literal) expression),
+                NodeType.LogicalExpression => ((BinaryExpression) expression).Operator switch
                 {
                     BinaryOperator.LogicalAnd => new JintLogicalAndExpression((BinaryExpression) expression),
                     BinaryOperator.LogicalOr => new JintLogicalOrExpression((BinaryExpression) expression),
                     BinaryOperator.NullishCoalescing => new NullishCoalescingExpression((BinaryExpression) expression),
                     _ => null
                 },
-                Nodes.MemberExpression => new JintMemberExpression((MemberExpression) expression),
-                Nodes.NewExpression => new JintNewExpression((NewExpression) expression),
-                Nodes.ObjectExpression => JintObjectExpression.Build((ObjectExpression) expression),
-                Nodes.SequenceExpression => new JintSequenceExpression((SequenceExpression) expression),
-                Nodes.ThisExpression => new JintThisExpression((ThisExpression) expression),
-                Nodes.UpdateExpression => new JintUpdateExpression((UpdateExpression) expression),
-                Nodes.UnaryExpression => JintUnaryExpression.Build((UnaryExpression) expression),
-                Nodes.SpreadElement => new JintSpreadExpression((SpreadElement) expression),
-                Nodes.TemplateLiteral => new JintTemplateLiteralExpression((TemplateLiteral) expression),
-                Nodes.TaggedTemplateExpression => new JintTaggedTemplateExpression((TaggedTemplateExpression) expression),
-                Nodes.ClassExpression => new JintClassExpression((ClassExpression) expression),
-                Nodes.ImportExpression => new JintImportExpression((ImportExpression) expression),
-                Nodes.Super => new JintSuperExpression((Super) expression),
-                Nodes.MetaProperty => new JintMetaPropertyExpression((MetaProperty) expression),
-                Nodes.ChainExpression => ((ChainExpression) expression).Expression.Type == Nodes.CallExpression
+                NodeType.MemberExpression => new JintMemberExpression((MemberExpression) expression),
+                NodeType.NewExpression => new JintNewExpression((NewExpression) expression),
+                NodeType.ObjectExpression => JintObjectExpression.Build((ObjectExpression) expression),
+                NodeType.SequenceExpression => new JintSequenceExpression((SequenceExpression) expression),
+                NodeType.ThisExpression => new JintThisExpression((ThisExpression) expression),
+                NodeType.UpdateExpression => new JintUpdateExpression((UpdateExpression) expression),
+                NodeType.UnaryExpression => JintUnaryExpression.Build((UnaryExpression) expression),
+                NodeType.SpreadElement => new JintSpreadExpression((SpreadElement) expression),
+                NodeType.TemplateLiteral => new JintTemplateLiteralExpression((TemplateLiteral) expression),
+                NodeType.TaggedTemplateExpression => new JintTaggedTemplateExpression((TaggedTemplateExpression) expression),
+                NodeType.ClassExpression => new JintClassExpression((ClassExpression) expression),
+                NodeType.ImportExpression => new JintImportExpression((ImportExpression) expression),
+                NodeType.Super => new JintSuperExpression((Super) expression),
+                NodeType.MetaProperty => new JintMetaPropertyExpression((MetaProperty) expression),
+                NodeType.ChainExpression => ((ChainExpression) expression).Expression.Type == NodeType.CallExpression
                     ? new JintCallExpression((CallExpression) ((ChainExpression) expression).Expression)
                     : new JintMemberExpression((MemberExpression) ((ChainExpression) expression).Expression),
-                Nodes.AwaitExpression => new JintAwaitExpression((AwaitExpression) expression),
-                Nodes.YieldExpression => new JintYieldExpression((YieldExpression) expression),
+                NodeType.AwaitExpression => new JintAwaitExpression((AwaitExpression) expression),
+                NodeType.YieldExpression => new JintYieldExpression((YieldExpression) expression),
                 _ =>  null
             };
 

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintFunctionExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Function;
 using Jint.Native.Object;

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintIdentifierExpression.cs

@@ -1,6 +1,5 @@
 using System.Diagnostics.CodeAnalysis;
 using System.Runtime.CompilerServices;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Runtime.Environments;
 using Environment = Jint.Runtime.Environments.Environment;

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintImportExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Object;
 using Jint.Native.Promise;

+ 0 - 2
Jint/Runtime/Interpreter/Expressions/JintLiteralExpression.cs

@@ -1,7 +1,5 @@
 using System.Numerics;
 using System.Text.RegularExpressions;
-using Esprima;
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Expressions

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintLogicalAndExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Expressions

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintLogicalOrExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Expressions

+ 1 - 2
Jint/Runtime/Interpreter/Expressions/JintMemberExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Runtime.Environments;
 
@@ -32,7 +31,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                     property = cache ? JsString.CachedCreate(identifier.Name) : JsString.Create(identifier.Name);
                 }
             }
-            else if (expression.Property.Type == Nodes.Literal)
+            else if (expression.Property.Type == NodeType.Literal)
             {
                 property = JintLiteralExpression.ConvertToJsValue((Literal) expression.Property);
             }

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintMetaPropertyExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Runtime.Modules;
 
 namespace Jint.Runtime.Interpreter.Expressions

+ 1 - 2
Jint/Runtime/Interpreter/Expressions/JintNewExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Expressions
@@ -29,7 +28,7 @@ namespace Jint.Runtime.Interpreter.Expressions
             {
                 var argument = expression.Arguments[i];
                 _jintArguments[i] = Build(argument);
-                _hasSpreads |= argument.Type == Nodes.SpreadElement;
+                _hasSpreads |= argument.Type == NodeType.SpreadElement;
             }
         }
 

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintObjectExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Collections;
 using Jint.Native;
 using Jint.Native.Function;

+ 0 - 2
Jint/Runtime/Interpreter/Expressions/JintPrivateIdentifierExpression.cs

@@ -1,5 +1,3 @@
-using Esprima.Ast;
-
 namespace Jint.Runtime.Interpreter.Expressions;
 
 internal sealed class JintPrivateIdentifierExpression : JintExpression

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintSequenceExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Expressions

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintSpreadExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Iterator;
 

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintSuperExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Runtime.Environments;
 
 namespace Jint.Runtime.Interpreter.Expressions

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintTaggedTemplateExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Object;
 using Jint.Runtime.Descriptors;

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintTemplateLiteralExpression.cs

@@ -1,5 +1,4 @@
 using System.Text;
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Expressions;

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintThisExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Expressions

+ 11 - 10
Jint/Runtime/Interpreter/Expressions/JintUnaryExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Extensions;
 using Jint.Native;
 using Jint.Runtime.Interop;
@@ -6,7 +5,9 @@ using System.Collections.Concurrent;
 using System.Diagnostics.CodeAnalysis;
 using System.Numerics;
 using System.Reflection;
+
 using Environment = Jint.Runtime.Environments.Environment;
+using Operator = Esprima.Ast.UnaryOperator;
 
 namespace Jint.Runtime.Interpreter.Expressions
 {
@@ -16,7 +17,7 @@ namespace Jint.Runtime.Interpreter.Expressions
         private static readonly ConcurrentDictionary<OperatorKey, MethodDescriptor?> _knownOperators = new();
 
         private readonly JintExpression _argument;
-        private readonly UnaryOperator _operator;
+        private readonly Operator _operator;
 
         private JintUnaryExpression(UnaryExpression expression) : base(expression)
         {
@@ -26,7 +27,7 @@ namespace Jint.Runtime.Interpreter.Expressions
 
         internal static JintExpression Build(UnaryExpression expression)
         {
-            if (expression.Operator == UnaryOperator.TypeOf)
+            if (expression.Operator == Operator.TypeOf)
             {
                 return new JintTypeOfExpression(expression);
             }
@@ -36,7 +37,7 @@ namespace Jint.Runtime.Interpreter.Expressions
 
         internal static JintExpression? BuildConstantExpression(UnaryExpression expression)
         {
-            if (expression is { Operator: UnaryOperator.Minus, Argument: Literal literal })
+            if (expression is { Operator: Operator.Minus, Argument: Literal literal })
             {
                 var value = JintLiteralExpression.ConvertToJsValue(literal);
                 if (value is not null)
@@ -137,7 +138,7 @@ namespace Jint.Runtime.Interpreter.Expressions
             var engine = context.Engine;
             switch (_operator)
             {
-                case UnaryOperator.Plus:
+                case Operator.Plus:
                 {
                     var v = _argument.GetValue(context);
                     if (context.OperatorOverloadingAllowed &&
@@ -148,7 +149,7 @@ namespace Jint.Runtime.Interpreter.Expressions
 
                     return TypeConverter.ToNumber(v);
                 }
-                case UnaryOperator.Minus:
+                case Operator.Minus:
                 {
                     var v = _argument.GetValue(context);
                     if (context.OperatorOverloadingAllowed &&
@@ -159,7 +160,7 @@ namespace Jint.Runtime.Interpreter.Expressions
 
                     return EvaluateMinus(v);
                 }
-                case UnaryOperator.BitwiseNot:
+                case Operator.BitwiseNot:
                 {
                     var v = _argument.GetValue(context);
                     if (context.OperatorOverloadingAllowed &&
@@ -176,7 +177,7 @@ namespace Jint.Runtime.Interpreter.Expressions
 
                     return JsBigInt.Create(~value.AsBigInt());
                 }
-                case UnaryOperator.LogicalNot:
+                case Operator.LogicalNot:
                 {
                     var v = _argument.GetValue(context);
                     if (context.OperatorOverloadingAllowed &&
@@ -188,7 +189,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                     return !TypeConverter.ToBoolean(v) ? JsBoolean.True : JsBoolean.False;
                 }
 
-                case UnaryOperator.Delete:
+                case Operator.Delete:
                     // https://262.ecma-international.org/5.1/#sec-11.4.1
                     if (_argument.Evaluate(context) is not Reference r)
                     {
@@ -244,7 +245,7 @@ namespace Jint.Runtime.Interpreter.Expressions
 
                     return bindings.DeleteBinding(property.ToString()) ? JsBoolean.True : JsBoolean.False;
 
-                case UnaryOperator.Void:
+                case Operator.Void:
                     _argument.GetValue(context);
                     return JsValue.Undefined;
 

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintUpdateExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Runtime.Environments;
 

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/JintYieldExpression.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Generator;
 using Jint.Native.Iterator;

+ 0 - 1
Jint/Runtime/Interpreter/Expressions/NullishCoalescingExpression.cs

@@ -1,5 +1,4 @@
 using System.Runtime.CompilerServices;
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Expressions

+ 7 - 8
Jint/Runtime/Interpreter/JintFunctionDefinition.cs

@@ -1,5 +1,4 @@
 using System.Runtime.CompilerServices;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Function;
 using Jint.Native.Generator;
@@ -238,7 +237,7 @@ internal sealed class JintFunctionDefinition
 
         state.ArgumentsObjectNeeded = true;
         var thisMode = function.Strict ? FunctionThisMode.Strict : FunctionThisMode.Global;
-        if (function.Type == Nodes.ArrowFunctionExpression)
+        if (function.Type == NodeType.ArrowFunctionExpression)
         {
             thisMode = FunctionThisMode.Lexical;
         }
@@ -442,16 +441,16 @@ internal sealed class JintFunctionDefinition
             var parameter = functionDeclarationParams[i];
             var type = parameter.Type;
 
-            if (type == Nodes.Identifier)
+            if (type == NodeType.Identifier)
             {
                 var id = (Identifier) parameter;
                 state.HasDuplicates |= parameterNames.Contains(id.Name);
                 hasArguments = string.Equals(id.Name, "arguments", StringComparison.Ordinal);
                 parameterNames.Add(id.Name);
             }
-            else if (type != Nodes.Literal)
+            else if (type != NodeType.Literal)
             {
-                countParameters &= type != Nodes.AssignmentPattern;
+                countParameters &= type != NodeType.AssignmentPattern;
                 state.IsSimpleParameterList = false;
                 GetBoundNames(
                     parameter,
@@ -463,7 +462,7 @@ internal sealed class JintFunctionDefinition
                     ref hasArguments);
             }
 
-            if (countParameters && type is Nodes.Identifier or Nodes.ObjectPattern or Nodes.ArrayPattern)
+            if (countParameters && type is NodeType.Identifier or NodeType.ObjectPattern or NodeType.ArrayPattern)
             {
                 state.Length++;
             }
@@ -498,14 +497,14 @@ internal sealed class JintFunctionDefinition
             foreach (var childNode in node.ChildNodes)
             {
                 var childType = childNode.Type;
-                if (childType == Nodes.Identifier)
+                if (childType == NodeType.Identifier)
                 {
                     if (string.Equals(((Identifier) childNode).Name, "arguments", StringComparison.Ordinal))
                     {
                         return true;
                     }
                 }
-                else if (childType != Nodes.FunctionDeclaration && !childNode.ChildNodes.IsEmpty())
+                else if (childType != NodeType.FunctionDeclaration && !childNode.ChildNodes.IsEmpty())
                 {
                     if (HasArgumentsReference(childNode))
                     {

+ 0 - 1
Jint/Runtime/Interpreter/JintStatementList.cs

@@ -1,5 +1,4 @@
 using System.Runtime.CompilerServices;
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Error;
 using Jint.Runtime.Interpreter.Statements;

+ 0 - 1
Jint/Runtime/Interpreter/Statements/ConstantReturnStatement.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Statements;

+ 0 - 1
Jint/Runtime/Interpreter/Statements/JintBlockStatement.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Runtime.Environments;
 using Environment = Jint.Runtime.Environments.Environment;
 

+ 0 - 1
Jint/Runtime/Interpreter/Statements/JintBreakStatement.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Statements;

+ 0 - 1
Jint/Runtime/Interpreter/Statements/JintClassDeclarationStatement.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Native.Function;
 

+ 0 - 1
Jint/Runtime/Interpreter/Statements/JintContinueStatement.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 
 namespace Jint.Runtime.Interpreter.Statements;

+ 0 - 1
Jint/Runtime/Interpreter/Statements/JintDebuggerStatement.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Runtime.Debugger;
 

+ 0 - 1
Jint/Runtime/Interpreter/Statements/JintDoWhileStatement.cs

@@ -1,4 +1,3 @@
-using Esprima.Ast;
 using Jint.Native;
 using Jint.Runtime.Interpreter.Expressions;
 

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác