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

Unified Diff: runtime/vm/scanner.cc

Issue 9240014: Set breakpoint at url, line number (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/scanner.h ('k') | runtime/vm/scanner_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scanner.cc
===================================================================
--- runtime/vm/scanner.cc (revision 3419)
+++ runtime/vm/scanner.cc (working copy)
@@ -25,23 +25,42 @@
}
+void Scanner::Reset() {
+ lookahead_pos_ = 0;
+ token_start_ = 0;
+ c0_ = source_length_ == 0 ? '\0' : source_.CharAt(0);
+ newline_seen_ = false;
+ while (saved_context_ != NULL) {
+ ScanContext* ctx = saved_context_;
+ saved_context_ = ctx->next;
+ delete ctx;
+ }
+ string_delimiter_ = '\0';
+ string_is_multiline_ = false;
+ brace_level_ = 0;
+ c0_pos_.line = 1;
+ c0_pos_.column = 1;
+}
+
+
Scanner::Scanner(const String& src, const String& private_key)
: source_(src),
source_length_(src.Length()),
- lookahead_pos_(0),
- token_start_(0),
- c0_(source_length_ == 0 ? '\0' : src.CharAt(0)),
- newline_seen_(false),
saved_context_(NULL),
- string_delimiter_('\0'),
- string_is_multiline_(false),
- brace_level_(0),
private_key_(String::ZoneHandle(private_key.raw())) {
- c0_pos_.line = 1;
- c0_pos_.column = 1;
+ Reset();
InitKeywordTable();
}
+Scanner::~Scanner() {
+ while (saved_context_ != NULL) {
+ ScanContext* ctx = saved_context_;
+ saved_context_ = ctx->next;
+ delete ctx;
+ }
+}
+
+
void Scanner::ErrorMsg(const char* msg) {
current_token_.kind = Token::kERROR;
current_token_.literal = &String::ZoneHandle(String::NewSymbol(msg));
@@ -795,14 +814,17 @@
void Scanner::ScanAll(GrowableTokenStream* token_stream) {
+ Reset();
do {
Scan();
token_stream->Add(current_token_);
} while (current_token_.kind != Token::kEOS);
}
+
void Scanner::ScanTo(intptr_t token_index) {
int index = 0;
+ Reset();
do {
Scan();
index++;
@@ -810,6 +832,22 @@
}
+intptr_t Scanner::TokenIndexAtLine(intptr_t line_number) {
+ ASSERT(line_number >= 0);
+ Reset();
+ int token_index = 0;
+ do {
+ Scan();
+ if (current_token_.position.line >= line_number) {
+ return token_index;
+ }
+ token_index++;
+ } while (current_token_.kind != Token::kEOS);
+ return -1;
+}
+
+
+
const Scanner::GrowableTokenStream& Scanner::GetStream() {
GrowableTokenStream* ts = new GrowableTokenStream(128);
ScanAll(ts);
« no previous file with comments | « runtime/vm/scanner.h ('k') | runtime/vm/scanner_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698