| 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 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1616 // one - there is no re-lookup (see the last parameter of the | 1616 // one - there is no re-lookup (see the last parameter of the |
| 1617 // Declare() call above). | 1617 // Declare() call above). |
| 1618 | 1618 |
| 1619 Expression* value = NULL; | 1619 Expression* value = NULL; |
| 1620 int position = -1; | 1620 int position = -1; |
| 1621 if (peek() == Token::ASSIGN) { | 1621 if (peek() == Token::ASSIGN) { |
| 1622 Expect(Token::ASSIGN, CHECK_OK); | 1622 Expect(Token::ASSIGN, CHECK_OK); |
| 1623 position = scanner().location().beg_pos; | 1623 position = scanner().location().beg_pos; |
| 1624 value = ParseAssignmentExpression(accept_IN, CHECK_OK); | 1624 value = ParseAssignmentExpression(accept_IN, CHECK_OK); |
| 1625 // Don't infer if it is "a = function(){...}();"-like expression. | 1625 // Don't infer if it is "a = function(){...}();"-like expression. |
| 1626 if (fni_ != NULL && value->AsCall() == NULL) fni_->Infer(); | 1626 if (fni_ != NULL && |
| 1627 value->AsCall() == NULL && |
| 1628 value->AsCallNew() == NULL) { |
| 1629 fni_->Infer(); |
| 1630 } |
| 1627 } | 1631 } |
| 1628 | 1632 |
| 1629 // Make sure that 'const c' actually initializes 'c' to undefined | 1633 // Make sure that 'const c' actually initializes 'c' to undefined |
| 1630 // even though it seems like a stupid thing to do. | 1634 // even though it seems like a stupid thing to do. |
| 1631 if (value == NULL && is_const) { | 1635 if (value == NULL && is_const) { |
| 1632 value = GetLiteralUndefined(); | 1636 value = GetLiteralUndefined(); |
| 1633 } | 1637 } |
| 1634 | 1638 |
| 1635 // Global variable declarations must be compiled in a specific | 1639 // Global variable declarations must be compiled in a specific |
| 1636 // way. When the script containing the global variable declaration | 1640 // way. When the script containing the global variable declaration |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2369 right->AsFunctionLiteral()->set_pretenure(true); | 2373 right->AsFunctionLiteral()->set_pretenure(true); |
| 2370 } | 2374 } |
| 2371 | 2375 |
| 2372 if (fni_ != NULL) { | 2376 if (fni_ != NULL) { |
| 2373 // Check if the right hand side is a call to avoid inferring a | 2377 // Check if the right hand side is a call to avoid inferring a |
| 2374 // name if we're dealing with "a = function(){...}();"-like | 2378 // name if we're dealing with "a = function(){...}();"-like |
| 2375 // expression. | 2379 // expression. |
| 2376 if ((op == Token::INIT_VAR | 2380 if ((op == Token::INIT_VAR |
| 2377 || op == Token::INIT_CONST | 2381 || op == Token::INIT_CONST |
| 2378 || op == Token::ASSIGN) | 2382 || op == Token::ASSIGN) |
| 2379 && (right->AsCall() == NULL)) { | 2383 && (right->AsCall() == NULL && right->AsCallNew() == NULL)) { |
| 2380 fni_->Infer(); | 2384 fni_->Infer(); |
| 2381 } | 2385 } |
| 2382 fni_->Leave(); | 2386 fni_->Leave(); |
| 2383 } | 2387 } |
| 2384 | 2388 |
| 2385 return new(zone()) Assignment(op, expression, right, pos); | 2389 return new(zone()) Assignment(op, expression, right, pos); |
| 2386 } | 2390 } |
| 2387 | 2391 |
| 2388 | 2392 |
| 2389 // Precedence = 3 | 2393 // Precedence = 3 |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2768 result = ParsePrimaryExpression(CHECK_OK); | 2772 result = ParsePrimaryExpression(CHECK_OK); |
| 2769 } | 2773 } |
| 2770 | 2774 |
| 2771 while (true) { | 2775 while (true) { |
| 2772 switch (peek()) { | 2776 switch (peek()) { |
| 2773 case Token::LBRACK: { | 2777 case Token::LBRACK: { |
| 2774 Consume(Token::LBRACK); | 2778 Consume(Token::LBRACK); |
| 2775 int pos = scanner().location().beg_pos; | 2779 int pos = scanner().location().beg_pos; |
| 2776 Expression* index = ParseExpression(true, CHECK_OK); | 2780 Expression* index = ParseExpression(true, CHECK_OK); |
| 2777 result = new(zone()) Property(result, index, pos); | 2781 result = new(zone()) Property(result, index, pos); |
| 2782 if (fni_ != NULL) { |
| 2783 if (index->IsPropertyName()) { |
| 2784 fni_->PushLiteralName(index->AsLiteral()->AsPropertyName()); |
| 2785 } else { |
| 2786 fni_->PushLiteralName(fni_->anonymous_function()); |
| 2787 } |
| 2788 } |
| 2778 Expect(Token::RBRACK, CHECK_OK); | 2789 Expect(Token::RBRACK, CHECK_OK); |
| 2779 break; | 2790 break; |
| 2780 } | 2791 } |
| 2781 case Token::PERIOD: { | 2792 case Token::PERIOD: { |
| 2782 Consume(Token::PERIOD); | 2793 Consume(Token::PERIOD); |
| 2783 int pos = scanner().location().beg_pos; | 2794 int pos = scanner().location().beg_pos; |
| 2784 Handle<String> name = ParseIdentifierName(CHECK_OK); | 2795 Handle<String> name = ParseIdentifierName(CHECK_OK); |
| 2785 result = new(zone()) Property(result, new(zone()) Literal(name), pos); | 2796 result = new(zone()) Property(result, new(zone()) Literal(name), pos); |
| 2786 if (fni_ != NULL) fni_->PushLiteralName(name); | 2797 if (fni_ != NULL) fni_->PushLiteralName(name); |
| 2787 break; | 2798 break; |
| (...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4995 info->is_global(), | 5006 info->is_global(), |
| 4996 info->StrictMode()); | 5007 info->StrictMode()); |
| 4997 } | 5008 } |
| 4998 } | 5009 } |
| 4999 | 5010 |
| 5000 info->SetFunction(result); | 5011 info->SetFunction(result); |
| 5001 return (result != NULL); | 5012 return (result != NULL); |
| 5002 } | 5013 } |
| 5003 | 5014 |
| 5004 } } // namespace v8::internal | 5015 } } // namespace v8::internal |
| OLD | NEW |