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

Class support #816

Merged
merged 30 commits into from Jan 3, 2021
Merged

Class support #816

merged 30 commits into from Jan 3, 2021

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Dec 12, 2020

No description provided.

@lahma lahma marked this pull request as ready for review January 2, 2021 18:41
Jint.Tests.Test262/Test262Test.cs Show resolved Hide resolved
if (name.StartsWith("language/statements/class/subclass/builtin-objects/Promise"))
{
skip = true;
reason = "Promise not implemented";
Copy link
Owner

Choose a reason for hiding this comment

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

WAT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just a small PR and you can enable this... Just need to have the constructor logic use correct methods, like I mentioned 😉

var r = new RegExpInstance(Engine);
r._prototype = PrototypeObject;

var scanner = new Scanner(regExp, new ParserOptions { AdaptRegexp = true });
Copy link
Owner

Choose a reason for hiding this comment

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

Where did this go?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was never used, so removed dead code with extreme prejudice.

@@ -14,6 +15,7 @@ public static T ThrowSyntaxError<T>(Engine engine, string message = null)
return default;
}

[DoesNotReturn]
Copy link
Owner

Choose a reason for hiding this comment

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

Saw that in your other PR, perf only? JIT?

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 it helps the compiler. Can write code like:

string? thisCanBeNull = SomeMethod();
if (thisCanBeNull is null)
   ThrowHelper.Throw();

// compiler won't complain about possibly being null as it knows the earlier branch won't return this code
thisCanBeNull.Substring(1,2);

var f = new BindFunctionInstance(Engine)
{
TargetFunction = thisObj,
BoundThis = thisObj is ArrowFunctionInstance ? Undefined : thisArg,
Copy link
Owner

Choose a reason for hiding this comment

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

So no more ArrowFunctionInstance, less code repetition then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, they now follow the same logic. We can separate again later if we want to fine-tune, but spec doesn't really talk about it being a separate concept, just configured differently.

if (expression is CallExpression callExpression)
{
expression = callExpression.Callee;
continue;
Copy link
Owner

Choose a reason for hiding this comment

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

The while(true) is only for this case? not a recursion instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is honestly a hack. The correct way to handle this later is to have parser enable options.Range = true which should give us start and end index, then if we have the script (string instance), we can substring it. Might even make sense to always provide those out of Esprima without config switch if there's no real performance penalty. So this is something like best-effort, should be replaced with proper solution...

@lahma lahma merged commit 5f1892c into sebastienros:dev Jan 3, 2021
@lahma lahma deleted the es6-classes branch January 3, 2021 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants