| 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 | 552 |
| 553 | 553 |
| 554 int ParserTraits::NextMaterializedLiteralIndex() { | 554 int ParserTraits::NextMaterializedLiteralIndex() { |
| 555 return parser_->current_function_state_->NextMaterializedLiteralIndex(); | 555 return parser_->current_function_state_->NextMaterializedLiteralIndex(); |
| 556 } | 556 } |
| 557 | 557 |
| 558 | 558 |
| 559 void ParserTraits::ReportMessageAt(Scanner::Location source_location, | 559 void ParserTraits::ReportMessageAt(Scanner::Location source_location, |
| 560 const char* message, | 560 const char* message, |
| 561 Vector<const char*> args) { | 561 Vector<const char*> args) { |
| 562 fprintf(stderr, "ParserTraits::ReportMessageAt\n"); |
| 562 MessageLocation location(parser_->script_, | 563 MessageLocation location(parser_->script_, |
| 563 source_location.beg_pos, | 564 source_location.beg_pos, |
| 564 source_location.end_pos); | 565 source_location.end_pos); |
| 566 fprintf(stderr, "message %s, args len %d\n", message, args.length()); |
| 565 Factory* factory = parser_->isolate()->factory(); | 567 Factory* factory = parser_->isolate()->factory(); |
| 566 Handle<FixedArray> elements = factory->NewFixedArray(args.length()); | 568 Handle<FixedArray> elements = factory->NewFixedArray(args.length()); |
| 567 for (int i = 0; i < args.length(); i++) { | 569 for (int i = 0; i < args.length(); i++) { |
| 570 fprintf(stderr, "looping %d %s\n", i, args[i]); |
| 568 Handle<String> arg_string = factory->NewStringFromUtf8(CStrVector(args[i])); | 571 Handle<String> arg_string = factory->NewStringFromUtf8(CStrVector(args[i])); |
| 569 elements->set(i, *arg_string); | 572 elements->set(i, *arg_string); |
| 570 } | 573 } |
| 571 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); | 574 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); |
| 572 Handle<Object> result = factory->NewSyntaxError(message, array); | 575 Handle<Object> result = factory->NewSyntaxError(message, array); |
| 573 parser_->isolate()->Throw(*result, &location); | 576 parser_->isolate()->Throw(*result, &location); |
| 577 fprintf(stderr, "ParserTraits::ReportMessageAt returns\n"); |
| 574 } | 578 } |
| 575 | 579 |
| 576 | 580 |
| 577 void ParserTraits::ReportMessage(const char* message, | 581 void ParserTraits::ReportMessage(const char* message, |
| 578 Vector<Handle<String> > args) { | 582 Vector<Handle<String> > args) { |
| 583 fprintf(stderr, "ParserTraits::ReportMessage\n"); |
| 579 Scanner::Location source_location = parser_->scanner().location(); | 584 Scanner::Location source_location = parser_->scanner().location(); |
| 580 ReportMessageAt(source_location, message, args); | 585 ReportMessageAt(source_location, message, args); |
| 586 fprintf(stderr, "ParserTraits::ReportMessage returns\n"); |
| 581 } | 587 } |
| 582 | 588 |
| 583 | 589 |
| 584 void ParserTraits::ReportMessageAt(Scanner::Location source_location, | 590 void ParserTraits::ReportMessageAt(Scanner::Location source_location, |
| 585 const char* message, | 591 const char* message, |
| 586 Vector<Handle<String> > args) { | 592 Vector<Handle<String> > args) { |
| 593 fprintf(stderr, "ParserTraits::ReportMessageAtB\n"); |
| 587 MessageLocation location(parser_->script_, | 594 MessageLocation location(parser_->script_, |
| 588 source_location.beg_pos, | 595 source_location.beg_pos, |
| 589 source_location.end_pos); | 596 source_location.end_pos); |
| 590 Factory* factory = parser_->isolate()->factory(); | 597 Factory* factory = parser_->isolate()->factory(); |
| 591 Handle<FixedArray> elements = factory->NewFixedArray(args.length()); | 598 Handle<FixedArray> elements = factory->NewFixedArray(args.length()); |
| 592 for (int i = 0; i < args.length(); i++) { | 599 for (int i = 0; i < args.length(); i++) { |
| 593 elements->set(i, *args[i]); | 600 elements->set(i, *args[i]); |
| 594 } | 601 } |
| 595 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); | 602 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); |
| 596 Handle<Object> result = factory->NewSyntaxError(message, array); | 603 Handle<Object> result = factory->NewSyntaxError(message, array); |
| 597 parser_->isolate()->Throw(*result, &location); | 604 parser_->isolate()->Throw(*result, &location); |
| 605 fprintf(stderr, "ParserTraits::ReportMessageAtB returns\n"); |
| 598 } | 606 } |
| 599 | 607 |
| 600 | 608 |
| 601 Handle<String> ParserTraits::GetSymbol() { | 609 Handle<String> ParserTraits::GetSymbol() { |
| 602 int symbol_id = -1; | 610 int symbol_id = -1; |
| 603 if (parser_->pre_parse_data() != NULL) { | 611 if (parser_->pre_parse_data() != NULL) { |
| 604 symbol_id = parser_->pre_parse_data()->GetSymbolIdentifier(); | 612 symbol_id = parser_->pre_parse_data()->GetSymbolIdentifier(); |
| 605 } | 613 } |
| 606 return parser_->LookupSymbol(symbol_id); | 614 return parser_->LookupSymbol(symbol_id); |
| 607 } | 615 } |
| (...skipping 2881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3489 // 'debugger' ';' | 3497 // 'debugger' ';' |
| 3490 | 3498 |
| 3491 int pos = peek_position(); | 3499 int pos = peek_position(); |
| 3492 Expect(Token::DEBUGGER, CHECK_OK); | 3500 Expect(Token::DEBUGGER, CHECK_OK); |
| 3493 ExpectSemicolon(CHECK_OK); | 3501 ExpectSemicolon(CHECK_OK); |
| 3494 return factory()->NewDebuggerStatement(pos); | 3502 return factory()->NewDebuggerStatement(pos); |
| 3495 } | 3503 } |
| 3496 | 3504 |
| 3497 | 3505 |
| 3498 void Parser::ReportInvalidPreparseData(Handle<String> name, bool* ok) { | 3506 void Parser::ReportInvalidPreparseData(Handle<String> name, bool* ok) { |
| 3507 fprintf(stderr, "ReportInvalidPreparseData\n"); |
| 3499 SmartArrayPointer<char> name_string = name->ToCString(DISALLOW_NULLS); | 3508 SmartArrayPointer<char> name_string = name->ToCString(DISALLOW_NULLS); |
| 3500 const char* element[1] = { name_string.get() }; | 3509 const char* element[1] = { name_string.get() }; |
| 3501 ReportMessage("invalid_preparser_data", | 3510 Vector<const char*> args_array(element, 1); |
| 3502 Vector<const char*>(element, 1)); | 3511 fprintf(stderr, "constructed args array, length is %d\n", args_array.length())
; |
| 3512 |
| 3513 // WTF: Adding this line makes it pass!!! |
| 3514 //fprintf(stderr, "args_array is at %p\n", reinterpret_cast<void*>(&args_array
)); |
| 3515 |
| 3516 // This is not enough: |
| 3517 // void* foo = reinterpret_cast<void*>(&args_array); |
| 3518 // USE(foo); |
| 3519 |
| 3520 // This is not enough either: |
| 3521 // const char* foo = reinterpret_cast<const char*>(&args_array); |
| 3522 // foo++; |
| 3523 |
| 3524 ReportMessage("invalid_preparser_data", args_array); |
| 3525 fprintf(stderr, "ReportInvalidPreparseData returns\n"); |
| 3503 *ok = false; | 3526 *ok = false; |
| 3504 } | 3527 } |
| 3505 | 3528 |
| 3506 | 3529 |
| 3507 Expression* Parser::ParsePrimaryExpression(bool* ok) { | 3530 Expression* Parser::ParsePrimaryExpression(bool* ok) { |
| 3508 // PrimaryExpression :: | 3531 // PrimaryExpression :: |
| 3509 // 'this' | 3532 // 'this' |
| 3510 // 'null' | 3533 // 'null' |
| 3511 // 'true' | 3534 // 'true' |
| 3512 // 'false' | 3535 // 'false' |
| (...skipping 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5526 ASSERT(info()->isolate()->has_pending_exception()); | 5549 ASSERT(info()->isolate()->has_pending_exception()); |
| 5527 } else { | 5550 } else { |
| 5528 result = ParseProgram(); | 5551 result = ParseProgram(); |
| 5529 } | 5552 } |
| 5530 } | 5553 } |
| 5531 info()->SetFunction(result); | 5554 info()->SetFunction(result); |
| 5532 return (result != NULL); | 5555 return (result != NULL); |
| 5533 } | 5556 } |
| 5534 | 5557 |
| 5535 } } // namespace v8::internal | 5558 } } // namespace v8::internal |
| OLD | NEW |