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 11 matching lines...) Expand all Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_PREPARSER_H | 28 #ifndef V8_PREPARSER_H |
29 #define V8_PREPARSER_H | 29 #define V8_PREPARSER_H |
30 | 30 |
31 #include "unicode.h" | 31 #include "unicode.h" |
| 32 #include "utils.h" |
32 | 33 |
33 namespace v8 { | 34 namespace v8 { |
34 namespace preparser { | 35 namespace preparser { |
35 | 36 |
36 // Preparsing checks a JavaScript program and emits preparse-data that helps | 37 // Preparsing checks a JavaScript program and emits preparse-data that helps |
37 // a later parsing to be faster. | 38 // a later parsing to be faster. |
38 // See preparser-data.h for the data. | 39 // See preparser-data.h for the data. |
39 | 40 |
40 // The PreParser checks that the syntax follows the grammar for JavaScript, | 41 // The PreParser checks that the syntax follows the grammar for JavaScript, |
41 // and collects some information about the program along the way. | 42 // and collects some information about the program along the way. |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 return GetIdentifierSymbol(); | 1378 return GetIdentifierSymbol(); |
1378 } | 1379 } |
1379 | 1380 |
1380 | 1381 |
1381 template <typename Scanner, typename Log> | 1382 template <typename Scanner, typename Log> |
1382 Identifier PreParser<Scanner, Log>::ParseIdentifierName(bool* ok) { | 1383 Identifier PreParser<Scanner, Log>::ParseIdentifierName(bool* ok) { |
1383 i::Token::Value next = Next(); | 1384 i::Token::Value next = Next(); |
1384 if (i::Token::IsKeyword(next)) { | 1385 if (i::Token::IsKeyword(next)) { |
1385 int pos = scanner_->location().beg_pos; | 1386 int pos = scanner_->location().beg_pos; |
1386 const char* keyword = i::Token::String(next); | 1387 const char* keyword = i::Token::String(next); |
1387 log_->LogSymbol(pos, keyword, strlen(keyword)); | 1388 log_->LogSymbol(pos, keyword, i::StrLength(keyword)); |
1388 return kUnknownExpression; | 1389 return kUnknownExpression; |
1389 } | 1390 } |
1390 if (next == i::Token::IDENTIFIER) { | 1391 if (next == i::Token::IDENTIFIER) { |
1391 return GetIdentifierSymbol(); | 1392 return GetIdentifierSymbol(); |
1392 } | 1393 } |
1393 *ok = false; | 1394 *ok = false; |
1394 return kUnknownIdentifier; | 1395 return kUnknownIdentifier; |
1395 } | 1396 } |
1396 | 1397 |
1397 | 1398 |
(...skipping 11 matching lines...) Expand all Loading... |
1409 *is_get = strncmp(token, "get", 3) == 0; | 1410 *is_get = strncmp(token, "get", 3) == 0; |
1410 *is_set = !*is_get && strncmp(token, "set", 3) == 0; | 1411 *is_set = !*is_get && strncmp(token, "set", 3) == 0; |
1411 } | 1412 } |
1412 return GetIdentifierSymbol(); | 1413 return GetIdentifierSymbol(); |
1413 } | 1414 } |
1414 | 1415 |
1415 #undef CHECK_OK | 1416 #undef CHECK_OK |
1416 } } // v8::preparser | 1417 } } // v8::preparser |
1417 | 1418 |
1418 #endif // V8_PREPARSER_H | 1419 #endif // V8_PREPARSER_H |
OLD | NEW |