OLD | NEW |
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 Loading... |
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 Loading... |
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 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3600 }; | 3600 }; |
3601 | 3601 |
3602 | 3602 |
3603 void ObjectLiteralPropertyChecker::CheckProperty( | 3603 void ObjectLiteralPropertyChecker::CheckProperty( |
3604 ObjectLiteral::Property* property, | 3604 ObjectLiteral::Property* property, |
3605 Scanner::Location loc, | 3605 Scanner::Location loc, |
3606 bool* ok) { | 3606 bool* ok) { |
3607 | 3607 |
3608 ASSERT(property != NULL); | 3608 ASSERT(property != NULL); |
3609 | 3609 |
3610 Literal *lit = property->key(); | 3610 Literal* lit = property->key(); |
3611 Handle<Object> handle = lit->handle(); | 3611 Handle<Object> handle = lit->handle(); |
3612 | 3612 |
3613 uint32_t hash; | 3613 uint32_t hash; |
3614 HashMap* map; | 3614 HashMap* map; |
3615 void* key; | 3615 void* key; |
3616 | 3616 |
3617 if (handle->IsSymbol()) { | 3617 if (handle->IsSymbol()) { |
3618 Handle<String> name(String::cast(*handle)); | 3618 Handle<String> name(String::cast(*handle)); |
3619 if (name->AsArrayIndex(&hash)) { | 3619 if (name->AsArrayIndex(&hash)) { |
3620 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 Loading... |
5689 ASSERT(info->isolate()->has_pending_exception()); | 5689 ASSERT(info->isolate()->has_pending_exception()); |
5690 } else { | 5690 } else { |
5691 result = parser.ParseProgram(info); | 5691 result = parser.ParseProgram(info); |
5692 } | 5692 } |
5693 } | 5693 } |
5694 info->SetFunction(result); | 5694 info->SetFunction(result); |
5695 return (result != NULL); | 5695 return (result != NULL); |
5696 } | 5696 } |
5697 | 5697 |
5698 } } // namespace v8::internal | 5698 } } // namespace v8::internal |
OLD | NEW |