浏览代码

Upgrade to Esprima 3.0.0-beta-4 (#1251)

Marko Lahma 3 年之前
父节点
当前提交
3605cd3d18
共有 32 个文件被更改,包括 71 次插入95 次删除
  1. 5 8
      Jint.Tests/Runtime/Debugger/TestHelpers.cs
  2. 1 1
      Jint/Engine.Modules.cs
  3. 4 4
      Jint/Engine.cs
  4. 5 5
      Jint/EsprimaExtensions.cs
  5. 2 2
      Jint/HoistingScope.cs
  6. 1 1
      Jint/Jint.csproj
  7. 1 1
      Jint/Native/Function/ClassDefinition.cs
  8. 1 1
      Jint/Native/Function/ScriptFunctionInstance.cs
  9. 7 5
      Jint/Native/Json/JsonParser.cs
  10. 1 1
      Jint/Native/TypedArray/IntrinsicTypedArrayPrototype.cs
  11. 1 2
      Jint/Runtime/CallStack/CallStackElement.cs
  12. 1 1
      Jint/Runtime/CallStack/JintCallStack.cs
  13. 1 1
      Jint/Runtime/Debugger/DebugHandler.cs
  14. 4 4
      Jint/Runtime/Environments/FunctionEnvironmentRecord.cs
  15. 1 1
      Jint/Runtime/Host.cs
  16. 7 7
      Jint/Runtime/Interpreter/Expressions/BindingPatternAssignmentExpression.cs
  17. 1 2
      Jint/Runtime/Interpreter/Expressions/JintArrowFunctionExpression.cs
  18. 3 3
      Jint/Runtime/Interpreter/Expressions/JintAssignmentExpression.cs
  19. 1 1
      Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs
  20. 3 3
      Jint/Runtime/Interpreter/Expressions/JintExpression.cs
  21. 1 2
      Jint/Runtime/Interpreter/Expressions/JintFunctionExpression.cs
  22. 1 1
      Jint/Runtime/Interpreter/Expressions/JintIdentifierExpression.cs
  23. 1 1
      Jint/Runtime/Interpreter/Expressions/JintImportExpression.cs
  24. 4 4
      Jint/Runtime/Interpreter/Expressions/JintObjectExpression.cs
  25. 5 5
      Jint/Runtime/Interpreter/JintFunctionDefinition.cs
  26. 1 1
      Jint/Runtime/Interpreter/Statements/JintClassDeclarationStatement.cs
  27. 1 20
      Jint/Runtime/Interpreter/Statements/JintExportNamedDeclaration.cs
  28. 1 1
      Jint/Runtime/Interpreter/Statements/JintForInForOfStatement.cs
  29. 1 1
      Jint/Runtime/Interpreter/Statements/JintImportDeclaration.cs
  30. 3 3
      Jint/Runtime/Interpreter/Statements/JintScript.cs
  31. 0 1
      Jint/Runtime/Interpreter/Statements/JintStatement.cs
  32. 1 1
      Jint/Runtime/Interpreter/Statements/JintVariableDeclaration.cs

+ 5 - 8
Jint.Tests/Runtime/Debugger/TestHelpers.cs

@@ -7,15 +7,12 @@ namespace Jint.Tests.Runtime.Debugger
     {
     {
         public static bool IsLiteral(this Node node, string requiredValue = null)
         public static bool IsLiteral(this Node node, string requiredValue = null)
         {
         {
-            switch (node)
+            return node switch
             {
             {
-                case Directive directive:
-                    return requiredValue == null || directive.Directiv == requiredValue;
-                case ExpressionStatement expr:
-                    return requiredValue == null || (expr.Expression is Literal literal && literal.StringValue == requiredValue);
-            }
-
-            return false;
+                Directive directive => requiredValue == null || directive.Value == requiredValue,
+                ExpressionStatement expr => requiredValue == null || (expr.Expression is Literal literal && literal.StringValue == requiredValue),
+                _ => false
+            };
         }
         }
 
 
         public static bool ReachedLiteral(this DebugInformation info, string requiredValue)
         public static bool ReachedLiteral(this DebugInformation info, string requiredValue)

+ 1 - 1
Jint/Engine.Modules.cs

@@ -149,7 +149,7 @@ namespace Jint
             }
             }
             else if (promise.State == PromiseState.Rejected)
             else if (promise.State == PromiseState.Rejected)
             {
             {
-                ExceptionHelper.ThrowJavaScriptException(this, promise.Value, new Completion(CompletionType.Throw, promise.Value!, null, new Location(new Position(), new Position(), specifier)));
+                ExceptionHelper.ThrowJavaScriptException(this, promise.Value, new Completion(CompletionType.Throw, promise.Value, null, new Location(new Position(), new Position(), specifier)));
             }
             }
             else if (promise.State != PromiseState.Fulfilled)
             else if (promise.State != PromiseState.Fulfilled)
             {
             {

+ 4 - 4
Jint/Engine.cs

@@ -804,7 +804,7 @@ namespace Jint
                 for (var i = functionDeclarations.Count - 1; i >= 0; i--)
                 for (var i = functionDeclarations.Count - 1; i >= 0; i--)
                 {
                 {
                     var d = functionDeclarations[i];
                     var d = functionDeclarations[i];
-                    var fn = d.Id!.Name!;
+                    var fn = d.Id!.Name;
                     if (!declaredFunctionNames.Contains(fn))
                     if (!declaredFunctionNames.Contains(fn))
                     {
                     {
                         var fnDefinable = env.CanDeclareGlobalFunction(fn);
                         var fnDefinable = env.CanDeclareGlobalFunction(fn);
@@ -1084,7 +1084,7 @@ namespace Jint
                     {
                     {
                         var variablesDeclaration = nodes[i];
                         var variablesDeclaration = nodes[i];
                         var identifier = (Identifier) variablesDeclaration.Declarations[0].Id;
                         var identifier = (Identifier) variablesDeclaration.Declarations[0].Id;
-                        if (globalEnvironmentRecord.HasLexicalDeclaration(identifier.Name!))
+                        if (globalEnvironmentRecord.HasLexicalDeclaration(identifier.Name))
                         {
                         {
                             ExceptionHelper.ThrowSyntaxError(realm, "Identifier '" + identifier.Name + "' has already been declared");
                             ExceptionHelper.ThrowSyntaxError(realm, "Identifier '" + identifier.Name + "' has already been declared");
                         }
                         }
@@ -1102,7 +1102,7 @@ namespace Jint
                         {
                         {
                             var variablesDeclaration = nodes[i];
                             var variablesDeclaration = nodes[i];
                             var identifier = (Identifier) variablesDeclaration.Declarations[0].Id;
                             var identifier = (Identifier) variablesDeclaration.Declarations[0].Id;
-                            if (thisEnvRec!.HasBinding(identifier.Name!))
+                            if (thisEnvRec!.HasBinding(identifier.Name))
                             {
                             {
                                 ExceptionHelper.ThrowSyntaxError(realm);
                                 ExceptionHelper.ThrowSyntaxError(realm);
                             }
                             }
@@ -1122,7 +1122,7 @@ namespace Jint
                 for (var i = functionDeclarations.Count - 1; i >= 0; i--)
                 for (var i = functionDeclarations.Count - 1; i >= 0; i--)
                 {
                 {
                     var d = functionDeclarations[i];
                     var d = functionDeclarations[i];
-                    var fn = d.Id!.Name!;
+                    var fn = d.Id!.Name;
                     if (!declaredFunctionNames.Contains(fn))
                     if (!declaredFunctionNames.Contains(fn))
                     {
                     {
                         if (varEnvRec is GlobalEnvironmentRecord ger)
                         if (varEnvRec is GlobalEnvironmentRecord ger)

+ 5 - 5
Jint/EsprimaExtensions.cs

@@ -187,7 +187,7 @@ namespace Jint
             // try to get away without a loop
             // try to get away without a loop
             if (parameter is Identifier id)
             if (parameter is Identifier id)
             {
             {
-                target.Add(id.Name!);
+                target.Add(id.Name);
                 return;
                 return;
             }
             }
 
 
@@ -201,7 +201,7 @@ namespace Jint
             {
             {
                 if (parameter is Identifier identifier)
                 if (parameter is Identifier identifier)
                 {
                 {
-                    target.Add(identifier.Name!);
+                    target.Add(identifier.Name);
                     return;
                     return;
                 }
                 }
 
 
@@ -255,7 +255,7 @@ namespace Jint
         }
         }
 
 
         internal static void BindingInitialization(
         internal static void BindingInitialization(
-            this Expression? expression,
+            this Node? expression,
             EvaluationContext context,
             EvaluationContext context,
             JsValue value,
             JsValue value,
             EnvironmentRecord env)
             EnvironmentRecord env)
@@ -263,7 +263,7 @@ namespace Jint
             if (expression is Identifier identifier)
             if (expression is Identifier identifier)
             {
             {
                 var catchEnvRecord = (DeclarativeEnvironmentRecord) env;
                 var catchEnvRecord = (DeclarativeEnvironmentRecord) env;
-                catchEnvRecord.CreateMutableBindingAndInitialize(identifier.Name!, canBeDeleted: false, value);
+                catchEnvRecord.CreateMutableBindingAndInitialize(identifier.Name, canBeDeleted: false, value);
             }
             }
             else if (expression is BindingPattern bindingPattern)
             else if (expression is BindingPattern bindingPattern)
             {
             {
@@ -306,7 +306,7 @@ namespace Jint
         {
         {
             var source = import.Source.StringValue!;
             var source = import.Source.StringValue!;
             var specifiers = import.Specifiers;
             var specifiers = import.Specifiers;
-            requestedModules.Add(source!);
+            requestedModules.Add(source);
 
 
             foreach (var specifier in specifiers)
             foreach (var specifier in specifiers)
             {
             {

+ 2 - 2
Jint/HoistingScope.cs

@@ -246,7 +246,7 @@ namespace Jint
                                 {
                                 {
                                     if (declaration.Id is Identifier identifier)
                                     if (declaration.Id is Identifier identifier)
                                     {
                                     {
-                                        _varNames.Add(identifier.Name!);
+                                        _varNames.Add(identifier.Name);
                                     }
                                     }
                                 }
                                 }
                             }
                             }
@@ -264,7 +264,7 @@ namespace Jint
                                 {
                                 {
                                     if (declaration.Id is Identifier identifier)
                                     if (declaration.Id is Identifier identifier)
                                     {
                                     {
-                                        _lexicalNames.Add(identifier.Name!);
+                                        _lexicalNames.Add(identifier.Name);
                                     }
                                     }
                                 }
                                 }
                             }
                             }

+ 1 - 1
Jint/Jint.csproj

@@ -11,7 +11,7 @@
   </PropertyGroup>
   </PropertyGroup>
 
 
   <ItemGroup>
   <ItemGroup>
-    <PackageReference Include="Esprima" Version="3.0.0-beta-3" />
+    <PackageReference Include="Esprima" Version="3.0.0-beta-4" />
     <PackageReference Include="IsExternalInit" Version="1.0.2" PrivateAssets="all" />
     <PackageReference Include="IsExternalInit" Version="1.0.2" PrivateAssets="all" />
     <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
     <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
     <PackageReference Include="Nullable" Version="1.3.0" PrivateAssets="all" />
     <PackageReference Include="Nullable" Version="1.3.0" PrivateAssets="all" />

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

@@ -26,7 +26,7 @@ namespace Jint.Native.Function
                 var parser = new JavaScriptParser(source);
                 var parser = new JavaScriptParser(source);
                 var script = parser.ParseScript();
                 var script = parser.ParseScript();
                 var classDeclaration = (ClassDeclaration) script.Body[0];
                 var classDeclaration = (ClassDeclaration) script.Body[0];
-                return (MethodDefinition) classDeclaration.Body.Body[0]!;
+                return (MethodDefinition) classDeclaration.Body.Body[0];
             }
             }
 
 
             _superConstructor = CreateConstructorMethodDefinition("class temp { constructor(...args) { super(...args); } }");
             _superConstructor = CreateConstructorMethodDefinition("class temp { constructor(...args) { super(...args); } }");

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

@@ -165,7 +165,7 @@ namespace Jint.Native.Function
 
 
                         if (kind == ConstructorKind.Base)
                         if (kind == ConstructorKind.Base)
                         {
                         {
-                            return (ObjectInstance) thisArgument!;
+                            return (ObjectInstance) thisArgument;
                         }
                         }
 
 
                         if (!result.Value.IsUndefined())
                         if (!result.Value.IsUndefined())

+ 7 - 5
Jint/Native/Json/JsonParser.cs

@@ -4,6 +4,8 @@ using Esprima.Ast;
 using Jint.Native.Object;
 using Jint.Native.Object;
 using Jint.Runtime;
 using Jint.Runtime;
 
 
+using Range = Esprima.Range;
+
 namespace Jint.Native.Json
 namespace Jint.Native.Json
 {
 {
     public class JsonParser
     public class JsonParser
@@ -465,7 +467,7 @@ namespace Jint.Native.Json
             {
             {
                 var range = new[] {token.Range[0], token.Range[1]};
                 var range = new[] {token.Range[0], token.Range[1]};
                 string value = _source.Slice(token.Range[0], token.Range[1]);
                 string value = _source.Slice(token.Range[0], token.Range[1]);
-                _extra!.Tokens.Add(new Token
+                _extra.Tokens.Add(new Token
                     {
                     {
                         Type = token.Type,
                         Type = token.Type,
                         Text = value,
                         Text = value,
@@ -479,7 +481,7 @@ namespace Jint.Native.Json
 
 
         private Token Lex()
         private Token Lex()
         {
         {
-            Token token = _lookahead!;
+            Token token = _lookahead;
             _index = token.Range[1];
             _index = token.Range[1];
             _lineNumber = token.LineNumber.HasValue ? token.LineNumber.Value : 0;
             _lineNumber = token.LineNumber.HasValue ? token.LineNumber.Value : 0;
             _lineStart = token.LineStart;
             _lineStart = token.LineStart;
@@ -521,7 +523,7 @@ namespace Jint.Native.Json
         {
         {
             if (_extra.Range != null)
             if (_extra.Range != null)
             {
             {
-                node.Range = new Esprima.Ast.Range(_state.MarkerStack.Pop(), _index);
+                node.Range = new Range(_state.MarkerStack.Pop(), _index);
             }
             }
             if (_extra.Loc.HasValue)
             if (_extra.Loc.HasValue)
             {
             {
@@ -659,7 +661,7 @@ namespace Jint.Native.Json
 
 
             while (!Match("}"))
             while (!Match("}"))
             {
             {
-                Tokens type = _lookahead!.Type;
+                Tokens type = _lookahead.Type;
                 if (type != Tokens.String)
                 if (type != Tokens.String)
                 {
                 {
                     ThrowUnexpected(Lex());
                     ThrowUnexpected(Lex());
@@ -790,7 +792,7 @@ namespace Jint.Native.Json
 
 
                 Peek();
                 Peek();
 
 
-                if(_lookahead!.Type != Tokens.EOF)
+                if(_lookahead.Type != Tokens.EOF)
                 {
                 {
                     ThrowError(_lookahead, Messages.UnexpectedToken, _lookahead.Text);
                     ThrowError(_lookahead, Messages.UnexpectedToken, _lookahead.Text);
                 }
                 }

+ 1 - 1
Jint/Native/TypedArray/IntrinsicTypedArrayPrototype.cs

@@ -1360,7 +1360,7 @@ namespace Jint.Native.TypedArray
                     return (int) v;
                     return (int) v;
                 }
                 }
 
 
-                if (x!.Type == Types.BigInt || y!.Type == Types.BigInt)
+                if (x.Type == Types.BigInt || y.Type == Types.BigInt)
                 {
                 {
                     var xBigInt = TypeConverter.ToBigInt(x);
                     var xBigInt = TypeConverter.ToBigInt(x);
                     var yBigInt = TypeConverter.ToBigInt(y);
                     var yBigInt = TypeConverter.ToBigInt(y);

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

@@ -36,8 +36,7 @@ namespace Jint.Runtime.CallStack
             }
             }
         }
         }
 
 
-        public NodeList<Expression>? Arguments =>
-            Function._functionDefinition?.Function.Params;
+        public NodeList<Node>? Arguments => Function._functionDefinition?.Function.Params;
 
 
         public override string ToString()
         public override string ToString()
         {
         {

+ 1 - 1
Jint/Runtime/CallStack/JintCallStack.cs

@@ -152,7 +152,7 @@ namespace Jint.Runtime.CallStack
         /// <summary>
         /// <summary>
         /// A version of <see cref="EsprimaExtensions.GetKey"/> that cannot get into loop as we are already building a stack.
         /// A version of <see cref="EsprimaExtensions.GetKey"/> that cannot get into loop as we are already building a stack.
         /// </summary>
         /// </summary>
-        private static string GetPropertyKey(Expression expression)
+        private static string GetPropertyKey(Node expression)
         {
         {
             if (expression is Literal literal)
             if (expression is Literal literal)
             {
             {

+ 1 - 1
Jint/Runtime/Debugger/DebugHandler.cs

@@ -212,7 +212,7 @@ namespace Jint.Runtime.Debugger
             var info = new DebugInformation(
             var info = new DebugInformation(
                 engine: _engine,
                 engine: _engine,
                 currentNode: node,
                 currentNode: node,
-                currentLocation: location ?? node!.Location,
+                currentLocation: location ?? node.Location,
                 returnValue: returnValue,
                 returnValue: returnValue,
                 currentMemoryUsage: _engine.CurrentMemoryUsage,
                 currentMemoryUsage: _engine.CurrentMemoryUsage,
                 pauseType: type,
                 pauseType: type,

+ 4 - 4
Jint/Runtime/Environments/FunctionEnvironmentRecord.cs

@@ -133,7 +133,7 @@ namespace Jint.Runtime.Environments
             if (parameter is Identifier identifier)
             if (parameter is Identifier identifier)
             {
             {
                 var argument = (uint) index < (uint) arguments.Length ? arguments[index] : Undefined;
                 var argument = (uint) index < (uint) arguments.Length ? arguments[index] : Undefined;
-                SetItemSafely(identifier.Name!, argument, initiallyEmpty);
+                SetItemSafely(identifier.Name, argument, initiallyEmpty);
             }
             }
             else
             else
             {
             {
@@ -205,7 +205,7 @@ namespace Jint.Runtime.Environments
                         JsString propertyName = JsString.Empty;
                         JsString propertyName = JsString.Empty;
                         if (p.Key is Identifier propertyIdentifier)
                         if (p.Key is Identifier propertyIdentifier)
                         {
                         {
-                            propertyName = JsString.Create(propertyIdentifier.Name!);
+                            propertyName = JsString.Create(propertyIdentifier.Name);
                         }
                         }
                         else if (p.Key is Literal propertyLiteral)
                         else if (p.Key is Literal propertyLiteral)
                         {
                         {
@@ -232,7 +232,7 @@ namespace Jint.Runtime.Environments
                         {
                         {
                             var rest = _engine.Realm.Intrinsics.Object.Construct(argumentObject.Properties!.Count - processedProperties!.Count);
                             var rest = _engine.Realm.Intrinsics.Object.Construct(argumentObject.Properties!.Count - processedProperties!.Count);
                             argumentObject.CopyDataProperties(rest, processedProperties);
                             argumentObject.CopyDataProperties(rest, processedProperties);
-                            SetItemSafely(restIdentifier.Name!, rest, initiallyEmpty);
+                            SetItemSafely(restIdentifier.Name, rest, initiallyEmpty);
                         }
                         }
                         else
                         else
                         {
                         {
@@ -312,7 +312,7 @@ namespace Jint.Runtime.Environments
 
 
             if (restElement.Argument is Identifier restIdentifier)
             if (restElement.Argument is Identifier restIdentifier)
             {
             {
-                SetItemSafely(restIdentifier.Name!, rest, initiallyEmpty);
+                SetItemSafely(restIdentifier.Name, rest, initiallyEmpty);
             }
             }
             else if (restElement.Argument is BindingPattern bindingPattern)
             else if (restElement.Argument is BindingPattern bindingPattern)
             {
             {

+ 1 - 1
Jint/Runtime/Host.cs

@@ -154,7 +154,7 @@ namespace Jint.Runtime
                 }
                 }
                 catch (JavaScriptException ex)
                 catch (JavaScriptException ex)
                 {
                 {
-                    promiseCapability.Reject.Call(JsValue.Undefined, new [] { ex.Error! });
+                    promiseCapability.Reject.Call(JsValue.Undefined, new [] { ex.Error });
                 }
                 }
                 return JsValue.Undefined;
                 return JsValue.Undefined;
             }, 0, PropertyFlag.Configurable);
             }, 0, PropertyFlag.Configurable);

+ 7 - 7
Jint/Runtime/Interpreter/Expressions/BindingPatternAssignmentExpression.cs

@@ -140,7 +140,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                             ConsumeFromIterator(iterator!, out value, out done);
                             ConsumeFromIterator(iterator!, out value, out done);
                         }
                         }
 
 
-                        AssignToIdentifier(engine, identifier.Name!, value, environment, checkReference);
+                        AssignToIdentifier(engine, identifier.Name, value, environment, checkReference);
                     }
                     }
                     else if (left is MemberExpression me)
                     else if (left is MemberExpression me)
                     {
                     {
@@ -214,7 +214,7 @@ namespace Jint.Runtime.Interpreter.Expressions
 
 
                         if (restElement.Argument is Identifier leftIdentifier)
                         if (restElement.Argument is Identifier leftIdentifier)
                         {
                         {
-                            AssignToIdentifier(engine, leftIdentifier.Name!, array, environment, checkReference);
+                            AssignToIdentifier(engine, leftIdentifier.Name, array, environment, checkReference);
                         }
                         }
                         else if (restElement.Argument is BindingPattern bp)
                         else if (restElement.Argument is BindingPattern bp)
                         {
                         {
@@ -252,10 +252,10 @@ namespace Jint.Runtime.Interpreter.Expressions
                         {
                         {
                             if (assignmentPattern.Right.IsFunctionDefinition())
                             if (assignmentPattern.Right.IsFunctionDefinition())
                             {
                             {
-                                ((FunctionInstance) value).SetFunctionName(new JsString(leftIdentifier.Name!));
+                                ((FunctionInstance) value).SetFunctionName(new JsString(leftIdentifier.Name));
                             }
                             }
 
 
-                            AssignToIdentifier(engine, leftIdentifier.Name!, value, environment, checkReference);
+                            AssignToIdentifier(engine, leftIdentifier.Name, value, environment, checkReference);
                         }
                         }
                         else if (assignmentPattern.Left is BindingPattern bp)
                         else if (assignmentPattern.Left is BindingPattern bp)
                         {
                         {
@@ -349,7 +349,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                             ((FunctionInstance) value).SetFunctionName(target!.Name);
                             ((FunctionInstance) value).SetFunctionName(target!.Name);
                         }
                         }
 
 
-                        AssignToIdentifier(context.Engine, target!.Name!, value, environment, checkReference);
+                        AssignToIdentifier(context.Engine, target!.Name, value, environment, checkReference);
                     }
                     }
                     else if (p.Value is BindingPattern bindingPattern)
                     else if (p.Value is BindingPattern bindingPattern)
                     {
                     {
@@ -367,7 +367,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         var identifierReference = p.Value as Identifier;
                         var identifierReference = p.Value as Identifier;
                         var target = identifierReference ?? identifier;
                         var target = identifierReference ?? identifier;
                         source.TryGetValue(sourceKey, out var v);
                         source.TryGetValue(sourceKey, out var v);
-                        AssignToIdentifier(context.Engine, target!.Name!, v, environment, checkReference);
+                        AssignToIdentifier(context.Engine, target!.Name, v, environment, checkReference);
                     }
                     }
                 }
                 }
                 else
                 else
@@ -378,7 +378,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         var count = Math.Max(0, source.Properties?.Count ?? 0) - processedProperties!.Count;
                         var count = Math.Max(0, source.Properties?.Count ?? 0) - processedProperties!.Count;
                         var rest = context.Engine.Realm.Intrinsics.Object.Construct(count);
                         var rest = context.Engine.Realm.Intrinsics.Object.Construct(count);
                         source.CopyDataProperties(rest, processedProperties);
                         source.CopyDataProperties(rest, processedProperties);
-                        AssignToIdentifier(context.Engine, leftIdentifier.Name!, rest, environment, checkReference);
+                        AssignToIdentifier(context.Engine, leftIdentifier.Name, rest, environment, checkReference);
                     }
                     }
                     else if (restElement.Argument is BindingPattern bp)
                     else if (restElement.Argument is BindingPattern bp)
                     {
                     {

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

@@ -8,8 +8,7 @@ namespace Jint.Runtime.Interpreter.Expressions
     {
     {
         private readonly JintFunctionDefinition _function;
         private readonly JintFunctionDefinition _function;
 
 
-        public JintArrowFunctionExpression(Engine engine, ArrowFunctionExpression function)
-            : base(ArrowParameterPlaceHolder.Empty)
+        public JintArrowFunctionExpression(Engine engine, ArrowFunctionExpression function) : base(function)
         {
         {
             _function = new JintFunctionDefinition(engine, function);
             _function = new JintFunctionDefinition(engine, function);
         }
         }

+ 3 - 3
Jint/Runtime/Interpreter/Expressions/JintAssignmentExpression.cs

@@ -15,7 +15,7 @@ namespace Jint.Runtime.Interpreter.Expressions
 
 
         private JintAssignmentExpression(Engine engine, AssignmentExpression expression) : base(expression)
         private JintAssignmentExpression(Engine engine, AssignmentExpression expression) : base(expression)
         {
         {
-            _left = Build(engine, expression.Left);
+            _left = Build(engine, (Expression) expression.Left);
             _right = Build(engine, expression.Right);
             _right = Build(engine, expression.Right);
             _operator = expression.Operator;
             _operator = expression.Operator;
         }
         }
@@ -344,8 +344,8 @@ namespace Jint.Runtime.Interpreter.Expressions
 
 
             protected override void Initialize(EvaluationContext context)
             protected override void Initialize(EvaluationContext context)
             {
             {
-                var assignmentExpression = ((AssignmentExpression) _expression);
-                _left = Build(context.Engine, assignmentExpression.Left);
+                var assignmentExpression = (AssignmentExpression) _expression;
+                _left = Build(context.Engine, (Expression) assignmentExpression.Left);
                 _leftIdentifier = _left as JintIdentifierExpression;
                 _leftIdentifier = _left as JintIdentifierExpression;
                 _evalOrArguments = _leftIdentifier?.HasEvalOrArguments == true;
                 _evalOrArguments = _leftIdentifier?.HasEvalOrArguments == true;
 
 

+ 1 - 1
Jint/Runtime/Interpreter/Expressions/JintBinaryExpression.cs

@@ -84,7 +84,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                 case BinaryOperator.StrictlyEqual:
                 case BinaryOperator.StrictlyEqual:
                     result = new StrictlyEqualBinaryExpression(engine, expression);
                     result = new StrictlyEqualBinaryExpression(engine, expression);
                     break;
                     break;
-                case BinaryOperator.StricltyNotEqual:
+                case BinaryOperator.StrictlyNotEqual:
                     result = new StrictlyNotEqualBinaryExpression(engine, expression);
                     result = new StrictlyNotEqualBinaryExpression(engine, expression);
                     break;
                     break;
                 case BinaryOperator.Less:
                 case BinaryOperator.Less:

+ 3 - 3
Jint/Runtime/Interpreter/Expressions/JintExpression.cs

@@ -31,7 +31,7 @@ namespace Jint.Runtime.Interpreter.Expressions
 
 
         public static implicit operator ExpressionResult(in Completion result)
         public static implicit operator ExpressionResult(in Completion result)
         {
         {
-            return new ExpressionResult((ExpressionCompletionType) result.Type, result.Value!, result.Location);
+            return new ExpressionResult((ExpressionCompletionType) result.Type, result.Value, result.Location);
         }
         }
     }
     }
 
 
@@ -465,7 +465,7 @@ namespace Jint.Runtime.Interpreter.Expressions
             for (var i = 0; i < jintExpressions.Length; i++)
             for (var i = 0; i < jintExpressions.Length; i++)
             {
             {
                 var completion = jintExpressions[i].GetValue(context);
                 var completion = jintExpressions[i].GetValue(context);
-                targetArray[i] = completion.Value!.Clone();
+                targetArray[i] = completion.Value.Clone();
             }
             }
         }
         }
 
 
@@ -499,7 +499,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                 else
                 else
                 {
                 {
                     var completion = jintExpression.GetValue(context);
                     var completion = jintExpression.GetValue(context);
-                    args.Add(completion.Value!.Clone());
+                    args.Add(completion.Value.Clone());
                 }
                 }
             }
             }
 
 

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

@@ -8,8 +8,7 @@ namespace Jint.Runtime.Interpreter.Expressions
     {
     {
         private readonly JintFunctionDefinition _function;
         private readonly JintFunctionDefinition _function;
 
 
-        public JintFunctionExpression(Engine engine, FunctionExpression function)
-            : base(ArrowParameterPlaceHolder.Empty)
+        public JintFunctionExpression(Engine engine, FunctionExpression function) : base(function)
         {
         {
             _function = new JintFunctionDefinition(engine, function);
             _function = new JintFunctionDefinition(engine, function);
         }
         }

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

@@ -12,7 +12,7 @@ namespace Jint.Runtime.Interpreter.Expressions
 
 
         public JintIdentifierExpression(Identifier expression) : base(expression)
         public JintIdentifierExpression(Identifier expression) : base(expression)
         {
         {
-            _expressionName = new EnvironmentRecord.BindingName(expression.Name!);
+            _expressionName = new EnvironmentRecord.BindingName(expression.Name);
             if (expression.Name == "undefined")
             if (expression.Name == "undefined")
             {
             {
                 _calculatedValue = JsValue.Undefined;
                 _calculatedValue = JsValue.Undefined;

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

@@ -16,7 +16,7 @@ internal sealed class JintImportExpression : JintExpression
     protected override void Initialize(EvaluationContext context)
     protected override void Initialize(EvaluationContext context)
     {
     {
         var expression = ((Import) _expression).Source;
         var expression = ((Import) _expression).Source;
-        _importExpression = Build(context.Engine, expression!);
+        _importExpression = Build(context.Engine, expression);
     }
     }
 
 
     /// <summary>
     /// <summary>

+ 4 - 4
Jint/Runtime/Interpreter/Expressions/JintObjectExpression.cs

@@ -90,10 +90,10 @@ namespace Jint.Runtime.Interpreter.Expressions
 
 
                     _properties[i] = new ObjectProperty(propName, p);
                     _properties[i] = new ObjectProperty(propName, p);
 
 
-                    if (p.Kind == PropertyKind.Init || p.Kind == PropertyKind.Data)
+                    if (p.Kind is PropertyKind.Init or PropertyKind.Data)
                     {
                     {
                         var propertyValue = p.Value;
                         var propertyValue = p.Value;
-                        _valueExpressions[i] = Build(engine, propertyValue);
+                        _valueExpressions[i] = Build(engine, (Expression) propertyValue);
                         _canBuildFast &= !propertyValue.IsFunctionDefinition();
                         _canBuildFast &= !propertyValue.IsFunctionDefinition();
                     }
                     }
                     else
                     else
@@ -139,7 +139,7 @@ namespace Jint.Runtime.Interpreter.Expressions
             {
             {
                 var objectProperty = _properties[i];
                 var objectProperty = _properties[i];
                 var valueExpression = _valueExpressions[i];
                 var valueExpression = _valueExpressions[i];
-                var propValue = valueExpression.GetValue(context).Value!.Clone();
+                var propValue = valueExpression.GetValue(context).Value.Clone();
                 properties[objectProperty!._key!] = new PropertyDescriptor(propValue, PropertyFlag.ConfigurableEnumerableWritable);
                 properties[objectProperty!._key!] = new PropertyDescriptor(propValue, PropertyFlag.ConfigurableEnumerableWritable);
             }
             }
 
 
@@ -202,7 +202,7 @@ namespace Jint.Runtime.Interpreter.Expressions
                         return completion;
                         return completion;
                     }
                     }
 
 
-                    var propValue = completion.Value!.Clone();
+                    var propValue = completion.Value.Clone();
                     if (expr._expression.IsFunctionDefinition())
                     if (expr._expression.IsFunctionDefinition())
                     {
                     {
                         var closure = (FunctionInstance) propValue;
                         var closure = (FunctionInstance) propValue;

+ 5 - 5
Jint/Runtime/Interpreter/JintFunctionDefinition.cs

@@ -144,7 +144,7 @@ namespace Jint.Runtime.Interpreter
                 for (var i = functionDeclarations.Count - 1; i >= 0; i--)
                 for (var i = functionDeclarations.Count - 1; i >= 0; i--)
                 {
                 {
                     var d = functionDeclarations[i];
                     var d = functionDeclarations[i];
-                    var fn = d.Id!.Name!;
+                    var fn = d.Id!.Name;
                     if (state.FunctionNames.Add(fn))
                     if (state.FunctionNames.Add(fn))
                     {
                     {
                         functionsToInitialize.AddFirst(new JintFunctionDefinition(_engine, d));
                         functionsToInitialize.AddFirst(new JintFunctionDefinition(_engine, d));
@@ -263,8 +263,8 @@ namespace Jint.Runtime.Interpreter
         {
         {
             if (parameter is Identifier identifier)
             if (parameter is Identifier identifier)
             {
             {
-                _hasDuplicates |= checkDuplicates && target.Contains(identifier.Name!);
-                target.Add(identifier.Name!);
+                _hasDuplicates |= checkDuplicates && target.Contains(identifier.Name);
+                target.Add(identifier.Name);
                 hasArguments |= identifier.Name == "arguments";
                 hasArguments |= identifier.Name == "arguments";
                 return;
                 return;
             }
             }
@@ -350,9 +350,9 @@ namespace Jint.Runtime.Interpreter
                 var parameter = functionDeclarationParams[i];
                 var parameter = functionDeclarationParams[i];
                 if (parameter is Identifier id)
                 if (parameter is Identifier id)
                 {
                 {
-                    state.HasDuplicates |= parameterNames.Contains(id.Name!);
+                    state.HasDuplicates |= parameterNames.Contains(id.Name);
                     hasArguments = id.Name == "arguments";
                     hasArguments = id.Name == "arguments";
-                    parameterNames.Add(id.Name!);
+                    parameterNames.Add(id.Name);
                     if (state.IsSimpleParameterList)
                     if (state.IsSimpleParameterList)
                     {
                     {
                         state.Length++;
                         state.Length++;

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

@@ -26,7 +26,7 @@ namespace Jint.Runtime.Interpreter.Statements
             var classBinding = _classDefinition._className;
             var classBinding = _classDefinition._className;
             if (classBinding != null)
             if (classBinding != null)
             {
             {
-                env.InitializeBinding(classBinding, completion.Value!);
+                env.InitializeBinding(classBinding, completion.Value);
             }
             }
 
 
             return new Completion(CompletionType.Normal, null!, null, Location);
             return new Completion(CompletionType.Normal, null!, null, Location);

+ 1 - 20
Jint/Runtime/Interpreter/Statements/JintExportNamedDeclaration.cs

@@ -1,12 +1,10 @@
 using Esprima.Ast;
 using Esprima.Ast;
 using Jint.Native;
 using Jint.Native;
-using Jint.Runtime.Interpreter.Expressions;
 
 
 namespace Jint.Runtime.Interpreter.Statements;
 namespace Jint.Runtime.Interpreter.Statements;
 
 
 internal sealed class JintExportNamedDeclaration : JintStatement<ExportNamedDeclaration>
 internal sealed class JintExportNamedDeclaration : JintStatement<ExportNamedDeclaration>
 {
 {
-    private JintExpression? _declarationExpression;
     private JintStatement? _declarationStatement;
     private JintStatement? _declarationStatement;
 
 
     public JintExportNamedDeclaration(ExportNamedDeclaration statement) : base(statement)
     public JintExportNamedDeclaration(ExportNamedDeclaration statement) : base(statement)
@@ -17,18 +15,7 @@ internal sealed class JintExportNamedDeclaration : JintStatement<ExportNamedDecl
     {
     {
         if (_statement.Declaration != null)
         if (_statement.Declaration != null)
         {
         {
-            switch (_statement.Declaration)
-            {
-                case Expression e:
-                    _declarationExpression = JintExpression.Build(context.Engine, e);
-                    break;
-                case Statement s:
-                    _declarationStatement = Build(s);
-                    break;
-                default:
-                    ExceptionHelper.ThrowNotSupportedException($"Statement {_statement.Declaration.Type} is not supported in an export declaration.");
-                    break;
-            }
+            _declarationStatement = Build(_statement.Declaration);
         }
         }
     }
     }
 
 
@@ -43,12 +30,6 @@ internal sealed class JintExportNamedDeclaration : JintStatement<ExportNamedDecl
             return NormalCompletion(Undefined.Instance);
             return NormalCompletion(Undefined.Instance);
         }
         }
 
 
-        if (_declarationExpression != null)
-        {
-            // Named exports don't require anything more since the values are available in the lexical context
-            return _declarationExpression.GetValue(context);
-        }
-
         return NormalCompletion(Undefined.Instance);
         return NormalCompletion(Undefined.Instance);
     }
     }
 }
 }

+ 1 - 1
Jint/Runtime/Interpreter/Statements/JintForInForOfStatement.cs

@@ -202,7 +202,7 @@ namespace Jint.Runtime.Interpreter.Statements
                         if (!destructuring)
                         if (!destructuring)
                         {
                         {
                             var identifier = (Identifier) ((VariableDeclaration) _leftNode).Declarations[0].Id;
                             var identifier = (Identifier) ((VariableDeclaration) _leftNode).Declarations[0].Id;
-                            lhsName ??= identifier.Name!;
+                            lhsName ??= identifier.Name;
                             lhsRef = new ExpressionResult(ExpressionCompletionType.Normal, engine.ResolveBinding(lhsName), identifier.Location);
                             lhsRef = new ExpressionResult(ExpressionCompletionType.Normal, engine.ResolveBinding(lhsName), identifier.Location);
                         }
                         }
                     }
                     }

+ 1 - 1
Jint/Runtime/Interpreter/Statements/JintImportDeclaration.cs

@@ -15,7 +15,7 @@ internal sealed class JintImportDeclaration : JintStatement<ImportDeclaration>
     protected override Completion ExecuteInternal(EvaluationContext context)
     protected override Completion ExecuteInternal(EvaluationContext context)
     {
     {
         // just to ensure module context or valid
         // just to ensure module context or valid
-        context.Engine.GetActiveScriptOrModule().AsModule(context.Engine, context.LastSyntaxNode!.Location);
+        context.Engine.GetActiveScriptOrModule().AsModule(context.Engine, context.LastSyntaxNode.Location);
         return Completion.Empty();
         return Completion.Empty();
     }
     }
 }
 }

+ 3 - 3
Jint/Runtime/Interpreter/Statements/JintScript.cs

@@ -2,16 +2,16 @@ using Esprima.Ast;
 
 
 namespace Jint.Runtime.Interpreter.Statements
 namespace Jint.Runtime.Interpreter.Statements
 {
 {
-    internal sealed class JintScript : JintStatement<Script>
+    internal sealed class JintScript
     {
     {
         private readonly JintStatementList _list;
         private readonly JintStatementList _list;
 
 
-        public JintScript(Script script) : base(script)
+        public JintScript(Script script)
         {
         {
             _list = new JintStatementList(script);
             _list = new JintStatementList(script);
         }
         }
 
 
-        protected override Completion ExecuteInternal(EvaluationContext context)
+        public Completion Execute(EvaluationContext context)
         {
         {
             return _list.Execute(context);
             return _list.Execute(context);
         }
         }

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

@@ -88,7 +88,6 @@ namespace Jint.Runtime.Interpreter.Statements
                 Nodes.WhileStatement => new JintWhileStatement((WhileStatement) statement),
                 Nodes.WhileStatement => new JintWhileStatement((WhileStatement) statement),
                 Nodes.WithStatement => new JintWithStatement((WithStatement) statement),
                 Nodes.WithStatement => new JintWithStatement((WithStatement) statement),
                 Nodes.DebuggerStatement => new JintDebuggerStatement((DebuggerStatement) statement),
                 Nodes.DebuggerStatement => new JintDebuggerStatement((DebuggerStatement) statement),
-                Nodes.Program when statement is Script s => new JintScript(s),
                 Nodes.ClassDeclaration => new JintClassDeclarationStatement((ClassDeclaration) statement),
                 Nodes.ClassDeclaration => new JintClassDeclarationStatement((ClassDeclaration) statement),
                 Nodes.ExportNamedDeclaration => new JintExportNamedDeclaration((ExportNamedDeclaration) statement),
                 Nodes.ExportNamedDeclaration => new JintExportNamedDeclaration((ExportNamedDeclaration) statement),
                 Nodes.ExportAllDeclaration => new JintExportAllDeclaration((ExportAllDeclaration) statement),
                 Nodes.ExportAllDeclaration => new JintExportAllDeclaration((ExportAllDeclaration) statement),

+ 1 - 1
Jint/Runtime/Interpreter/Statements/JintVariableDeclaration.cs

@@ -43,7 +43,7 @@ namespace Jint.Runtime.Interpreter.Statements
                 }
                 }
                 else
                 else
                 {
                 {
-                    left = JintExpression.Build(engine, declaration.Id);
+                    left = JintExpression.Build(engine, (Identifier) declaration.Id);
                 }
                 }
 
 
                 if (declaration.Init != null)
                 if (declaration.Init != null)