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/parser.h" | 5 #include "src/parser.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 5709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5720 result->contains_anchor = parser.contains_anchor(); | 5720 result->contains_anchor = parser.contains_anchor(); |
5721 result->capture_count = capture_count; | 5721 result->capture_count = capture_count; |
5722 } | 5722 } |
5723 return !parser.failed(); | 5723 return !parser.failed(); |
5724 } | 5724 } |
5725 | 5725 |
5726 | 5726 |
5727 bool Parser::ParseStatic(ParseInfo* info) { | 5727 bool Parser::ParseStatic(ParseInfo* info) { |
5728 Parser parser(info); | 5728 Parser parser(info); |
5729 if (parser.Parse(info)) { | 5729 if (parser.Parse(info)) { |
5730 info->set_language_mode(info->function()->language_mode()); | 5730 info->set_language_mode(info->literal()->language_mode()); |
5731 return true; | 5731 return true; |
5732 } | 5732 } |
5733 return false; | 5733 return false; |
5734 } | 5734 } |
5735 | 5735 |
5736 | 5736 |
5737 bool Parser::Parse(ParseInfo* info) { | 5737 bool Parser::Parse(ParseInfo* info) { |
5738 DCHECK(info->function() == NULL); | 5738 DCHECK(info->literal() == NULL); |
5739 FunctionLiteral* result = NULL; | 5739 FunctionLiteral* result = NULL; |
5740 // Ok to use Isolate here; this function is only called in the main thread. | 5740 // Ok to use Isolate here; this function is only called in the main thread. |
5741 DCHECK(parsing_on_main_thread_); | 5741 DCHECK(parsing_on_main_thread_); |
5742 Isolate* isolate = info->isolate(); | 5742 Isolate* isolate = info->isolate(); |
5743 pre_parse_timer_ = isolate->counters()->pre_parse(); | 5743 pre_parse_timer_ = isolate->counters()->pre_parse(); |
5744 if (FLAG_trace_parse || allow_natives() || extension_ != NULL) { | 5744 if (FLAG_trace_parse || allow_natives() || extension_ != NULL) { |
5745 // If intrinsics are allowed, the Parser cannot operate independent of the | 5745 // If intrinsics are allowed, the Parser cannot operate independent of the |
5746 // V8 heap because of Runtime. Tell the string table to internalize strings | 5746 // V8 heap because of Runtime. Tell the string table to internalize strings |
5747 // and values right after they're created. | 5747 // and values right after they're created. |
5748 ast_value_factory()->Internalize(isolate); | 5748 ast_value_factory()->Internalize(isolate); |
(...skipping 14 matching lines...) Expand all Loading... |
5763 | 5763 |
5764 Internalize(isolate, info->script(), result == NULL); | 5764 Internalize(isolate, info->script(), result == NULL); |
5765 DCHECK(ast_value_factory()->IsInternalized()); | 5765 DCHECK(ast_value_factory()->IsInternalized()); |
5766 return (result != NULL); | 5766 return (result != NULL); |
5767 } | 5767 } |
5768 | 5768 |
5769 | 5769 |
5770 void Parser::ParseOnBackground(ParseInfo* info) { | 5770 void Parser::ParseOnBackground(ParseInfo* info) { |
5771 parsing_on_main_thread_ = false; | 5771 parsing_on_main_thread_ = false; |
5772 | 5772 |
5773 DCHECK(info->function() == NULL); | 5773 DCHECK(info->literal() == NULL); |
5774 FunctionLiteral* result = NULL; | 5774 FunctionLiteral* result = NULL; |
5775 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); | 5775 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); |
5776 | 5776 |
5777 CompleteParserRecorder recorder; | 5777 CompleteParserRecorder recorder; |
5778 if (produce_cached_parse_data()) log_ = &recorder; | 5778 if (produce_cached_parse_data()) log_ = &recorder; |
5779 | 5779 |
5780 DCHECK(info->source_stream() != NULL); | 5780 DCHECK(info->source_stream() != NULL); |
5781 ExternalStreamingStream stream(info->source_stream(), | 5781 ExternalStreamingStream stream(info->source_stream(), |
5782 info->source_stream_encoding()); | 5782 info->source_stream_encoding()); |
5783 scanner_.Initialize(&stream); | 5783 scanner_.Initialize(&stream); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6042 Expression* Parser::SpreadCallNew(Expression* function, | 6042 Expression* Parser::SpreadCallNew(Expression* function, |
6043 ZoneList<v8::internal::Expression*>* args, | 6043 ZoneList<v8::internal::Expression*>* args, |
6044 int pos) { | 6044 int pos) { |
6045 args->InsertAt(0, function, zone()); | 6045 args->InsertAt(0, function, zone()); |
6046 | 6046 |
6047 return factory()->NewCallRuntime( | 6047 return factory()->NewCallRuntime( |
6048 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 6048 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
6049 } | 6049 } |
6050 } // namespace internal | 6050 } // namespace internal |
6051 } // namespace v8 | 6051 } // namespace v8 |
OLD | NEW |