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