OLD | NEW |
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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 #include "src/asmjs/asm-scanner.h" | 5 #include "src/asmjs/asm-scanner.h" |
6 | 6 |
7 #include "src/conversions.h" | 7 #include "src/conversions.h" |
8 #include "src/flags.h" | 8 #include "src/flags.h" |
9 #include "src/parsing/scanner.h" | 9 #include "src/parsing/scanner.h" |
10 #include "src/unicode-cache.h" | 10 #include "src/unicode-cache.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } else { | 138 } else { |
139 // TODO(bradnelson): Support unicode (probably via UnicodeCache). | 139 // TODO(bradnelson): Support unicode (probably via UnicodeCache). |
140 token_ = kParseError; | 140 token_ = kParseError; |
141 } | 141 } |
142 return; | 142 return; |
143 } | 143 } |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 void AsmJsScanner::Rewind() { | 147 void AsmJsScanner::Rewind() { |
| 148 // TODO(bradnelson): Currently rewinding needs to leave in place the |
| 149 // preceding newline state (in case a |0 ends a line). |
| 150 // This is weird and stateful, fix me. |
148 DCHECK(!rewind_); | 151 DCHECK(!rewind_); |
149 next_token_ = token_; | 152 next_token_ = token_; |
150 token_ = preceding_token_; | 153 token_ = preceding_token_; |
151 preceding_token_ = kUninitialized; | 154 preceding_token_ = kUninitialized; |
152 rewind_ = true; | 155 rewind_ = true; |
153 preceded_by_newline_ = false; | |
154 identifier_string_.clear(); | 156 identifier_string_.clear(); |
155 } | 157 } |
156 | 158 |
157 void AsmJsScanner::ResetLocals() { local_names_.clear(); } | 159 void AsmJsScanner::ResetLocals() { local_names_.clear(); } |
158 | 160 |
159 #if DEBUG | 161 #if DEBUG |
160 // Only used for debugging. | 162 // Only used for debugging. |
161 std::string AsmJsScanner::Name(token_t token) const { | 163 std::string AsmJsScanner::Name(token_t token) const { |
162 if (token >= 32 && token < 127) { | 164 if (token >= 32 && token < 127) { |
163 return std::string(1, static_cast<char>(token)); | 165 return std::string(1, static_cast<char>(token)); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 bool AsmJsScanner::IsIdentifierPart(uc32 ch) { | 406 bool AsmJsScanner::IsIdentifierPart(uc32 ch) { |
405 return IsIdentifierStart(ch) || (ch >= '0' && ch <= '9'); | 407 return IsIdentifierStart(ch) || (ch >= '0' && ch <= '9'); |
406 } | 408 } |
407 | 409 |
408 bool AsmJsScanner::IsNumberStart(uc32 ch) { | 410 bool AsmJsScanner::IsNumberStart(uc32 ch) { |
409 return ch == '.' || (ch >= '0' && ch <= '9'); | 411 return ch == '.' || (ch >= '0' && ch <= '9'); |
410 } | 412 } |
411 | 413 |
412 } // namespace internal | 414 } // namespace internal |
413 } // namespace v8 | 415 } // namespace v8 |
OLD | NEW |