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 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 dupe_error_loc = scanner()->location(); | 1316 dupe_error_loc = scanner()->location(); |
1317 } | 1317 } |
1318 | 1318 |
1319 done = (peek() == Token::RPAREN); | 1319 done = (peek() == Token::RPAREN); |
1320 if (!done) { | 1320 if (!done) { |
1321 Expect(Token::COMMA, CHECK_OK); | 1321 Expect(Token::COMMA, CHECK_OK); |
1322 } | 1322 } |
1323 } | 1323 } |
1324 Expect(Token::RPAREN, CHECK_OK); | 1324 Expect(Token::RPAREN, CHECK_OK); |
1325 | 1325 |
1326 // Determine if the function will be lazily compiled. | 1326 // See Parser::ParseFunctionLiteral for more information about lazy parsing |
1327 // Currently only happens to top-level functions. | 1327 // and lazy compilation. |
1328 // Optimistically assume that all top-level functions are lazily compiled. | 1328 bool is_lazily_parsed = (outer_scope_type == GLOBAL_SCOPE && |
1329 bool is_lazily_compiled = (outer_scope_type == GLOBAL_SCOPE && | 1329 !inside_with && allow_lazy() && |
1330 !inside_with && allow_lazy() && | 1330 !parenthesized_function_); |
1331 !parenthesized_function_); | |
1332 parenthesized_function_ = false; | 1331 parenthesized_function_ = false; |
1333 | 1332 |
1334 Expect(Token::LBRACE, CHECK_OK); | 1333 Expect(Token::LBRACE, CHECK_OK); |
1335 if (is_lazily_compiled) { | 1334 if (is_lazily_parsed) { |
1336 ParseLazyFunctionLiteralBody(CHECK_OK); | 1335 ParseLazyFunctionLiteralBody(CHECK_OK); |
1337 } else { | 1336 } else { |
1338 ParseSourceElements(Token::RBRACE, ok); | 1337 ParseSourceElements(Token::RBRACE, ok); |
1339 } | 1338 } |
1340 Expect(Token::RBRACE, CHECK_OK); | 1339 Expect(Token::RBRACE, CHECK_OK); |
1341 | 1340 |
1342 // Validate strict mode. We can do this only after parsing the function, | 1341 // Validate strict mode. We can do this only after parsing the function, |
1343 // since the function can declare itself strict. | 1342 // since the function can declare itself strict. |
1344 if (!scope_->is_classic_mode()) { | 1343 if (!scope_->is_classic_mode()) { |
1345 if (function_name.IsEvalOrArguments()) { | 1344 if (function_name.IsEvalOrArguments()) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 int identifier_pos = position(); | 1415 int identifier_pos = position(); |
1417 if (scanner()->is_literal_ascii()) { | 1416 if (scanner()->is_literal_ascii()) { |
1418 log_->LogAsciiSymbol(identifier_pos, scanner()->literal_ascii_string()); | 1417 log_->LogAsciiSymbol(identifier_pos, scanner()->literal_ascii_string()); |
1419 } else { | 1418 } else { |
1420 log_->LogUtf16Symbol(identifier_pos, scanner()->literal_utf16_string()); | 1419 log_->LogUtf16Symbol(identifier_pos, scanner()->literal_utf16_string()); |
1421 } | 1420 } |
1422 } | 1421 } |
1423 | 1422 |
1424 | 1423 |
1425 } } // v8::internal | 1424 } } // v8::internal |
OLD | NEW |