Revision f230a1cf deps/v8/src/scanner.h
deps/v8/src/scanner.h | ||
---|---|---|
34 | 34 |
#include "char-predicates.h" |
35 | 35 |
#include "checks.h" |
36 | 36 |
#include "globals.h" |
37 |
#include "hashmap.h" |
|
38 |
#include "list.h" |
|
37 | 39 |
#include "token.h" |
38 | 40 |
#include "unicode-inl.h" |
39 | 41 |
#include "utils.h" |
... | ... | |
121 | 123 |
}; |
122 | 124 |
|
123 | 125 |
|
124 |
class UnicodeCache { |
|
125 | 126 |
// --------------------------------------------------------------------- |
126 | 127 |
// Caching predicates used by scanners. |
128 |
|
|
129 |
class UnicodeCache { |
|
127 | 130 |
public: |
128 | 131 |
UnicodeCache() {} |
129 | 132 |
typedef unibrow::Utf8Decoder<512> Utf8Decoder; |
... | ... | |
148 | 151 |
}; |
149 | 152 |
|
150 | 153 |
|
154 |
// --------------------------------------------------------------------- |
|
155 |
// DuplicateFinder discovers duplicate symbols. |
|
156 |
|
|
157 |
class DuplicateFinder { |
|
158 |
public: |
|
159 |
explicit DuplicateFinder(UnicodeCache* constants) |
|
160 |
: unicode_constants_(constants), |
|
161 |
backing_store_(16), |
|
162 |
map_(&Match) { } |
|
163 |
|
|
164 |
int AddAsciiSymbol(Vector<const char> key, int value); |
|
165 |
int AddUtf16Symbol(Vector<const uint16_t> key, int value); |
|
166 |
// Add a a number literal by converting it (if necessary) |
|
167 |
// to the string that ToString(ToNumber(literal)) would generate. |
|
168 |
// and then adding that string with AddAsciiSymbol. |
|
169 |
// This string is the actual value used as key in an object literal, |
|
170 |
// and the one that must be different from the other keys. |
|
171 |
int AddNumber(Vector<const char> key, int value); |
|
172 |
|
|
173 |
private: |
|
174 |
int AddSymbol(Vector<const byte> key, bool is_ascii, int value); |
|
175 |
// Backs up the key and its length in the backing store. |
|
176 |
// The backup is stored with a base 127 encoding of the |
|
177 |
// length (plus a bit saying whether the string is ASCII), |
|
178 |
// followed by the bytes of the key. |
|
179 |
byte* BackupKey(Vector<const byte> key, bool is_ascii); |
|
180 |
|
|
181 |
// Compare two encoded keys (both pointing into the backing store) |
|
182 |
// for having the same base-127 encoded lengths and ASCII-ness, |
|
183 |
// and then having the same 'length' bytes following. |
|
184 |
static bool Match(void* first, void* second); |
|
185 |
// Creates a hash from a sequence of bytes. |
|
186 |
static uint32_t Hash(Vector<const byte> key, bool is_ascii); |
|
187 |
// Checks whether a string containing a JS number is its canonical |
|
188 |
// form. |
|
189 |
static bool IsNumberCanonical(Vector<const char> key); |
|
190 |
|
|
191 |
// Size of buffer. Sufficient for using it to call DoubleToCString in |
|
192 |
// from conversions.h. |
|
193 |
static const int kBufferSize = 100; |
|
194 |
|
|
195 |
UnicodeCache* unicode_constants_; |
|
196 |
// Backing store used to store strings used as hashmap keys. |
|
197 |
SequenceCollector<unsigned char> backing_store_; |
|
198 |
HashMap map_; |
|
199 |
// Buffer used for string->number->canonical string conversions. |
|
200 |
char number_buffer_[kBufferSize]; |
|
201 |
}; |
|
202 |
|
|
203 |
|
|
151 | 204 |
// ---------------------------------------------------------------------------- |
152 | 205 |
// LiteralBuffer - Collector of chars of literals. |
153 | 206 |
|
Also available in: Unified diff