Closed Bug 760304 Opened 12 years ago Closed 12 years ago

Reflect.parse needs to be updated to support defaults and rest parameters

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla16

People

(Reporter: Benjamin, Assigned: Benjamin)

References

Details

Attachments

(1 file, 1 obsolete file)

The reflect AST needs to have additions for rest parameters and defaults. I need bug 759498 first, since it alters the parse tree for defaults.
Attached patch support rest and defaults (obsolete) — Splinter Review
Attachment #629676 - Flags: review?(dherman)
Comment on attachment 629676 [details] [diff] [review]
support rest and defaults

>     return newNode(type, pos,
>                    "id", id,
>                    "params", array,
>+                   "defaults", defarray,
>                    "body", body,
>+                   "rest", BooleanValue(hasRest),

The rest-argument has a name -- are you including the name in the params list and this just indicates whether the last name is a rest-arg? Would it be a nicer API to have the params array only have the non-rest params, and the .rest field to be either a string or null?

>                    "generator", BooleanValue(isGenerator),
>                    "expression", BooleanValue(isExpression),
>                    dst);
> }

>diff --git a/js/src/tests/js1_8_5/extensions/reflect-parse.js b/js/src/tests/js1_8_5/extensions/reflect-parse.js
>--- a/js/src/tests/js1_8_5/extensions/reflect-parse.js
>+++ b/js/src/tests/js1_8_5/extensions/reflect-parse.js
>@@ -20,24 +20,28 @@ var _ = Pattern.ANY;

...

>+assertDecl("function foo(...rest) { }",
>+           funDecl(ident("foo"), [ident("rest")], blockStmt([]), [], true));

Yeah, so I was thinking it might make more sense for the API to return

    funDecl(ident("foo"), [], blockStmt([]), [], "rest")

But I'm not adamant about this. It just seems a little less error-prone somehow. What do you think?

Please update the docs at https://developer.mozilla.org/en/SpiderMonkey/Parser_API if you haven't already.

Overall looks good. r=me; it's up to you if you want to make that API change I suggested, or we can discuss in the bug.

Thanks,
Dave
Attachment #629676 - Flags: review?(dherman) → review+
I think your suggested API is better.
Attachment #629676 - Attachment is obsolete: true
Keywords: checkin-needed
The wiki has been updated.
Flags: in-testsuite+
Target Milestone: --- → mozilla16
https://hg.mozilla.org/mozilla-central/rev/c2ce10a018d8
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: