| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 literal_flags_ = literal_flags | kLiteralIdentifier; | 157 literal_flags_ = literal_flags | kLiteralIdentifier; |
| 158 Init(); | 158 Init(); |
| 159 // Skip initial whitespace allowing HTML comment ends just like | 159 // Skip initial whitespace allowing HTML comment ends just like |
| 160 // after a newline and scan first token. | 160 // after a newline and scan first token. |
| 161 has_line_terminator_before_next_ = true; | 161 has_line_terminator_before_next_ = true; |
| 162 SkipWhiteSpace(); | 162 SkipWhiteSpace(); |
| 163 Scan(); | 163 Scan(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 | 166 |
| 167 Token::Value V8JavaScriptScanner::NextCheckStack() { | |
| 168 // BUG 1215673: Find a thread safe way to set a stack limit in | |
| 169 // pre-parse mode. Otherwise, we cannot safely pre-parse from other | |
| 170 // threads. | |
| 171 StackLimitCheck check; | |
| 172 if (check.HasOverflowed()) { | |
| 173 stack_overflow_ = true; | |
| 174 current_ = next_; | |
| 175 next_.token = Token::ILLEGAL; | |
| 176 return current_.token; | |
| 177 } else { | |
| 178 return Next(); | |
| 179 } | |
| 180 } | |
| 181 | |
| 182 | |
| 183 UTF16Buffer* StreamInitializer::Init(Handle<String> source, | 167 UTF16Buffer* StreamInitializer::Init(Handle<String> source, |
| 184 unibrow::CharacterStream* stream, | 168 unibrow::CharacterStream* stream, |
| 185 int start_position, | 169 int start_position, |
| 186 int end_position) { | 170 int end_position) { |
| 187 // Either initialize the scanner from a character stream or from a | 171 // Either initialize the scanner from a character stream or from a |
| 188 // string. | 172 // string. |
| 189 ASSERT(source.is_null() || stream == NULL); | 173 ASSERT(source.is_null() || stream == NULL); |
| 190 | 174 |
| 191 // Initialize the source buffer. | 175 // Initialize the source buffer. |
| 192 if (!source.is_null() && StringShape(*source).IsExternalTwoByte()) { | 176 if (!source.is_null() && StringShape(*source).IsExternalTwoByte()) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 ScanJson(); | 213 ScanJson(); |
| 230 } | 214 } |
| 231 | 215 |
| 232 | 216 |
| 233 Token::Value JsonScanner::Next() { | 217 Token::Value JsonScanner::Next() { |
| 234 // BUG 1215673: Find a thread safe way to set a stack limit in | 218 // BUG 1215673: Find a thread safe way to set a stack limit in |
| 235 // pre-parse mode. Otherwise, we cannot safely pre-parse from other | 219 // pre-parse mode. Otherwise, we cannot safely pre-parse from other |
| 236 // threads. | 220 // threads. |
| 237 current_ = next_; | 221 current_ = next_; |
| 238 // Check for stack-overflow before returning any tokens. | 222 // Check for stack-overflow before returning any tokens. |
| 239 StackLimitCheck check; | 223 ScanJson(); |
| 240 if (check.HasOverflowed()) { | |
| 241 stack_overflow_ = true; | |
| 242 next_.token = Token::ILLEGAL; | |
| 243 } else { | |
| 244 ScanJson(); | |
| 245 } | |
| 246 return current_.token; | 224 return current_.token; |
| 247 } | 225 } |
| 248 | 226 |
| 249 | 227 |
| 250 bool JsonScanner::SkipJsonWhiteSpace() { | 228 bool JsonScanner::SkipJsonWhiteSpace() { |
| 251 int start_position = source_pos(); | 229 int start_position = source_pos(); |
| 252 // JSON WhiteSpace is tab, carrige-return, newline and space. | 230 // JSON WhiteSpace is tab, carrige-return, newline and space. |
| 253 while (c0_ == ' ' || c0_ == '\n' || c0_ == '\r' || c0_ == '\t') { | 231 while (c0_ == ' ' || c0_ == '\n' || c0_ == '\r' || c0_ == '\t') { |
| 254 Advance(); | 232 Advance(); |
| 255 } | 233 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 text++; | 417 text++; |
| 440 } | 418 } |
| 441 if (ScannerConstants::kIsIdentifierPart.get(c0_)) return Token::ILLEGAL; | 419 if (ScannerConstants::kIsIdentifierPart.get(c0_)) return Token::ILLEGAL; |
| 442 literal.Complete(); | 420 literal.Complete(); |
| 443 return token; | 421 return token; |
| 444 } | 422 } |
| 445 | 423 |
| 446 | 424 |
| 447 | 425 |
| 448 } } // namespace v8::internal | 426 } } // namespace v8::internal |
| OLD | NEW |