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 #ifndef V8_SCANNER_H_ | 7 #ifndef V8_SCANNER_H_ |
8 #define V8_SCANNER_H_ | 8 #define V8_SCANNER_H_ |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 public: | 145 public: |
146 explicit DuplicateFinder(UnicodeCache* constants) | 146 explicit DuplicateFinder(UnicodeCache* constants) |
147 : unicode_constants_(constants), | 147 : unicode_constants_(constants), |
148 backing_store_(16), | 148 backing_store_(16), |
149 map_(&Match) { } | 149 map_(&Match) { } |
150 | 150 |
151 int AddOneByteSymbol(Vector<const uint8_t> key, int value); | 151 int AddOneByteSymbol(Vector<const uint8_t> key, int value); |
152 int AddTwoByteSymbol(Vector<const uint16_t> key, int value); | 152 int AddTwoByteSymbol(Vector<const uint16_t> key, int value); |
153 // Add a a number literal by converting it (if necessary) | 153 // Add a a number literal by converting it (if necessary) |
154 // to the string that ToString(ToNumber(literal)) would generate. | 154 // to the string that ToString(ToNumber(literal)) would generate. |
155 // and then adding that string with AddAsciiSymbol. | 155 // and then adding that string with AddOneByteSymbol. |
156 // This string is the actual value used as key in an object literal, | 156 // This string is the actual value used as key in an object literal, |
157 // and the one that must be different from the other keys. | 157 // and the one that must be different from the other keys. |
158 int AddNumber(Vector<const uint8_t> key, int value); | 158 int AddNumber(Vector<const uint8_t> key, int value); |
159 | 159 |
160 private: | 160 private: |
161 int AddSymbol(Vector<const uint8_t> key, bool is_one_byte, int value); | 161 int AddSymbol(Vector<const uint8_t> key, bool is_one_byte, int value); |
162 // Backs up the key and its length in the backing store. | 162 // Backs up the key and its length in the backing store. |
163 // The backup is stored with a base 127 encoding of the | 163 // The backup is stored with a base 127 encoding of the |
164 // length (plus a bit saying whether the string is one byte), | 164 // length (plus a bit saying whether the string is one byte), |
165 // followed by the bytes of the key. | 165 // followed by the bytes of the key. |
166 uint8_t* BackupKey(Vector<const uint8_t> key, bool is_one_byte); | 166 uint8_t* BackupKey(Vector<const uint8_t> key, bool is_one_byte); |
167 | 167 |
168 // Compare two encoded keys (both pointing into the backing store) | 168 // Compare two encoded keys (both pointing into the backing store) |
169 // for having the same base-127 encoded lengths and ASCII-ness, | 169 // for having the same base-127 encoded lengths and representation. |
170 // and then having the same 'length' bytes following. | 170 // and then having the same 'length' bytes following. |
171 static bool Match(void* first, void* second); | 171 static bool Match(void* first, void* second); |
172 // Creates a hash from a sequence of bytes. | 172 // Creates a hash from a sequence of bytes. |
173 static uint32_t Hash(Vector<const uint8_t> key, bool is_one_byte); | 173 static uint32_t Hash(Vector<const uint8_t> key, bool is_one_byte); |
174 // Checks whether a string containing a JS number is its canonical | 174 // Checks whether a string containing a JS number is its canonical |
175 // form. | 175 // form. |
176 static bool IsNumberCanonical(Vector<const uint8_t> key); | 176 static bool IsNumberCanonical(Vector<const uint8_t> key); |
177 | 177 |
178 // Size of buffer. Sufficient for using it to call DoubleToCString in | 178 // Size of buffer. Sufficient for using it to call DoubleToCString in |
179 // from conversions.h. | 179 // from conversions.h. |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 bool harmony_modules_; | 653 bool harmony_modules_; |
654 // Whether we scan 0o777 and 0b111 as numbers. | 654 // Whether we scan 0o777 and 0b111 as numbers. |
655 bool harmony_numeric_literals_; | 655 bool harmony_numeric_literals_; |
656 // Whether we scan 'super' as keyword. | 656 // Whether we scan 'super' as keyword. |
657 bool harmony_classes_; | 657 bool harmony_classes_; |
658 }; | 658 }; |
659 | 659 |
660 } } // namespace v8::internal | 660 } } // namespace v8::internal |
661 | 661 |
662 #endif // V8_SCANNER_H_ | 662 #endif // V8_SCANNER_H_ |
OLD | NEW |