| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 static Identifier Eval() { | 87 static Identifier Eval() { |
| 88 return Identifier(kEvalIdentifier); | 88 return Identifier(kEvalIdentifier); |
| 89 } | 89 } |
| 90 static Identifier Arguments() { | 90 static Identifier Arguments() { |
| 91 return Identifier(kArgumentsIdentifier); | 91 return Identifier(kArgumentsIdentifier); |
| 92 } | 92 } |
| 93 static Identifier FutureReserved() { | 93 static Identifier FutureReserved() { |
| 94 return Identifier(kFutureReservedIdentifier); | 94 return Identifier(kFutureReservedIdentifier); |
| 95 } | 95 } |
| 96 static Identifier FutureStrictReserved() { |
| 97 return Identifier(kFutureStrictReservedIdentifier); |
| 98 } |
| 96 bool IsEval() { return type_ == kEvalIdentifier; } | 99 bool IsEval() { return type_ == kEvalIdentifier; } |
| 97 bool IsArguments() { return type_ == kArgumentsIdentifier; } | 100 bool IsArguments() { return type_ == kArgumentsIdentifier; } |
| 98 bool IsEvalOrArguments() { return type_ >= kEvalIdentifier; } | 101 bool IsEvalOrArguments() { return type_ >= kEvalIdentifier; } |
| 99 bool IsFutureReserved() { return type_ == kFutureReservedIdentifier; } | 102 bool IsFutureReserved() { return type_ == kFutureReservedIdentifier; } |
| 103 bool IsFutureStrictReserved() { |
| 104 return type_ == kFutureStrictReservedIdentifier; |
| 105 } |
| 100 bool IsValidStrictVariable() { return type_ == kUnknownIdentifier; } | 106 bool IsValidStrictVariable() { return type_ == kUnknownIdentifier; } |
| 107 |
| 101 private: | 108 private: |
| 102 enum Type { | 109 enum Type { |
| 103 kUnknownIdentifier, | 110 kUnknownIdentifier, |
| 104 kFutureReservedIdentifier, | 111 kFutureReservedIdentifier, |
| 112 kFutureStrictReservedIdentifier, |
| 105 kEvalIdentifier, | 113 kEvalIdentifier, |
| 106 kArgumentsIdentifier | 114 kArgumentsIdentifier |
| 107 }; | 115 }; |
| 108 explicit Identifier(Type type) : type_(type) { } | 116 explicit Identifier(Type type) : type_(type) { } |
| 109 Type type_; | 117 Type type_; |
| 110 | 118 |
| 111 friend class Expression; | 119 friend class Expression; |
| 112 }; | 120 }; |
| 113 | 121 |
| 114 // Bits 0 and 1 are used to identify the type of expression: | 122 // Bits 0 and 1 are used to identify the type of expression: |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 373 |
| 366 void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok); | 374 void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok); |
| 367 | 375 |
| 368 // All ParseXXX functions take as the last argument an *ok parameter | 376 // All ParseXXX functions take as the last argument an *ok parameter |
| 369 // which is set to false if parsing failed; it is unchanged otherwise. | 377 // which is set to false if parsing failed; it is unchanged otherwise. |
| 370 // By making the 'exception handling' explicit, we are forced to check | 378 // By making the 'exception handling' explicit, we are forced to check |
| 371 // for failure at the call sites. | 379 // for failure at the call sites. |
| 372 SourceElements ParseSourceElements(int end_token, bool* ok); | 380 SourceElements ParseSourceElements(int end_token, bool* ok); |
| 373 Statement ParseStatement(bool* ok); | 381 Statement ParseStatement(bool* ok); |
| 374 Statement ParseFunctionDeclaration(bool* ok); | 382 Statement ParseFunctionDeclaration(bool* ok); |
| 375 Statement ParseNativeDeclaration(bool* ok); | |
| 376 Statement ParseBlock(bool* ok); | 383 Statement ParseBlock(bool* ok); |
| 377 Statement ParseVariableStatement(bool* ok); | 384 Statement ParseVariableStatement(bool* ok); |
| 378 Statement ParseVariableDeclarations(bool accept_IN, int* num_decl, bool* ok); | 385 Statement ParseVariableDeclarations(bool accept_IN, int* num_decl, bool* ok); |
| 379 Statement ParseExpressionOrLabelledStatement(bool* ok); | 386 Statement ParseExpressionOrLabelledStatement(bool* ok); |
| 380 Statement ParseIfStatement(bool* ok); | 387 Statement ParseIfStatement(bool* ok); |
| 381 Statement ParseContinueStatement(bool* ok); | 388 Statement ParseContinueStatement(bool* ok); |
| 382 Statement ParseBreakStatement(bool* ok); | 389 Statement ParseBreakStatement(bool* ok); |
| 383 Statement ParseReturnStatement(bool* ok); | 390 Statement ParseReturnStatement(bool* ok); |
| 384 Statement ParseWithStatement(bool* ok); | 391 Statement ParseWithStatement(bool* ok); |
| 385 Statement ParseSwitchStatement(bool* ok); | 392 Statement ParseSwitchStatement(bool* ok); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 404 Expression ParseArrayLiteral(bool* ok); | 411 Expression ParseArrayLiteral(bool* ok); |
| 405 Expression ParseObjectLiteral(bool* ok); | 412 Expression ParseObjectLiteral(bool* ok); |
| 406 Expression ParseRegExpLiteral(bool seen_equal, bool* ok); | 413 Expression ParseRegExpLiteral(bool seen_equal, bool* ok); |
| 407 Expression ParseV8Intrinsic(bool* ok); | 414 Expression ParseV8Intrinsic(bool* ok); |
| 408 | 415 |
| 409 Arguments ParseArguments(bool* ok); | 416 Arguments ParseArguments(bool* ok); |
| 410 Expression ParseFunctionLiteral(bool* ok); | 417 Expression ParseFunctionLiteral(bool* ok); |
| 411 | 418 |
| 412 Identifier ParseIdentifier(bool* ok); | 419 Identifier ParseIdentifier(bool* ok); |
| 413 Identifier ParseIdentifierName(bool* ok); | 420 Identifier ParseIdentifierName(bool* ok); |
| 414 Identifier ParseIdentifierOrGetOrSet(bool* is_get, bool* is_set, bool* ok); | 421 Identifier ParseIdentifierNameOrGetOrSet(bool* is_get, |
| 422 bool* is_set, |
| 423 bool* ok); |
| 415 | 424 |
| 416 // Logs the currently parsed literal as a symbol in the preparser data. | 425 // Logs the currently parsed literal as a symbol in the preparser data. |
| 417 void LogSymbol(); | 426 void LogSymbol(); |
| 418 // Log the currently parsed identifier. | 427 // Log the currently parsed identifier. |
| 419 Identifier GetIdentifierSymbol(); | 428 Identifier GetIdentifierSymbol(); |
| 420 // Log the currently parsed string literal. | 429 // Log the currently parsed string literal. |
| 421 Expression GetStringSymbol(); | 430 Expression GetStringSymbol(); |
| 422 | 431 |
| 423 i::Token::Value peek() { | 432 i::Token::Value peek() { |
| 424 if (stack_overflow_) return i::Token::ILLEGAL; | 433 if (stack_overflow_) return i::Token::ILLEGAL; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 uintptr_t stack_limit_; | 493 uintptr_t stack_limit_; |
| 485 i::Scanner::Location strict_mode_violation_location_; | 494 i::Scanner::Location strict_mode_violation_location_; |
| 486 const char* strict_mode_violation_type_; | 495 const char* strict_mode_violation_type_; |
| 487 bool stack_overflow_; | 496 bool stack_overflow_; |
| 488 bool allow_lazy_; | 497 bool allow_lazy_; |
| 489 bool parenthesized_function_; | 498 bool parenthesized_function_; |
| 490 }; | 499 }; |
| 491 } } // v8::preparser | 500 } } // v8::preparser |
| 492 | 501 |
| 493 #endif // V8_PREPARSER_H | 502 #endif // V8_PREPARSER_H |
| OLD | NEW |