| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
| 6 #include "vm/flags.h" | 6 #include "vm/flags.h" |
| 7 | 7 |
| 8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
| 9 | 9 |
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
| (...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1606 intptr_t index = func.num_fixed_parameters() + i; | 1606 intptr_t index = func.num_fixed_parameters() + i; |
| 1607 arg_names.SetAt(i, String::Handle(func.ParameterNameAt(index))); | 1607 arg_names.SetAt(i, String::Handle(func.ParameterNameAt(index))); |
| 1608 } | 1608 } |
| 1609 func_args->set_names(arg_names); | 1609 func_args->set_names(arg_names); |
| 1610 } | 1610 } |
| 1611 | 1611 |
| 1612 const String& func_name = String::ZoneHandle(parent.name()); | 1612 const String& func_name = String::ZoneHandle(parent.name()); |
| 1613 const Class& owner = Class::Handle(parent.Owner()); | 1613 const Class& owner = Class::Handle(parent.Owner()); |
| 1614 Function& target = Function::ZoneHandle(owner.LookupFunction(func_name)); | 1614 Function& target = Function::ZoneHandle(owner.LookupFunction(func_name)); |
| 1615 if (target.raw() != parent.raw()) { | 1615 if (target.raw() != parent.raw()) { |
| 1616 ASSERT(Isolate::Current()->HasAttemptedReload()); | 1616 NOT_IN_PRODUCT(ASSERT(Isolate::Current()->HasAttemptedReload())); |
| 1617 if (target.IsNull() || (target.is_static() != parent.is_static()) || | 1617 if (target.IsNull() || (target.is_static() != parent.is_static()) || |
| 1618 (target.kind() != parent.kind())) { | 1618 (target.kind() != parent.kind())) { |
| 1619 target = Function::null(); | 1619 target = Function::null(); |
| 1620 } | 1620 } |
| 1621 } | 1621 } |
| 1622 | 1622 |
| 1623 AstNode* call = NULL; | 1623 AstNode* call = NULL; |
| 1624 // Check the target still exists and has compatible parameters. If not, | 1624 // Check the target still exists and has compatible parameters. If not, |
| 1625 // throw NSME/call nSM instead of forwarding the call. Note we compare the | 1625 // throw NSME/call nSM instead of forwarding the call. Note we compare the |
| 1626 // parent not func because func has an extra parameter for the closure | 1626 // parent not func because func has an extra parameter for the closure |
| 1627 // receiver. | 1627 // receiver. |
| 1628 if (!target.IsNull() && | 1628 if (!target.IsNull() && |
| 1629 (parent.num_fixed_parameters() == target.num_fixed_parameters())) { | 1629 (parent.num_fixed_parameters() == target.num_fixed_parameters())) { |
| 1630 call = new StaticCallNode(token_pos, target, func_args); | 1630 call = new StaticCallNode(token_pos, target, func_args); |
| 1631 } else if (!parent.is_static()) { | 1631 } else if (!parent.is_static()) { |
| 1632 ASSERT(Isolate::Current()->HasAttemptedReload()); | 1632 NOT_IN_PRODUCT(ASSERT(Isolate::Current()->HasAttemptedReload())); |
| 1633 // If a subsequent reload reintroduces the target in the middle of the | 1633 // If a subsequent reload reintroduces the target in the middle of the |
| 1634 // Invocation object being constructed, we won't be able to successfully | 1634 // Invocation object being constructed, we won't be able to successfully |
| 1635 // deopt because the generated AST will change. | 1635 // deopt because the generated AST will change. |
| 1636 func.SetIsOptimizable(false); | 1636 func.SetIsOptimizable(false); |
| 1637 | 1637 |
| 1638 ArgumentListNode* arguments = BuildNoSuchMethodArguments( | 1638 ArgumentListNode* arguments = BuildNoSuchMethodArguments( |
| 1639 token_pos, func_name, *func_args, NULL, false); | 1639 token_pos, func_name, *func_args, NULL, false); |
| 1640 const intptr_t kTypeArgsLen = 0; | 1640 const intptr_t kTypeArgsLen = 0; |
| 1641 const intptr_t kNumArguments = 2; // Receiver, InvocationMirror. | 1641 const intptr_t kNumArguments = 2; // Receiver, InvocationMirror. |
| 1642 ArgumentsDescriptor args_desc(Array::Handle( | 1642 ArgumentsDescriptor args_desc(Array::Handle( |
| 1643 Z, ArgumentsDescriptor::New(kTypeArgsLen, kNumArguments))); | 1643 Z, ArgumentsDescriptor::New(kTypeArgsLen, kNumArguments))); |
| 1644 Function& no_such_method = | 1644 Function& no_such_method = |
| 1645 Function::ZoneHandle(Z, Resolver::ResolveDynamicForReceiverClass( | 1645 Function::ZoneHandle(Z, Resolver::ResolveDynamicForReceiverClass( |
| 1646 owner, Symbols::NoSuchMethod(), args_desc)); | 1646 owner, Symbols::NoSuchMethod(), args_desc)); |
| 1647 if (no_such_method.IsNull()) { | 1647 if (no_such_method.IsNull()) { |
| 1648 // If noSuchMethod(i) is not found, call Object:noSuchMethod. | 1648 // If noSuchMethod(i) is not found, call Object:noSuchMethod. |
| 1649 no_such_method ^= Resolver::ResolveDynamicForReceiverClass( | 1649 no_such_method ^= Resolver::ResolveDynamicForReceiverClass( |
| 1650 Class::Handle(Z, I->object_store()->object_class()), | 1650 Class::Handle(Z, I->object_store()->object_class()), |
| 1651 Symbols::NoSuchMethod(), args_desc); | 1651 Symbols::NoSuchMethod(), args_desc); |
| 1652 } | 1652 } |
| 1653 call = new StaticCallNode(token_pos, no_such_method, arguments); | 1653 call = new StaticCallNode(token_pos, no_such_method, arguments); |
| 1654 } else { | 1654 } else { |
| 1655 ASSERT(Isolate::Current()->HasAttemptedReload()); | 1655 NOT_IN_PRODUCT(ASSERT(Isolate::Current()->HasAttemptedReload())); |
| 1656 // If a subsequent reload reintroduces the target in the middle of the | 1656 // If a subsequent reload reintroduces the target in the middle of the |
| 1657 // arguments array being constructed, we won't be able to successfully | 1657 // arguments array being constructed, we won't be able to successfully |
| 1658 // deopt because the generated AST will change. | 1658 // deopt because the generated AST will change. |
| 1659 func.SetIsOptimizable(false); | 1659 func.SetIsOptimizable(false); |
| 1660 | 1660 |
| 1661 InvocationMirror::Type im_type; | 1661 InvocationMirror::Type im_type; |
| 1662 if (parent.IsImplicitGetterFunction()) { | 1662 if (parent.IsImplicitGetterFunction()) { |
| 1663 im_type = InvocationMirror::kGetter; | 1663 im_type = InvocationMirror::kGetter; |
| 1664 } else if (parent.IsImplicitSetterFunction()) { | 1664 } else if (parent.IsImplicitSetterFunction()) { |
| 1665 im_type = InvocationMirror::kSetter; | 1665 im_type = InvocationMirror::kSetter; |
| (...skipping 13435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15101 bool Parser::FieldHasFunctionLiteralInitializer(const Field& field, | 15101 bool Parser::FieldHasFunctionLiteralInitializer(const Field& field, |
| 15102 TokenPosition* start, | 15102 TokenPosition* start, |
| 15103 TokenPosition* end) { | 15103 TokenPosition* end) { |
| 15104 UNREACHABLE(); | 15104 UNREACHABLE(); |
| 15105 return false; | 15105 return false; |
| 15106 } | 15106 } |
| 15107 | 15107 |
| 15108 } // namespace dart | 15108 } // namespace dart |
| 15109 | 15109 |
| 15110 #endif // DART_PRECOMPILED_RUNTIME | 15110 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |