OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 if (op == Token::BIT_NOT) { | 638 if (op == Token::BIT_NOT) { |
639 return factory->NewBinaryOperation( | 639 return factory->NewBinaryOperation( |
640 Token::BIT_XOR, expression, factory->NewNumberLiteral(~0, pos), pos); | 640 Token::BIT_XOR, expression, factory->NewNumberLiteral(~0, pos), pos); |
641 } | 641 } |
642 return factory->NewUnaryOperation(op, expression, pos); | 642 return factory->NewUnaryOperation(op, expression, pos); |
643 } | 643 } |
644 | 644 |
645 | 645 |
646 Expression* ParserTraits::NewThrowReferenceError( | 646 Expression* ParserTraits::NewThrowReferenceError( |
647 MessageTemplate::Template message, int pos) { | 647 MessageTemplate::Template message, int pos) { |
648 return NewThrowError( | 648 return NewThrowError(Runtime::kNewReferenceError, message, |
649 parser_->ast_value_factory()->make_reference_error_string(), message, | 649 parser_->ast_value_factory()->empty_string(), pos); |
650 parser_->ast_value_factory()->empty_string(), pos); | |
651 } | 650 } |
652 | 651 |
653 | 652 |
654 Expression* ParserTraits::NewThrowSyntaxError(MessageTemplate::Template message, | 653 Expression* ParserTraits::NewThrowSyntaxError(MessageTemplate::Template message, |
655 const AstRawString* arg, | 654 const AstRawString* arg, |
656 int pos) { | 655 int pos) { |
657 return NewThrowError(parser_->ast_value_factory()->make_syntax_error_string(), | 656 return NewThrowError(Runtime::kNewSyntaxError, message, arg, pos); |
658 message, arg, pos); | |
659 } | 657 } |
660 | 658 |
661 | 659 |
662 Expression* ParserTraits::NewThrowTypeError(MessageTemplate::Template message, | 660 Expression* ParserTraits::NewThrowTypeError(MessageTemplate::Template message, |
663 const AstRawString* arg, int pos) { | 661 const AstRawString* arg, int pos) { |
664 return NewThrowError(parser_->ast_value_factory()->make_type_error_string(), | 662 return NewThrowError(Runtime::kNewTypeError, message, arg, pos); |
665 message, arg, pos); | |
666 } | 663 } |
667 | 664 |
668 | 665 |
669 Expression* ParserTraits::NewThrowError(const AstRawString* constructor, | 666 Expression* ParserTraits::NewThrowError(Runtime::FunctionId id, |
670 MessageTemplate::Template message, | 667 MessageTemplate::Template message, |
671 const AstRawString* arg, int pos) { | 668 const AstRawString* arg, int pos) { |
672 Zone* zone = parser_->zone(); | 669 Zone* zone = parser_->zone(); |
673 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone); | 670 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone); |
674 args->Add(parser_->factory()->NewSmiLiteral(message, pos), zone); | 671 args->Add(parser_->factory()->NewSmiLiteral(message, pos), zone); |
675 args->Add(parser_->factory()->NewStringLiteral(arg, pos), zone); | 672 args->Add(parser_->factory()->NewStringLiteral(arg, pos), zone); |
676 CallRuntime* call_constructor = | 673 CallRuntime* call_constructor = parser_->factory()->NewCallRuntime( |
677 parser_->factory()->NewCallRuntime(constructor, NULL, args, pos); | 674 parser_->ast_value_factory()->empty_string(), Runtime::FunctionForId(id), |
| 675 args, pos); |
678 return parser_->factory()->NewThrow(call_constructor, pos); | 676 return parser_->factory()->NewThrow(call_constructor, pos); |
679 } | 677 } |
680 | 678 |
681 | 679 |
682 void ParserTraits::ReportMessageAt(Scanner::Location source_location, | 680 void ParserTraits::ReportMessageAt(Scanner::Location source_location, |
683 MessageTemplate::Template message, | 681 MessageTemplate::Template message, |
684 const char* arg, ParseErrorType error_type) { | 682 const char* arg, ParseErrorType error_type) { |
685 if (parser_->stack_overflow()) { | 683 if (parser_->stack_overflow()) { |
686 // Suppress the error message (syntax error or such) in the presence of a | 684 // Suppress the error message (syntax error or such) in the presence of a |
687 // stack overflow. The isolate allows only one pending exception at at time | 685 // stack overflow. The isolate allows only one pending exception at at time |
(...skipping 5210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5898 Expression* Parser::SpreadCallNew(Expression* function, | 5896 Expression* Parser::SpreadCallNew(Expression* function, |
5899 ZoneList<v8::internal::Expression*>* args, | 5897 ZoneList<v8::internal::Expression*>* args, |
5900 int pos) { | 5898 int pos) { |
5901 args->InsertAt(0, function, zone()); | 5899 args->InsertAt(0, function, zone()); |
5902 | 5900 |
5903 return factory()->NewCallRuntime( | 5901 return factory()->NewCallRuntime( |
5904 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 5902 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
5905 } | 5903 } |
5906 } // namespace internal | 5904 } // namespace internal |
5907 } // namespace v8 | 5905 } // namespace v8 |
OLD | NEW |