Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: src/parser.cc

Issue 112863002: Merge bleeding_edge 18021:18297 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects-printer.cc ('k') | src/platform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 scanner_->Init(); 591 scanner_->Init();
592 result = DoParseProgram(info(), source); 592 result = DoParseProgram(info(), source);
593 593
594 if (FLAG_trace_parse && result != NULL) { 594 if (FLAG_trace_parse && result != NULL) {
595 double ms = timer.Elapsed().InMillisecondsF(); 595 double ms = timer.Elapsed().InMillisecondsF();
596 if (info()->is_eval()) { 596 if (info()->is_eval()) {
597 PrintF("[parsing eval"); 597 PrintF("[parsing eval");
598 } else if (info()->script()->name()->IsString()) { 598 } else if (info()->script()->name()->IsString()) {
599 String* name = String::cast(info()->script()->name()); 599 String* name = String::cast(info()->script()->name());
600 SmartArrayPointer<char> name_chars = name->ToCString(); 600 SmartArrayPointer<char> name_chars = name->ToCString();
601 PrintF("[parsing script: %s", *name_chars); 601 PrintF("[parsing script: %s", name_chars.get());
602 } else { 602 } else {
603 PrintF("[parsing script"); 603 PrintF("[parsing script");
604 } 604 }
605 PrintF(" - took %0.3f ms]\n", ms); 605 PrintF(" - took %0.3f ms]\n", ms);
606 } 606 }
607 return result; 607 return result;
608 } 608 }
609 609
610 610
611 FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, 611 FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 timer.Start(); 707 timer.Start();
708 } 708 }
709 // Initialize parser state. 709 // Initialize parser state.
710 FlattenString(source); 710 FlattenString(source);
711 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); 711 Handle<SharedFunctionInfo> shared_info = info()->shared_info();
712 FunctionLiteral* result = ParseLazy( 712 FunctionLiteral* result = ParseLazy(
713 source, shared_info->start_position(), shared_info->end_position()); 713 source, shared_info->start_position(), shared_info->end_position());
714 if (FLAG_trace_parse && result != NULL) { 714 if (FLAG_trace_parse && result != NULL) {
715 double ms = timer.Elapsed().InMillisecondsF(); 715 double ms = timer.Elapsed().InMillisecondsF();
716 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString(); 716 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString();
717 PrintF("[parsing function: %s - took %0.3f ms]\n", *name_chars, ms); 717 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms);
718 } 718 }
719 return result; 719 return result;
720 } 720 }
721 721
722 722
723 FunctionLiteral* Parser::ParseLazy(Handle<String> source, int start, int end) { 723 FunctionLiteral* Parser::ParseLazy(Handle<String> source, int start, int end) {
724 delete reusable_preparser_; 724 delete reusable_preparser_;
725 delete scanner_; 725 delete scanner_;
726 if (source->IsTwoByteRepresentation()) { 726 if (source->IsTwoByteRepresentation()) {
727 scanner_ = new ExperimentalScanner<uint16_t>(source, isolate()); 727 scanner_ = new ExperimentalScanner<uint16_t>(source, isolate());
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 // 1510 //
1511 // function () { let x; { var x; } } 1511 // function () { let x; { var x; } }
1512 // 1512 //
1513 // because the var declaration is hoisted to the function scope where 'x' 1513 // because the var declaration is hoisted to the function scope where 'x'
1514 // is already bound. 1514 // is already bound.
1515 ASSERT(IsDeclaredVariableMode(var->mode())); 1515 ASSERT(IsDeclaredVariableMode(var->mode()));
1516 if (is_extended_mode()) { 1516 if (is_extended_mode()) {
1517 // In harmony mode we treat re-declarations as early errors. See 1517 // In harmony mode we treat re-declarations as early errors. See
1518 // ES5 16 for a definition of early errors. 1518 // ES5 16 for a definition of early errors.
1519 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS); 1519 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS);
1520 const char* elms[2] = { "Variable", *c_string }; 1520 const char* elms[2] = { "Variable", c_string.get() };
1521 Vector<const char*> args(elms, 2); 1521 Vector<const char*> args(elms, 2);
1522 ReportMessage("redeclaration", args); 1522 ReportMessage("redeclaration", args);
1523 *ok = false; 1523 *ok = false;
1524 return; 1524 return;
1525 } 1525 }
1526 Handle<String> message_string = 1526 Handle<String> message_string =
1527 isolate()->factory()->NewStringFromUtf8(CStrVector("Variable"), 1527 isolate()->factory()->NewStringFromUtf8(CStrVector("Variable"),
1528 TENURED); 1528 TENURED);
1529 Expression* expression = 1529 Expression* expression =
1530 NewThrowTypeError(isolate()->factory()->redeclaration_string(), 1530 NewThrowTypeError(isolate()->factory()->redeclaration_string(),
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 // identifier. 2134 // identifier.
2135 VariableProxy* var = expr->AsVariableProxy(); 2135 VariableProxy* var = expr->AsVariableProxy();
2136 Handle<String> label = var->name(); 2136 Handle<String> label = var->name();
2137 // TODO(1240780): We don't check for redeclaration of labels 2137 // TODO(1240780): We don't check for redeclaration of labels
2138 // during preparsing since keeping track of the set of active 2138 // during preparsing since keeping track of the set of active
2139 // labels requires nontrivial changes to the way scopes are 2139 // labels requires nontrivial changes to the way scopes are
2140 // structured. However, these are probably changes we want to 2140 // structured. However, these are probably changes we want to
2141 // make later anyway so we should go back and fix this then. 2141 // make later anyway so we should go back and fix this then.
2142 if (ContainsLabel(labels, label) || TargetStackContainsLabel(label)) { 2142 if (ContainsLabel(labels, label) || TargetStackContainsLabel(label)) {
2143 SmartArrayPointer<char> c_string = label->ToCString(DISALLOW_NULLS); 2143 SmartArrayPointer<char> c_string = label->ToCString(DISALLOW_NULLS);
2144 const char* elms[2] = { "Label", *c_string }; 2144 const char* elms[2] = { "Label", c_string.get() };
2145 Vector<const char*> args(elms, 2); 2145 Vector<const char*> args(elms, 2);
2146 ReportMessage("redeclaration", args); 2146 ReportMessage("redeclaration", args);
2147 *ok = false; 2147 *ok = false;
2148 return NULL; 2148 return NULL;
2149 } 2149 }
2150 if (labels == NULL) { 2150 if (labels == NULL) {
2151 labels = new(zone()) ZoneStringList(4, zone()); 2151 labels = new(zone()) ZoneStringList(4, zone());
2152 } 2152 }
2153 labels->Add(label, zone()); 2153 labels->Add(label, zone());
2154 // Remove the "ghost" variable that turned out to be a label 2154 // Remove the "ghost" variable that turned out to be a label
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
3501 default: 3501 default:
3502 const char* name = Token::String(token); 3502 const char* name = Token::String(token);
3503 ASSERT(name != NULL); 3503 ASSERT(name != NULL);
3504 ReportMessage("unexpected_token", Vector<const char*>(&name, 1)); 3504 ReportMessage("unexpected_token", Vector<const char*>(&name, 1));
3505 } 3505 }
3506 } 3506 }
3507 3507
3508 3508
3509 void Parser::ReportInvalidPreparseData(Handle<String> name, bool* ok) { 3509 void Parser::ReportInvalidPreparseData(Handle<String> name, bool* ok) {
3510 SmartArrayPointer<char> name_string = name->ToCString(DISALLOW_NULLS); 3510 SmartArrayPointer<char> name_string = name->ToCString(DISALLOW_NULLS);
3511 const char* element[1] = { *name_string }; 3511 const char* element[1] = { name_string.get() };
3512 ReportMessage("invalid_preparser_data", 3512 ReportMessage("invalid_preparser_data",
3513 Vector<const char*>(element, 1)); 3513 Vector<const char*>(element, 1));
3514 *ok = false; 3514 *ok = false;
3515 } 3515 }
3516 3516
3517 3517
3518 Expression* Parser::ParsePrimaryExpression(bool* ok) { 3518 Expression* Parser::ParsePrimaryExpression(bool* ok) {
3519 // PrimaryExpression :: 3519 // PrimaryExpression ::
3520 // 'this' 3520 // 'this'
3521 // 'null' 3521 // 'null'
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
4592 } 4592 }
4593 4593
4594 4594
4595 void Parser::CheckConflictingVarDeclarations(Scope* scope, bool* ok) { 4595 void Parser::CheckConflictingVarDeclarations(Scope* scope, bool* ok) {
4596 Declaration* decl = scope->CheckConflictingVarDeclarations(); 4596 Declaration* decl = scope->CheckConflictingVarDeclarations();
4597 if (decl != NULL) { 4597 if (decl != NULL) {
4598 // In harmony mode we treat conflicting variable bindinds as early 4598 // In harmony mode we treat conflicting variable bindinds as early
4599 // errors. See ES5 16 for a definition of early errors. 4599 // errors. See ES5 16 for a definition of early errors.
4600 Handle<String> name = decl->proxy()->name(); 4600 Handle<String> name = decl->proxy()->name();
4601 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS); 4601 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS);
4602 const char* elms[2] = { "Variable", *c_string }; 4602 const char* elms[2] = { "Variable", c_string.get() };
4603 Vector<const char*> args(elms, 2); 4603 Vector<const char*> args(elms, 2);
4604 int position = decl->proxy()->position(); 4604 int position = decl->proxy()->position();
4605 ScannerBase::Location location = position == RelocInfo::kNoPosition 4605 ScannerBase::Location location = position == RelocInfo::kNoPosition
4606 ? ScannerBase::Location::invalid() 4606 ? ScannerBase::Location::invalid()
4607 : ScannerBase::Location(position, position + 1); 4607 : ScannerBase::Location(position, position + 1);
4608 ReportMessageAt(location, "redeclaration", args); 4608 ReportMessageAt(location, "redeclaration", args);
4609 *ok = false; 4609 *ok = false;
4610 } 4610 }
4611 } 4611 }
4612 4612
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
5699 } 5699 }
5700 5700
5701 5701
5702 void Parser::SetScannerFlags() { 5702 void Parser::SetScannerFlags() {
5703 scanner_->SetHarmonyScoping(allow_harmony_scoping_); 5703 scanner_->SetHarmonyScoping(allow_harmony_scoping_);
5704 scanner_->SetHarmonyModules(allow_harmony_modules_); 5704 scanner_->SetHarmonyModules(allow_harmony_modules_);
5705 scanner_->SetHarmonyNumericLiterals(allow_harmony_numeric_literals_); 5705 scanner_->SetHarmonyNumericLiterals(allow_harmony_numeric_literals_);
5706 } 5706 }
5707 5707
5708 } } // namespace v8::internal 5708 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-printer.cc ('k') | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698