| 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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 return factory->NewBinaryOperation( | 512 return factory->NewBinaryOperation( |
| 513 Token::BIT_XOR, expression, factory->NewNumberLiteral(~0, pos), pos); | 513 Token::BIT_XOR, expression, factory->NewNumberLiteral(~0, pos), pos); |
| 514 } | 514 } |
| 515 return factory->NewUnaryOperation(op, expression, pos); | 515 return factory->NewUnaryOperation(op, expression, pos); |
| 516 } | 516 } |
| 517 | 517 |
| 518 | 518 |
| 519 Expression* ParserTraits::NewThrowReferenceError(const char* message, int pos) { | 519 Expression* ParserTraits::NewThrowReferenceError(const char* message, int pos) { |
| 520 return NewThrowError( | 520 return NewThrowError( |
| 521 parser_->ast_value_factory()->make_reference_error_string(), message, | 521 parser_->ast_value_factory()->make_reference_error_string(), message, |
| 522 NULL, pos); | 522 parser_->ast_value_factory()->empty_string(), pos); |
| 523 } | 523 } |
| 524 | 524 |
| 525 | 525 |
| 526 Expression* ParserTraits::NewThrowSyntaxError( | 526 Expression* ParserTraits::NewThrowSyntaxError( |
| 527 const char* message, const AstRawString* arg, int pos) { | 527 const char* message, const AstRawString* arg, int pos) { |
| 528 return NewThrowError(parser_->ast_value_factory()->make_syntax_error_string(), | 528 return NewThrowError(parser_->ast_value_factory()->make_syntax_error_string(), |
| 529 message, arg, pos); | 529 message, arg, pos); |
| 530 } | 530 } |
| 531 | 531 |
| 532 | 532 |
| 533 Expression* ParserTraits::NewThrowTypeError( | 533 Expression* ParserTraits::NewThrowTypeError( |
| 534 const char* message, const AstRawString* arg, int pos) { | 534 const char* message, const AstRawString* arg, int pos) { |
| 535 return NewThrowError(parser_->ast_value_factory()->make_type_error_string(), | 535 return NewThrowError(parser_->ast_value_factory()->make_type_error_string(), |
| 536 message, arg, pos); | 536 message, arg, pos); |
| 537 } | 537 } |
| 538 | 538 |
| 539 | 539 |
| 540 Expression* ParserTraits::NewThrowError( | 540 Expression* ParserTraits::NewThrowError( |
| 541 const AstRawString* constructor, const char* message, | 541 const AstRawString* constructor, const char* message, |
| 542 const AstRawString* arg, int pos) { | 542 const AstRawString* arg, int pos) { |
| 543 Zone* zone = parser_->zone(); | 543 Zone* zone = parser_->zone(); |
| 544 int argc = arg != NULL ? 1 : 0; | |
| 545 const AstRawString* type = | 544 const AstRawString* type = |
| 546 parser_->ast_value_factory()->GetOneByteString(message); | 545 parser_->ast_value_factory()->GetOneByteString(message); |
| 547 ZoneList<const AstRawString*>* array = | |
| 548 new (zone) ZoneList<const AstRawString*>(argc, zone); | |
| 549 if (arg != NULL) { | |
| 550 array->Add(arg, zone); | |
| 551 } | |
| 552 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone); | 546 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone); |
| 553 args->Add(parser_->factory()->NewStringLiteral(type, pos), zone); | 547 args->Add(parser_->factory()->NewStringLiteral(type, pos), zone); |
| 554 args->Add(parser_->factory()->NewStringListLiteral(array, pos), zone); | 548 args->Add(parser_->factory()->NewStringLiteral(arg, pos), zone); |
| 555 CallRuntime* call_constructor = | 549 CallRuntime* call_constructor = |
| 556 parser_->factory()->NewCallRuntime(constructor, NULL, args, pos); | 550 parser_->factory()->NewCallRuntime(constructor, NULL, args, pos); |
| 557 return parser_->factory()->NewThrow(call_constructor, pos); | 551 return parser_->factory()->NewThrow(call_constructor, pos); |
| 558 } | 552 } |
| 559 | 553 |
| 560 | 554 |
| 561 void ParserTraits::ReportMessageAt(Scanner::Location source_location, | 555 void ParserTraits::ReportMessageAt(Scanner::Location source_location, |
| 562 const char* message, | 556 const char* message, |
| 563 const char* arg, | 557 const char* arg, |
| 564 bool is_reference_error) { | 558 bool is_reference_error) { |
| (...skipping 4396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4961 | 4955 |
| 4962 // We cannot internalize on a background thread; a foreground task will take | 4956 // We cannot internalize on a background thread; a foreground task will take |
| 4963 // care of calling Parser::Internalize just before compilation. | 4957 // care of calling Parser::Internalize just before compilation. |
| 4964 | 4958 |
| 4965 if (compile_options() == ScriptCompiler::kProduceParserCache) { | 4959 if (compile_options() == ScriptCompiler::kProduceParserCache) { |
| 4966 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); | 4960 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); |
| 4967 log_ = NULL; | 4961 log_ = NULL; |
| 4968 } | 4962 } |
| 4969 } | 4963 } |
| 4970 } } // namespace v8::internal | 4964 } } // namespace v8::internal |
| OLD | NEW |