| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3484 Smi* literal_type = Smi::cast(value->get(kLiteralTypeSlot)); | 3484 Smi* literal_type = Smi::cast(value->get(kLiteralTypeSlot)); |
| 3485 return static_cast<LiteralType>(literal_type->value()); | 3485 return static_cast<LiteralType>(literal_type->value()); |
| 3486 } | 3486 } |
| 3487 | 3487 |
| 3488 | 3488 |
| 3489 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { | 3489 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { |
| 3490 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot))); | 3490 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot))); |
| 3491 } | 3491 } |
| 3492 | 3492 |
| 3493 | 3493 |
| 3494 class SingletonLogger : public ParserRecorder { | |
| 3495 public: | |
| 3496 SingletonLogger() : has_error_(false), start_(-1), end_(-1) { } | |
| 3497 virtual ~SingletonLogger() { } | |
| 3498 | |
| 3499 void Reset() { has_error_ = false; } | |
| 3500 | |
| 3501 virtual void LogFunction(int start, | |
| 3502 int end, | |
| 3503 int literals, | |
| 3504 int properties, | |
| 3505 StrictMode strict_mode) { | |
| 3506 ASSERT(!has_error_); | |
| 3507 start_ = start; | |
| 3508 end_ = end; | |
| 3509 literals_ = literals; | |
| 3510 properties_ = properties; | |
| 3511 strict_mode_ = strict_mode; | |
| 3512 }; | |
| 3513 | |
| 3514 // Logs a symbol creation of a literal or identifier. | |
| 3515 virtual void LogOneByteSymbol(int start, Vector<const uint8_t> literal) { } | |
| 3516 virtual void LogTwoByteSymbol(int start, Vector<const uint16_t> literal) { } | |
| 3517 | |
| 3518 // Logs an error message and marks the log as containing an error. | |
| 3519 // Further logging will be ignored, and ExtractData will return a vector | |
| 3520 // representing the error only. | |
| 3521 virtual void LogMessage(int start, | |
| 3522 int end, | |
| 3523 const char* message, | |
| 3524 const char* argument_opt) { | |
| 3525 if (has_error_) return; | |
| 3526 has_error_ = true; | |
| 3527 start_ = start; | |
| 3528 end_ = end; | |
| 3529 message_ = message; | |
| 3530 argument_opt_ = argument_opt; | |
| 3531 } | |
| 3532 | |
| 3533 virtual int function_position() { return 0; } | |
| 3534 | |
| 3535 virtual int symbol_position() { return 0; } | |
| 3536 | |
| 3537 virtual int symbol_ids() { return -1; } | |
| 3538 | |
| 3539 virtual Vector<unsigned> ExtractData() { | |
| 3540 UNREACHABLE(); | |
| 3541 return Vector<unsigned>(); | |
| 3542 } | |
| 3543 | |
| 3544 virtual void PauseRecording() { } | |
| 3545 | |
| 3546 virtual void ResumeRecording() { } | |
| 3547 | |
| 3548 bool has_error() { return has_error_; } | |
| 3549 | |
| 3550 int start() { return start_; } | |
| 3551 int end() { return end_; } | |
| 3552 int literals() { | |
| 3553 ASSERT(!has_error_); | |
| 3554 return literals_; | |
| 3555 } | |
| 3556 int properties() { | |
| 3557 ASSERT(!has_error_); | |
| 3558 return properties_; | |
| 3559 } | |
| 3560 StrictMode strict_mode() { | |
| 3561 ASSERT(!has_error_); | |
| 3562 return strict_mode_; | |
| 3563 } | |
| 3564 const char* message() { | |
| 3565 ASSERT(has_error_); | |
| 3566 return message_; | |
| 3567 } | |
| 3568 const char* argument_opt() { | |
| 3569 ASSERT(has_error_); | |
| 3570 return argument_opt_; | |
| 3571 } | |
| 3572 | |
| 3573 private: | |
| 3574 bool has_error_; | |
| 3575 int start_; | |
| 3576 int end_; | |
| 3577 // For function entries. | |
| 3578 int literals_; | |
| 3579 int properties_; | |
| 3580 StrictMode strict_mode_; | |
| 3581 // For error messages. | |
| 3582 const char* message_; | |
| 3583 const char* argument_opt_; | |
| 3584 }; | |
| 3585 | |
| 3586 | |
| 3587 FunctionLiteral* Parser::ParseFunctionLiteral( | 3494 FunctionLiteral* Parser::ParseFunctionLiteral( |
| 3588 Handle<String> function_name, | 3495 Handle<String> function_name, |
| 3589 Scanner::Location function_name_location, | 3496 Scanner::Location function_name_location, |
| 3590 bool name_is_strict_reserved, | 3497 bool name_is_strict_reserved, |
| 3591 bool is_generator, | 3498 bool is_generator, |
| 3592 int function_token_pos, | 3499 int function_token_pos, |
| 3593 FunctionLiteral::FunctionType function_type, | 3500 FunctionLiteral::FunctionType function_type, |
| 3594 bool* ok) { | 3501 bool* ok) { |
| 3595 // Function :: | 3502 // Function :: |
| 3596 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 3503 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
| (...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5168 ASSERT(info()->isolate()->has_pending_exception()); | 5075 ASSERT(info()->isolate()->has_pending_exception()); |
| 5169 } else { | 5076 } else { |
| 5170 result = ParseProgram(); | 5077 result = ParseProgram(); |
| 5171 } | 5078 } |
| 5172 } | 5079 } |
| 5173 info()->SetFunction(result); | 5080 info()->SetFunction(result); |
| 5174 return (result != NULL); | 5081 return (result != NULL); |
| 5175 } | 5082 } |
| 5176 | 5083 |
| 5177 } } // namespace v8::internal | 5084 } } // namespace v8::internal |
| OLD | NEW |