| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1968 is_generator ? FunctionKind::kGeneratorFunction | 1968 is_generator ? FunctionKind::kGeneratorFunction |
| 1969 : FunctionKind::kNormalFunction, | 1969 : FunctionKind::kNormalFunction, |
| 1970 pos, FunctionLiteral::DECLARATION, | 1970 pos, FunctionLiteral::DECLARATION, |
| 1971 FunctionLiteral::NORMAL_ARITY, CHECK_OK); | 1971 FunctionLiteral::NORMAL_ARITY, CHECK_OK); |
| 1972 // Even if we're not at the top-level of the global or a function | 1972 // Even if we're not at the top-level of the global or a function |
| 1973 // scope, we treat it as such and introduce the function with its | 1973 // scope, we treat it as such and introduce the function with its |
| 1974 // initial value upon entering the corresponding scope. | 1974 // initial value upon entering the corresponding scope. |
| 1975 // In ES6, a function behaves as a lexical binding, except in | 1975 // In ES6, a function behaves as a lexical binding, except in |
| 1976 // a script scope, or the initial scope of eval or another function. | 1976 // a script scope, or the initial scope of eval or another function. |
| 1977 VariableMode mode = | 1977 VariableMode mode = |
| 1978 is_strong(language_mode()) ? CONST : |
| 1978 allow_harmony_scoping() && is_strict(language_mode()) && | 1979 allow_harmony_scoping() && is_strict(language_mode()) && |
| 1979 !(scope_->is_script_scope() || scope_->is_eval_scope() || | 1980 !(scope_->is_script_scope() || scope_->is_eval_scope() || |
| 1980 scope_->is_function_scope()) | 1981 scope_->is_function_scope()) |
| 1981 ? LET | 1982 ? LET |
| 1982 : VAR; | 1983 : VAR; |
| 1983 VariableProxy* proxy = NewUnresolved(name, mode); | 1984 VariableProxy* proxy = NewUnresolved(name, mode); |
| 1984 Declaration* declaration = | 1985 Declaration* declaration = |
| 1985 factory()->NewFunctionDeclaration(proxy, mode, fun, scope_, pos); | 1986 factory()->NewFunctionDeclaration(proxy, mode, fun, scope_, pos); |
| 1986 Declare(declaration, true, CHECK_OK); | 1987 Declare(declaration, true, CHECK_OK); |
| 1987 if (names) names->Add(name, zone()); | 1988 if (names) names->Add(name, zone()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2011 return NULL; | 2012 return NULL; |
| 2012 } | 2013 } |
| 2013 | 2014 |
| 2014 int pos = position(); | 2015 int pos = position(); |
| 2015 bool is_strict_reserved = false; | 2016 bool is_strict_reserved = false; |
| 2016 const AstRawString* name = | 2017 const AstRawString* name = |
| 2017 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); | 2018 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); |
| 2018 ClassLiteral* value = ParseClassLiteral(name, scanner()->location(), | 2019 ClassLiteral* value = ParseClassLiteral(name, scanner()->location(), |
| 2019 is_strict_reserved, pos, CHECK_OK); | 2020 is_strict_reserved, pos, CHECK_OK); |
| 2020 | 2021 |
| 2021 VariableProxy* proxy = NewUnresolved(name, LET); | 2022 VariableMode mode = is_strong(language_mode()) ? CONST : LET; |
| 2023 VariableProxy* proxy = NewUnresolved(name, mode); |
| 2022 Declaration* declaration = | 2024 Declaration* declaration = |
| 2023 factory()->NewVariableDeclaration(proxy, LET, scope_, pos); | 2025 factory()->NewVariableDeclaration(proxy, mode, scope_, pos); |
| 2024 Declare(declaration, true, CHECK_OK); | 2026 Declare(declaration, true, CHECK_OK); |
| 2025 proxy->var()->set_initializer_position(pos); | 2027 proxy->var()->set_initializer_position(pos); |
| 2026 | 2028 |
| 2027 Token::Value init_op = Token::INIT_LET; | 2029 Token::Value init_op = |
| 2030 is_strong(language_mode()) ? Token::INIT_CONST : Token::INIT_LET; |
| 2028 Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos); | 2031 Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos); |
| 2029 Statement* assignment_statement = | 2032 Statement* assignment_statement = |
| 2030 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); | 2033 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); |
| 2031 if (names) names->Add(name, zone()); | 2034 if (names) names->Add(name, zone()); |
| 2032 return assignment_statement; | 2035 return assignment_statement; |
| 2033 } | 2036 } |
| 2034 | 2037 |
| 2035 | 2038 |
| 2036 Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) { | 2039 Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) { |
| 2037 if (allow_harmony_scoping() && is_strict(language_mode())) { | 2040 if (allow_harmony_scoping() && is_strict(language_mode())) { |
| (...skipping 3402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5440 } else { | 5443 } else { |
| 5441 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5444 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
| 5442 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5445 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
| 5443 raw_string->length()); | 5446 raw_string->length()); |
| 5444 } | 5447 } |
| 5445 } | 5448 } |
| 5446 | 5449 |
| 5447 return running_hash; | 5450 return running_hash; |
| 5448 } | 5451 } |
| 5449 } } // namespace v8::internal | 5452 } } // namespace v8::internal |
| OLD | NEW |