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. | |
151 DCHECK(!rewind_); | 148 DCHECK(!rewind_); |
152 next_token_ = token_; | 149 next_token_ = token_; |
153 token_ = preceding_token_; | 150 token_ = preceding_token_; |
154 preceding_token_ = kUninitialized; | 151 preceding_token_ = kUninitialized; |
155 rewind_ = true; | 152 rewind_ = true; |
| 153 preceded_by_newline_ = false; |
156 identifier_string_.clear(); | 154 identifier_string_.clear(); |
157 } | 155 } |
158 | 156 |
159 void AsmJsScanner::ResetLocals() { local_names_.clear(); } | 157 void AsmJsScanner::ResetLocals() { local_names_.clear(); } |
160 | 158 |
161 #if DEBUG | 159 #if DEBUG |
162 // Only used for debugging. | 160 // Only used for debugging. |
163 std::string AsmJsScanner::Name(token_t token) const { | 161 std::string AsmJsScanner::Name(token_t token) const { |
164 if (token >= 32 && token < 127) { | 162 if (token >= 32 && token < 127) { |
165 return std::string(1, static_cast<char>(token)); | 163 return std::string(1, static_cast<char>(token)); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 bool AsmJsScanner::IsIdentifierPart(uc32 ch) { | 404 bool AsmJsScanner::IsIdentifierPart(uc32 ch) { |
407 return IsIdentifierStart(ch) || (ch >= '0' && ch <= '9'); | 405 return IsIdentifierStart(ch) || (ch >= '0' && ch <= '9'); |
408 } | 406 } |
409 | 407 |
410 bool AsmJsScanner::IsNumberStart(uc32 ch) { | 408 bool AsmJsScanner::IsNumberStart(uc32 ch) { |
411 return ch == '.' || (ch >= '0' && ch <= '9'); | 409 return ch == '.' || (ch >= '0' && ch <= '9'); |
412 } | 410 } |
413 | 411 |
414 } // namespace internal | 412 } // namespace internal |
415 } // namespace v8 | 413 } // namespace v8 |
OLD | NEW |