| 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
| 9 * from the given element. | 9 * from the given element. |
| 10 */ | 10 */ |
| (...skipping 1804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1815 // Only the native classes can have renaming accessors. | 1815 // Only the native classes can have renaming accessors. |
| 1816 assert(classIsNative); | 1816 assert(classIsNative); |
| 1817 } | 1817 } |
| 1818 | 1818 |
| 1819 int getterCode = 0; | 1819 int getterCode = 0; |
| 1820 if (needsGetter) { | 1820 if (needsGetter) { |
| 1821 if (field.isInstanceMember()) { | 1821 if (field.isInstanceMember()) { |
| 1822 // 01: function() { return this.field; } | 1822 // 01: function() { return this.field; } |
| 1823 // 10: function(receiver) { return receiver.field; } | 1823 // 10: function(receiver) { return receiver.field; } |
| 1824 // 11: function(receiver) { return this.field; } | 1824 // 11: function(receiver) { return this.field; } |
| 1825 getterCode += backend.fieldHasInterceptedGetter(field) ? 2 : 0; | 1825 bool isIntercepted = backend.fieldHasInterceptedGetter(field); |
| 1826 getterCode += isIntercepted ? 2 : 0; |
| 1826 getterCode += backend.isInterceptorClass(element) ? 0 : 1; | 1827 getterCode += backend.isInterceptorClass(element) ? 0 : 1; |
| 1827 // TODO(sra): 'isInterceptorClass' might not be the correct test | 1828 // TODO(sra): 'isInterceptorClass' might not be the correct test |
| 1828 // for methods forced to use the interceptor convention because | 1829 // for methods forced to use the interceptor convention because |
| 1829 // the method's class was elsewhere mixed-in to an interceptor. | 1830 // the method's class was elsewhere mixed-in to an interceptor. |
| 1830 assert(!field.isInstanceMember() || getterCode != 0); | 1831 assert(!field.isInstanceMember() || getterCode != 0); |
| 1832 if (isIntercepted) { |
| 1833 interceptorInvocationNames.add(namer.getterName(field)); |
| 1834 } |
| 1831 } else { | 1835 } else { |
| 1832 getterCode = 1; | 1836 getterCode = 1; |
| 1833 } | 1837 } |
| 1834 } | 1838 } |
| 1835 int setterCode = 0; | 1839 int setterCode = 0; |
| 1836 if (needsSetter) { | 1840 if (needsSetter) { |
| 1837 if (field.isInstanceMember()) { | 1841 if (field.isInstanceMember()) { |
| 1838 // 01: function(value) { this.field = value; } | 1842 // 01: function(value) { this.field = value; } |
| 1839 // 10: function(receiver, value) { receiver.field = value; } | 1843 // 10: function(receiver, value) { receiver.field = value; } |
| 1840 // 11: function(receiver, value) { this.field = value; } | 1844 // 11: function(receiver, value) { this.field = value; } |
| 1841 setterCode += backend.fieldHasInterceptedSetter(field) ? 2 : 0; | 1845 bool isIntercepted = backend.fieldHasInterceptedSetter(field); |
| 1846 setterCode += isIntercepted ? 2 : 0; |
| 1842 setterCode += backend.isInterceptorClass(element) ? 0 : 1; | 1847 setterCode += backend.isInterceptorClass(element) ? 0 : 1; |
| 1843 assert(!field.isInstanceMember() || setterCode != 0); | 1848 assert(!field.isInstanceMember() || setterCode != 0); |
| 1849 if (isIntercepted) { |
| 1850 interceptorInvocationNames.add(namer.setterName(field)); |
| 1851 } |
| 1844 } else { | 1852 } else { |
| 1845 setterCode = 1; | 1853 setterCode = 1; |
| 1846 } | 1854 } |
| 1847 } | 1855 } |
| 1848 int code = getterCode + (setterCode << 2); | 1856 int code = getterCode + (setterCode << 2); |
| 1849 if (code == 0) { | 1857 if (code == 0) { |
| 1850 compiler.reportInternalError( | 1858 compiler.reportInternalError( |
| 1851 field, 'Internal error: code is 0 ($element/$field)'); | 1859 field, 'Internal error: code is 0 ($element/$field)'); |
| 1852 } else { | 1860 } else { |
| 1853 buffer.write(FIELD_CODE_CHARACTERS[code - FIRST_FIELD_CODE]); | 1861 buffer.write(FIELD_CODE_CHARACTERS[code - FIRST_FIELD_CODE]); |
| (...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4157 | 4165 |
| 4158 const String HOOKS_API_USAGE = """ | 4166 const String HOOKS_API_USAGE = """ |
| 4159 // The code supports the following hooks: | 4167 // The code supports the following hooks: |
| 4160 // dartPrint(message) - if this function is defined it is called | 4168 // dartPrint(message) - if this function is defined it is called |
| 4161 // instead of the Dart [print] method. | 4169 // instead of the Dart [print] method. |
| 4162 // dartMainRunner(main) - if this function is defined, the Dart [main] | 4170 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 4163 // method will not be invoked directly. | 4171 // method will not be invoked directly. |
| 4164 // Instead, a closure that will invoke [main] is | 4172 // Instead, a closure that will invoke [main] is |
| 4165 // passed to [dartMainRunner]. | 4173 // passed to [dartMainRunner]. |
| 4166 """; | 4174 """; |
| OLD | NEW |