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/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 | 881 |
882 if (produce_cached_parse_data()) { | 882 if (produce_cached_parse_data()) { |
883 log_ = &recorder; | 883 log_ = &recorder; |
884 } else if (consume_cached_parse_data()) { | 884 } else if (consume_cached_parse_data()) { |
885 cached_parse_data_->Initialize(); | 885 cached_parse_data_->Initialize(); |
886 } | 886 } |
887 | 887 |
888 source = String::Flatten(source); | 888 source = String::Flatten(source); |
889 FunctionLiteral* result; | 889 FunctionLiteral* result; |
890 | 890 |
891 if (source->IsExternalTwoByteString()) { | 891 { |
892 // Notice that the stream is destroyed at the end of the branch block. | 892 std::unique_ptr<Utf16CharacterStream> stream; |
893 // The last line of the blocks can't be moved outside, even though they're | 893 if (source->IsExternalTwoByteString()) { |
894 // identical calls. | 894 stream.reset(new ExternalTwoByteStringUtf16CharacterStream( |
895 ExternalTwoByteStringUtf16CharacterStream stream( | 895 Handle<ExternalTwoByteString>::cast(source), 0, source->length())); |
896 Handle<ExternalTwoByteString>::cast(source), 0, source->length()); | 896 } else if (source->IsExternalOneByteString()) { |
897 scanner_.Initialize(&stream); | 897 stream.reset(new ExternalOneByteStringUtf16CharacterStream( |
898 result = DoParseProgram(info); | 898 Handle<ExternalOneByteString>::cast(source), 0, source->length())); |
899 } else { | 899 } else { |
900 GenericStringUtf16CharacterStream stream(source, 0, source->length()); | 900 stream.reset( |
901 scanner_.Initialize(&stream); | 901 new GenericStringUtf16CharacterStream(source, 0, source->length())); |
| 902 } |
| 903 scanner_.Initialize(stream.get()); |
902 result = DoParseProgram(info); | 904 result = DoParseProgram(info); |
903 } | 905 } |
904 if (result != NULL) { | 906 if (result != NULL) { |
905 DCHECK_EQ(scanner_.peek_location().beg_pos, source->length()); | 907 DCHECK_EQ(scanner_.peek_location().beg_pos, source->length()); |
906 } | 908 } |
907 HandleSourceURLComments(isolate, info->script()); | 909 HandleSourceURLComments(isolate, info->script()); |
908 | 910 |
909 if (FLAG_trace_parse && result != NULL) { | 911 if (FLAG_trace_parse && result != NULL) { |
910 double ms = timer.Elapsed().InMillisecondsF(); | 912 double ms = timer.Elapsed().InMillisecondsF(); |
911 if (info->is_eval()) { | 913 if (info->is_eval()) { |
(...skipping 6182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7094 node->Print(Isolate::Current()); | 7096 node->Print(Isolate::Current()); |
7095 } | 7097 } |
7096 #endif // DEBUG | 7098 #endif // DEBUG |
7097 | 7099 |
7098 #undef CHECK_OK | 7100 #undef CHECK_OK |
7099 #undef CHECK_OK_VOID | 7101 #undef CHECK_OK_VOID |
7100 #undef CHECK_FAILED | 7102 #undef CHECK_FAILED |
7101 | 7103 |
7102 } // namespace internal | 7104 } // namespace internal |
7103 } // namespace v8 | 7105 } // namespace v8 |
OLD | NEW |