Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1099 InitializationBlockFinder block_finder; | 1099 InitializationBlockFinder block_finder; |
| 1100 ThisNamedPropertyAssigmentFinder this_property_assignment_finder; | 1100 ThisNamedPropertyAssigmentFinder this_property_assignment_finder; |
| 1101 bool directive_prologue = true; // Parsing directive prologue. | 1101 bool directive_prologue = true; // Parsing directive prologue. |
| 1102 | 1102 |
| 1103 while (peek() != end_token) { | 1103 while (peek() != end_token) { |
| 1104 if (directive_prologue && peek() != Token::STRING) { | 1104 if (directive_prologue && peek() != Token::STRING) { |
| 1105 directive_prologue = false; | 1105 directive_prologue = false; |
| 1106 } | 1106 } |
| 1107 | 1107 |
| 1108 Scanner::Location token_loc = scanner().peek_location(); | 1108 Scanner::Location token_loc = scanner().peek_location(); |
| 1109 Statement* stat = ParseStatement(NULL, CHECK_OK); | 1109 |
| 1110 Statement* stat; | |
| 1111 if (peek() == Token::FUNCTION) { | |
|
Mads Ager (chromium)
2011/02/28 08:30:12
You should add a comment here as well to make it c
Martin Maly
2011/02/28 18:57:33
Done.
| |
| 1112 stat = ParseFunctionDeclaration(CHECK_OK); | |
| 1113 } else { | |
| 1114 stat = ParseStatement(NULL, CHECK_OK); | |
| 1115 } | |
| 1110 | 1116 |
| 1111 if (stat == NULL || stat->IsEmpty()) { | 1117 if (stat == NULL || stat->IsEmpty()) { |
| 1112 directive_prologue = false; // End of directive prologue. | 1118 directive_prologue = false; // End of directive prologue. |
| 1113 continue; | 1119 continue; |
| 1114 } | 1120 } |
| 1115 | 1121 |
| 1116 if (directive_prologue) { | 1122 if (directive_prologue) { |
| 1117 // A shot at a directive. | 1123 // A shot at a directive. |
| 1118 ExpressionStatement *e_stat; | 1124 ExpressionStatement *e_stat; |
| 1119 Literal *literal; | 1125 Literal *literal; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1256 Block* result = new Block(labels, 1, false); | 1262 Block* result = new Block(labels, 1, false); |
| 1257 Target target(&this->target_stack_, result); | 1263 Target target(&this->target_stack_, result); |
| 1258 TryStatement* statement = ParseTryStatement(CHECK_OK); | 1264 TryStatement* statement = ParseTryStatement(CHECK_OK); |
| 1259 if (statement) { | 1265 if (statement) { |
| 1260 statement->set_statement_pos(statement_pos); | 1266 statement->set_statement_pos(statement_pos); |
| 1261 } | 1267 } |
| 1262 if (result) result->AddStatement(statement); | 1268 if (result) result->AddStatement(statement); |
| 1263 return result; | 1269 return result; |
| 1264 } | 1270 } |
| 1265 | 1271 |
| 1266 case Token::FUNCTION: | 1272 case Token::FUNCTION: { |
| 1273 // In strict mode, FunctionDeclaration is only allowed in the context | |
| 1274 // of SourceElements. | |
| 1275 if (temp_scope_->StrictMode()) { | |
| 1276 ReportMessageAt(scanner().peek_location(), "strict_function", | |
| 1277 Vector<const char*>::empty()); | |
| 1278 *ok = false; | |
| 1279 return NULL; | |
| 1280 } | |
| 1267 return ParseFunctionDeclaration(ok); | 1281 return ParseFunctionDeclaration(ok); |
| 1282 } | |
| 1268 | 1283 |
| 1269 case Token::NATIVE: | 1284 case Token::NATIVE: |
| 1270 return ParseNativeDeclaration(ok); | 1285 return ParseNativeDeclaration(ok); |
| 1271 | 1286 |
| 1272 case Token::DEBUGGER: | 1287 case Token::DEBUGGER: |
| 1273 stmt = ParseDebuggerStatement(ok); | 1288 stmt = ParseDebuggerStatement(ok); |
| 1274 break; | 1289 break; |
| 1275 | 1290 |
| 1276 default: | 1291 default: |
| 1277 stmt = ParseExpressionOrLabelledStatement(labels, ok); | 1292 stmt = ParseExpressionOrLabelledStatement(labels, ok); |
| (...skipping 3836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5114 info->is_global(), | 5129 info->is_global(), |
| 5115 info->StrictMode()); | 5130 info->StrictMode()); |
| 5116 } | 5131 } |
| 5117 } | 5132 } |
| 5118 | 5133 |
| 5119 info->SetFunction(result); | 5134 info->SetFunction(result); |
| 5120 return (result != NULL); | 5135 return (result != NULL); |
| 5121 } | 5136 } |
| 5122 | 5137 |
| 5123 } } // namespace v8::internal | 5138 } } // namespace v8::internal |
| OLD | NEW |