OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 // Features shared by parsing and pre-parsing scanners. | 5 // Features shared by parsing and pre-parsing scanners. |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "scanner.h" | 9 #include "scanner.h" |
10 | 10 |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 } | 1088 } |
1089 literal.Complete(); | 1089 literal.Complete(); |
1090 | 1090 |
1091 next_.location.end_pos = source_pos() - 1; | 1091 next_.location.end_pos = source_pos() - 1; |
1092 return true; | 1092 return true; |
1093 } | 1093 } |
1094 | 1094 |
1095 | 1095 |
1096 Handle<String> Scanner::AllocateNextLiteralString(Isolate* isolate, | 1096 Handle<String> Scanner::AllocateNextLiteralString(Isolate* isolate, |
1097 PretenureFlag tenured) { | 1097 PretenureFlag tenured) { |
1098 MaybeHandle<String> maybe_result; | |
1099 if (is_next_literal_one_byte()) { | 1098 if (is_next_literal_one_byte()) { |
1100 maybe_result = isolate->factory()->NewStringFromOneByte( | 1099 return isolate->factory()->NewStringFromOneByte( |
1101 next_literal_one_byte_string(), tenured); | 1100 next_literal_one_byte_string(), tenured).ToHandleChecked(); |
1102 } else { | 1101 } else { |
1103 maybe_result = isolate->factory()->NewStringFromTwoByte( | 1102 return isolate->factory()->NewStringFromTwoByte( |
1104 next_literal_two_byte_string(), tenured); | 1103 next_literal_two_byte_string(), tenured).ToHandleChecked(); |
1105 } | 1104 } |
1106 // TODO(ishell): Temporarily returning null handle from here. I will proceed | |
1107 // with maybehandlification in next CLs. | |
1108 Handle<String> result; | |
1109 if (!maybe_result.ToHandle(&result)) return Handle<String>(); | |
1110 return result; | |
1111 } | 1105 } |
1112 | 1106 |
1113 | 1107 |
1114 Handle<String> Scanner::AllocateInternalizedString(Isolate* isolate) { | 1108 Handle<String> Scanner::AllocateInternalizedString(Isolate* isolate) { |
1115 if (is_literal_one_byte()) { | 1109 if (is_literal_one_byte()) { |
1116 return isolate->factory()->InternalizeOneByteString( | 1110 return isolate->factory()->InternalizeOneByteString( |
1117 literal_one_byte_string()); | 1111 literal_one_byte_string()); |
1118 } else { | 1112 } else { |
1119 return isolate->factory()->InternalizeTwoByteString( | 1113 return isolate->factory()->InternalizeTwoByteString( |
1120 literal_two_byte_string()); | 1114 literal_two_byte_string()); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 } | 1280 } |
1287 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1281 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
1288 } | 1282 } |
1289 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1283 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
1290 | 1284 |
1291 backing_store_.AddBlock(bytes); | 1285 backing_store_.AddBlock(bytes); |
1292 return backing_store_.EndSequence().start(); | 1286 return backing_store_.EndSequence().start(); |
1293 } | 1287 } |
1294 | 1288 |
1295 } } // namespace v8::internal | 1289 } } // namespace v8::internal |
OLD | NEW |