| 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 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 | 1566 |
| 1567 if (CurrentToken() == Token::kLBRACK) { | 1567 if (CurrentToken() == Token::kLBRACK) { |
| 1568 ConsumeToken(); | 1568 ConsumeToken(); |
| 1569 AstNode* index_expr = ParseExpr(kAllowConst, kConsumeCascades); | 1569 AstNode* index_expr = ParseExpr(kAllowConst, kConsumeCascades); |
| 1570 ExpectToken(Token::kRBRACK); | 1570 ExpectToken(Token::kRBRACK); |
| 1571 AstNode* receiver = LoadReceiver(operator_pos); | 1571 AstNode* receiver = LoadReceiver(operator_pos); |
| 1572 const Class& super_class = Class::ZoneHandle(current_class().SuperClass()); | 1572 const Class& super_class = Class::ZoneHandle(current_class().SuperClass()); |
| 1573 ASSERT(!super_class.IsNull()); | 1573 ASSERT(!super_class.IsNull()); |
| 1574 super_op = | 1574 super_op = |
| 1575 new LoadIndexedNode(operator_pos, receiver, index_expr, super_class); | 1575 new LoadIndexedNode(operator_pos, receiver, index_expr, super_class); |
| 1576 } else if (Token::CanBeOverloaded(CurrentToken()) || | 1576 } else { |
| 1577 (CurrentToken() == Token::kNE)) { | 1577 ASSERT(Token::CanBeOverloaded(CurrentToken()) || |
| 1578 (CurrentToken() == Token::kNE)); |
| 1578 Token::Kind op = CurrentToken(); | 1579 Token::Kind op = CurrentToken(); |
| 1579 ConsumeToken(); | 1580 ConsumeToken(); |
| 1580 | 1581 |
| 1581 bool negate_result = false; | 1582 bool negate_result = false; |
| 1582 if (op == Token::kNE) { | 1583 if (op == Token::kNE) { |
| 1583 op = Token::kEQ; | 1584 op = Token::kEQ; |
| 1584 negate_result = true; | 1585 negate_result = true; |
| 1585 } | 1586 } |
| 1586 | 1587 |
| 1587 ASSERT(Token::Precedence(op) >= Token::Precedence(Token::kBIT_OR)); | 1588 ASSERT(Token::Precedence(op) >= Token::Precedence(Token::kBIT_OR)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 | 1650 |
| 1650 const String& getter_name = | 1651 const String& getter_name = |
| 1651 String::ZoneHandle(Field::GetterName(field_name)); | 1652 String::ZoneHandle(Field::GetterName(field_name)); |
| 1652 const Function& super_getter = Function::ZoneHandle( | 1653 const Function& super_getter = Function::ZoneHandle( |
| 1653 Resolver::ResolveDynamicAnyArgs(super_class, getter_name)); | 1654 Resolver::ResolveDynamicAnyArgs(super_class, getter_name)); |
| 1654 if (super_getter.IsNull()) { | 1655 if (super_getter.IsNull()) { |
| 1655 const String& setter_name = | 1656 const String& setter_name = |
| 1656 String::ZoneHandle(Field::SetterName(field_name)); | 1657 String::ZoneHandle(Field::SetterName(field_name)); |
| 1657 const Function& super_setter = Function::ZoneHandle( | 1658 const Function& super_setter = Function::ZoneHandle( |
| 1658 Resolver::ResolveDynamicAnyArgs(super_class, setter_name)); | 1659 Resolver::ResolveDynamicAnyArgs(super_class, setter_name)); |
| 1659 if (!super_setter.IsNull()) { | 1660 if (super_setter.IsNull()) { |
| 1660 return new StaticGetterNode( | 1661 // Check if this is an access to an implicit closure using 'super'. |
| 1661 field_pos, implicit_argument, true, super_class, field_name); | 1662 // If a function exists of the specified field_name then try |
| 1663 // accessing it as a getter, at runtime we will handle this by |
| 1664 // creating an implicit closure of the function and returning it. |
| 1665 const Function& super_function = Function::ZoneHandle( |
| 1666 Resolver::ResolveDynamicAnyArgs(super_class, field_name)); |
| 1667 if (!super_function.IsNull()) { |
| 1668 // In case CreateAssignmentNode is called later on this |
| 1669 // CreateImplicitClosureNode, it will be replaced by a StaticSetterNode. |
| 1670 return CreateImplicitClosureNode(super_function, |
| 1671 field_pos, |
| 1672 implicit_argument); |
| 1673 } |
| 1674 // No function or field exists of the specified field_name. |
| 1675 // Emit a StaticGetterNode anyway, so that noSuchMethod gets called. |
| 1662 } | 1676 } |
| 1663 } | 1677 } |
| 1664 if (super_getter.IsNull()) { | |
| 1665 // Check if this is an access to an implicit closure using 'super'. | |
| 1666 // If a function exists of the specified field_name then try | |
| 1667 // accessing it as a getter, at runtime we will handle this by | |
| 1668 // creating an implicit closure of the function and returning it. | |
| 1669 const Function& super_function = Function::ZoneHandle( | |
| 1670 Resolver::ResolveDynamicAnyArgs(super_class, field_name)); | |
| 1671 if (!super_function.IsNull()) { | |
| 1672 // In case CreateAssignmentNode is called later on this | |
| 1673 // CreateImplicitClosureNode, it will be replaced by a StaticSetterNode. | |
| 1674 return CreateImplicitClosureNode(super_function, | |
| 1675 field_pos, | |
| 1676 implicit_argument); | |
| 1677 } | |
| 1678 // No function or field exists of the specified field_name. | |
| 1679 // Emit a StaticGetterNode anyway, so that noSuchMethod gets called. | |
| 1680 } | |
| 1681 return new StaticGetterNode( | 1678 return new StaticGetterNode( |
| 1682 field_pos, implicit_argument, true, super_class, field_name); | 1679 field_pos, implicit_argument, true, super_class, field_name); |
| 1683 } | 1680 } |
| 1684 | 1681 |
| 1685 | 1682 |
| 1686 void Parser::GenerateSuperConstructorCall(const Class& cls, | 1683 void Parser::GenerateSuperConstructorCall(const Class& cls, |
| 1687 LocalVariable* receiver) { | 1684 LocalVariable* receiver) { |
| 1688 const intptr_t supercall_pos = TokenPos(); | 1685 const intptr_t supercall_pos = TokenPos(); |
| 1689 const Class& super_class = Class::Handle(cls.SuperClass()); | 1686 const Class& super_class = Class::Handle(cls.SuperClass()); |
| 1690 // Omit the implicit super() if there is no super class (i.e. | 1687 // Omit the implicit super() if there is no super class (i.e. |
| (...skipping 8302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9993 void Parser::SkipQualIdent() { | 9990 void Parser::SkipQualIdent() { |
| 9994 ASSERT(IsIdentifier()); | 9991 ASSERT(IsIdentifier()); |
| 9995 ConsumeToken(); | 9992 ConsumeToken(); |
| 9996 if (CurrentToken() == Token::kPERIOD) { | 9993 if (CurrentToken() == Token::kPERIOD) { |
| 9997 ConsumeToken(); // Consume the kPERIOD token. | 9994 ConsumeToken(); // Consume the kPERIOD token. |
| 9998 ExpectIdentifier("identifier expected after '.'"); | 9995 ExpectIdentifier("identifier expected after '.'"); |
| 9999 } | 9996 } |
| 10000 } | 9997 } |
| 10001 | 9998 |
| 10002 } // namespace dart | 9999 } // namespace dart |
| OLD | NEW |