Last Comment Bug 709322 - Make break/continue parse nodes type-safe
: Make break/continue parse nodes type-safe
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: All All
: -- minor (vote)
: mozilla11
Assigned To: Jeff Walden [:Waldo] (remove +bmo to email)
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-09 14:30 PST by Jeff Walden [:Waldo] (remove +bmo to email)
Modified: 2011-12-16 06:12 PST (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch (7.67 KB, patch)
2011-12-09 14:30 PST, Jeff Walden [:Waldo] (remove +bmo to email)
jorendorff: review+
Details | Diff | Review

Description Jeff Walden [:Waldo] (remove +bmo to email) 2011-12-09 14:30:45 PST
Created attachment 580553 [details] [diff] [review]
Patch

Construct them using constructors that are purely a function of their arguments, and make access to the associated label type-safe.  This is more code than the current way, but I think it's easier to follow by being more explicit and not relying on implicit state.
Comment 1 Jason Orendorff [:jorendorff] 2011-12-09 14:48:51 PST
Comment on attachment 580553 [details] [diff] [review]
Patch

Splitting BreakStatement and ContinueStatement is farther than I would have gone, but OK.

In Parser.cpp, Parser::statement, case TOK_BREAK:
>+        BreakStatement *breakStmt = tc->parser->new_<BreakStatement>(label, begin, end);
>+        if (!breakStmt)
>             return NULL;
[...]
>+        pn = breakStmt;

Looks like you could just assign directly to pn. Same thing in case TOK_CONTINUE.

Those two cases look awfully similar.
Comment 2 Ed Morley [:emorley] 2011-12-16 06:12:31 PST
https://hg.mozilla.org/mozilla-central/rev/8b1a1c88441a

Note You need to log in before you can comment on or make changes to this bug.