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/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
6 | 6 |
7 #include "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
9 #include "vm/code_descriptors.h" | 9 #include "vm/code_descriptors.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 Array::ZoneHandle(), | 1784 Array::ZoneHandle(), |
1785 1)); // Checked argument count. | 1785 1)); // Checked argument count. |
1786 ReturnComputation( | 1786 ReturnComputation( |
1787 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); | 1787 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); |
1788 } | 1788 } |
1789 | 1789 |
1790 | 1790 |
1791 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { | 1791 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { |
1792 const String& getter_name = | 1792 const String& getter_name = |
1793 String::Handle(Field::GetterName(node->field_name())); | 1793 String::Handle(Field::GetterName(node->field_name())); |
1794 const Function& getter_function = | |
1795 Function::ZoneHandle(node->cls().LookupStaticFunction(getter_name)); | |
1796 ASSERT(!getter_function.IsNull()); | |
1797 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1794 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1798 new ZoneGrowableArray<PushArgumentInstr*>(); | 1795 new ZoneGrowableArray<PushArgumentInstr*>(); |
| 1796 Function& getter_function = Function::ZoneHandle(); |
| 1797 if (node->is_super_getter()) { |
| 1798 // Statically resolved instance getter, i.e. "super getter". |
| 1799 getter_function = |
| 1800 Resolver::ResolveDynamicAnyArgs(node->cls(), getter_name); |
| 1801 ASSERT(!getter_function.IsNull()); |
| 1802 ASSERT(node->receiver() != NULL); |
| 1803 ValueGraphVisitor receiver_value(owner(), temp_index()); |
| 1804 node->receiver()->Visit(&receiver_value); |
| 1805 Append(receiver_value); |
| 1806 arguments->Add(PushArgument(receiver_value.value())); |
| 1807 } else { |
| 1808 getter_function = node->cls().LookupStaticFunction(getter_name); |
| 1809 ASSERT(!getter_function.IsNull()); |
| 1810 } |
1799 StaticCallComp* call = new StaticCallComp(node->token_pos(), | 1811 StaticCallComp* call = new StaticCallComp(node->token_pos(), |
1800 owner()->try_index(), | 1812 owner()->try_index(), |
1801 getter_function, | 1813 getter_function, |
1802 Array::ZoneHandle(), // No names. | 1814 Array::ZoneHandle(), // No names. |
1803 arguments); | 1815 arguments); |
1804 ReturnComputation(call); | 1816 ReturnComputation(call); |
1805 } | 1817 } |
1806 | 1818 |
1807 | 1819 |
1808 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node, | 1820 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node, |
1809 bool result_is_needed) { | 1821 bool result_is_needed) { |
1810 const String& setter_name = | 1822 const String& setter_name = |
1811 String::Handle(Field::SetterName(node->field_name())); | 1823 String::Handle(Field::SetterName(node->field_name())); |
| 1824 // A super setter is an instance setter whose setter function is |
| 1825 // resolved at compile time (in the caller instance getter's super class). |
| 1826 // Unlike a static getter, a super getter has a receiver parameter. |
| 1827 const bool is_super_setter = (node->receiver() != NULL); |
1812 const Function& setter_function = | 1828 const Function& setter_function = |
1813 Function::ZoneHandle(node->cls().LookupStaticFunction(setter_name)); | 1829 Function::ZoneHandle(is_super_setter |
| 1830 ? Resolver::ResolveDynamicAnyArgs(node->cls(), setter_name) |
| 1831 : node->cls().LookupStaticFunction(setter_name)); |
1814 ASSERT(!setter_function.IsNull()); | 1832 ASSERT(!setter_function.IsNull()); |
| 1833 |
| 1834 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1835 new ZoneGrowableArray<PushArgumentInstr*>(1); |
| 1836 if (is_super_setter) { |
| 1837 // Add receiver of instance getter. |
| 1838 ValueGraphVisitor for_receiver(owner(), temp_index()); |
| 1839 node->receiver()->Visit(&for_receiver); |
| 1840 Append(for_receiver); |
| 1841 arguments->Add(PushArgument(for_receiver.value())); |
| 1842 } |
1815 ValueGraphVisitor for_value(owner(), temp_index()); | 1843 ValueGraphVisitor for_value(owner(), temp_index()); |
1816 node->value()->Visit(&for_value); | 1844 node->value()->Visit(&for_value); |
1817 Append(for_value); | 1845 Append(for_value); |
1818 Value* value = NULL; | 1846 Value* value = NULL; |
1819 if (result_is_needed) { | 1847 if (result_is_needed) { |
1820 value = Bind( | 1848 value = Bind( |
1821 BuildStoreLocal(*owner()->parsed_function().expression_temp_var(), | 1849 BuildStoreLocal(*owner()->parsed_function().expression_temp_var(), |
1822 for_value.value())); | 1850 for_value.value())); |
1823 } else { | 1851 } else { |
1824 value = for_value.value(); | 1852 value = for_value.value(); |
1825 } | 1853 } |
1826 ZoneGrowableArray<PushArgumentInstr*>* arguments = | |
1827 new ZoneGrowableArray<PushArgumentInstr*>(1); | |
1828 arguments->Add(PushArgument(value)); | 1854 arguments->Add(PushArgument(value)); |
| 1855 |
1829 StaticCallComp* call = new StaticCallComp(node->token_pos(), | 1856 StaticCallComp* call = new StaticCallComp(node->token_pos(), |
1830 owner()->try_index(), | 1857 owner()->try_index(), |
1831 setter_function, | 1858 setter_function, |
1832 Array::ZoneHandle(), // No names. | 1859 Array::ZoneHandle(), // No names. |
1833 arguments); | 1860 arguments); |
1834 if (result_is_needed) { | 1861 if (result_is_needed) { |
1835 Do(call); | 1862 Do(call); |
1836 ReturnComputation( | 1863 ReturnComputation( |
1837 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); | 1864 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); |
1838 } else { | 1865 } else { |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2772 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
2746 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2773 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
2747 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2774 OS::SNPrint(chars, len, kFormat, function_name, reason); |
2748 const Error& error = Error::Handle( | 2775 const Error& error = Error::Handle( |
2749 LanguageError::New(String::Handle(String::New(chars)))); | 2776 LanguageError::New(String::Handle(String::New(chars)))); |
2750 Isolate::Current()->long_jump_base()->Jump(1, error); | 2777 Isolate::Current()->long_jump_base()->Jump(1, error); |
2751 } | 2778 } |
2752 | 2779 |
2753 | 2780 |
2754 } // namespace dart | 2781 } // namespace dart |
OLD | NEW |