Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: src/scanner.h

Issue 1302893002: Tighten & check the BookmarkScope API contract a bit. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 352 }
353 353
354 private: 354 private:
355 Scanner* scanner_; 355 Scanner* scanner_;
356 bool complete_; 356 bool complete_;
357 }; 357 };
358 358
359 // Scoped helper for a re-settable bookmark. 359 // Scoped helper for a re-settable bookmark.
360 class BookmarkScope { 360 class BookmarkScope {
361 public: 361 public:
362 explicit BookmarkScope(Scanner* scanner) : scanner_(scanner) { 362 explicit BookmarkScope(Scanner* scanner)
363 : scanner_(scanner), my_bookmark_(false) {
363 DCHECK_NOT_NULL(scanner_); 364 DCHECK_NOT_NULL(scanner_);
364 } 365 }
365 ~BookmarkScope() { scanner_->DropBookmark(); } 366 ~BookmarkScope() {
367 if (my_bookmark_) scanner_->DropBookmark();
rossberg 2015/08/20 15:45:12 Hm, this _does_ change the semantics, doesn't it?
vogelheim 2015/08/20 16:26:31 Yes, good observation. But I think the case where
368 }
366 369
367 bool Set() { return scanner_->SetBookmark(); } 370 bool Set() {
368 void Reset() { scanner_->ResetToBookmark(); } 371 DCHECK(!my_bookmark_);
369 bool HasBeenSet() { return scanner_->BookmarkHasBeenSet(); } 372 my_bookmark_ = scanner_->SetBookmark();
370 bool HasBeenReset() { return scanner_->BookmarkHasBeenReset(); } 373 return my_bookmark_;
374 }
375 void Reset() {
376 DCHECK(my_bookmark_);
377 scanner_->ResetToBookmark();
378 }
379 bool HasBeenSet() {
380 DCHECK(my_bookmark_);
381 return scanner_->BookmarkHasBeenSet();
382 }
383 bool HasBeenReset() {
384 DCHECK(my_bookmark_);
385 return scanner_->BookmarkHasBeenReset();
386 }
371 387
372 private: 388 private:
373 Scanner* scanner_; 389 Scanner* scanner_;
390 bool my_bookmark_; // Did this BookmarkScope set the current bookmark?
374 391
375 DISALLOW_COPY_AND_ASSIGN(BookmarkScope); 392 DISALLOW_COPY_AND_ASSIGN(BookmarkScope);
376 }; 393 };
377 394
378 // Representation of an interval of source positions. 395 // Representation of an interval of source positions.
379 struct Location { 396 struct Location {
380 Location(int b, int e) : beg_pos(b), end_pos(e) { } 397 Location(int b, int e) : beg_pos(b), end_pos(e) { }
381 Location() : beg_pos(0), end_pos(0) { } 398 Location() : beg_pos(0), end_pos(0) { }
382 399
383 bool IsValid() const { 400 bool IsValid() const {
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 // inside multiline comments. 802 // inside multiline comments.
786 bool has_line_terminator_before_next_; 803 bool has_line_terminator_before_next_;
787 // Whether there is a multi-line comment that contains a 804 // Whether there is a multi-line comment that contains a
788 // line-terminator after the current token, and before the next. 805 // line-terminator after the current token, and before the next.
789 bool has_multiline_comment_before_next_; 806 bool has_multiline_comment_before_next_;
790 }; 807 };
791 808
792 } } // namespace v8::internal 809 } } // namespace v8::internal
793 810
794 #endif // V8_SCANNER_H_ 811 #endif // V8_SCANNER_H_
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698