68 if (static_cast<unsigned>(c) <= 9)
return c;
69 c = (c | 0x20) - (
'a' -
'0');
70 if (static_cast<unsigned>(c) <= 5)
return c + 10;
111 unsigned buffered_chars =
113 if (code_unit_count <= buffered_chars) {
115 pos_ += code_unit_count;
116 return code_unit_count;
151 return &utf8_decoder_;
178 if (backing_store_.
length() > 0) {
183 INLINE(
void AddChar(uint32_t code_unit)) {
184 if (position_ >= backing_store_.
length()) ExpandBuffer();
187 backing_store_[position_] =
static_cast<byte>(code_unit);
193 ASSERT(code_unit < 0x10000u);
194 *
reinterpret_cast<uc16*
>(&backing_store_[position_]) = code_unit;
202 ASSERT((position_ & 0x1) == 0);
204 reinterpret_cast<const uc16*
>(backing_store_.
start()),
211 reinterpret_cast<const char*
>(backing_store_.
start()),
216 return is_ascii_ ? position_ : (position_ >> 1);
225 static const int kInitialCapacity = 16;
226 static const int kGrowthFactory = 4;
227 static const int kMinConversionSlack = 256;
228 static const int kMaxGrowth = 1 *
MB;
229 inline int NewCapacity(
int min_capacity) {
230 int capacity =
Max(min_capacity, backing_store_.
length());
231 int new_capacity =
Min(capacity * kGrowthFactory, capacity + kMaxGrowth);
235 void ExpandBuffer() {
237 memcpy(new_store.start(), backing_store_.
start(), position_);
239 backing_store_ = new_store;
242 void ConvertToUtf16() {
244 Vector<byte> new_store;
245 int new_content_size = position_ *
kUC16Size;
246 if (new_content_size >= backing_store_.
length()) {
251 new_store = backing_store_;
253 char* src =
reinterpret_cast<char*
>(backing_store_.
start());
254 uc16* dst =
reinterpret_cast<uc16*
>(new_store.start());
255 for (
int i = position_ - 1; i >= 0; i--) {
258 if (new_store.start() != backing_store_.
start()) {
260 backing_store_ = new_store;
262 position_ = new_content_size;
268 Vector<byte> backing_store_;
284 : scanner_(self), complete_(
false) {
285 scanner_->StartLiteral();
288 if (!complete_) scanner_->DropLiteral();
291 scanner_->TerminateLiteral();
339 return current_.literal_chars->ascii_literal();
343 return current_.literal_chars->utf16_literal();
347 return current_.literal_chars->is_ascii();
351 return current_.literal_chars->length();
357 if (current_.token == Token::STRING) {
361 return current_.literal_chars->length() != source_length;
375 return next_.literal_chars->ascii_literal();
379 return next_.literal_chars->utf16_literal();
383 return next_.literal_chars->is_ascii();
387 return next_.literal_chars->length();
408 return harmony_scoping_;
411 harmony_scoping_ = scoping;
414 return harmony_modules_;
424 return has_line_terminator_before_next_ ||
425 has_multiline_comment_before_next_;
453 current_.literal_chars =
NULL;
457 inline void StartLiteral() {
458 LiteralBuffer* free_buffer = (current_.literal_chars == &literal_buffer1_) ?
459 &literal_buffer2_ : &literal_buffer1_;
460 free_buffer->Reset();
461 next_.literal_chars = free_buffer;
464 INLINE(
void AddLiteralChar(
uc32 c)) {
466 next_.literal_chars->AddChar(c);
470 inline void TerminateLiteral() {
476 inline void DropLiteral() {
477 next_.literal_chars =
NULL;
480 inline void AddLiteralCharAdvance() {
486 void Advance() { c0_ = source_->
Advance(); }
487 void PushBack(
uc32 ch) {
507 uc32 ScanHexNumber(
int expected_length);
512 bool SkipWhiteSpace();
518 void ScanDecimalDigits();
521 Token::Value ScanIdentifierSuffix(LiteralScope* literal);
531 uc32 ScanIdentifierUnicodeEscape();
535 bool ScanLiteralUnicodeEscape();
542 UnicodeCache* unicode_cache_;
545 LiteralBuffer literal_buffer1_;
546 LiteralBuffer literal_buffer2_;
552 Utf16CharacterStream* source_;
564 bool has_line_terminator_before_next_;
567 bool has_multiline_comment_before_next_;
569 bool harmony_scoping_;
571 bool harmony_modules_;
576 #endif // V8_SCANNER_H_
bool HarmonyModules() const
bool IsIdentifierPart(unibrow::uchar c)
uc32 ScanOctalEscape(uc32 c, int length)
LiteralScope(Scanner *self)
virtual unsigned SlowSeekForward(unsigned code_unit_count)=0
unibrow::Utf8InputBuffer< 1024 > Utf8Decoder
bool is_next_literal_ascii()
Vector< const char > ascii_literal()
const uc16 * buffer_cursor_
static const uc32 kEndOfInput
#define ASSERT_NOT_NULL(p)
void SetHarmonyScoping(bool scoping)
int literal_length() const
const uint32_t kMaxAsciiCharCodeU
bool IsWhiteSpace(unibrow::uchar c)
Scanner(UnicodeCache *scanner_contants)
#define ASSERT(condition)
void SetHarmonyModules(bool modules)
bool HasAnyLineTerminatorBeforeNext() const
bool HarmonyScoping() const
int next_literal_length() const
STATIC_ASSERT((FixedDoubleArray::kHeaderSize &kDoubleAlignmentMask)==0)
bool literal_contains_escapes() const
Vector< const char > next_literal_ascii_string()
void SeekForward(int pos)
virtual void PushBack(int32_t code_unit)=0
static Vector< T > New(int length)
activate correct semantics for inheriting readonliness false
void Initialize(Utf16CharacterStream *source)
bool IsLineTerminator(unibrow::uchar c)
unibrow::Utf8InputBuffer< 1024 > Utf8Decoder
static Location invalid()
Location location() const
static const int kNoOctalLocation
static bool IsIdentifier(unibrow::CharacterStream *buffer)
void clear_octal_position()
virtual bool ReadBlock()=0
Vector< const uc16 > next_literal_utf16_string()
Vector< const char > literal_ascii_string()
Token::Value peek() const
Vector< const uc16 > utf16_literal()
Location octal_position() const
INLINE(void AddChar(uint32_t code_unit))
StaticResource< Utf8Decoder > * utf8_decoder()
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
Token::Value current_token()
Vector< const uc16 > literal_utf16_string()
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony modules(implies block scoping)") DEFINE_bool(harmony_proxies
virtual ~Utf16CharacterStream()
bool IsIdentifierStart(unibrow::uchar c)
unsigned SeekForward(unsigned code_unit_count)
bool ScanRegExpPattern(bool seen_equal)
static const int kCharacterLookaheadBufferSize
UnicodeCache * unicode_cache()
Location peek_location() const