OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1569 // is always the function scope. | 1569 // is always the function scope. |
1570 | 1570 |
1571 // If a function scope exists, then we can statically declare this | 1571 // If a function scope exists, then we can statically declare this |
1572 // variable and also set its mode. In any case, a Declaration node | 1572 // variable and also set its mode. In any case, a Declaration node |
1573 // will be added to the scope so that the declaration can be added | 1573 // will be added to the scope so that the declaration can be added |
1574 // to the corresponding activation frame at runtime if necessary. | 1574 // to the corresponding activation frame at runtime if necessary. |
1575 // For instance declarations inside an eval scope need to be added | 1575 // For instance declarations inside an eval scope need to be added |
1576 // to the calling function context. | 1576 // to the calling function context. |
1577 if (top_scope_->is_function_scope()) { | 1577 if (top_scope_->is_function_scope()) { |
1578 // Declare the variable in the function scope. | 1578 // Declare the variable in the function scope. |
1579 var = top_scope_->LookupLocal(name); | 1579 var = top_scope_->LocalLookup(name); |
1580 if (var == NULL) { | 1580 if (var == NULL) { |
1581 // Declare the name. | 1581 // Declare the name. |
1582 var = top_scope_->Declare(name, mode); | 1582 var = top_scope_->DeclareLocal(name, mode); |
1583 } else { | 1583 } else { |
1584 // The name was declared before; check for conflicting | 1584 // The name was declared before; check for conflicting |
1585 // re-declarations. If the previous declaration was a const or the | 1585 // re-declarations. If the previous declaration was a const or the |
1586 // current declaration is a const then we have a conflict. There is | 1586 // current declaration is a const then we have a conflict. There is |
1587 // similar code in runtime.cc in the Declare functions. | 1587 // similar code in runtime.cc in the Declare functions. |
1588 if ((mode == Variable::CONST) || (var->mode() == Variable::CONST)) { | 1588 if ((mode == Variable::CONST) || (var->mode() == Variable::CONST)) { |
1589 // We only have vars and consts in declarations. | 1589 // We only have vars and consts in declarations. |
1590 ASSERT(var->mode() == Variable::VAR || | 1590 ASSERT(var->mode() == Variable::VAR || |
1591 var->mode() == Variable::CONST); | 1591 var->mode() == Variable::CONST); |
1592 const char* type = (var->mode() == Variable::VAR) ? "var" : "const"; | 1592 const char* type = (var->mode() == Variable::VAR) ? "var" : "const"; |
(...skipping 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3459 top_scope_->SetScopeName(name); | 3459 top_scope_->SetScopeName(name); |
3460 | 3460 |
3461 // FormalParameterList :: | 3461 // FormalParameterList :: |
3462 // '(' (Identifier)*[','] ')' | 3462 // '(' (Identifier)*[','] ')' |
3463 Expect(Token::LPAREN, CHECK_OK); | 3463 Expect(Token::LPAREN, CHECK_OK); |
3464 int start_pos = scanner_.location().beg_pos; | 3464 int start_pos = scanner_.location().beg_pos; |
3465 bool done = (peek() == Token::RPAREN); | 3465 bool done = (peek() == Token::RPAREN); |
3466 while (!done) { | 3466 while (!done) { |
3467 Handle<String> param_name = ParseIdentifier(CHECK_OK); | 3467 Handle<String> param_name = ParseIdentifier(CHECK_OK); |
3468 if (!is_pre_parsing_) { | 3468 if (!is_pre_parsing_) { |
3469 top_scope_->AddParameter(top_scope_->Declare(param_name, | 3469 top_scope_->AddParameter(top_scope_->DeclareLocal(param_name, |
3470 Variable::VAR)); | 3470 Variable::VAR)); |
3471 num_parameters++; | 3471 num_parameters++; |
3472 } | 3472 } |
3473 done = (peek() == Token::RPAREN); | 3473 done = (peek() == Token::RPAREN); |
3474 if (!done) Expect(Token::COMMA, CHECK_OK); | 3474 if (!done) Expect(Token::COMMA, CHECK_OK); |
3475 } | 3475 } |
3476 Expect(Token::RPAREN, CHECK_OK); | 3476 Expect(Token::RPAREN, CHECK_OK); |
3477 | 3477 |
3478 Expect(Token::LBRACE, CHECK_OK); | 3478 Expect(Token::LBRACE, CHECK_OK); |
3479 ZoneListWrapper<Statement> body = factory()->NewList<Statement>(8); | 3479 ZoneListWrapper<Statement> body = factory()->NewList<Statement>(8); |
3480 | 3480 |
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4676 start_position, | 4676 start_position, |
4677 is_expression); | 4677 is_expression); |
4678 return result; | 4678 return result; |
4679 } | 4679 } |
4680 | 4680 |
4681 | 4681 |
4682 #undef NEW | 4682 #undef NEW |
4683 | 4683 |
4684 | 4684 |
4685 } } // namespace v8::internal | 4685 } } // namespace v8::internal |
OLD | NEW |