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

Side by Side Diff: src/parser.cc

Issue 307393002: Misc cleanup (split from the "delay string / value internalization" CL). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix (the amount of error reporting functions is too damn high!) Created 6 years, 6 months 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/list.h ('k') | src/preparser.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 // 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/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/char-predicates-inl.h" 10 #include "src/char-predicates-inl.h"
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 // pre-resolve the proxy because it resides in the same scope as the 2100 // pre-resolve the proxy because it resides in the same scope as the
2101 // declaration. 2101 // declaration.
2102 Interface* interface = 2102 Interface* interface =
2103 is_const ? Interface::NewConst() : Interface::NewValue(); 2103 is_const ? Interface::NewConst() : Interface::NewValue();
2104 VariableProxy* proxy = NewUnresolved(name, mode, interface); 2104 VariableProxy* proxy = NewUnresolved(name, mode, interface);
2105 Declaration* declaration = 2105 Declaration* declaration =
2106 factory()->NewVariableDeclaration(proxy, mode, scope_, pos); 2106 factory()->NewVariableDeclaration(proxy, mode, scope_, pos);
2107 Declare(declaration, mode != VAR, CHECK_OK); 2107 Declare(declaration, mode != VAR, CHECK_OK);
2108 nvars++; 2108 nvars++;
2109 if (declaration_scope->num_var_or_const() > kMaxNumFunctionLocals) { 2109 if (declaration_scope->num_var_or_const() > kMaxNumFunctionLocals) {
2110 ReportMessageAt(scanner()->location(), "too_many_variables"); 2110 ReportMessage("too_many_variables");
2111 *ok = false; 2111 *ok = false;
2112 return NULL; 2112 return NULL;
2113 } 2113 }
2114 if (names) names->Add(name, zone()); 2114 if (names) names->Add(name, zone());
2115 2115
2116 // Parse initialization expression if present and/or needed. A 2116 // Parse initialization expression if present and/or needed. A
2117 // declaration of the form: 2117 // declaration of the form:
2118 // 2118 //
2119 // var v = x; 2119 // var v = x;
2120 // 2120 //
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
2398 label = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 2398 label = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK);
2399 } 2399 }
2400 IterationStatement* target = NULL; 2400 IterationStatement* target = NULL;
2401 target = LookupContinueTarget(label, CHECK_OK); 2401 target = LookupContinueTarget(label, CHECK_OK);
2402 if (target == NULL) { 2402 if (target == NULL) {
2403 // Illegal continue statement. 2403 // Illegal continue statement.
2404 const char* message = "illegal_continue"; 2404 const char* message = "illegal_continue";
2405 if (!label.is_null()) { 2405 if (!label.is_null()) {
2406 message = "unknown_label"; 2406 message = "unknown_label";
2407 } 2407 }
2408 ParserTraits::ReportMessageAt(scanner()->location(), message, label); 2408 ParserTraits::ReportMessage(message, label);
2409 *ok = false; 2409 *ok = false;
2410 return NULL; 2410 return NULL;
2411 } 2411 }
2412 ExpectSemicolon(CHECK_OK); 2412 ExpectSemicolon(CHECK_OK);
2413 return factory()->NewContinueStatement(target, pos); 2413 return factory()->NewContinueStatement(target, pos);
2414 } 2414 }
2415 2415
2416 2416
2417 Statement* Parser::ParseBreakStatement(ZoneStringList* labels, bool* ok) { 2417 Statement* Parser::ParseBreakStatement(ZoneStringList* labels, bool* ok) {
2418 // BreakStatement :: 2418 // BreakStatement ::
(...skipping 15 matching lines...) Expand all
2434 return factory()->NewEmptyStatement(pos); 2434 return factory()->NewEmptyStatement(pos);
2435 } 2435 }
2436 BreakableStatement* target = NULL; 2436 BreakableStatement* target = NULL;
2437 target = LookupBreakTarget(label, CHECK_OK); 2437 target = LookupBreakTarget(label, CHECK_OK);
2438 if (target == NULL) { 2438 if (target == NULL) {
2439 // Illegal break statement. 2439 // Illegal break statement.
2440 const char* message = "illegal_break"; 2440 const char* message = "illegal_break";
2441 if (!label.is_null()) { 2441 if (!label.is_null()) {
2442 message = "unknown_label"; 2442 message = "unknown_label";
2443 } 2443 }
2444 ParserTraits::ReportMessageAt(scanner()->location(), message, label); 2444 ParserTraits::ReportMessage(message, label);
2445 *ok = false; 2445 *ok = false;
2446 return NULL; 2446 return NULL;
2447 } 2447 }
2448 ExpectSemicolon(CHECK_OK); 2448 ExpectSemicolon(CHECK_OK);
2449 return factory()->NewBreakStatement(target, pos); 2449 return factory()->NewBreakStatement(target, pos);
2450 } 2450 }
2451 2451
2452 2452
2453 Statement* Parser::ParseReturnStatement(bool* ok) { 2453 Statement* Parser::ParseReturnStatement(bool* ok) {
2454 // ReturnStatement :: 2454 // ReturnStatement ::
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
3382 reserved_loc = scanner()->location(); 3382 reserved_loc = scanner()->location();
3383 } 3383 }
3384 if (!dupe_error_loc.IsValid() && scope_->IsDeclared(param_name)) { 3384 if (!dupe_error_loc.IsValid() && scope_->IsDeclared(param_name)) {
3385 duplicate_parameters = FunctionLiteral::kHasDuplicateParameters; 3385 duplicate_parameters = FunctionLiteral::kHasDuplicateParameters;
3386 dupe_error_loc = scanner()->location(); 3386 dupe_error_loc = scanner()->location();
3387 } 3387 }
3388 3388
3389 scope_->DeclareParameter(param_name, VAR); 3389 scope_->DeclareParameter(param_name, VAR);
3390 num_parameters++; 3390 num_parameters++;
3391 if (num_parameters > Code::kMaxArguments) { 3391 if (num_parameters > Code::kMaxArguments) {
3392 ReportMessageAt(scanner()->location(), "too_many_parameters"); 3392 ReportMessage("too_many_parameters");
3393 *ok = false; 3393 *ok = false;
3394 return NULL; 3394 return NULL;
3395 } 3395 }
3396 done = (peek() == Token::RPAREN); 3396 done = (peek() == Token::RPAREN);
3397 if (!done) Expect(Token::COMMA, CHECK_OK); 3397 if (!done) Expect(Token::COMMA, CHECK_OK);
3398 } 3398 }
3399 Expect(Token::RPAREN, CHECK_OK); 3399 Expect(Token::RPAREN, CHECK_OK);
3400 3400
3401 Expect(Token::LBRACE, CHECK_OK); 3401 Expect(Token::LBRACE, CHECK_OK);
3402 3402
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after
4781 ASSERT(info()->isolate()->has_pending_exception()); 4781 ASSERT(info()->isolate()->has_pending_exception());
4782 } else { 4782 } else {
4783 result = ParseProgram(); 4783 result = ParseProgram();
4784 } 4784 }
4785 } 4785 }
4786 info()->SetFunction(result); 4786 info()->SetFunction(result);
4787 return (result != NULL); 4787 return (result != NULL);
4788 } 4788 }
4789 4789
4790 } } // namespace v8::internal 4790 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/list.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698