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/ast-literal-reindexer.h" | 9 #include "src/ast-literal-reindexer.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 pre_parse_timer_(NULL), | 905 pre_parse_timer_(NULL), |
906 parsing_on_main_thread_(true) { | 906 parsing_on_main_thread_(true) { |
907 // Even though we were passed ParseInfo, we should not store it in | 907 // Even though we were passed ParseInfo, we should not store it in |
908 // Parser - this makes sure that Isolate is not accidentally accessed via | 908 // Parser - this makes sure that Isolate is not accidentally accessed via |
909 // ParseInfo during background parsing. | 909 // ParseInfo during background parsing. |
910 DCHECK(!info->script().is_null() || info->source_stream() != NULL); | 910 DCHECK(!info->script().is_null() || info->source_stream() != NULL); |
911 set_allow_lazy(info->allow_lazy_parsing()); | 911 set_allow_lazy(info->allow_lazy_parsing()); |
912 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); | 912 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); |
913 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); | 913 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); |
914 set_allow_harmony_sloppy(FLAG_harmony_sloppy); | 914 set_allow_harmony_sloppy(FLAG_harmony_sloppy); |
| 915 set_allow_harmony_sloppy_function(FLAG_harmony_sloppy_function); |
915 set_allow_harmony_sloppy_let(FLAG_harmony_sloppy_let); | 916 set_allow_harmony_sloppy_let(FLAG_harmony_sloppy_let); |
916 set_allow_harmony_rest_parameters(FLAG_harmony_rest_parameters); | 917 set_allow_harmony_rest_parameters(FLAG_harmony_rest_parameters); |
917 set_allow_harmony_spreadcalls(FLAG_harmony_spreadcalls); | 918 set_allow_harmony_spreadcalls(FLAG_harmony_spreadcalls); |
918 set_allow_harmony_destructuring(FLAG_harmony_destructuring); | 919 set_allow_harmony_destructuring(FLAG_harmony_destructuring); |
919 set_allow_harmony_spread_arrays(FLAG_harmony_spread_arrays); | 920 set_allow_harmony_spread_arrays(FLAG_harmony_spread_arrays); |
920 set_allow_harmony_new_target(FLAG_harmony_new_target); | 921 set_allow_harmony_new_target(FLAG_harmony_new_target); |
921 set_allow_strong_mode(FLAG_strong_mode); | 922 set_allow_strong_mode(FLAG_strong_mode); |
922 set_allow_legacy_const(FLAG_legacy_const); | 923 set_allow_legacy_const(FLAG_legacy_const); |
923 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; | 924 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; |
924 ++feature) { | 925 ++feature) { |
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2217 if (fni_ != NULL) fni_->Leave(); | 2218 if (fni_ != NULL) fni_->Leave(); |
2218 | 2219 |
2219 // Even if we're not at the top-level of the global or a function | 2220 // Even if we're not at the top-level of the global or a function |
2220 // scope, we treat it as such and introduce the function with its | 2221 // scope, we treat it as such and introduce the function with its |
2221 // initial value upon entering the corresponding scope. | 2222 // initial value upon entering the corresponding scope. |
2222 // In ES6, a function behaves as a lexical binding, except in | 2223 // In ES6, a function behaves as a lexical binding, except in |
2223 // a script scope, or the initial scope of eval or another function. | 2224 // a script scope, or the initial scope of eval or another function. |
2224 VariableMode mode = | 2225 VariableMode mode = |
2225 is_strong(language_mode()) | 2226 is_strong(language_mode()) |
2226 ? CONST | 2227 ? CONST |
2227 : (is_strict(language_mode()) || allow_harmony_sloppy()) && | 2228 : (is_strict(language_mode()) || allow_harmony_sloppy_function()) && |
2228 !scope_->is_declaration_scope() ? LET : VAR; | 2229 !scope_->is_declaration_scope() |
| 2230 ? LET |
| 2231 : VAR; |
2229 VariableProxy* proxy = NewUnresolved(name, mode); | 2232 VariableProxy* proxy = NewUnresolved(name, mode); |
2230 Declaration* declaration = | 2233 Declaration* declaration = |
2231 factory()->NewFunctionDeclaration(proxy, mode, fun, scope_, pos); | 2234 factory()->NewFunctionDeclaration(proxy, mode, fun, scope_, pos); |
2232 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); | 2235 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); |
2233 if (names) names->Add(name, zone()); | 2236 if (names) names->Add(name, zone()); |
2234 return factory()->NewEmptyStatement(RelocInfo::kNoPosition); | 2237 return factory()->NewEmptyStatement(RelocInfo::kNoPosition); |
2235 } | 2238 } |
2236 | 2239 |
2237 | 2240 |
2238 Statement* Parser::ParseClassDeclaration(ZoneList<const AstRawString*>* names, | 2241 Statement* Parser::ParseClassDeclaration(ZoneList<const AstRawString*>* names, |
(...skipping 3773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6012 Expression* Parser::SpreadCallNew(Expression* function, | 6015 Expression* Parser::SpreadCallNew(Expression* function, |
6013 ZoneList<v8::internal::Expression*>* args, | 6016 ZoneList<v8::internal::Expression*>* args, |
6014 int pos) { | 6017 int pos) { |
6015 args->InsertAt(0, function, zone()); | 6018 args->InsertAt(0, function, zone()); |
6016 | 6019 |
6017 return factory()->NewCallRuntime( | 6020 return factory()->NewCallRuntime( |
6018 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 6021 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
6019 } | 6022 } |
6020 } // namespace internal | 6023 } // namespace internal |
6021 } // namespace v8 | 6024 } // namespace v8 |
OLD | NEW |