-
Notifications
You must be signed in to change notification settings - Fork 857
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
Refactor IRFactory #1188
Refactor IRFactory #1188
Conversation
After getting harness to work in this way, some of the tests for @@ -458,7 +458,7 @@
name.js
private-identifiers-not-empty.js {unsupported: [class-fields-private]}
-built-ins/Function 194/505 (38.42%)
+built-ins/Function 188/505 (37.23%)
internals/Call 2/2 (100.0%)
internals/Construct 6/6 (100.0%)
length/S15.3.5.1_A1_T3.js strict
@@ -528,7 +528,6 @@
prototype/Symbol.hasInstance/value-negative.js
prototype/Symbol.hasInstance/value-non-obj.js
prototype/Symbol.hasInstance/value-positive.js
- prototype/toString/arrow-function.js
prototype/toString/async-arrow-function.js {unsupported: [async-functions]}
prototype/toString/async-function-declaration.js {unsupported: [async-functions]}
prototype/toString/async-function-expression.js {unsupported: [async-functions]}
@@ -554,9 +553,7 @@
prototype/toString/class-expression-explicit-ctor.js
prototype/toString/class-expression-implicit-ctor.js
prototype/toString/Function.js
- prototype/toString/function-declaration.js
prototype/toString/function-declaration-non-simple-parameter-list.js
- prototype/toString/function-expression.js
prototype/toString/generator-function-declaration.js
prototype/toString/generator-function-expression.js
prototype/toString/generator-method.js
@@ -566,9 +563,6 @@
prototype/toString/getter-class-statement.js
prototype/toString/getter-class-statement-static.js
prototype/toString/getter-object.js
- prototype/toString/line-terminator-normalisation-CR.js
- prototype/toString/line-terminator-normalisation-CR-LF.js
- prototype/toString/line-terminator-normalisation-LF.js
prototype/toString/method-class-expression.js
prototype/toString/method-class-expression-static.js
prototype/toString/method-class-statement.js |
Personally i really like this stuff to bring Rhino into the future. So far my point of view |
I'm also all for moving forward, the only question is how exactly. Personally, i prefer working on a 1.7.15 and a 2.0.0 simultaneously, where we try to put as much as we can into v1.7.15 as possible, and only put stuff into v2.0.0 if it entails a breaking change. Examples of breaking changes: changing the Callable interface to accommodate for implementing strict-mode properly and possibly breaking changes to properly implement block-level scoping of const/let/functions. Whether this PR contains breaking changes that we cannot do without I'm not sure (haven't had the chance to look it over in detail). I did see some public api changes (getEncodedSource, using enum instead of int for flags param for example), but on the surface it looked like those aren't absolutely necessary (but I might be wrong about that), they seemed to just clean up the code a bit |
This is necessary. Currently,
This is not absolutely necessary. |
But technically you could've kept using the 'getEncodedSource' name, no? Both return a string Anyway: with any change, we could be breaking something. Even the fixing of the Regex propetly types @rbri is working on could be a breaking change for some. The question is how likely and does it warrant a bump of the major version. I do think that when we bump the major version, we must include all breaking changes we can identify at once, which means no release can be made until we've resolved them all |
Maybe we should move this discussion to a discussion and plan that meeting that @gbrail proposed a while ago |
https://www.hyrumslaw.com/ |
I'm happy to discuss new versions elsewhere. Right now however we only have a few people contributing to Rhino -- only really three people right now are regularly contributing to new feature development, plus various people who drop in to fix a bug (and those drop-ins are really appreciated). But in addition to that:
So I don't personally see how we have any choice other than to keep moving forward with coming up to date with newer standards, and make pragmatic decisions about backward compatibility without necessarily promising that nothing would ever change. Relevant to this particular PR, does anyone know how commonly the "Decompiler" is used externally? I do know that a number of projects, including some popular ones, use Rhino as a JavaScript parser, but I think that they mostly use the Parser and various AST classes. Perhaps this particular PR is one that breaks compatibility but not in what we'd consider to be a "core" part of the API. |
Another way to convert AST back to source code is to use rhino/src/org/mozilla/javascript/Decompiler.java Lines 13 to 35 in 30ac938
|
By all means I'm just guessing as well, but I think that the Decompiler approach may have been taken to save memory, by storing tokenized source instead of the original string value? Judging by the history of the Decompiler file, it's contents was specifically made public so it could be called from outside org.mozilla.javascript, see cecdd47 Further exposing public stuff happened in 66cf82e Having said that: I've not found any open source code that actually interacts with the Decompiler directly |
FYI I've managed to get the latest version of test262 to execute against Rhino, after implementing Regex unicode flag support and a work-around in the Test262TestSuite class when loading harness code that contains for/of loops with consts (which Rhino doesn't support yet). So once I've wrapped up the unicode flag support and it gets merged, we can start running against the latest test262 version |
I'd like to merge this but I'm still worried about removing Decompiler. I searched GitHub for "import org.mozilla.javascript.Decompiler" and I got about 4000 results, so at least some older code uses it. It looks like Decompiler has only one public function -- what if you were to replace the whole class with a new class that only implements that one function using the new and improved toString method, or AstNode.toSource as you mentioned? It's OK with me if some of the flags no longer work, or if the output is different, but at least that doesn't take away a whole top-level public class. If you can do that, then I think we should merge this. |
@tuchida i really like to try this with HtmlUnit - can you please remove the draft flag from this |
Its been a while, are you still on this? In #1188 (comment) @gbrail detailed what he thinks still needs to happen to this PR for it to become mergable |
I am not making progress now. Sorry. |
ok, understood. I am presuming that eventually you'll get back to this? |
Yes. |
Hi @tuchida I looked at the changes in this PR and it looks like they are two-fold:
Any change you could split the two, so we can at least merge the later and then have a more focused discussion about the former? |
I'm still willing to address this, as it only has a small affect on compatibility. We can do one of two things:
|
Sorry for the late reply. This is a Pull Request from a long time ago, so my memory may be faulty.
@p-bakker As far as I can remember, there were no such changes.
@gbrail The public method of |
Just for the records - did something similar. Is in use in HtmlUnit for some weeks now. But it might introduce problems with the debugger.... |
This Pull Request can be split into these two.
|
I have isolated this as a separate issue.
This will not pass the test262 test if Regex u flag is not implemented. |
I split the Pull Request. ref. #1519 |
Great! So if I understand correctly, of the 3 items you identified in the first comment on this PR:
|
Yes. This PR removes |
Probably cleanest to create a new PR for the removal of the Decompiler and close this one. Am still looking into the Regex /u flag, slow going, little time |
ref. 1ea785f |
ref. #967
IRFactory
no longer inherits fromParser
. This eliminates Code reuse via inheritance.Decompiler
has been removed. This make thatFunction.prototype.toString
behaves as per the ECMA262 specification.SyntaxError
inIRFactory
. It will no longer terminate at1=1
.I believe that this fix is necessary if we are going to add the latest ECMA262 features to Rhino in the future. When I actually tried to add Computed Property Names and default parameters, I had trouble with the
IRFactory
andDecompiler
code. However, I also understand that it is a big risk for Rhino, with its old history, to accept such a big modification. I can also split the Pull Request.I would like to discuss with you what kind of pull requests you can accept.