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

Side by Side Diff: src/parser.cc

Issue 9227007: Version 3.8.6 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 11 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/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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 1179
1180 Scanner::Location token_loc = scanner().peek_location(); 1180 Scanner::Location token_loc = scanner().peek_location();
1181 Statement* stat = ParseSourceElement(NULL, CHECK_OK); 1181 Statement* stat = ParseSourceElement(NULL, CHECK_OK);
1182 if (stat == NULL || stat->IsEmpty()) { 1182 if (stat == NULL || stat->IsEmpty()) {
1183 directive_prologue = false; // End of directive prologue. 1183 directive_prologue = false; // End of directive prologue.
1184 continue; 1184 continue;
1185 } 1185 }
1186 1186
1187 if (directive_prologue) { 1187 if (directive_prologue) {
1188 // A shot at a directive. 1188 // A shot at a directive.
1189 ExpressionStatement *e_stat; 1189 ExpressionStatement* e_stat;
1190 Literal *literal; 1190 Literal* literal;
1191 // Still processing directive prologue? 1191 // Still processing directive prologue?
1192 if ((e_stat = stat->AsExpressionStatement()) != NULL && 1192 if ((e_stat = stat->AsExpressionStatement()) != NULL &&
1193 (literal = e_stat->expression()->AsLiteral()) != NULL && 1193 (literal = e_stat->expression()->AsLiteral()) != NULL &&
1194 literal->handle()->IsString()) { 1194 literal->handle()->IsString()) {
1195 Handle<String> directive = Handle<String>::cast(literal->handle()); 1195 Handle<String> directive = Handle<String>::cast(literal->handle());
1196 1196
1197 // Check "use strict" directive (ES5 14.1). 1197 // Check "use strict" directive (ES5 14.1).
1198 if (top_scope_->is_classic_mode() && 1198 if (top_scope_->is_classic_mode() &&
1199 directive->Equals(isolate()->heap()->use_strict()) && 1199 directive->Equals(isolate()->heap()->use_strict()) &&
1200 token_loc.end_pos - token_loc.beg_pos == 1200 token_loc.end_pos - token_loc.beg_pos ==
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 Handle<ScopeInfo>(fun->shared()->scope_info())); 1555 Handle<ScopeInfo>(fun->shared()->scope_info()));
1556 shared->set_construct_stub(*construct_stub); 1556 shared->set_construct_stub(*construct_stub);
1557 1557
1558 // Copy the function data to the shared function info. 1558 // Copy the function data to the shared function info.
1559 shared->set_function_data(fun->shared()->function_data()); 1559 shared->set_function_data(fun->shared()->function_data());
1560 int parameters = fun->shared()->formal_parameter_count(); 1560 int parameters = fun->shared()->formal_parameter_count();
1561 shared->set_formal_parameter_count(parameters); 1561 shared->set_formal_parameter_count(parameters);
1562 1562
1563 // TODO(1240846): It's weird that native function declarations are 1563 // TODO(1240846): It's weird that native function declarations are
1564 // introduced dynamically when we meet their declarations, whereas 1564 // introduced dynamically when we meet their declarations, whereas
1565 // other functions are setup when entering the surrounding scope. 1565 // other functions are set up when entering the surrounding scope.
1566 SharedFunctionInfoLiteral* lit = 1566 SharedFunctionInfoLiteral* lit =
1567 new(zone()) SharedFunctionInfoLiteral(isolate(), shared); 1567 new(zone()) SharedFunctionInfoLiteral(isolate(), shared);
1568 VariableProxy* var = Declare(name, VAR, NULL, true, CHECK_OK); 1568 VariableProxy* var = Declare(name, VAR, NULL, true, CHECK_OK);
1569 return new(zone()) ExpressionStatement(new(zone()) Assignment( 1569 return new(zone()) ExpressionStatement(new(zone()) Assignment(
1570 isolate(), Token::INIT_VAR, var, lit, RelocInfo::kNoPosition)); 1570 isolate(), Token::INIT_VAR, var, lit, RelocInfo::kNoPosition));
1571 } 1571 }
1572 1572
1573 1573
1574 Statement* Parser::ParseFunctionDeclaration(bool* ok) { 1574 Statement* Parser::ParseFunctionDeclaration(bool* ok) {
1575 // FunctionDeclaration :: 1575 // FunctionDeclaration ::
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after
2996 case Token::LBRACK: { 2996 case Token::LBRACK: {
2997 Consume(Token::LBRACK); 2997 Consume(Token::LBRACK);
2998 int pos = scanner().location().beg_pos; 2998 int pos = scanner().location().beg_pos;
2999 Expression* index = ParseExpression(true, CHECK_OK); 2999 Expression* index = ParseExpression(true, CHECK_OK);
3000 result = new(zone()) Property(isolate(), result, index, pos); 3000 result = new(zone()) Property(isolate(), result, index, pos);
3001 Expect(Token::RBRACK, CHECK_OK); 3001 Expect(Token::RBRACK, CHECK_OK);
3002 break; 3002 break;
3003 } 3003 }
3004 3004
3005 case Token::LPAREN: { 3005 case Token::LPAREN: {
3006 int pos = scanner().location().beg_pos; 3006 int pos;
3007 if (scanner().current_token() == Token::IDENTIFIER) {
3008 // For call of an identifier we want to report position of
3009 // the identifier as position of the call in the stack trace.
3010 pos = scanner().location().beg_pos;
3011 } else {
3012 // For other kinds of calls we record position of the parenthesis as
3013 // position of the call. Note that this is extremely important for
3014 // expressions of the form function(){...}() for which call position
3015 // should not point to the closing brace otherwise it will intersect
3016 // with positions recorded for function literal and confuse debugger.
3017 pos = scanner().peek_location().beg_pos;
3018 }
3007 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); 3019 ZoneList<Expression*>* args = ParseArguments(CHECK_OK);
3008 3020
3009 // Keep track of eval() calls since they disable all local variable 3021 // Keep track of eval() calls since they disable all local variable
3010 // optimizations. 3022 // optimizations.
3011 // The calls that need special treatment are the 3023 // The calls that need special treatment are the
3012 // direct eval calls. These calls are all of the form eval(...), with 3024 // direct eval calls. These calls are all of the form eval(...), with
3013 // no explicit receiver. 3025 // no explicit receiver.
3014 // These calls are marked as potentially direct eval calls. Whether 3026 // These calls are marked as potentially direct eval calls. Whether
3015 // they are actually direct calls to eval is determined at run time. 3027 // they are actually direct calls to eval is determined at run time.
3016 VariableProxy* callee = result->AsVariableProxy(); 3028 VariableProxy* callee = result->AsVariableProxy();
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
3588 }; 3600 };
3589 3601
3590 3602
3591 void ObjectLiteralPropertyChecker::CheckProperty( 3603 void ObjectLiteralPropertyChecker::CheckProperty(
3592 ObjectLiteral::Property* property, 3604 ObjectLiteral::Property* property,
3593 Scanner::Location loc, 3605 Scanner::Location loc,
3594 bool* ok) { 3606 bool* ok) {
3595 3607
3596 ASSERT(property != NULL); 3608 ASSERT(property != NULL);
3597 3609
3598 Literal *lit = property->key(); 3610 Literal* lit = property->key();
3599 Handle<Object> handle = lit->handle(); 3611 Handle<Object> handle = lit->handle();
3600 3612
3601 uint32_t hash; 3613 uint32_t hash;
3602 HashMap* map; 3614 HashMap* map;
3603 void* key; 3615 void* key;
3604 3616
3605 if (handle->IsSymbol()) { 3617 if (handle->IsSymbol()) {
3606 Handle<String> name(String::cast(*handle)); 3618 Handle<String> name(String::cast(*handle));
3607 if (name->AsArrayIndex(&hash)) { 3619 if (name->AsArrayIndex(&hash)) {
3608 Handle<Object> key_handle = FACTORY->NewNumberFromUint(hash); 3620 Handle<Object> key_handle = FACTORY->NewNumberFromUint(hash);
(...skipping 2068 matching lines...) Expand 10 before | Expand all | Expand 10 after
5677 ASSERT(info->isolate()->has_pending_exception()); 5689 ASSERT(info->isolate()->has_pending_exception());
5678 } else { 5690 } else {
5679 result = parser.ParseProgram(info); 5691 result = parser.ParseProgram(info);
5680 } 5692 }
5681 } 5693 }
5682 info->SetFunction(result); 5694 info->SetFunction(result);
5683 return (result != NULL); 5695 return (result != NULL);
5684 } 5696 }
5685 5697
5686 } } // namespace v8::internal 5698 } } // 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