| 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 "src/scanner.h" | 9 #include "src/scanner.h" |
| 10 | 10 |
| 11 #include "include/v8stdint.h" | 11 #include "include/v8stdint.h" |
| 12 #include "src/ast-value-factory.h" | |
| 13 #include "src/char-predicates-inl.h" | 12 #include "src/char-predicates-inl.h" |
| 14 #include "src/conversions-inl.h" | 13 #include "src/conversions-inl.h" |
| 15 #include "src/list-inl.h" | 14 #include "src/list-inl.h" |
| 16 #include "src/v8.h" | 15 #include "src/v8.h" |
| 17 #include "src/parser.h" | 16 #include "src/parser.h" |
| 18 | 17 |
| 19 namespace v8 { | 18 namespace v8 { |
| 20 namespace internal { | 19 namespace internal { |
| 21 | 20 |
| 22 // ---------------------------------------------------------------------------- | 21 // ---------------------------------------------------------------------------- |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 Advance(); | 1086 Advance(); |
| 1088 } | 1087 } |
| 1089 } | 1088 } |
| 1090 literal.Complete(); | 1089 literal.Complete(); |
| 1091 | 1090 |
| 1092 next_.location.end_pos = source_pos() - 1; | 1091 next_.location.end_pos = source_pos() - 1; |
| 1093 return true; | 1092 return true; |
| 1094 } | 1093 } |
| 1095 | 1094 |
| 1096 | 1095 |
| 1097 const AstString* Scanner::CurrentSymbol(AstValueFactory* ast_value_factory) { | 1096 Handle<String> Scanner::AllocateNextLiteralString(Isolate* isolate, |
| 1098 if (is_literal_one_byte()) { | 1097 PretenureFlag tenured) { |
| 1099 return ast_value_factory->GetOneByteString(literal_one_byte_string()); | 1098 if (is_next_literal_one_byte()) { |
| 1099 return isolate->factory()->NewStringFromOneByte( |
| 1100 next_literal_one_byte_string(), tenured).ToHandleChecked(); |
| 1101 } else { |
| 1102 return isolate->factory()->NewStringFromTwoByte( |
| 1103 next_literal_two_byte_string(), tenured).ToHandleChecked(); |
| 1100 } | 1104 } |
| 1101 return ast_value_factory->GetTwoByteString(literal_two_byte_string()); | |
| 1102 } | 1105 } |
| 1103 | 1106 |
| 1104 | 1107 |
| 1105 const AstString* Scanner::NextSymbol(AstValueFactory* ast_value_factory) { | 1108 Handle<String> Scanner::AllocateInternalizedString(Isolate* isolate) { |
| 1106 if (is_next_literal_one_byte()) { | 1109 if (is_literal_one_byte()) { |
| 1107 return ast_value_factory->GetOneByteString(next_literal_one_byte_string()); | 1110 return isolate->factory()->InternalizeOneByteString( |
| 1111 literal_one_byte_string()); |
| 1112 } else { |
| 1113 return isolate->factory()->InternalizeTwoByteString( |
| 1114 literal_two_byte_string()); |
| 1108 } | 1115 } |
| 1109 return ast_value_factory->GetTwoByteString(next_literal_two_byte_string()); | |
| 1110 } | 1116 } |
| 1111 | 1117 |
| 1112 | 1118 |
| 1113 double Scanner::DoubleValue() { | 1119 double Scanner::DoubleValue() { |
| 1114 ASSERT(is_literal_one_byte()); | 1120 ASSERT(is_literal_one_byte()); |
| 1115 return StringToDouble( | 1121 return StringToDouble( |
| 1116 unicode_cache_, | 1122 unicode_cache_, |
| 1117 literal_one_byte_string(), | 1123 literal_one_byte_string(), |
| 1118 ALLOW_HEX | ALLOW_OCTAL | ALLOW_IMPLICIT_OCTAL | ALLOW_BINARY); | 1124 ALLOW_HEX | ALLOW_OCTAL | ALLOW_IMPLICIT_OCTAL | ALLOW_BINARY); |
| 1119 } | 1125 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 } | 1271 } |
| 1266 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1272 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
| 1267 } | 1273 } |
| 1268 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1274 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
| 1269 | 1275 |
| 1270 backing_store_.AddBlock(bytes); | 1276 backing_store_.AddBlock(bytes); |
| 1271 return backing_store_.EndSequence().start(); | 1277 return backing_store_.EndSequence().start(); |
| 1272 } | 1278 } |
| 1273 | 1279 |
| 1274 } } // namespace v8::internal | 1280 } } // namespace v8::internal |
| OLD | NEW |