Skip to content

Commit

Permalink
Upgrade Esprima to 3.0.0-beta-2 (#1195)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma authored Jun 13, 2022
1 parent 2303348 commit 4d6b6ef
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 17 deletions.
1 change: 0 additions & 1 deletion Jint.Tests.Test262/Test262Harness.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"class-static-methods-private",
"FinalizationRegistry",
"generators",
"hashbang",
"import-assertions",
"Promise.allSettled",
"Promise.any",
Expand Down
4 changes: 2 additions & 2 deletions Jint.Tests/Runtime/Domain/Dimensional.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private MeasureUnit GetMeasureUnitByName(string name)
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");
Expand All @@ -48,7 +48,7 @@ public int CompareTo(Dimensional? obj)

public override string ToString()
{
return Value.ToString() + " " + MeasureUnit.Name;
return Value + " " + MeasureUnit.Name;
}
}

Expand Down
1 change: 0 additions & 1 deletion Jint.Tests/Runtime/ModuleTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.IO;
using System.Reflection;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
1 change: 0 additions & 1 deletion Jint.Tests/Runtime/ShadowRealmTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Jint.Native;
using Jint.Native.Object;
using Xunit;

Expand Down
10 changes: 5 additions & 5 deletions Jint/EsprimaExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -32,12 +32,12 @@ public static JsValue GetKey(this Expression expression, Engine engine, bool res
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)
Expand Down Expand Up @@ -108,7 +108,7 @@ internal static bool IsConstantDeclaration(this Declaration d)
{
return d is VariableDeclaration { Kind: VariableDeclarationKind.Const };
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool HasName<T>(this T node) where T : Node
{
Expand Down Expand Up @@ -282,7 +282,7 @@ internal static void BindingInitialization(
/// <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));
Expand Down
2 changes: 1 addition & 1 deletion Jint/Jint.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
3 changes: 2 additions & 1 deletion Jint/Native/Function/ClassDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ static MethodDefinition CreateConstructorMethodDefinition(string source)
{
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); } }");
Expand Down
3 changes: 2 additions & 1 deletion Jint/Native/ShadowRealm/ShadowRealmInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,10 @@ public ShadowScriptValidator(Realm realm)
_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;
}
}
}
1 change: 0 additions & 1 deletion Jint/Runtime/ExecutionContextStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

using System.Runtime.CompilerServices;
using Jint.Collections;
using Jint.Native.Generator;
using Jint.Runtime.Environments;

namespace Jint.Runtime
Expand Down
1 change: 0 additions & 1 deletion Jint/Runtime/Host.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#nullable enable

using System.Collections;
using System.Collections.Generic;
using Jint.Native;
using Jint.Native.Global;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Esprima.Ast;
using Jint.Native;
using Jint.Runtime.Modules;

namespace Jint.Runtime.Interpreter.Expressions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#nullable enable

using Esprima.Ast;
using Jint.Native;
using Jint.Native.Function;

namespace Jint.Runtime.Interpreter.Statements
Expand Down

0 comments on commit 4d6b6ef

Please sign in to comment.