Home | History | Annotate | Download | only in parsing

Lines Matching refs:Position

26 // source (ReadBlock can be called with pos() pointing to any position,
37 // FillBuffer should read up to kBufferSize characters at position and store
39 virtual size_t FillBuffer(size_t position) = 0;
52 size_t position = pos();
53 buffer_pos_ = position;
55 buffer_end_ = buffer_ + FillBuffer(position);
56 DCHECK_EQ(pos(), position);
72 size_t FillBuffer(size_t position) override;
130 size_t position = pos();
131 bool have_data = start_pos_ <= position && position < end_pos_;
134 buffer_cursor_ = raw_data_ + (position - start_pos_),
137 buffer_pos_ = position;
160 size_t FillBuffer(size_t position) override;
192 // character position is tricky because the byte position cannot be dericed
193 // from the character position.
208 size_t FillBuffer(size_t position) override;
211 // A position within the data stream. It stores:
212 // - The 'physical' position (# of bytes in the stream),
213 // - the 'logical' position (# of ucs-2 characters, also within the stream),
214 // - a possibly incomplete utf-8 char at the current 'physical' position.
221 // Position contains a StreamPosition and the index of the chunk the position
224 struct Position {
231 // - the position at the first byte of the chunk.
238 // Within the current chunk, skip forward from current_ towards position.
239 bool SkipToPosition(size_t position);
244 // Search through the chunks and set current_ to point to the given position.
246 void SearchPosition(size_t position);
249 Position current_;
254 bool Utf8ExternalStreamingStream::SkipToPosition(size_t position) {
255 DCHECK_LE(current_.pos.chars, position); // We can only skip forward.
258 if (current_.pos.chars == position) return true;
267 while (it < chunk.length && chars < position) {
284 return current_.pos.chars == position;
352 void Utf8ExternalStreamingStream::SearchPosition(size_t position) {
353 // If current_ already points to the right position, we're done.
357 if (current_.pos.chars == position) return;
367 // Search for the last chunk whose start position is less or equal to
368 // position.
370 while (chunk_no > 0 && chunks_[chunk_no].start.chars > position) {
375 // behind the end of the data, and position does not exist.
382 // Did we find the non-last chunk? Then our position must be within chunk_no.
393 size_t skip = position - chunks_[chunk_no].start.chars;
400 SkipToPosition(position);
403 // Since position was within the chunk, SkipToPosition should have found
405 DCHECK_EQ(position, current_.pos.chars);
409 // What's left: We're in the last, non-terminating chunk. Our position
415 bool found = SkipToPosition(position);
419 found = have_more_data && SkipToPosition(position);
422 // We'll return with a postion != the desired position only if we're out
424 DCHECK_EQ(found, current_.pos.chars == position);
430 size_t Utf8ExternalStreamingStream::FillBuffer(size_t position) {
434 SearchPosition(position);
450 DCHECK_EQ(current_.pos.chars - position,
471 // Return the chunk index for the chunk containing position.
472 // If position is behind the end of the stream, the index of the last,
475 size_t position, RuntimeCallStats* stats) {
483 while (!out_of_data && end_pos <= position + 1) {
500 DCHECK(position < end_pos || out_of_data);
502 // Edge case: position is behind the end of stream: Return the last (length 0)
504 if (position >= end_pos) {
512 while (chunks[chunk_no].byte_pos > position) {
516 DCHECK_LE(chunks[chunk_no].byte_pos, position);
517 DCHECK_LT(position, chunks[chunk_no].byte_pos + chunks[chunk_no].byte_length);
536 size_t FillBuffer(size_t position) override;
544 size_t OneByteExternalStreamingStream::FillBuffer(size_t position) {
545 const Chunk& chunk = chunks_[FindChunk(chunks_, source_, position, stats_)];
548 size_t start_pos = position - chunk.byte_pos;
591 size_t position = pos();
595 size_t chunk_no = FindChunk(chunks_, source_, 2 * position + 1, stats_);
610 bool lonely_byte = (chunks_[chunk_no].byte_pos == (2 * position + 1));
623 buffer_pos_ = position;
631 DCHECK_LE(current.byte_pos, 2 * position);
632 DCHECK_LT(2 * position + 1, current.byte_pos + current.byte_length);
640 // to point to position. Be careful when converting the byte positions (in
645 buffer_cursor_ = buffer_start_ + (position - buffer_pos_);
646 DCHECK_EQ(position, pos());
671 // FillBuffer should read up to kBufferSize characters at position and store
673 size_t FillBuffer(size_t position, size_t chunk_no);
695 size_t position = pos();
696 // Find chunk in which the position belongs
697 size_t chunk_no = FindChunk(chunks_, source_, 2 * position + 1, stats_);
710 DCHECK_LE(current.byte_pos, 2 * position + odd_start);
711 DCHECK_LT(2 * position + 1, current.byte_pos + current.byte_length);
721 buffer_cursor_ = buffer_start_ + (position - buffer_pos_);
722 DCHECK_EQ(position, pos());
726 buffer_pos_ = position;
728 buffer_end_ = buffer_ + FillBuffer(position, chunk_no);
729 DCHECK_EQ(pos(), position);
735 size_t TwoByteExternalBufferedStream::FillBuffer(size_t position,
741 size_t new_pos = position / kBufferSize * kBufferSize;
742 if (new_pos != position) {
745 buffer_cursor_ = buffer_start_ + (position - buffer_pos_);
746 position = new_pos;
758 bool lonely_byte = (current->byte_pos == (2 * position + 1));
768 DCHECK_LE(current->byte_pos, 2 * position + odd_start);
769 DCHECK_LT(2 * position + 1, current->byte_pos + current->byte_length);
773 size_t chunk_pos = position - current->byte_pos / 2;
783 position = (current->byte_pos + current->byte_length) / 2;
784 if (position - buffer_pos_ < kBufferSize) {
785 chunk_no = FindChunk(chunks_, source_, 2 * position + 1, stats_);
791 DCHECK_LE(current->byte_pos, 2 * position + odd_start);
792 DCHECK_LT(2 * position + 1, current->byte_pos + current->byte_length);
797 position = (current->byte_pos + current->byte_length) / 2;
798 chunk_no = FindChunk(chunks_, source_, 2 * position + 1, stats_);