diff --git a/.gitignore b/.gitignore
index 1cf8432776..8be328851e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -165,3 +165,4 @@ BenchmarkDotNet.Artifacts*
# generated code
Jint.Tests.Test262/Generated
+/artifacts
diff --git a/Directory.Build.props b/Directory.Build.props
index d4159e07cc..81faa74db7 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,7 +1,37 @@
+
+ Sebastien Ros
+ Sebastien Ros
+
+ Javascript interpreter for .NET.
+ javascript, interpreter, es5, es2015, es6, ecmascript, interop
+ https://github.com/sebastienros/jint
+ BSD-2-Clause
+
+ 0
+ 3.0.1
+ beta-$(BuildNumber)
+ $(VersionPrefix).$(BuildNumber)
+
+ true
+ true
+ true
+ portable
+ snupkg
+
+ true
true
+
+
+
+
+
+
+
+
+
diff --git a/Jint.Benchmark/DromaeoBenchmark.cs b/Jint.Benchmark/DromaeoBenchmark.cs
index ad77dd7cab..295df63160 100644
--- a/Jint.Benchmark/DromaeoBenchmark.cs
+++ b/Jint.Benchmark/DromaeoBenchmark.cs
@@ -1,5 +1,4 @@
using BenchmarkDotNet.Attributes;
-using Esprima.Ast;
namespace Jint.Benchmark;
diff --git a/Jint.Benchmark/EngineComparisonBenchmark.cs b/Jint.Benchmark/EngineComparisonBenchmark.cs
index eab0dfebe4..b3c1ce178a 100644
--- a/Jint.Benchmark/EngineComparisonBenchmark.cs
+++ b/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;
diff --git a/Jint.Benchmark/EngineConstructionBenchmark.cs b/Jint.Benchmark/EngineConstructionBenchmark.cs
index dc1d79fd6b..709f17a024 100644
--- a/Jint.Benchmark/EngineConstructionBenchmark.cs
+++ b/Jint.Benchmark/EngineConstructionBenchmark.cs
@@ -1,6 +1,4 @@
using BenchmarkDotNet.Attributes;
-using Esprima;
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Benchmark;
diff --git a/Jint.Benchmark/Jint.Benchmark.csproj b/Jint.Benchmark/Jint.Benchmark.csproj
index d1675bf7b7..223d04007d 100644
--- a/Jint.Benchmark/Jint.Benchmark.csproj
+++ b/Jint.Benchmark/Jint.Benchmark.csproj
@@ -10,6 +10,8 @@
false
false
false
+ false
+ false
..\Jint\Jint.snk
true
latest
@@ -29,4 +31,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/Jint.Benchmark/ObjectAccessBenchmark.cs b/Jint.Benchmark/ObjectAccessBenchmark.cs
index 283a4fb625..532e1d9233 100644
--- a/Jint.Benchmark/ObjectAccessBenchmark.cs
+++ b/Jint.Benchmark/ObjectAccessBenchmark.cs
@@ -1,5 +1,4 @@
using BenchmarkDotNet.Attributes;
-using Esprima.Ast;
namespace Jint.Benchmark;
diff --git a/Jint.Benchmark/ShadowRealmBenchmark.cs b/Jint.Benchmark/ShadowRealmBenchmark.cs
index 754a4916a2..27841e60f3 100644
--- a/Jint.Benchmark/ShadowRealmBenchmark.cs
+++ b/Jint.Benchmark/ShadowRealmBenchmark.cs
@@ -1,5 +1,4 @@
using BenchmarkDotNet.Attributes;
-using Esprima.Ast;
namespace Jint.Benchmark;
diff --git a/Jint.Benchmark/SingleScriptBenchmark.cs b/Jint.Benchmark/SingleScriptBenchmark.cs
index 4ee9b10c1e..69c64d9b85 100644
--- a/Jint.Benchmark/SingleScriptBenchmark.cs
+++ b/Jint.Benchmark/SingleScriptBenchmark.cs
@@ -1,5 +1,4 @@
using BenchmarkDotNet.Attributes;
-using Esprima.Ast;
namespace Jint.Benchmark;
diff --git a/Jint.Repl/Program.cs b/Jint.Repl/Program.cs
index 3cc3d3e2c8..cdc8c4442f 100644
--- a/Jint.Repl/Program.cs
+++ b/Jint.Repl/Program.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using Esprima;
using Jint;
using Jint.Native;
using Jint.Native.Json;
diff --git a/Jint.Tests.CommonScripts/ConcurrencyTest.cs b/Jint.Tests.CommonScripts/ConcurrencyTest.cs
index 9e54d6e8b5..826ab95ca8 100644
--- a/Jint.Tests.CommonScripts/ConcurrencyTest.cs
+++ b/Jint.Tests.CommonScripts/ConcurrencyTest.cs
@@ -1,5 +1,3 @@
-using Esprima;
-
namespace Jint.Tests.CommonScripts;
[Parallelizable(ParallelScope.Fixtures)]
diff --git a/Jint.Tests.PublicInterface/ModuleLoaderTests.cs b/Jint.Tests.PublicInterface/ModuleLoaderTests.cs
index 322f0f1e47..95acd32a39 100644
--- a/Jint.Tests.PublicInterface/ModuleLoaderTests.cs
+++ b/Jint.Tests.PublicInterface/ModuleLoaderTests.cs
@@ -3,6 +3,8 @@
using Jint.Native.Json;
using Jint.Runtime.Modules;
+using Module = Jint.Runtime.Modules.Module;
+
#nullable enable
namespace Jint.Tests.PublicInterface;
diff --git a/Jint.Tests.PublicInterface/RavenApiUsageTests.cs b/Jint.Tests.PublicInterface/RavenApiUsageTests.cs
index 352add825d..ef21108bd5 100644
--- a/Jint.Tests.PublicInterface/RavenApiUsageTests.cs
+++ b/Jint.Tests.PublicInterface/RavenApiUsageTests.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Constraints;
using Jint.Native;
using Jint.Native.Function;
diff --git a/Jint.Tests.Test262/State.cs b/Jint.Tests.Test262/State.cs
index d889ee4de8..4e67aca755 100644
--- a/Jint.Tests.Test262/State.cs
+++ b/Jint.Tests.Test262/State.cs
@@ -1,5 +1,3 @@
-using Esprima.Ast;
-
namespace Jint.Tests.Test262;
///
diff --git a/Jint.Tests.Test262/Test262Test.cs b/Jint.Tests.Test262/Test262Test.cs
index 8ba8467d43..811a6c1921 100644
--- a/Jint.Tests.Test262/Test262Test.cs
+++ b/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;
diff --git a/Jint.Tests/Parser/JavascriptParserTests.cs b/Jint.Tests/Parser/JavascriptParserTests.cs
index 1370c12afd..8c00b4e938 100644
--- a/Jint.Tests/Parser/JavascriptParserTests.cs
+++ b/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 @@ public void ShouldParseThis()
var body = program.Body;
Assert.Single(body);
- Assert.Equal(Nodes.ThisExpression, body.First().As().Expression.Type);
+ Assert.Equal(NodeType.ThisExpression, body.First().As().Expression.Type);
}
[Fact]
@@ -23,7 +21,7 @@ public void ShouldParseNull()
var body = program.Body;
Assert.Single(body);
- Assert.Equal(Nodes.Literal, body.First().As().Expression.Type);
+ Assert.Equal(NodeType.Literal, body.First().As().Expression.Type);
Assert.Equal(null, body.First().As().Expression.As().Value);
Assert.Equal("null", body.First().As().Expression.As().Raw);
}
@@ -38,7 +36,7 @@ public void ShouldParseNumeric()
var body = program.Body;
Assert.Single(body);
- Assert.Equal(Nodes.Literal, body.First().As().Expression.Type);
+ Assert.Equal(NodeType.Literal, body.First().As().Expression.Type);
Assert.Equal(42d, body.First().As().Expression.As().Value);
Assert.Equal("42", body.First().As().Expression.As().Raw);
}
diff --git a/Jint.Tests/Runtime/Debugger/CallStackTests.cs b/Jint.Tests/Runtime/Debugger/CallStackTests.cs
index 7115cb900a..deeabea3e3 100644
--- a/Jint.Tests/Runtime/Debugger/CallStackTests.cs
+++ b/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
{
diff --git a/Jint.Tests/Runtime/Debugger/EvaluateTests.cs b/Jint.Tests/Runtime/Debugger/EvaluateTests.cs
index d57c7adb3e..7d85fa0176 100644
--- a/Jint.Tests/Runtime/Debugger/EvaluateTests.cs
+++ b/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;
diff --git a/Jint.Tests/Runtime/Debugger/StepFlowTests.cs b/Jint.Tests/Runtime/Debugger/StepFlowTests.cs
index fc6f12e6e2..13d36a9d01 100644
--- a/Jint.Tests/Runtime/Debugger/StepFlowTests.cs
+++ b/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 @@ private List StepIntoScript(string script)
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));
diff --git a/Jint.Tests/Runtime/Debugger/TestHelpers.cs b/Jint.Tests/Runtime/Debugger/TestHelpers.cs
index d00b16b9c6..bb53986ece 100644
--- a/Jint.Tests/Runtime/Debugger/TestHelpers.cs
+++ b/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
{
diff --git a/Jint.Tests/Runtime/EngineTests.ScriptPreparation.cs b/Jint.Tests/Runtime/EngineTests.ScriptPreparation.cs
index d762a9e81b..390109ac1c 100644
--- a/Jint.Tests/Runtime/EngineTests.ScriptPreparation.cs
+++ b/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;
diff --git a/Jint.Tests/Runtime/EngineTests.cs b/Jint.Tests/Runtime/EngineTests.cs
index a708591259..5d8ed87d39 100644
--- a/Jint.Tests/Runtime/EngineTests.cs
+++ b/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;
diff --git a/Jint.Tests/Runtime/ErrorTests.cs b/Jint.Tests/Runtime/ErrorTests.cs
index f21233472c..9e273e45c2 100644
--- a/Jint.Tests/Runtime/ErrorTests.cs
+++ b/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;
diff --git a/Jint.Tests/Runtime/ModuleTests.cs b/Jint.Tests/Runtime/ModuleTests.cs
index 260df9c71a..f8b5e1e5e2 100644
--- a/Jint.Tests/Runtime/ModuleTests.cs
+++ b/Jint.Tests/Runtime/ModuleTests.cs
@@ -2,6 +2,8 @@
using Jint.Runtime;
using Jint.Runtime.Modules;
+using Module = Jint.Runtime.Modules.Module;
+
namespace Jint.Tests.Runtime;
public class ModuleTests
diff --git a/Jint/Directory.Build.props b/Jint/Directory.Build.props
deleted file mode 100644
index 0c6e50f915..0000000000
--- a/Jint/Directory.Build.props
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
- Sebastien Ros
- Sebastien Ros
-
- Jint
- Jint
- Javascript interpreter for .NET.
-
- 0
- 3.0.1
- beta-$(BuildNumber)
- $(VersionPrefix).$(BuildNumber)
-
- Jint
- javascript, interpreter, es5, es2015, es6, ecmascript, interop
- https://github.com/sebastienros/jint
- BSD-2-Clause
-
- true
- true
- true
- portable
- snupkg
-
- true
-
-
-
-
diff --git a/Jint/Engine.Ast.cs b/Jint/Engine.Ast.cs
index 56b6584de8..51f4e781bc 100644
--- a/Jint/Engine.Ast.cs
+++ b/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 void NodeVisitor(Node node)
{
switch (node.Type)
{
- case Nodes.Identifier:
+ case NodeType.Identifier:
var identifier = (Identifier) node;
var name = identifier.Name;
@@ -82,7 +80,7 @@ public void NodeVisitor(Node node)
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 void NodeVisitor(Node node)
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 void NodeVisitor(Node node)
break;
- case Nodes.ReturnStatement:
+ case NodeType.ReturnStatement:
var returnStatement = (ReturnStatement) node;
if (returnStatement.Argument is Literal returnedLiteral)
{
diff --git a/Jint/Engine.Modules.cs b/Jint/Engine.Modules.cs
index c900426c55..a65038076f 100644
--- a/Jint/Engine.Modules.cs
+++ b/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 @@ private JsValue EvaluateModule(string specifier, Module module)
{
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);
diff --git a/Jint/Engine.cs b/Jint/Engine.cs
index d25c4a3bc3..3c48afbdf5 100644
--- a/Jint/Engine.cs
+++ b/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 @@ internal void RunBeforeExecuteStatementChecks(StatementListItem? statement)
constraint.Check();
}
- if (_isDebugMode && statement != null && statement.Type != Nodes.BlockStatement)
+ if (_isDebugMode && statement != null && statement.Type != NodeType.BlockStatement)
{
Debugger.OnStep(statement);
}
diff --git a/Jint/EsprimaExtensions.cs b/Jint/EsprimaExtensions.cs
index f8361c1c73..8f322eb7c9 100644
--- a/Jint/EsprimaExtensions.cs
+++ b/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 @@ internal static JsValue TryGetKey(this T expression, Engine engine, bool reso
private static JsValue TryGetComputedPropertyKey(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 @@ internal static bool IsFunctionDefinition(this T node) where T : Node
{
var type = node.Type;
return type
- is Nodes.FunctionExpression
- or Nodes.ArrowFunctionExpression
- or Nodes.ClassExpression;
+ is NodeType.FunctionExpression
+ or NodeType.ArrowFunctionExpression
+ or NodeType.ClassExpression;
}
///
@@ -178,7 +175,7 @@ internal static void GetBoundNames(this VariableDeclaration variableDeclaration,
internal static void GetBoundNames(this Node? parameter, List target)
{
- if (parameter is null || parameter.Type == Nodes.Literal)
+ if (parameter is null || parameter.Type == NodeType.Literal)
{
return;
}
@@ -257,18 +254,18 @@ internal static void GetBoundNames(this Node? parameter, List target)
///
internal static void PrivateBoundIdentifiers(this Node parameter, HashSet 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 @@ private static string GetModuleKey(this Expression expression)
///
/// Creates a dummy node that can be used when only location available and node is required.
///
- internal static SyntaxElement CreateLocationNode(in Location location)
+ internal static SyntaxElement CreateLocationNode(in SourceLocation location)
{
return new MinimalSyntaxElement(location);
}
@@ -492,7 +489,7 @@ internal static void AllPrivateIdentifiersValid(this Script script, Realm realm,
private sealed class MinimalSyntaxElement : SyntaxElement
{
- public MinimalSyntaxElement(in Location location)
+ public MinimalSyntaxElement(in SourceLocation location)
{
Location = location;
}
diff --git a/Jint/HoistingScope.cs b/Jint/HoistingScope.cs
index ceb9a1e0c8..0799b56e16 100644
--- a/Jint/HoistingScope.cs
+++ b/Jint/HoistingScope.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Runtime.Modules;
using Module = Esprima.Ast.Module;
@@ -80,7 +79,7 @@ public static HoistingScope GetModuleLevelDeclarations(
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 @@ public static HoistingScope GetModuleLevelDeclarations(
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 @@ public void Visit(Node node, Node? parent)
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 @@ public void Visit(Node node, Node? parent)
}
}
}
- 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();
_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();
_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 @@ internal void Visit(Node node)
{
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 ??= [];
diff --git a/Jint/JsValueExtensions.cs b/Jint/JsValueExtensions.cs
index e23834a577..610fbeb0d0 100644
--- a/Jint/JsValueExtensions.cs
+++ b/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;
diff --git a/Jint/Native/Function/ClassDefinition.cs b/Jint/Native/Function/ClassDefinition.cs
index 8cf1ecb224..1b4b2286c0 100644
--- a/Jint/Native/Function/ClassDefinition.cs
+++ b/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 @@ private sealed class ClassFieldFunction : Node, IFunction
private readonly NodeList _nodeList;
private readonly BlockStatement _statement;
- public ClassFieldFunction(Expression expression) : base(Nodes.ExpressionStatement)
+ public ClassFieldFunction(Expression expression) : base(NodeType.ExpressionStatement)
{
var nodeList = NodeList.Create(new [] { new ReturnStatement(expression) });
_statement = new BlockStatement(nodeList);
@@ -323,7 +320,7 @@ private sealed class ClassStaticBlockFunction : Node, IFunction
private readonly BlockStatement _statement;
private readonly NodeList _params;
- public ClassStaticBlockFunction(StaticBlock staticBlock) : base(Nodes.StaticBlock)
+ public ClassStaticBlockFunction(StaticBlock staticBlock) : base(NodeType.StaticBlock)
{
_statement = new BlockStatement(staticBlock.Body);
_params = new NodeList();
diff --git a/Jint/Native/Function/EvalFunction.cs b/Jint/Native/Function/EvalFunction.cs
index 0002633092..b724ae8882 100644
--- a/Jint/Native/Function/EvalFunction.cs
+++ b/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 @@ protected override object VisitMetaProperty(MetaProperty metaProperty)
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);
}
}
diff --git a/Jint/Native/Function/Function.cs b/Jint/Native/Function/Function.cs
index 881edbe974..d41369ebc4 100644
--- a/Jint/Native/Function/Function.cs
+++ b/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;
diff --git a/Jint/Native/Function/FunctionInstance.Dynamic.cs b/Jint/Native/Function/FunctionInstance.Dynamic.cs
index b4b500f04e..d3d82800b5 100644
--- a/Jint/Native/Function/FunctionInstance.Dynamic.cs
+++ b/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;
diff --git a/Jint/Native/Function/ScriptFunction.cs b/Jint/Native/Function/ScriptFunction.cs
index 18d0a0ea27..950a447001 100644
--- a/Jint/Native/Function/ScriptFunction.cs
+++ b/Jint/Native/Function/ScriptFunction.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native.Object;
using Jint.Runtime;
using Jint.Runtime.Descriptors;
diff --git a/Jint/Native/Generator/GeneratorInstance.cs b/Jint/Native/Generator/GeneratorInstance.cs
index f4c03802fb..50e7492bc6 100644
--- a/Jint/Native/Generator/GeneratorInstance.cs
+++ b/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 @@ public JsValue GeneratorResumeAbrupt(in Completion abruptCompletion, JsValue? ge
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 @@ public JsValue GeneratorResumeAbrupt(in Completion abruptCompletion, JsValue? ge
if (_error is not null)
{
- ExceptionHelper.ThrowJavaScriptException(_engine, _error, new Location());
+ ExceptionHelper.ThrowJavaScriptException(_engine, _error, (SourceLocation) default);
}
return ResumeExecution(genContext, new EvaluationContext(_engine));
diff --git a/Jint/Native/Global/GlobalObject.cs b/Jint/Native/Global/GlobalObject.cs
index 28304e9ddf..91edc90dd5 100644
--- a/Jint/Native/Global/GlobalObject.cs
+++ b/Jint/Native/Global/GlobalObject.cs
@@ -3,7 +3,6 @@
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
-using Esprima;
using Jint.Native.Object;
using Jint.Native.String;
using Jint.Runtime;
diff --git a/Jint/Native/JsRegExp.cs b/Jint/Native/JsRegExp.cs
index fe89de5b3f..c193a0a413 100644
--- a/Jint/Native/JsRegExp.cs
+++ b/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;
diff --git a/Jint/Native/JsTypedArray.cs b/Jint/Native/JsTypedArray.cs
index 80a2f07ed3..64a246669d 100644
--- a/Jint/Native/JsTypedArray.cs
+++ b/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;
diff --git a/Jint/Native/Json/JsonParser.cs b/Jint/Native/Json/JsonParser.cs
index 81d0e2ed31..ae1ad0e52d 100644
--- a/Jint/Native/Json/JsonParser.cs
+++ b/Jint/Native/Json/JsonParser.cs
@@ -4,7 +4,6 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
-using Esprima;
using Jint.Runtime;
namespace Jint.Native.Json
diff --git a/Jint/Native/PrivateName.cs b/Jint/Native/PrivateName.cs
index 8a0396452e..55f4cba75a 100644
--- a/Jint/Native/PrivateName.cs
+++ b/Jint/Native/PrivateName.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Runtime;
namespace Jint.Native;
diff --git a/Jint/Native/RegExp/RegExpConstructor.cs b/Jint/Native/RegExp/RegExpConstructor.cs
index 1d0202a4c5..060ca87449 100644
--- a/Jint/Native/RegExp/RegExpConstructor.cs
+++ b/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;
diff --git a/Jint/Native/ShadowRealm/ShadowRealm.cs b/Jint/Native/ShadowRealm/ShadowRealm.cs
index d371a8a60f..d4fba7fe54 100644
--- a/Jint/Native/ShadowRealm/ShadowRealm.cs
+++ b/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;
diff --git a/Jint/Runtime/CallStack/CallStackElement.cs b/Jint/Runtime/CallStack/CallStackElement.cs
index 31d309dbc6..8ff39c758f 100644
--- a/Jint/Runtime/CallStack/CallStackElement.cs
+++ b/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 @@ public CallStackElement(
public readonly JintExpression? Expression;
public readonly CallStackExecutionContext CallingExecutionContext;
- public Location Location
+ public SourceLocation Location
{
get
{
diff --git a/Jint/Runtime/CallStack/JintCallStack.cs b/Jint/Runtime/CallStack/JintCallStack.cs
index d4b26749bd..319a52f44c 100644
--- a/Jint/Runtime/CallStack/JintCallStack.cs
+++ b/Jint/Runtime/CallStack/JintCallStack.cs
@@ -2,8 +2,6 @@
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 @@ public override string ToString()
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");
diff --git a/Jint/Runtime/Completion.cs b/Jint/Runtime/Completion.cs
index c7a77950b4..7b84d88ee0 100644
--- a/Jint/Runtime/Completion.cs
+++ b/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 Completion(CompletionType type, JsValue value, SyntaxElement source)
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;
diff --git a/Jint/Runtime/Debugger/CallFrame.cs b/Jint/Runtime/Debugger/CallFrame.cs
index 1c0377d08f..9ff5da607f 100644
--- a/Jint/Runtime/Debugger/CallFrame.cs
+++ b/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 @@ public sealed class CallFrame
internal CallFrame(
CallStackElement? element,
in CallStackExecutionContext context,
- Location location,
+ in SourceLocation location,
JsValue? returnValue)
{
_element = element;
@@ -38,12 +36,12 @@ internal CallFrame(
/// Source location of function of this call frame.
///
/// For top level (global) call frames, as well as functions not defined in script, this will be null.
- public Location? FunctionLocation => (_element?.Function._functionDefinition?.Function as Node)?.Location;
+ public SourceLocation? FunctionLocation => (_element?.Function._functionDefinition?.Function as Node)?.Location;
///
/// Currently executing source location in this call frame.
///
- public Location Location { get; }
+ public SourceLocation Location { get; }
///
/// The scope chain of this call frame.
diff --git a/Jint/Runtime/Debugger/DebugCallStack.cs b/Jint/Runtime/Debugger/DebugCallStack.cs
index 3db38f83bc..3f1023f8f9 100644
--- a/Jint/Runtime/Debugger/DebugCallStack.cs
+++ b/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 @@ public sealed class DebugCallStack : IReadOnlyList
{
private readonly List _stack;
- internal DebugCallStack(Engine engine, Location location, JintCallStack callStack, JsValue? returnValue)
+ internal DebugCallStack(Engine engine, SourceLocation location, JintCallStack callStack, JsValue? returnValue)
{
_stack = new List(callStack.Count + 1);
var executionContext = new CallStackExecutionContext(engine.ExecutionContext);
diff --git a/Jint/Runtime/Debugger/DebugHandler.cs b/Jint/Runtime/Debugger/DebugHandler.cs
index 25323c374f..bb5f345a81 100644
--- a/Jint/Runtime/Debugger/DebugHandler.cs
+++ b/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 @@ internal DebugHandler(Engine engine, StepMode initialStepMode)
/// The location is available as long as DebugMode is enabled - i.e. even when not stepping
/// or hitting a breakpoint.
///
- public Location? CurrentLocation { get; private set; }
+ public SourceLocation? CurrentLocation { get; private set; }
///
/// Collection of active breakpoints for the engine.
@@ -170,14 +168,14 @@ internal void OnReturnPoint(Node functionBody, JsValue returnValue)
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 @@ private void CheckBreakPointAndPause(
{
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 @@ private void CheckBreakPointAndPause(
private void Pause(
PauseType type,
Node? node,
- Location location,
+ in SourceLocation location,
JsValue? returnValue = null,
BreakPoint? breakPoint = null)
{
diff --git a/Jint/Runtime/Debugger/DebugInformation.cs b/Jint/Runtime/Debugger/DebugInformation.cs
index b484d9a3e3..e8b5400863 100644
--- a/Jint/Runtime/Debugger/DebugInformation.cs
+++ b/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 @@ public sealed class DebugInformation : EventArgs
internal DebugInformation(
Engine engine,
Node? currentNode,
- Location currentLocation,
+ in SourceLocation currentLocation,
JsValue? returnValue,
long currentMemoryUsage,
PauseType pauseType,
@@ -57,7 +55,7 @@ internal DebugInformation(
/// The current source Location.
/// For return points, this starts and ends at the end of the function body.
///
- public Location Location => CurrentCallFrame.Location;
+ public SourceLocation Location => CurrentCallFrame.Location;
///
/// Not implemented. Will always return 0.
diff --git a/Jint/Runtime/Environments/FunctionEnvironment.cs b/Jint/Runtime/Environments/FunctionEnvironment.cs
index 869a1fc05a..9dde14bffa 100644
--- a/Jint/Runtime/Environments/FunctionEnvironment.cs
+++ b/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 @@ private void HandleArrayPattern(EvaluationContext context, bool initiallyEmpty,
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;
diff --git a/Jint/Runtime/Environments/ModuleEnvironment.cs b/Jint/Runtime/Environments/ModuleEnvironment.cs
index 329b00f223..02f866bbb6 100644
--- a/Jint/Runtime/Environments/ModuleEnvironment.cs
+++ b/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;
diff --git a/Jint/Runtime/Environments/PrivateEnvironment.cs b/Jint/Runtime/Environments/PrivateEnvironment.cs
index b7edc3f58d..e96b745942 100644
--- a/Jint/Runtime/Environments/PrivateEnvironment.cs
+++ b/Jint/Runtime/Environments/PrivateEnvironment.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Environments;
diff --git a/Jint/Runtime/ExceptionHelper.cs b/Jint/Runtime/ExceptionHelper.cs
index c86307928d..3bade86ca8 100644
--- a/Jint/Runtime/ExceptionHelper.cs
+++ b/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 @@ public static void ThrowSyntaxError(Realm realm, string? message = null)
}
[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 @@ public static void ThrowJavaScriptException(Engine engine, JsValue value, in Com
}
[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);
}
diff --git a/Jint/Runtime/Host.cs b/Jint/Runtime/Host.cs
index d2ad5ebea3..9ebb9301ee 100644
--- a/Jint/Runtime/Host.cs
+++ b/Jint/Runtime/Host.cs
@@ -6,6 +6,7 @@
using Jint.Runtime.Environments;
using Jint.Runtime.Interop;
using Jint.Runtime.Modules;
+using Module = Jint.Runtime.Modules.Module;
namespace Jint.Runtime
{
diff --git a/Jint/Runtime/IScriptOrModule.Extensions.cs b/Jint/Runtime/IScriptOrModule.Extensions.cs
index 4bc057e513..cb3d1f77fd 100644
--- a/Jint/Runtime/IScriptOrModule.Extensions.cs
+++ b/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)
{
diff --git a/Jint/Runtime/Interop/DefaultTypeConverter.cs b/Jint/Runtime/Interop/DefaultTypeConverter.cs
index b530a9d387..6ddd7cfb86 100644
--- a/Jint/Runtime/Interop/DefaultTypeConverter.cs
+++ b/Jint/Runtime/Interop/DefaultTypeConverter.cs
@@ -9,6 +9,7 @@
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
diff --git a/Jint/Runtime/Interpreter/EvaluationContext.cs b/Jint/Runtime/Interpreter/EvaluationContext.cs
index 395dd384d1..4b2f03857e 100644
--- a/Jint/Runtime/Interpreter/EvaluationContext.cs
+++ b/Jint/Runtime/Interpreter/EvaluationContext.cs
@@ -1,5 +1,4 @@
using System.Runtime.CompilerServices;
-using Esprima.Ast;
namespace Jint.Runtime.Interpreter;
diff --git a/Jint/Runtime/Interpreter/Expressions/BindingPatternAssignmentExpression.cs b/Jint/Runtime/Interpreter/Expressions/BindingPatternAssignmentExpression.cs
index 60fa18cbb6..f2d3417ec9 100644
--- a/Jint/Runtime/Interpreter/Expressions/BindingPatternAssignmentExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/BindingPatternAssignmentExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Array;
using Jint.Native.Function;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintArrayExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintArrayExpression.cs
index 230b9ff4b8..523c70c507 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintArrayExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintArrayExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Iterator;
@@ -32,7 +31,7 @@ private void Initialize()
{
var expression = Build(expr);
expressions[n] = expression;
- _hasSpreads |= expr.Type == Nodes.SpreadElement;
+ _hasSpreads |= expr.Type == NodeType.SpreadElement;
}
}
diff --git a/Jint/Runtime/Interpreter/Expressions/JintArrowFunctionExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintArrowFunctionExpression.cs
index 77fe664852..cf165b2867 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintArrowFunctionExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintArrowFunctionExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Function;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintAssignmentExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintAssignmentExpression.cs
index 0a6c0f3a28..570cb0f513 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintAssignmentExpression.cs
+++ b/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 @@ internal sealed class JintAssignmentExpression : JintExpression
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 @@ private JintAssignmentExpression(AssignmentExpression expression) : base(express
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 @@ protected override object EvaluateInternal(EvaluationContext context)
{
switch (_operator)
{
- case AssignmentOperator.PlusAssign:
+ case Operator.PlusAssign:
{
var rval = _right.GetValue(context);
if (AreIntegerOperands(originalLeftValue, rval))
@@ -114,7 +115,7 @@ protected override object EvaluateInternal(EvaluationContext context)
break;
}
- case AssignmentOperator.MinusAssign:
+ case Operator.MinusAssign:
{
var rval = _right.GetValue(context);
if (AreIntegerOperands(originalLeftValue, rval))
@@ -133,7 +134,7 @@ protected override object EvaluateInternal(EvaluationContext context)
break;
}
- case AssignmentOperator.TimesAssign:
+ case Operator.TimesAssign:
{
var rval = _right.GetValue(context);
if (AreIntegerOperands(originalLeftValue, rval))
@@ -156,14 +157,14 @@ protected override object EvaluateInternal(EvaluationContext context)
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 @@ protected override object EvaluateInternal(EvaluationContext context)
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 @@ protected override object EvaluateInternal(EvaluationContext context)
break;
}
- case AssignmentOperator.AndAssign:
+ case Operator.AndAssign:
{
if (!TypeConverter.ToBoolean(originalLeftValue))
{
@@ -244,7 +245,7 @@ protected override object EvaluateInternal(EvaluationContext context)
break;
}
- case AssignmentOperator.OrAssign:
+ case Operator.OrAssign:
{
if (TypeConverter.ToBoolean(originalLeftValue))
{
@@ -256,7 +257,7 @@ protected override object EvaluateInternal(EvaluationContext context)
break;
}
- case AssignmentOperator.ExponentiationAssign:
+ case Operator.ExponentiationAssign:
{
var rval = _right.GetValue(context);
if (!originalLeftValue.IsBigInt() && !rval.IsBigInt())
@@ -297,41 +298,41 @@ protected override object EvaluateInternal(EvaluationContext context)
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 @@ protected override object EvaluateInternal(EvaluationContext context)
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);
}
diff --git a/Jint/Runtime/Interpreter/Expressions/JintAwaitExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintAwaitExpression.cs
index d0fae80a1b..ce461f0308 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintAwaitExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintAwaitExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Expressions;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs
index ac8b23a441..a28a045985 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs
@@ -4,13 +4,14 @@
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 @@ internal static JintExpression Build(BinaryExpression expression)
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 @@ internal static JintExpression Build(BinaryExpression expression)
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 @@ private string? OperatorClrName
{
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 @@ protected override object EvaluateInternal(EvaluationContext context)
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 @@ private JsValue EvaluateNonInteger(JsValue left, JsValue right)
{
switch (_operator)
{
- case BinaryOperator.BitwiseAnd:
+ case Operator.BitwiseAnd:
{
if (!left.IsBigInt())
{
@@ -859,7 +860,7 @@ private JsValue EvaluateNonInteger(JsValue left, JsValue right)
return JsBigInt.Create(TypeConverter.ToBigInt(left) & TypeConverter.ToBigInt(right));
}
- case BinaryOperator.BitwiseOr:
+ case Operator.BitwiseOr:
{
if (!left.IsBigInt())
{
@@ -868,7 +869,7 @@ private JsValue EvaluateNonInteger(JsValue left, JsValue right)
return JsBigInt.Create(TypeConverter.ToBigInt(left) | TypeConverter.ToBigInt(right));
}
- case BinaryOperator.BitwiseXor:
+ case Operator.BitwiseXor:
{
if (!left.IsBigInt())
{
@@ -877,7 +878,7 @@ private JsValue EvaluateNonInteger(JsValue left, JsValue right)
return JsBigInt.Create(TypeConverter.ToBigInt(left) ^ TypeConverter.ToBigInt(right));
}
- case BinaryOperator.LeftShift:
+ case Operator.LeftShift:
{
if (!left.IsBigInt())
{
@@ -886,7 +887,7 @@ private JsValue EvaluateNonInteger(JsValue left, JsValue right)
return JsBigInt.Create(TypeConverter.ToBigInt(left) << (int) TypeConverter.ToBigInt(right));
}
- case BinaryOperator.RightShift:
+ case Operator.RightShift:
{
if (!left.IsBigInt())
{
@@ -895,7 +896,7 @@ private JsValue EvaluateNonInteger(JsValue left, JsValue right)
return JsBigInt.Create(TypeConverter.ToBigInt(left) >> (int) TypeConverter.ToBigInt(right));
}
- case BinaryOperator.UnsignedRightShift:
+ case Operator.UnsignedRightShift:
{
if (!left.IsBigInt())
{
diff --git a/Jint/Runtime/Interpreter/Expressions/JintCallExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintCallExpression.cs
index b7d791f47d..c93277a888 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintCallExpression.cs
+++ b/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 @@ static bool CanSpread(Node? e)
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 @@ static bool CanSpread(Node? e)
{
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 @@ protected override object EvaluateInternal(EvaluationContext context)
return StackGuard.RunOnEmptyStack(EvaluateInternal, context);
}
- if (_calleeExpression._expression.Type == Nodes.Super)
+ if (_calleeExpression._expression.Type == NodeType.Super)
{
return SuperCall(context);
}
diff --git a/Jint/Runtime/Interpreter/Expressions/JintClassExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintClassExpression.cs
index f721bb539f..b9ae69b0ca 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintClassExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintClassExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native.Function;
namespace Jint.Runtime.Interpreter.Expressions
diff --git a/Jint/Runtime/Interpreter/Expressions/JintConditionalExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintConditionalExpression.cs
index 59a637441e..1c7925abcd 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintConditionalExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintConditionalExpression.cs
@@ -1,5 +1,3 @@
-using Esprima.Ast;
-
namespace Jint.Runtime.Interpreter.Expressions
{
internal sealed class JintConditionalExpression : JintExpression
diff --git a/Jint/Runtime/Interpreter/Expressions/JintConstantExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintConstantExpression.cs
index 6e738971da..0d60fd153b 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintConstantExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintConstantExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Expressions;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintExpression.cs
index cbd8978df7..8798cc8c65 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintExpression.cs
+++ b/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 @@ protected internal static JintExpression Build(Expression expression)
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
};
diff --git a/Jint/Runtime/Interpreter/Expressions/JintFunctionExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintFunctionExpression.cs
index 06f5356993..d9a4e73c70 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintFunctionExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintFunctionExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Function;
using Jint.Native.Object;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintIdentifierExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintIdentifierExpression.cs
index d83102a444..611b398a88 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintIdentifierExpression.cs
+++ b/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;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintImportExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintImportExpression.cs
index 4bce265103..6b46db4892 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintImportExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintImportExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Object;
using Jint.Native.Promise;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintLiteralExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintLiteralExpression.cs
index 7a3b781a1f..e0ad08ab8a 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintLiteralExpression.cs
+++ b/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
diff --git a/Jint/Runtime/Interpreter/Expressions/JintLogicalAndExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintLogicalAndExpression.cs
index 8a091bdb40..c4f55b109f 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintLogicalAndExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintLogicalAndExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Expressions
diff --git a/Jint/Runtime/Interpreter/Expressions/JintLogicalOrExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintLogicalOrExpression.cs
index 0f727d4e19..698d248c76 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintLogicalOrExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintLogicalOrExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Expressions
diff --git a/Jint/Runtime/Interpreter/Expressions/JintMemberExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintMemberExpression.cs
index 0cae4b962b..614e091ebd 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintMemberExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintMemberExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Environments;
@@ -32,7 +31,7 @@ internal static JsValue InitializeDeterminedProperty(MemberExpression expression
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);
}
diff --git a/Jint/Runtime/Interpreter/Expressions/JintMetaPropertyExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintMetaPropertyExpression.cs
index 407f387b80..c78ae4d5ff 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintMetaPropertyExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintMetaPropertyExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Runtime.Modules;
namespace Jint.Runtime.Interpreter.Expressions
diff --git a/Jint/Runtime/Interpreter/Expressions/JintNewExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintNewExpression.cs
index 20d6c51aa8..a1e7cf24cc 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintNewExpression.cs
+++ b/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 @@ private void Initialize()
{
var argument = expression.Arguments[i];
_jintArguments[i] = Build(argument);
- _hasSpreads |= argument.Type == Nodes.SpreadElement;
+ _hasSpreads |= argument.Type == NodeType.SpreadElement;
}
}
diff --git a/Jint/Runtime/Interpreter/Expressions/JintObjectExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintObjectExpression.cs
index 4d3d7886c0..5e8be35403 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintObjectExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintObjectExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Collections;
using Jint.Native;
using Jint.Native.Function;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintPrivateIdentifierExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintPrivateIdentifierExpression.cs
index 2a2b6dab62..77090bbf85 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintPrivateIdentifierExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintPrivateIdentifierExpression.cs
@@ -1,5 +1,3 @@
-using Esprima.Ast;
-
namespace Jint.Runtime.Interpreter.Expressions;
internal sealed class JintPrivateIdentifierExpression : JintExpression
diff --git a/Jint/Runtime/Interpreter/Expressions/JintSequenceExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintSequenceExpression.cs
index b4a2148d59..a407288cb5 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintSequenceExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintSequenceExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Expressions
diff --git a/Jint/Runtime/Interpreter/Expressions/JintSpreadExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintSpreadExpression.cs
index 2290a10cb5..5527c4f575 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintSpreadExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintSpreadExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Iterator;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintSuperExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintSuperExpression.cs
index 2e46974637..1ac4abc88a 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintSuperExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintSuperExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Runtime.Environments;
namespace Jint.Runtime.Interpreter.Expressions
diff --git a/Jint/Runtime/Interpreter/Expressions/JintTaggedTemplateExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintTaggedTemplateExpression.cs
index 02f422fade..8aa0011f1b 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintTaggedTemplateExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintTaggedTemplateExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Object;
using Jint.Runtime.Descriptors;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintTemplateLiteralExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintTemplateLiteralExpression.cs
index 8b0b2157bf..840991fc7f 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintTemplateLiteralExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintTemplateLiteralExpression.cs
@@ -1,5 +1,4 @@
using System.Text;
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Expressions;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintThisExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintThisExpression.cs
index 1ee24874a8..e105e6d984 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintThisExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintThisExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Expressions
diff --git a/Jint/Runtime/Interpreter/Expressions/JintUnaryExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintUnaryExpression.cs
index bcbb78796a..28aed9df53 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintUnaryExpression.cs
+++ b/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.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 @@ internal sealed class JintUnaryExpression : JintExpression
private static readonly ConcurrentDictionary _knownOperators = new();
private readonly JintExpression _argument;
- private readonly UnaryOperator _operator;
+ private readonly Operator _operator;
private JintUnaryExpression(UnaryExpression expression) : base(expression)
{
@@ -26,7 +27,7 @@ private JintUnaryExpression(UnaryExpression expression) : base(expression)
internal static JintExpression Build(UnaryExpression expression)
{
- if (expression.Operator == UnaryOperator.TypeOf)
+ if (expression.Operator == Operator.TypeOf)
{
return new JintTypeOfExpression(expression);
}
@@ -36,7 +37,7 @@ internal static JintExpression Build(UnaryExpression expression)
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 @@ private JsValue EvaluateJsValue(EvaluationContext context)
var engine = context.Engine;
switch (_operator)
{
- case UnaryOperator.Plus:
+ case Operator.Plus:
{
var v = _argument.GetValue(context);
if (context.OperatorOverloadingAllowed &&
@@ -148,7 +149,7 @@ private JsValue EvaluateJsValue(EvaluationContext context)
return TypeConverter.ToNumber(v);
}
- case UnaryOperator.Minus:
+ case Operator.Minus:
{
var v = _argument.GetValue(context);
if (context.OperatorOverloadingAllowed &&
@@ -159,7 +160,7 @@ private JsValue EvaluateJsValue(EvaluationContext context)
return EvaluateMinus(v);
}
- case UnaryOperator.BitwiseNot:
+ case Operator.BitwiseNot:
{
var v = _argument.GetValue(context);
if (context.OperatorOverloadingAllowed &&
@@ -176,7 +177,7 @@ private JsValue EvaluateJsValue(EvaluationContext context)
return JsBigInt.Create(~value.AsBigInt());
}
- case UnaryOperator.LogicalNot:
+ case Operator.LogicalNot:
{
var v = _argument.GetValue(context);
if (context.OperatorOverloadingAllowed &&
@@ -188,7 +189,7 @@ private JsValue EvaluateJsValue(EvaluationContext context)
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 @@ private JsValue EvaluateJsValue(EvaluationContext context)
return bindings.DeleteBinding(property.ToString()) ? JsBoolean.True : JsBoolean.False;
- case UnaryOperator.Void:
+ case Operator.Void:
_argument.GetValue(context);
return JsValue.Undefined;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintUpdateExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintUpdateExpression.cs
index 6e8646682b..b34570a3c4 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintUpdateExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintUpdateExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Environments;
diff --git a/Jint/Runtime/Interpreter/Expressions/JintYieldExpression.cs b/Jint/Runtime/Interpreter/Expressions/JintYieldExpression.cs
index 21c45916d9..37113056bd 100644
--- a/Jint/Runtime/Interpreter/Expressions/JintYieldExpression.cs
+++ b/Jint/Runtime/Interpreter/Expressions/JintYieldExpression.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Generator;
using Jint.Native.Iterator;
diff --git a/Jint/Runtime/Interpreter/Expressions/NullishCoalescingExpression.cs b/Jint/Runtime/Interpreter/Expressions/NullishCoalescingExpression.cs
index 74cc6b6926..26d568e71d 100644
--- a/Jint/Runtime/Interpreter/Expressions/NullishCoalescingExpression.cs
+++ b/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
diff --git a/Jint/Runtime/Interpreter/JintFunctionDefinition.cs b/Jint/Runtime/Interpreter/JintFunctionDefinition.cs
index bc2283c7aa..ee15a83f42 100644
--- a/Jint/Runtime/Interpreter/JintFunctionDefinition.cs
+++ b/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 static State BuildState(IFunction function)
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 @@ private static void ProcessParameters(
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 @@ private static void ProcessParameters(
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 @@ private static bool HasArgumentsReference(Node node)
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))
{
diff --git a/Jint/Runtime/Interpreter/JintStatementList.cs b/Jint/Runtime/Interpreter/JintStatementList.cs
index 77f2ea9c63..1dc3b1940a 100644
--- a/Jint/Runtime/Interpreter/JintStatementList.cs
+++ b/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;
diff --git a/Jint/Runtime/Interpreter/Statements/ConstantReturnStatement.cs b/Jint/Runtime/Interpreter/Statements/ConstantReturnStatement.cs
index c621accc88..e441324194 100644
--- a/Jint/Runtime/Interpreter/Statements/ConstantReturnStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/ConstantReturnStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Statements;
diff --git a/Jint/Runtime/Interpreter/Statements/JintBlockStatement.cs b/Jint/Runtime/Interpreter/Statements/JintBlockStatement.cs
index f6cc58a2c5..3bf3655485 100644
--- a/Jint/Runtime/Interpreter/Statements/JintBlockStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintBlockStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Runtime.Environments;
using Environment = Jint.Runtime.Environments.Environment;
diff --git a/Jint/Runtime/Interpreter/Statements/JintBreakStatement.cs b/Jint/Runtime/Interpreter/Statements/JintBreakStatement.cs
index 308fb77749..c29e52cde5 100644
--- a/Jint/Runtime/Interpreter/Statements/JintBreakStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintBreakStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Statements;
diff --git a/Jint/Runtime/Interpreter/Statements/JintClassDeclarationStatement.cs b/Jint/Runtime/Interpreter/Statements/JintClassDeclarationStatement.cs
index bb55ae6536..e2c687b409 100644
--- a/Jint/Runtime/Interpreter/Statements/JintClassDeclarationStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintClassDeclarationStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Function;
diff --git a/Jint/Runtime/Interpreter/Statements/JintContinueStatement.cs b/Jint/Runtime/Interpreter/Statements/JintContinueStatement.cs
index e6025428d1..896576bdff 100644
--- a/Jint/Runtime/Interpreter/Statements/JintContinueStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintContinueStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Statements;
diff --git a/Jint/Runtime/Interpreter/Statements/JintDebuggerStatement.cs b/Jint/Runtime/Interpreter/Statements/JintDebuggerStatement.cs
index ea6e702b8e..5626b6b0bd 100644
--- a/Jint/Runtime/Interpreter/Statements/JintDebuggerStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintDebuggerStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Debugger;
diff --git a/Jint/Runtime/Interpreter/Statements/JintDoWhileStatement.cs b/Jint/Runtime/Interpreter/Statements/JintDoWhileStatement.cs
index c77aaf79f9..40e447cbe4 100644
--- a/Jint/Runtime/Interpreter/Statements/JintDoWhileStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintDoWhileStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Interpreter.Expressions;
diff --git a/Jint/Runtime/Interpreter/Statements/JintEmptyStatement.cs b/Jint/Runtime/Interpreter/Statements/JintEmptyStatement.cs
index 2f98efdba4..2d17224349 100644
--- a/Jint/Runtime/Interpreter/Statements/JintEmptyStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintEmptyStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Statements;
diff --git a/Jint/Runtime/Interpreter/Statements/JintExportAllDeclaration.cs b/Jint/Runtime/Interpreter/Statements/JintExportAllDeclaration.cs
index 4be77341ee..13781c7f98 100644
--- a/Jint/Runtime/Interpreter/Statements/JintExportAllDeclaration.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintExportAllDeclaration.cs
@@ -1,5 +1,3 @@
-using Esprima.Ast;
-
namespace Jint.Runtime.Interpreter.Statements;
internal sealed class JintExportAllDeclaration : JintStatement
diff --git a/Jint/Runtime/Interpreter/Statements/JintExportDefaultDeclaration.cs b/Jint/Runtime/Interpreter/Statements/JintExportDefaultDeclaration.cs
index b01dd0f368..b40772ad3f 100644
--- a/Jint/Runtime/Interpreter/Statements/JintExportDefaultDeclaration.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintExportDefaultDeclaration.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Function;
using Jint.Runtime.Interpreter.Expressions;
diff --git a/Jint/Runtime/Interpreter/Statements/JintExportNamedDeclaration.cs b/Jint/Runtime/Interpreter/Statements/JintExportNamedDeclaration.cs
index 4fa20ce2f6..3f8e532863 100644
--- a/Jint/Runtime/Interpreter/Statements/JintExportNamedDeclaration.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintExportNamedDeclaration.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Statements;
diff --git a/Jint/Runtime/Interpreter/Statements/JintExpressionStatement.cs b/Jint/Runtime/Interpreter/Statements/JintExpressionStatement.cs
index e13a7a6329..3a51caf9d2 100644
--- a/Jint/Runtime/Interpreter/Statements/JintExpressionStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintExpressionStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Runtime.Interpreter.Expressions;
namespace Jint.Runtime.Interpreter.Statements;
diff --git a/Jint/Runtime/Interpreter/Statements/JintForInForOfStatement.cs b/Jint/Runtime/Interpreter/Statements/JintForInForOfStatement.cs
index 9cbb432470..62b1c9fe32 100644
--- a/Jint/Runtime/Interpreter/Statements/JintForInForOfStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintForInForOfStatement.cs
@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis;
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Iterator;
using Jint.Runtime.Environments;
@@ -221,7 +220,7 @@ private Completion BodyEvaluation(
else
{
var reference = (Reference) lhsRef;
- if (lhsKind == LhsKind.LexicalBinding || _leftNode.Type == Nodes.Identifier && !reference.IsUnresolvableReference)
+ if (lhsKind == LhsKind.LexicalBinding || _leftNode.Type == NodeType.Identifier && !reference.IsUnresolvableReference)
{
reference.InitializeReferencedBinding(nextValue);
}
diff --git a/Jint/Runtime/Interpreter/Statements/JintForStatement.cs b/Jint/Runtime/Interpreter/Statements/JintForStatement.cs
index bca21bc967..30a42ad762 100644
--- a/Jint/Runtime/Interpreter/Statements/JintForStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintForStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Environments;
using Jint.Runtime.Interpreter.Expressions;
@@ -33,7 +32,7 @@ protected override void Initialize(EvaluationContext context)
if (_statement.Init != null)
{
- if (_statement.Init.Type == Nodes.VariableDeclaration)
+ if (_statement.Init.Type == NodeType.VariableDeclaration)
{
var d = (VariableDeclaration) _statement.Init;
if (d.Kind != VariableDeclarationKind.Var)
diff --git a/Jint/Runtime/Interpreter/Statements/JintFunctionDeclarationStatement.cs b/Jint/Runtime/Interpreter/Statements/JintFunctionDeclarationStatement.cs
index dc2a4e7c3b..99fbb4a5d9 100644
--- a/Jint/Runtime/Interpreter/Statements/JintFunctionDeclarationStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintFunctionDeclarationStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
namespace Jint.Runtime.Interpreter.Statements;
diff --git a/Jint/Runtime/Interpreter/Statements/JintIfStatement.cs b/Jint/Runtime/Interpreter/Statements/JintIfStatement.cs
index c06c02897d..a90f539d0e 100644
--- a/Jint/Runtime/Interpreter/Statements/JintIfStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintIfStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Interpreter.Expressions;
diff --git a/Jint/Runtime/Interpreter/Statements/JintImportDeclaration.cs b/Jint/Runtime/Interpreter/Statements/JintImportDeclaration.cs
index d34de6a3fe..da2be8a66a 100644
--- a/Jint/Runtime/Interpreter/Statements/JintImportDeclaration.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintImportDeclaration.cs
@@ -1,6 +1,4 @@
-using Esprima.Ast;
-
-namespace Jint.Runtime.Interpreter.Statements;
+namespace Jint.Runtime.Interpreter.Statements;
internal sealed class JintImportDeclaration : JintStatement
{
diff --git a/Jint/Runtime/Interpreter/Statements/JintLabeledStatement.cs b/Jint/Runtime/Interpreter/Statements/JintLabeledStatement.cs
index dca3c85358..c8021a2a0a 100644
--- a/Jint/Runtime/Interpreter/Statements/JintLabeledStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintLabeledStatement.cs
@@ -1,5 +1,3 @@
-using Esprima.Ast;
-
namespace Jint.Runtime.Interpreter.Statements
{
internal sealed class JintLabeledStatement : JintStatement
diff --git a/Jint/Runtime/Interpreter/Statements/JintReturnStatement.cs b/Jint/Runtime/Interpreter/Statements/JintReturnStatement.cs
index 26e170fbcb..c26679ae33 100644
--- a/Jint/Runtime/Interpreter/Statements/JintReturnStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintReturnStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Interpreter.Expressions;
diff --git a/Jint/Runtime/Interpreter/Statements/JintScript.cs b/Jint/Runtime/Interpreter/Statements/JintScript.cs
index 9aeadc8300..f9db4e6481 100644
--- a/Jint/Runtime/Interpreter/Statements/JintScript.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintScript.cs
@@ -1,5 +1,3 @@
-using Esprima.Ast;
-
namespace Jint.Runtime.Interpreter.Statements
{
internal sealed class JintScript
diff --git a/Jint/Runtime/Interpreter/Statements/JintStatement.cs b/Jint/Runtime/Interpreter/Statements/JintStatement.cs
index f0d03fee56..a99a3a47b8 100644
--- a/Jint/Runtime/Interpreter/Statements/JintStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintStatement.cs
@@ -1,6 +1,4 @@
using System.Runtime.CompilerServices;
-using Esprima;
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Interpreter.Expressions;
@@ -29,7 +27,7 @@ protected JintStatement(Statement statement)
[MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)]
public Completion Execute(EvaluationContext context)
{
- if (_statement.Type != Nodes.BlockStatement)
+ if (_statement.Type != NodeType.BlockStatement)
{
context.PrepareFor(_statement);
context.RunBeforeExecuteStatementChecks(_statement);
@@ -46,7 +44,7 @@ public Completion Execute(EvaluationContext context)
protected abstract Completion ExecuteInternal(EvaluationContext context);
- public ref readonly Location Location => ref _statement.Location;
+ public ref readonly SourceLocation Location => ref _statement.Location;
///
/// Opportunity to build one-time structures and caching based on lexical context.
@@ -65,31 +63,31 @@ protected internal static JintStatement Build(Statement statement)
JintStatement? result = statement.Type switch
{
- Nodes.BlockStatement => new JintBlockStatement((BlockStatement) statement),
- Nodes.ReturnStatement => new JintReturnStatement((ReturnStatement) statement),
- Nodes.VariableDeclaration => new JintVariableDeclaration((VariableDeclaration) statement),
- Nodes.BreakStatement => new JintBreakStatement((BreakStatement) statement),
- Nodes.ContinueStatement => new JintContinueStatement((ContinueStatement) statement),
- Nodes.DoWhileStatement => new JintDoWhileStatement((DoWhileStatement) statement),
- Nodes.EmptyStatement => new JintEmptyStatement((EmptyStatement) statement),
- Nodes.ExpressionStatement => new JintExpressionStatement((ExpressionStatement) statement),
- Nodes.ForStatement => new JintForStatement((ForStatement) statement),
- Nodes.ForInStatement => new JintForInForOfStatement((ForInStatement) statement),
- Nodes.ForOfStatement => new JintForInForOfStatement((ForOfStatement) statement),
- Nodes.IfStatement => new JintIfStatement((IfStatement) statement),
- Nodes.LabeledStatement => new JintLabeledStatement((LabeledStatement) statement),
- Nodes.SwitchStatement => new JintSwitchStatement((SwitchStatement) statement),
- Nodes.FunctionDeclaration => new JintFunctionDeclarationStatement((FunctionDeclaration) statement),
- Nodes.ThrowStatement => new JintThrowStatement((ThrowStatement) statement),
- Nodes.TryStatement => new JintTryStatement((TryStatement) statement),
- Nodes.WhileStatement => new JintWhileStatement((WhileStatement) statement),
- Nodes.WithStatement => new JintWithStatement((WithStatement) statement),
- Nodes.DebuggerStatement => new JintDebuggerStatement((DebuggerStatement) statement),
- Nodes.ClassDeclaration => new JintClassDeclarationStatement((ClassDeclaration) statement),
- Nodes.ExportNamedDeclaration => new JintExportNamedDeclaration((ExportNamedDeclaration) statement),
- Nodes.ExportAllDeclaration => new JintExportAllDeclaration((ExportAllDeclaration) statement),
- Nodes.ExportDefaultDeclaration => new JintExportDefaultDeclaration((ExportDefaultDeclaration) statement),
- Nodes.ImportDeclaration => new JintImportDeclaration((ImportDeclaration) statement),
+ NodeType.BlockStatement => new JintBlockStatement((BlockStatement) statement),
+ NodeType.ReturnStatement => new JintReturnStatement((ReturnStatement) statement),
+ NodeType.VariableDeclaration => new JintVariableDeclaration((VariableDeclaration) statement),
+ NodeType.BreakStatement => new JintBreakStatement((BreakStatement) statement),
+ NodeType.ContinueStatement => new JintContinueStatement((ContinueStatement) statement),
+ NodeType.DoWhileStatement => new JintDoWhileStatement((DoWhileStatement) statement),
+ NodeType.EmptyStatement => new JintEmptyStatement((EmptyStatement) statement),
+ NodeType.ExpressionStatement => new JintExpressionStatement((ExpressionStatement) statement),
+ NodeType.ForStatement => new JintForStatement((ForStatement) statement),
+ NodeType.ForInStatement => new JintForInForOfStatement((ForInStatement) statement),
+ NodeType.ForOfStatement => new JintForInForOfStatement((ForOfStatement) statement),
+ NodeType.IfStatement => new JintIfStatement((IfStatement) statement),
+ NodeType.LabeledStatement => new JintLabeledStatement((LabeledStatement) statement),
+ NodeType.SwitchStatement => new JintSwitchStatement((SwitchStatement) statement),
+ NodeType.FunctionDeclaration => new JintFunctionDeclarationStatement((FunctionDeclaration) statement),
+ NodeType.ThrowStatement => new JintThrowStatement((ThrowStatement) statement),
+ NodeType.TryStatement => new JintTryStatement((TryStatement) statement),
+ NodeType.WhileStatement => new JintWhileStatement((WhileStatement) statement),
+ NodeType.WithStatement => new JintWithStatement((WithStatement) statement),
+ NodeType.DebuggerStatement => new JintDebuggerStatement((DebuggerStatement) statement),
+ NodeType.ClassDeclaration => new JintClassDeclarationStatement((ClassDeclaration) statement),
+ NodeType.ExportNamedDeclaration => new JintExportNamedDeclaration((ExportNamedDeclaration) statement),
+ NodeType.ExportAllDeclaration => new JintExportAllDeclaration((ExportAllDeclaration) statement),
+ NodeType.ExportDefaultDeclaration => new JintExportDefaultDeclaration((ExportDefaultDeclaration) statement),
+ NodeType.ImportDeclaration => new JintImportDeclaration((ImportDeclaration) statement),
_ => null
};
diff --git a/Jint/Runtime/Interpreter/Statements/JintSwitchBlock.cs b/Jint/Runtime/Interpreter/Statements/JintSwitchBlock.cs
index 6c6dd606bd..f6364b1b16 100644
--- a/Jint/Runtime/Interpreter/Statements/JintSwitchBlock.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintSwitchBlock.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Environments;
using Jint.Runtime.Interpreter.Expressions;
diff --git a/Jint/Runtime/Interpreter/Statements/JintSwitchStatement.cs b/Jint/Runtime/Interpreter/Statements/JintSwitchStatement.cs
index 3f026cd942..ff64028350 100644
--- a/Jint/Runtime/Interpreter/Statements/JintSwitchStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintSwitchStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Runtime.Interpreter.Expressions;
namespace Jint.Runtime.Interpreter.Statements
diff --git a/Jint/Runtime/Interpreter/Statements/JintThrowStatement.cs b/Jint/Runtime/Interpreter/Statements/JintThrowStatement.cs
index 08c1a34936..6e848bef4c 100644
--- a/Jint/Runtime/Interpreter/Statements/JintThrowStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintThrowStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Runtime.Interpreter.Expressions;
namespace Jint.Runtime.Interpreter.Statements
diff --git a/Jint/Runtime/Interpreter/Statements/JintTryStatement.cs b/Jint/Runtime/Interpreter/Statements/JintTryStatement.cs
index 7a2e4fe805..4304128c0b 100644
--- a/Jint/Runtime/Interpreter/Statements/JintTryStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintTryStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Environments;
diff --git a/Jint/Runtime/Interpreter/Statements/JintVariableDeclaration.cs b/Jint/Runtime/Interpreter/Statements/JintVariableDeclaration.cs
index 06b8923805..f20ee82c41 100644
--- a/Jint/Runtime/Interpreter/Statements/JintVariableDeclaration.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintVariableDeclaration.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Function;
using Jint.Runtime.Interpreter.Expressions;
diff --git a/Jint/Runtime/Interpreter/Statements/JintWhileStatement.cs b/Jint/Runtime/Interpreter/Statements/JintWhileStatement.cs
index 4a57128df0..da83e67452 100644
--- a/Jint/Runtime/Interpreter/Statements/JintWhileStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintWhileStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Interpreter.Expressions;
diff --git a/Jint/Runtime/Interpreter/Statements/JintWithStatement.cs b/Jint/Runtime/Interpreter/Statements/JintWithStatement.cs
index 46fed8c8f6..5b06ead534 100644
--- a/Jint/Runtime/Interpreter/Statements/JintWithStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/JintWithStatement.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Runtime.Environments;
using Jint.Runtime.Interpreter.Expressions;
diff --git a/Jint/Runtime/Interpreter/Statements/ProbablyBlockStatement.cs b/Jint/Runtime/Interpreter/Statements/ProbablyBlockStatement.cs
index e4fec8ce4d..a79ebacaad 100644
--- a/Jint/Runtime/Interpreter/Statements/ProbablyBlockStatement.cs
+++ b/Jint/Runtime/Interpreter/Statements/ProbablyBlockStatement.cs
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using Esprima.Ast;
namespace Jint.Runtime.Interpreter.Statements;
diff --git a/Jint/Runtime/JavaScriptException.cs b/Jint/Runtime/JavaScriptException.cs
index d79b546062..7f407a9d5c 100644
--- a/Jint/Runtime/JavaScriptException.cs
+++ b/Jint/Runtime/JavaScriptException.cs
@@ -1,5 +1,4 @@
using System.Text;
-using Esprima;
using Jint.Native;
using Jint.Native.Error;
using Jint.Native.Object;
@@ -27,7 +26,7 @@ public class JavaScriptException : JintException
private readonly JavaScriptErrorWrapperException _jsErrorException;
public string? JavaScriptStackTrace => _jsErrorException.StackTrace;
- public ref readonly Location Location => ref _jsErrorException.Location;
+ public ref readonly SourceLocation Location => ref _jsErrorException.Location;
public JsValue Error => _jsErrorException.Error;
internal JavaScriptException(ErrorConstructor errorConstructor)
@@ -50,13 +49,13 @@ public JavaScriptException(JsValue error)
public string GetJavaScriptErrorString() => _jsErrorException.ToString();
- public JavaScriptException SetJavaScriptCallstack(Engine engine, in Location location, bool overwriteExisting = false)
+ public JavaScriptException SetJavaScriptCallstack(Engine engine, in SourceLocation location, bool overwriteExisting = false)
{
_jsErrorException.SetCallstack(engine, location, overwriteExisting);
return this;
}
- public JavaScriptException SetJavaScriptLocation(in Location location)
+ public JavaScriptException SetJavaScriptLocation(in SourceLocation location)
{
_jsErrorException.SetLocation(location);
return this;
@@ -65,7 +64,7 @@ public JavaScriptException SetJavaScriptLocation(in Location location)
private sealed class JavaScriptErrorWrapperException : JintException
{
private string? _callStack;
- private Location _location;
+ private SourceLocation _location;
internal JavaScriptErrorWrapperException(JsValue error, string? message = null)
: base(message ?? GetMessage(error))
@@ -75,14 +74,14 @@ internal JavaScriptErrorWrapperException(JsValue error, string? message = null)
public JsValue Error { get; }
- public ref readonly Location Location => ref _location;
+ public ref readonly SourceLocation Location => ref _location;
- internal void SetLocation(Location location)
+ internal void SetLocation(in SourceLocation location)
{
_location = location;
}
- internal void SetCallstack(Engine engine, Location location, bool overwriteExisting)
+ internal void SetCallstack(Engine engine, in SourceLocation location, bool overwriteExisting)
{
_location = location;
diff --git a/Jint/Runtime/Modules/CyclicModule.cs b/Jint/Runtime/Modules/CyclicModule.cs
index bd073c0451..b92e434c32 100644
--- a/Jint/Runtime/Modules/CyclicModule.cs
+++ b/Jint/Runtime/Modules/CyclicModule.cs
@@ -1,6 +1,5 @@
#nullable disable
-using Esprima;
using Jint.Native;
using Jint.Native.Promise;
using Jint.Runtime.Descriptors;
@@ -40,7 +39,7 @@ internal CyclicModule(Engine engine, Realm realm, string location, bool async) :
internal ModuleStatus Status { get; private set; }
- internal Location AbnormalCompletionLocation { get; private set; }
+ internal SourceLocation AbnormalCompletionLocation { get; private set; }
///
/// https://tc39.es/ecma262/#sec-moduledeclarationlinking
diff --git a/Jint/Runtime/Modules/ModuleBuilder.cs b/Jint/Runtime/Modules/ModuleBuilder.cs
index c297daf272..0448f4dcb6 100644
--- a/Jint/Runtime/Modules/ModuleBuilder.cs
+++ b/Jint/Runtime/Modules/ModuleBuilder.cs
@@ -1,6 +1,4 @@
using System.Diagnostics.CodeAnalysis;
-using Esprima;
-using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Interop;
@@ -140,7 +138,8 @@ public ModuleBuilder WithOptions(Action configure)
}
catch (ParserException ex)
{
- ExceptionHelper.ThrowSyntaxError(_engine.Realm, $"Error while loading module: error in module '{_specifier}': {ex.Error}", Location.From(Position.From(ex.LineNumber, ex.Column), Position.From(ex.LineNumber, ex.Column), _specifier));
+ var location = SourceLocation.From(Position.From(ex.LineNumber, ex.Column), Position.From(ex.LineNumber, ex.Column), _specifier);
+ ExceptionHelper.ThrowSyntaxError(_engine.Realm, $"Error while loading module: error in module '{_specifier}': {ex.Error}", location);
return null!;
}
}
diff --git a/Jint/Runtime/Modules/ModuleFactory.cs b/Jint/Runtime/Modules/ModuleFactory.cs
index cb3e4821a6..0c7f09a2f0 100644
--- a/Jint/Runtime/Modules/ModuleFactory.cs
+++ b/Jint/Runtime/Modules/ModuleFactory.cs
@@ -1,5 +1,4 @@
-using Esprima;
-using Jint.Native;
+using Jint.Native;
using Jint.Native.Json;
namespace Jint.Runtime.Modules;
@@ -35,7 +34,7 @@ public static Module BuildSourceTextModule(Engine engine, ResolvedSpecifier reso
}
catch (Exception)
{
- ExceptionHelper.ThrowJavaScriptException(engine, $"Could not load module {source}", (Location) default);
+ ExceptionHelper.ThrowJavaScriptException(engine, $"Could not load module {source}", (SourceLocation) default);
module = null;
}
@@ -75,7 +74,7 @@ public static Module BuildJsonModule(Engine engine, ResolvedSpecifier resolved,
}
catch (Exception)
{
- ExceptionHelper.ThrowJavaScriptException(engine, $"Could not load module {source}", (Location) default);
+ ExceptionHelper.ThrowJavaScriptException(engine, $"Could not load module {source}", (SourceLocation) default);
module = null;
}
diff --git a/Jint/Runtime/Modules/ModuleLoader.cs b/Jint/Runtime/Modules/ModuleLoader.cs
index d77d82550b..76d69ce40b 100644
--- a/Jint/Runtime/Modules/ModuleLoader.cs
+++ b/Jint/Runtime/Modules/ModuleLoader.cs
@@ -1,5 +1,3 @@
-using Esprima;
-
namespace Jint.Runtime.Modules;
///
@@ -18,7 +16,7 @@ public Module LoadModule(Engine engine, ResolvedSpecifier resolved)
}
catch (Exception)
{
- ExceptionHelper.ThrowJavaScriptException(engine, $"Could not load module {resolved.ModuleRequest.Specifier}", (Location) default);
+ ExceptionHelper.ThrowJavaScriptException(engine, $"Could not load module {resolved.ModuleRequest.Specifier}", (SourceLocation) default);
return default!;
}
diff --git a/Jint/Runtime/Modules/SyntheticModule.cs b/Jint/Runtime/Modules/SyntheticModule.cs
index 0a0f156159..d397407330 100644
--- a/Jint/Runtime/Modules/SyntheticModule.cs
+++ b/Jint/Runtime/Modules/SyntheticModule.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Promise;
using Jint.Runtime.Environments;
diff --git a/Jint/Runtime/Realm.cs b/Jint/Runtime/Realm.cs
index ceb9c317d5..d4a7067032 100644
--- a/Jint/Runtime/Realm.cs
+++ b/Jint/Runtime/Realm.cs
@@ -1,4 +1,3 @@
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Object;
using Jint.Runtime.Environments;
diff --git a/Jint/Runtime/ScriptRecord.cs b/Jint/Runtime/ScriptRecord.cs
index 424ca7b059..cb3e27ca90 100644
--- a/Jint/Runtime/ScriptRecord.cs
+++ b/Jint/Runtime/ScriptRecord.cs
@@ -1,5 +1,3 @@
-using Esprima.Ast;
-
namespace Jint.Runtime;
internal sealed record ScriptRecord(Realm Realm, Script EcmaScriptCode, string? Location) : IScriptOrModule;
diff --git a/Jint/Runtime/TypeConverter.cs b/Jint/Runtime/TypeConverter.cs
index eeb2cc26d2..1c7f8b455c 100644
--- a/Jint/Runtime/TypeConverter.cs
+++ b/Jint/Runtime/TypeConverter.cs
@@ -1,8 +1,6 @@
using System.Globalization;
using System.Numerics;
using System.Runtime.CompilerServices;
-using Esprima;
-using Esprima.Ast;
using Jint.Native;
using Jint.Native.Number;
using Jint.Native.Object;
diff --git a/Jint/Runtime/TypeErrorException.cs b/Jint/Runtime/TypeErrorException.cs
index d343cdc2e8..f0967ece62 100644
--- a/Jint/Runtime/TypeErrorException.cs
+++ b/Jint/Runtime/TypeErrorException.cs
@@ -1,5 +1,3 @@
-using Esprima.Ast;
-
namespace Jint.Runtime
{
///