Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BigInt parsing logic #214

Merged
merged 4 commits into from
Dec 15, 2021
Merged

Fix BigInt parsing logic #214

merged 4 commits into from
Dec 15, 2021

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Dec 13, 2021

  • fix various issues found while integrating into Jint
  • add netstandard2.1 target
  • use spans for literal parsing
  • add System.Memory as dependency

* add netstandard2.1 target
* use spans for literal parsing
* add System.Memory as dependency
// ensure we get positive number
number = ("0" + number.ToString()).AsSpan();
}
#if !NETFRAMEWORK && !NETSTANDARD2_0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if !NETFRAMEWORK && !NETSTANDARD2_0
#if NETSTANDARD2_1_OR_GREATER

Is that what you meant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it include everything like NETCOREAPP31 onwards? standard vs modern net5/6 can be confusing.

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
<PackageReference Include="System.Memory" Version="4.5.4" />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1- What's coming from it?
2- Would it be removed if TFMs included netcoreapp3.1 ... net6.0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically the AsSpan, might be good idea to refine targets and remove dep if possible

@sebastienros
Copy link
Owner

Can you add the new operator on BigIntLiteral.cs while you are at it, to remove the warnings?

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
<PackageReference Include="System.Memory" Version="4.5.4" Condition=" '$(TargetFramework)' != 'netstandard2.1'"/>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required for netstandard2.1 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that compilation works without it.

if (c > 7 && Character.IsHexDigit(c))
{
// ensure we get positive number
number = ("0" + number.ToString()).AsSpan();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToString() on spans, maybe this method should just take the original string, that had to be converted as a span.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Span is part of read source, this is a special case when we need to materialize in order to get parsing to work correctly.

@lahma
Copy link
Collaborator Author

lahma commented Dec 15, 2021

Can you add the new operator on BigIntLiteral.cs while you are at it, to remove the warnings?

Pushed a commit.

@sebastienros
Copy link
Owner

Not this PR, I feel like we need a custom class for each Literal type. Would also prevent boxing.

@lahma
Copy link
Collaborator Author

lahma commented Dec 15, 2021

Jint now passes its bigint test suite with these changes.

@lahma lahma marked this pull request as ready for review December 15, 2021 19:31
@lahma lahma merged commit 51f17f8 into sebastienros:main Dec 15, 2021
@lahma lahma deleted the fix-bigint-parsing branch December 15, 2021 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants