-
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
convert RegEx properties #1183
base: master
Are you sure you want to change the base?
convert RegEx properties #1183
Conversation
@@ -109,6 +109,12 @@ | |||
|
|||
private static final int ANCHOR_BOL = -2; | |||
|
|||
private static final SymbolKey GET_FLAGS = new SymbolKey("[Symbol.getFlags]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a Symbol
? Symbol
is written as [ @@match ]
.
https://262.ecma-international.org/12.0/#sec-get-regexp.prototype.flags
@@ -126,6 +132,36 @@ public static void init(Context cx, Scriptable scope, boolean sealed) { | |||
|
|||
ctor.setImmunePrototypeProperty(proto); | |||
|
|||
ScriptableObject desc = (ScriptableObject) cx.newObject(scope); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I don't know much about this area, but...) Could you write simply using Lambda?
rhino/src/org/mozilla/javascript/NativePromise.java
Lines 41 to 76 in ae78dbf
constructor.defineConstructorMethod( | |
scope, "resolve", 1, NativePromise::resolve, DONTENUM, DONTENUM | READONLY); | |
constructor.defineConstructorMethod( | |
scope, "reject", 1, NativePromise::reject, DONTENUM, DONTENUM | READONLY); | |
constructor.defineConstructorMethod( | |
scope, "all", 1, NativePromise::all, DONTENUM, DONTENUM | READONLY); | |
constructor.defineConstructorMethod( | |
scope, "allSettled", 1, NativePromise::allSettled, DONTENUM, DONTENUM | READONLY); | |
constructor.defineConstructorMethod( | |
scope, "race", 1, NativePromise::race, DONTENUM, DONTENUM | READONLY); | |
ScriptableObject speciesDescriptor = (ScriptableObject) cx.newObject(scope); | |
ScriptableObject.putProperty(speciesDescriptor, "enumerable", false); | |
ScriptableObject.putProperty(speciesDescriptor, "configurable", true); | |
ScriptableObject.putProperty( | |
speciesDescriptor, | |
"get", | |
new LambdaFunction( | |
scope, | |
"get [Symbol.species]", | |
0, | |
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> | |
constructor)); | |
constructor.defineOwnProperty(cx, SymbolKey.SPECIES, speciesDescriptor, false); | |
constructor.definePrototypeMethod( | |
scope, | |
"then", | |
2, | |
(Context lcx, Scriptable lscope, Scriptable thisObj, Object[] args) -> { | |
NativePromise self = | |
LambdaConstructor.convertThisObject(thisObj, NativePromise.class); | |
return self.then(lcx, lscope, constructor, args); | |
}, | |
DONTENUM, | |
DONTENUM | READONLY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will check.....
prototype/multiline/this-val-regexp-prototype.js | ||
prototype/source/cross-realm.js {unsupported: [cross-realm]} | ||
prototype/source/length.js | ||
prototype/source/name.js | ||
prototype/source/prop-desc.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why this one doesn't pass yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange will have a look
This symbol seem to be too hacky, but the id scriptable object is a nightmare for this kind of properties. I have to digg deeper into the mud here. - will require some more days. |
@rbri just wondering how this PR is coming along, as I'm working on implementing the unicode flag and while analysing failing tests related to the unicode property, some are due me currently having added the unicode property as a data property instead of an accessor property |
prototype/source/prop-desc.js | ||
prototype/source/this-val-regexp-prototype.js | ||
prototype/source/value-empty.js | ||
prototype/source/value-line-terminator.js | ||
prototype/source/value-u.js | ||
prototype/sticky/cross-realm.js {unsupported: [cross-realm]} | ||
prototype/sticky/length.js | ||
prototype/sticky/name.js | ||
prototype/sticky/prop-desc.js | ||
prototype/sticky/this-val-regexp-prototype.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is dependant on the sticky property being implemented as an accessor property. However, it looks like your changes haven't caused it to pass yet.
Not sure if that is due to the accessor property impl or if something else, possibly unrelated, is going on
@rbri just wondering how this PR is coming along |
@rbri any chance for a quick update on this one? Is getting these types of properties properly implemented in IdScriptables maybe dead in the water completely and we should look at converting relevant implementations into lambda's instead? |
Implements the Regex part of #963