Support let in switch-case statement lists, scoped by switch body (411279, r=mrbkap).

This commit is contained in:
brendan@mozilla.org 2008-01-08 16:49:35 -08:00
parent 34718748bd
commit 6fdb9f94ad
2 changed files with 10 additions and 7 deletions

View File

@ -66,10 +66,10 @@ typedef enum JSStmtType {
STMT_LABEL, /* labeled statement: L: s */
STMT_IF, /* if (then) statement */
STMT_ELSE, /* else clause of if statement */
STMT_SWITCH, /* switch statement */
STMT_BODY, /* synthetic body of function with
destructuring formal parameters */
STMT_BLOCK, /* compound statement: { s1[;... sN] } */
STMT_SWITCH, /* switch statement */
STMT_WITH, /* with statement */
STMT_CATCH, /* catch block */
STMT_TRY, /* try block */
@ -87,14 +87,16 @@ typedef enum JSStmtType {
* A comment on the encoding of the JSStmtType enum and type-testing macros:
*
* STMT_TYPE_MAYBE_SCOPE tells whether a statement type is always, or may
* become, a lexical scope. Per the proposed JS2/ES4 spec, it includes only
* syntactic blocks: block statements and try/catch/finally statements.
* become, a lexical scope. It therefore includes block and switch (the two
* low-numbered "maybe" scope types) and excludes with (with has dynamic scope
* pending the "reformed with" in ES4/JS2). It includes all try-catch-finally
* types, which are high-numbered maybe-scope types.
*
* STMT_TYPE_LINKS_SCOPE tells whether a JSStmtInfo of the given type eagerly
* links to other scoping statement info records. It excludes the the "maybe"
* type, block, as well as the try and both finally types, since try and the
* other trailing maybe-scope types don't need block scope unless they contain
* let declarations.
* links to other scoping statement info records. It excludes the two early
* "maybe" types, block and switch, as well as the try and both finally types,
* since try and the other trailing maybe-scope types don't need block scope
* unless they contain let declarations.
*
* We treat WITH as a static scope because it prevents lexical binding from
* continuing further up the static scope chain. With the "reformed with"

View File

@ -3253,6 +3253,7 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
if (stmt != tc->topScopeStmt) {
JS_ASSERT(!stmt->downScope);
JS_ASSERT(stmt->type == STMT_BLOCK ||
stmt->type == STMT_SWITCH ||
stmt->type == STMT_TRY ||
stmt->type == STMT_FINALLY);
stmt->downScope = tc->topScopeStmt;