Chromium Code Reviews| Index: src/parser.cc |
| =================================================================== |
| --- src/parser.cc (revision 9568) |
| +++ src/parser.cc (working copy) |
| @@ -1345,7 +1345,7 @@ |
| VariableProxy* Parser::Declare(Handle<String> name, |
| - Variable::Mode mode, |
| + VariableMode mode, |
| FunctionLiteral* fun, |
| bool resolve, |
| bool* ok) { |
| @@ -1363,7 +1363,7 @@ |
| // Similarly, strict mode eval scope does not leak variable declarations to |
| // the caller's scope so we declare all locals, too. |
| - Scope* declaration_scope = mode == Variable::LET ? top_scope_ |
| + Scope* declaration_scope = mode == LET ? top_scope_ |
| : top_scope_->DeclarationScope(); |
| if (declaration_scope->is_function_scope() || |
| declaration_scope->is_strict_mode_eval_scope() || |
| @@ -1385,11 +1385,11 @@ |
| // |
| // because the var declaration is hoisted to the function scope where 'x' |
| // is already bound. |
| - if ((mode != Variable::VAR) || (var->mode() != Variable::VAR)) { |
| + if ((mode != VAR) || (var->mode() != VAR)) { |
| // We only have vars, consts and lets in declarations. |
| - ASSERT(var->mode() == Variable::VAR || |
| - var->mode() == Variable::CONST || |
| - var->mode() == Variable::LET); |
| + ASSERT(var->mode() == VAR || |
| + var->mode() == CONST || |
| + var->mode() == LET); |
| if (harmony_block_scoping_) { |
| // In harmony mode we treat re-declarations as early errors. See |
| // ES5 16 for a definition of early errors. |
| @@ -1400,8 +1400,8 @@ |
| *ok = false; |
| return NULL; |
| } |
| - const char* type = (var->mode() == Variable::VAR) ? "var" : |
| - (var->mode() == Variable::CONST) ? "const" : "let"; |
| + const char* type = (var->mode() == VAR) ? "var" : |
| + (var->mode() == CONST) ? "const" : "let"; |
| Handle<String> type_string = |
| isolate()->factory()->NewStringFromUtf8(CStrVector(type), TENURED); |
| Expression* expression = |
| @@ -1434,14 +1434,10 @@ |
| new(zone()) Declaration(proxy, mode, fun, top_scope_)); |
| // For global const variables we bind the proxy to a variable. |
| - if (mode == Variable::CONST && declaration_scope->is_global_scope()) { |
| + if (mode == CONST && declaration_scope->is_global_scope()) { |
| ASSERT(resolve); // should be set by all callers |
| Variable::Kind kind = Variable::NORMAL; |
| - var = new(zone()) Variable(declaration_scope, |
| - name, |
| - Variable::CONST, |
| - true, |
| - kind); |
| + var = new(zone()) Variable(declaration_scope, name, CONST, true, kind); |
| } |
| // If requested and we have a local variable, bind the proxy to the variable |
| @@ -1524,7 +1520,7 @@ |
| // other functions are setup when entering the surrounding scope. |
| SharedFunctionInfoLiteral* lit = |
| new(zone()) SharedFunctionInfoLiteral(isolate(), shared); |
| - VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK); |
| + VariableProxy* var = Declare(name, VAR, NULL, true, CHECK_OK); |
| return new(zone()) ExpressionStatement(new(zone()) Assignment( |
| isolate(), Token::INIT_VAR, var, lit, RelocInfo::kNoPosition)); |
| } |
| @@ -1546,7 +1542,7 @@ |
| // Even if we're not at the top-level of the global or a function |
| // scope, we treat is as such and introduce the function with it's |
| // initial value upon entering the corresponding scope. |
| - Variable::Mode mode = harmony_block_scoping_ ? Variable::LET : Variable::VAR; |
| + VariableMode mode = harmony_block_scoping_ ? LET : VAR; |
| Declare(name, mode, fun, true, CHECK_OK); |
| return EmptyStatement(); |
| } |
| @@ -1651,7 +1647,7 @@ |
| // VariableDeclarations :: |
| // ('var' | 'const') (Identifier ('=' AssignmentExpression)?)+[','] |
| - Variable::Mode mode = Variable::VAR; |
| + VariableMode mode = VAR; |
| // True if the binding needs initialization. 'let' and 'const' declared |
| // bindings are created uninitialized by their declaration nodes and |
| // need initialization. 'var' declared bindings are always initialized |
| @@ -1668,7 +1664,7 @@ |
| *ok = false; |
| return NULL; |
| } |
| - mode = Variable::CONST; |
| + mode = CONST; |
| is_const = true; |
| needs_init = true; |
| init_op = Token::INIT_CONST; |
| @@ -1681,14 +1677,14 @@ |
| *ok = false; |
| return NULL; |
| } |
| - mode = Variable::LET; |
| + mode = LET; |
| needs_init = true; |
| init_op = Token::INIT_LET; |
| } else { |
| UNREACHABLE(); // by current callers |
| } |
| - Scope* declaration_scope = mode == Variable::LET |
|
Yang
2011/10/11 07:56:35
Consider adding brackets here for better readabili
fschneider
2011/10/11 11:04:22
Done.
|
| + Scope* declaration_scope = mode == LET |
| ? top_scope_ : top_scope_->DeclarationScope(); |
| // The scope of a var/const declared variable anywhere inside a function |
| // is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). Thus we can |
| @@ -1879,7 +1875,7 @@ |
| // as the declaration. Thus dynamic lookups are unnecessary even if the |
| // block scope is inside a with. |
| if (value != NULL) { |
| - bool in_with = mode == Variable::VAR ? inside_with() : false; |
|
Yang
2011/10/11 07:56:35
Consider brackets.
fschneider
2011/10/11 11:04:22
Done.
|
| + bool in_with = mode == VAR ? inside_with() : false; |
| VariableProxy* proxy = |
| initialization_scope->NewUnresolved(name, in_with); |
| Assignment* assignment = |
| @@ -2253,8 +2249,7 @@ |
| if (top_scope_->is_strict_mode()) { |
| catch_scope->EnableStrictMode(); |
| } |
| - Variable::Mode mode = harmony_block_scoping_ |
| - ? Variable::LET : Variable::VAR; |
| + VariableMode mode = harmony_block_scoping_ ? LET : VAR; |
| catch_variable = catch_scope->DeclareLocal(name, mode); |
| Scope* saved_scope = top_scope_; |
| @@ -3763,9 +3758,7 @@ |
| } |
| top_scope_->DeclareParameter(param_name, |
| - harmony_block_scoping_ |
| - ? Variable::LET |
| - : Variable::VAR); |
| + harmony_block_scoping_ ? LET : VAR); |
| num_parameters++; |
| if (num_parameters > kMaxNumFunctionParameters) { |
| ReportMessageAt(scanner().location(), "too_many_parameters", |