| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 // For instance declarations inside an eval scope need to be added | 1303 // For instance declarations inside an eval scope need to be added |
| 1304 // to the calling function context. | 1304 // to the calling function context. |
| 1305 // Similarly, strict mode eval scope does not leak variable declarations to | 1305 // Similarly, strict mode eval scope does not leak variable declarations to |
| 1306 // the caller's scope so we declare all locals, too. | 1306 // the caller's scope so we declare all locals, too. |
| 1307 if (top_scope_->is_function_scope() || | 1307 if (top_scope_->is_function_scope() || |
| 1308 top_scope_->is_strict_mode_eval_scope()) { | 1308 top_scope_->is_strict_mode_eval_scope()) { |
| 1309 // Declare the variable in the function scope. | 1309 // Declare the variable in the function scope. |
| 1310 var = top_scope_->LocalLookup(name); | 1310 var = top_scope_->LocalLookup(name); |
| 1311 if (var == NULL) { | 1311 if (var == NULL) { |
| 1312 // Declare the name. | 1312 // Declare the name. |
| 1313 var = top_scope_->DeclareLocal(name, mode, Scope::VAR_OR_CONST); | 1313 var = top_scope_->DeclareLocal(name, mode); |
| 1314 } else { | 1314 } else { |
| 1315 // The name was declared before; check for conflicting | 1315 // The name was declared before; check for conflicting |
| 1316 // re-declarations. If the previous declaration was a const or the | 1316 // re-declarations. If the previous declaration was a const or the |
| 1317 // current declaration is a const then we have a conflict. There is | 1317 // current declaration is a const then we have a conflict. There is |
| 1318 // similar code in runtime.cc in the Declare functions. | 1318 // similar code in runtime.cc in the Declare functions. |
| 1319 if ((mode == Variable::CONST) || (var->mode() == Variable::CONST)) { | 1319 if ((mode == Variable::CONST) || (var->mode() == Variable::CONST)) { |
| 1320 // We only have vars and consts in declarations. | 1320 // We only have vars and consts in declarations. |
| 1321 ASSERT(var->mode() == Variable::VAR || | 1321 ASSERT(var->mode() == Variable::VAR || |
| 1322 var->mode() == Variable::CONST); | 1322 var->mode() == Variable::CONST); |
| 1323 const char* type = (var->mode() == Variable::VAR) ? "var" : "const"; | 1323 const char* type = (var->mode() == Variable::VAR) ? "var" : "const"; |
| (...skipping 2242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3566 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { | 3566 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { |
| 3567 name_loc = scanner().location(); | 3567 name_loc = scanner().location(); |
| 3568 } | 3568 } |
| 3569 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { | 3569 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { |
| 3570 dupe_loc = scanner().location(); | 3570 dupe_loc = scanner().location(); |
| 3571 } | 3571 } |
| 3572 if (!reserved_loc.IsValid() && is_reserved) { | 3572 if (!reserved_loc.IsValid() && is_reserved) { |
| 3573 reserved_loc = scanner().location(); | 3573 reserved_loc = scanner().location(); |
| 3574 } | 3574 } |
| 3575 | 3575 |
| 3576 Variable* parameter = top_scope_->DeclareLocal(param_name, | 3576 top_scope_->DeclareParameter(param_name); |
| 3577 Variable::VAR, | |
| 3578 Scope::PARAMETER); | |
| 3579 top_scope_->AddParameter(parameter); | |
| 3580 num_parameters++; | 3577 num_parameters++; |
| 3581 if (num_parameters > kMaxNumFunctionParameters) { | 3578 if (num_parameters > kMaxNumFunctionParameters) { |
| 3582 ReportMessageAt(scanner().location(), "too_many_parameters", | 3579 ReportMessageAt(scanner().location(), "too_many_parameters", |
| 3583 Vector<const char*>::empty()); | 3580 Vector<const char*>::empty()); |
| 3584 *ok = false; | 3581 *ok = false; |
| 3585 return NULL; | 3582 return NULL; |
| 3586 } | 3583 } |
| 3587 done = (peek() == Token::RPAREN); | 3584 done = (peek() == Token::RPAREN); |
| 3588 if (!done) Expect(Token::COMMA, CHECK_OK); | 3585 if (!done) Expect(Token::COMMA, CHECK_OK); |
| 3589 } | 3586 } |
| (...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4988 info->is_global(), | 4985 info->is_global(), |
| 4989 info->StrictMode()); | 4986 info->StrictMode()); |
| 4990 } | 4987 } |
| 4991 } | 4988 } |
| 4992 | 4989 |
| 4993 info->SetFunction(result); | 4990 info->SetFunction(result); |
| 4994 return (result != NULL); | 4991 return (result != NULL); |
| 4995 } | 4992 } |
| 4996 | 4993 |
| 4997 } } // namespace v8::internal | 4994 } } // namespace v8::internal |
| OLD | NEW |