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

Side by Side Diff: src/parser.cc

Issue 101763003: Replace 'operator*' with explicit 'get' method on SmartPointer (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Reupload to make rietveld happy 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/regexp-macro-assembler-tracer.cc » ('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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 result = DoParseProgram(info(), source); 593 result = DoParseProgram(info(), source);
594 } 594 }
595 595
596 if (FLAG_trace_parse && result != NULL) { 596 if (FLAG_trace_parse && result != NULL) {
597 double ms = timer.Elapsed().InMillisecondsF(); 597 double ms = timer.Elapsed().InMillisecondsF();
598 if (info()->is_eval()) { 598 if (info()->is_eval()) {
599 PrintF("[parsing eval"); 599 PrintF("[parsing eval");
600 } else if (info()->script()->name()->IsString()) { 600 } else if (info()->script()->name()->IsString()) {
601 String* name = String::cast(info()->script()->name()); 601 String* name = String::cast(info()->script()->name());
602 SmartArrayPointer<char> name_chars = name->ToCString(); 602 SmartArrayPointer<char> name_chars = name->ToCString();
603 PrintF("[parsing script: %s", *name_chars); 603 PrintF("[parsing script: %s", name_chars.get());
604 } else { 604 } else {
605 PrintF("[parsing script"); 605 PrintF("[parsing script");
606 } 606 }
607 PrintF(" - took %0.3f ms]\n", ms); 607 PrintF(" - took %0.3f ms]\n", ms);
608 } 608 }
609 return result; 609 return result;
610 } 610 }
611 611
612 612
613 FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, 613 FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 } else { 722 } else {
723 GenericStringUtf16CharacterStream stream(source, 723 GenericStringUtf16CharacterStream stream(source,
724 shared_info->start_position(), 724 shared_info->start_position(),
725 shared_info->end_position()); 725 shared_info->end_position());
726 result = ParseLazy(&stream); 726 result = ParseLazy(&stream);
727 } 727 }
728 728
729 if (FLAG_trace_parse && result != NULL) { 729 if (FLAG_trace_parse && result != NULL) {
730 double ms = timer.Elapsed().InMillisecondsF(); 730 double ms = timer.Elapsed().InMillisecondsF();
731 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString(); 731 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString();
732 PrintF("[parsing function: %s - took %0.3f ms]\n", *name_chars, ms); 732 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms);
733 } 733 }
734 return result; 734 return result;
735 } 735 }
736 736
737 737
738 FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) { 738 FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) {
739 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); 739 Handle<SharedFunctionInfo> shared_info = info()->shared_info();
740 scanner_.Initialize(source); 740 scanner_.Initialize(source);
741 ASSERT(top_scope_ == NULL); 741 ASSERT(top_scope_ == NULL);
742 ASSERT(target_stack_ == NULL); 742 ASSERT(target_stack_ == NULL);
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 // 1514 //
1515 // function () { let x; { var x; } } 1515 // function () { let x; { var x; } }
1516 // 1516 //
1517 // because the var declaration is hoisted to the function scope where 'x' 1517 // because the var declaration is hoisted to the function scope where 'x'
1518 // is already bound. 1518 // is already bound.
1519 ASSERT(IsDeclaredVariableMode(var->mode())); 1519 ASSERT(IsDeclaredVariableMode(var->mode()));
1520 if (is_extended_mode()) { 1520 if (is_extended_mode()) {
1521 // In harmony mode we treat re-declarations as early errors. See 1521 // In harmony mode we treat re-declarations as early errors. See
1522 // ES5 16 for a definition of early errors. 1522 // ES5 16 for a definition of early errors.
1523 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS); 1523 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS);
1524 const char* elms[2] = { "Variable", *c_string }; 1524 const char* elms[2] = { "Variable", c_string.get() };
1525 Vector<const char*> args(elms, 2); 1525 Vector<const char*> args(elms, 2);
1526 ReportMessage("redeclaration", args); 1526 ReportMessage("redeclaration", args);
1527 *ok = false; 1527 *ok = false;
1528 return; 1528 return;
1529 } 1529 }
1530 Handle<String> message_string = 1530 Handle<String> message_string =
1531 isolate()->factory()->NewStringFromUtf8(CStrVector("Variable"), 1531 isolate()->factory()->NewStringFromUtf8(CStrVector("Variable"),
1532 TENURED); 1532 TENURED);
1533 Expression* expression = 1533 Expression* expression =
1534 NewThrowTypeError(isolate()->factory()->redeclaration_string(), 1534 NewThrowTypeError(isolate()->factory()->redeclaration_string(),
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 // identifier. 2138 // identifier.
2139 VariableProxy* var = expr->AsVariableProxy(); 2139 VariableProxy* var = expr->AsVariableProxy();
2140 Handle<String> label = var->name(); 2140 Handle<String> label = var->name();
2141 // TODO(1240780): We don't check for redeclaration of labels 2141 // TODO(1240780): We don't check for redeclaration of labels
2142 // during preparsing since keeping track of the set of active 2142 // during preparsing since keeping track of the set of active
2143 // labels requires nontrivial changes to the way scopes are 2143 // labels requires nontrivial changes to the way scopes are
2144 // structured. However, these are probably changes we want to 2144 // structured. However, these are probably changes we want to
2145 // make later anyway so we should go back and fix this then. 2145 // make later anyway so we should go back and fix this then.
2146 if (ContainsLabel(labels, label) || TargetStackContainsLabel(label)) { 2146 if (ContainsLabel(labels, label) || TargetStackContainsLabel(label)) {
2147 SmartArrayPointer<char> c_string = label->ToCString(DISALLOW_NULLS); 2147 SmartArrayPointer<char> c_string = label->ToCString(DISALLOW_NULLS);
2148 const char* elms[2] = { "Label", *c_string }; 2148 const char* elms[2] = { "Label", c_string.get() };
2149 Vector<const char*> args(elms, 2); 2149 Vector<const char*> args(elms, 2);
2150 ReportMessage("redeclaration", args); 2150 ReportMessage("redeclaration", args);
2151 *ok = false; 2151 *ok = false;
2152 return NULL; 2152 return NULL;
2153 } 2153 }
2154 if (labels == NULL) { 2154 if (labels == NULL) {
2155 labels = new(zone()) ZoneStringList(4, zone()); 2155 labels = new(zone()) ZoneStringList(4, zone());
2156 } 2156 }
2157 labels->Add(label, zone()); 2157 labels->Add(label, zone());
2158 // Remove the "ghost" variable that turned out to be a label 2158 // Remove the "ghost" variable that turned out to be a label
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
3505 default: 3505 default:
3506 const char* name = Token::String(token); 3506 const char* name = Token::String(token);
3507 ASSERT(name != NULL); 3507 ASSERT(name != NULL);
3508 ReportMessage("unexpected_token", Vector<const char*>(&name, 1)); 3508 ReportMessage("unexpected_token", Vector<const char*>(&name, 1));
3509 } 3509 }
3510 } 3510 }
3511 3511
3512 3512
3513 void Parser::ReportInvalidPreparseData(Handle<String> name, bool* ok) { 3513 void Parser::ReportInvalidPreparseData(Handle<String> name, bool* ok) {
3514 SmartArrayPointer<char> name_string = name->ToCString(DISALLOW_NULLS); 3514 SmartArrayPointer<char> name_string = name->ToCString(DISALLOW_NULLS);
3515 const char* element[1] = { *name_string }; 3515 const char* element[1] = { name_string.get() };
3516 ReportMessage("invalid_preparser_data", 3516 ReportMessage("invalid_preparser_data",
3517 Vector<const char*>(element, 1)); 3517 Vector<const char*>(element, 1));
3518 *ok = false; 3518 *ok = false;
3519 } 3519 }
3520 3520
3521 3521
3522 Expression* Parser::ParsePrimaryExpression(bool* ok) { 3522 Expression* Parser::ParsePrimaryExpression(bool* ok) {
3523 // PrimaryExpression :: 3523 // PrimaryExpression ::
3524 // 'this' 3524 // 'this'
3525 // 'null' 3525 // 'null'
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
4594 } 4594 }
4595 4595
4596 4596
4597 void Parser::CheckConflictingVarDeclarations(Scope* scope, bool* ok) { 4597 void Parser::CheckConflictingVarDeclarations(Scope* scope, bool* ok) {
4598 Declaration* decl = scope->CheckConflictingVarDeclarations(); 4598 Declaration* decl = scope->CheckConflictingVarDeclarations();
4599 if (decl != NULL) { 4599 if (decl != NULL) {
4600 // In harmony mode we treat conflicting variable bindinds as early 4600 // In harmony mode we treat conflicting variable bindinds as early
4601 // errors. See ES5 16 for a definition of early errors. 4601 // errors. See ES5 16 for a definition of early errors.
4602 Handle<String> name = decl->proxy()->name(); 4602 Handle<String> name = decl->proxy()->name();
4603 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS); 4603 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS);
4604 const char* elms[2] = { "Variable", *c_string }; 4604 const char* elms[2] = { "Variable", c_string.get() };
4605 Vector<const char*> args(elms, 2); 4605 Vector<const char*> args(elms, 2);
4606 int position = decl->proxy()->position(); 4606 int position = decl->proxy()->position();
4607 Scanner::Location location = position == RelocInfo::kNoPosition 4607 Scanner::Location location = position == RelocInfo::kNoPosition
4608 ? Scanner::Location::invalid() 4608 ? Scanner::Location::invalid()
4609 : Scanner::Location(position, position + 1); 4609 : Scanner::Location(position, position + 1);
4610 ReportMessageAt(location, "redeclaration", args); 4610 ReportMessageAt(location, "redeclaration", args);
4611 *ok = false; 4611 *ok = false;
4612 } 4612 }
4613 } 4613 }
4614 4614
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
5686 ASSERT(info()->isolate()->has_pending_exception()); 5686 ASSERT(info()->isolate()->has_pending_exception());
5687 } else { 5687 } else {
5688 result = ParseProgram(); 5688 result = ParseProgram();
5689 } 5689 }
5690 } 5690 }
5691 info()->SetFunction(result); 5691 info()->SetFunction(result);
5692 return (result != NULL); 5692 return (result != NULL);
5693 } 5693 }
5694 5694
5695 } } // namespace v8::internal 5695 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-printer.cc ('k') | src/regexp-macro-assembler-tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698