Преглед на файлове

Upgrade Esprima to 3.0.0-beta-2 (#1195)

Marko Lahma преди 3 години
родител
ревизия
4d6b6ef2b4

+ 0 - 1
Jint.Tests.Test262/Test262Harness.settings.json

@@ -19,7 +19,6 @@
     "class-static-methods-private",
     "FinalizationRegistry",
     "generators",
-    "hashbang",
     "import-assertions",
     "Promise.allSettled",
     "Promise.any",

+ 2 - 2
Jint.Tests/Runtime/Domain/Dimensional.cs

@@ -39,7 +39,7 @@ namespace Jint.Tests.Runtime.Domain
             return PossibleMeasureUnits.FirstOrDefault(mu => mu.Name == name);
         }
 
-        public int CompareTo(Dimensional? obj)
+        public int CompareTo(Dimensional obj)
         {
             if (MeasureUnit.MeasureType != obj.MeasureUnit.MeasureType)
                 throw new InvalidOperationException("Dimensionals with different measure types are non-comparable");
@@ -48,7 +48,7 @@ namespace Jint.Tests.Runtime.Domain
 
         public override string ToString()
         {
-            return Value.ToString() + " " + MeasureUnit.Name;
+            return Value + " " + MeasureUnit.Name;
         }
     }
 

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

@@ -1,5 +1,4 @@
 using System.IO;
-using System.Reflection;
 using System;
 using System.Collections.Generic;
 using System.Linq;

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

@@ -1,4 +1,3 @@
-using Jint.Native;
 using Jint.Native.Object;
 using Xunit;
 

+ 5 - 5
Jint/EsprimaExtensions.cs

@@ -18,7 +18,7 @@ namespace Jint
 {
     public static class EsprimaExtensions
     {
-        public static JsValue GetKey<T>(this T property, Engine engine) where T : ClassProperty => GetKey(property.Key, engine, property.Computed);
+        public static JsValue GetKey<T>(this T property, Engine engine) where T : IProperty => GetKey(property.Key, engine, property.Computed);
 
         public static JsValue GetKey(this Expression expression, Engine engine, bool resolveComputed = false)
         {
@@ -32,12 +32,12 @@ namespace Jint
             return JsValue.Undefined;
         }
 
-        internal static Completion TryGetKey(this ClassProperty property, Engine engine)
+        internal static Completion TryGetKey<T>(this T property, Engine engine) where T : IProperty
         {
             return TryGetKey(property.Key, engine, property.Computed);
         }
 
-        internal static Completion TryGetKey(this Expression expression, Engine engine, bool resolveComputed)
+        internal static Completion TryGetKey<T>(this T expression, Engine engine, bool resolveComputed) where T : Expression
         {
             JsValue key;
             if (expression is Literal literal)
@@ -108,7 +108,7 @@ namespace Jint
         {
             return d is VariableDeclaration { Kind: VariableDeclarationKind.Const };
         }
-        
+
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         internal static bool HasName<T>(this T node) where T : Node
         {
@@ -282,7 +282,7 @@ namespace Jint
         /// <summary>
         /// https://tc39.es/ecma262/#sec-runtime-semantics-definemethod
         /// </summary>
-        internal static Record DefineMethod(this ClassProperty m, ObjectInstance obj, ObjectInstance? functionPrototype = null)
+        internal static Record DefineMethod<T>(this T m, ObjectInstance obj, ObjectInstance? functionPrototype = null) where T : IProperty
         {
             var engine = obj.Engine;
             var propKey = TypeConverter.ToPropertyKey(m.GetKey(engine));

+ 1 - 1
Jint/Jint.csproj

@@ -8,7 +8,7 @@
     <IsPackable>true</IsPackable>
   </PropertyGroup>
   <ItemGroup>
-    <PackageReference Include="Esprima" Version="3.0.0-beta-1" />
+    <PackageReference Include="Esprima" Version="3.0.0-beta-2" />
     <PackageReference Include="IsExternalInit" Version="1.0.2" PrivateAssets="all" />
     <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
     <PackageReference Include="Nullable" Version="1.3.0" PrivateAssets="all" />

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

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

+ 2 - 1
Jint/Native/ShadowRealm/ShadowRealmInstance.cs

@@ -322,9 +322,10 @@ public sealed class ShadowRealmInstance : ObjectInstance
             _realm = realm;
         }
 
-        protected override void VisitSuper(Super super)
+        protected override object? VisitSuper(Super super)
         {
             ExceptionHelper.ThrowTypeError(_realm, "Shadow realm code cannot contain super");
+            return null;
         }
     }
 }

+ 0 - 1
Jint/Runtime/ExecutionContextStack.cs

@@ -2,7 +2,6 @@
 
 using System.Runtime.CompilerServices;
 using Jint.Collections;
-using Jint.Native.Generator;
 using Jint.Runtime.Environments;
 
 namespace Jint.Runtime

+ 0 - 1
Jint/Runtime/Host.cs

@@ -1,6 +1,5 @@
 #nullable enable
 
-using System.Collections;
 using System.Collections.Generic;
 using Jint.Native;
 using Jint.Native.Global;

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

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

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

@@ -1,7 +1,6 @@
 #nullable enable
 
 using Esprima.Ast;
-using Jint.Native;
 using Jint.Native.Function;
 
 namespace Jint.Runtime.Interpreter.Statements