| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 bool* ok) { | 1508 bool* ok) { |
| 1509 // VariableDeclarations :: | 1509 // VariableDeclarations :: |
| 1510 // ('var' | 'const') (Identifier ('=' AssignmentExpression)?)+[','] | 1510 // ('var' | 'const') (Identifier ('=' AssignmentExpression)?)+[','] |
| 1511 | 1511 |
| 1512 Variable::Mode mode = Variable::VAR; | 1512 Variable::Mode mode = Variable::VAR; |
| 1513 bool is_const = false; | 1513 bool is_const = false; |
| 1514 if (peek() == Token::VAR) { | 1514 if (peek() == Token::VAR) { |
| 1515 Consume(Token::VAR); | 1515 Consume(Token::VAR); |
| 1516 } else if (peek() == Token::CONST) { | 1516 } else if (peek() == Token::CONST) { |
| 1517 Consume(Token::CONST); | 1517 Consume(Token::CONST); |
| 1518 if (temp_scope_->StrictMode()) { |
| 1519 ReportMessage("strict_const", Vector<const char*>::empty()); |
| 1520 *ok = false; |
| 1521 return NULL; |
| 1522 } |
| 1518 mode = Variable::CONST; | 1523 mode = Variable::CONST; |
| 1519 is_const = true; | 1524 is_const = true; |
| 1520 } else { | 1525 } else { |
| 1521 UNREACHABLE(); // by current callers | 1526 UNREACHABLE(); // by current callers |
| 1522 } | 1527 } |
| 1523 | 1528 |
| 1524 // The scope of a variable/const declared anywhere inside a function | 1529 // The scope of a variable/const declared anywhere inside a function |
| 1525 // is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). Thus we can | 1530 // is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). Thus we can |
| 1526 // transform a source-level variable/const declaration into a (Function) | 1531 // transform a source-level variable/const declaration into a (Function) |
| 1527 // Scope declaration, and rewrite the source-level initialization into an | 1532 // Scope declaration, and rewrite the source-level initialization into an |
| (...skipping 3586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5114 info->is_global(), | 5119 info->is_global(), |
| 5115 info->StrictMode()); | 5120 info->StrictMode()); |
| 5116 } | 5121 } |
| 5117 } | 5122 } |
| 5118 | 5123 |
| 5119 info->SetFunction(result); | 5124 info->SetFunction(result); |
| 5120 return (result != NULL); | 5125 return (result != NULL); |
| 5121 } | 5126 } |
| 5122 | 5127 |
| 5123 } } // namespace v8::internal | 5128 } } // namespace v8::internal |
| OLD | NEW |