Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(869)

Side by Side Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10831154: Make field-get/set work without elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 class SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 final JavaScriptBackend backend; 6 final JavaScriptBackend backend;
7 SsaCodeGeneratorTask(JavaScriptBackend backend) 7 SsaCodeGeneratorTask(JavaScriptBackend backend)
8 : this.backend = backend, 8 : this.backend = backend,
9 super(backend.compiler); 9 super(backend.compiler);
10 String get name() => 'SSA code generator'; 10 String get name() => 'SSA code generator';
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 // Remove the element and 'this'. 1804 // Remove the element and 'this'.
1805 int argumentCount = node.inputs.length - 2; 1805 int argumentCount = node.inputs.length - 2;
1806 String className = compiler.namer.isolateAccess(superClass); 1806 String className = compiler.namer.isolateAccess(superClass);
1807 if (superMethod.kind == ElementKind.FUNCTION || 1807 if (superMethod.kind == ElementKind.FUNCTION ||
1808 superMethod.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { 1808 superMethod.kind == ElementKind.GENERATIVE_CONSTRUCTOR) {
1809 String methodName = compiler.namer.instanceMethodName( 1809 String methodName = compiler.namer.instanceMethodName(
1810 currentLibrary, superMethod.name, argumentCount); 1810 currentLibrary, superMethod.name, argumentCount);
1811 buffer.add('$className.prototype.$methodName.call'); 1811 buffer.add('$className.prototype.$methodName.call');
1812 visitArguments(node.inputs); 1812 visitArguments(node.inputs);
1813 } else if (superMethod.kind == ElementKind.FIELD) { 1813 } else if (superMethod.kind == ElementKind.FIELD) {
1814 buffer.add('this.${compiler.namer.getName(superMethod)}'); 1814 ClassElement currentClass = work.element.enclosingElement;
1815 if (currentClass.isShadowedByField(superMethod)) {
1816 buffer.add('this.${compiler.namer.shadowedFieldName(superMethod)}');
1817 } else {
1818 LibraryElement library = superMethod.getLibrary();
1819 SourceString name = superMethod.name;
1820 buffer.add('this.${compiler.namer.instanceFieldName(library, name)}');
1821 }
1815 } else { 1822 } else {
1816 assert(superMethod.kind == ElementKind.GETTER || 1823 assert(superMethod.kind == ElementKind.GETTER ||
1817 superMethod.kind == ElementKind.SETTER); 1824 superMethod.kind == ElementKind.SETTER);
1818 String methodName; 1825 String methodName;
1819 if (superMethod.kind == ElementKind.GETTER) { 1826 if (superMethod.kind == ElementKind.GETTER) {
1820 methodName = 1827 methodName =
1821 compiler.namer.getterName(currentLibrary, superMethod.name); 1828 compiler.namer.getterName(currentLibrary, superMethod.name);
1822 } else { 1829 } else {
1823 methodName = 1830 methodName =
1824 compiler.namer.setterName(currentLibrary, superMethod.name); 1831 compiler.namer.setterName(currentLibrary, superMethod.name);
1825 } 1832 }
1826 buffer.add('$className.prototype.$methodName.call'); 1833 buffer.add('$className.prototype.$methodName.call');
1827 visitArguments(node.inputs); 1834 visitArguments(node.inputs);
1828 } 1835 }
1829 endExpression(JSPrecedence.CALL_PRECEDENCE); 1836 endExpression(JSPrecedence.CALL_PRECEDENCE);
1830 world.registerStaticUse(superMethod); 1837 world.registerStaticUse(superMethod);
1831 } 1838 }
1832 1839
1833 visitFieldGet(HFieldGet node) { 1840 visitFieldGet(HFieldGet node) {
1834 String name = compiler.namer.getName(node.element); 1841 String name =
1842 compiler.namer.instanceFieldName(node.library, node.fieldName);
1835 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); 1843 beginExpression(JSPrecedence.MEMBER_PRECEDENCE);
1836 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 1844 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
1837 buffer.add('.'); 1845 buffer.add('.');
1838 buffer.add(name); 1846 buffer.add(name);
1839 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); 1847 beginExpression(JSPrecedence.MEMBER_PRECEDENCE);
1840 Type type = node.receiver.propagatedType.computeType(compiler); 1848 Type type = node.receiver.propagatedType.computeType(compiler);
1841 if (type != null) { 1849 if (type != null) {
1842 world.registerFieldGetter(node.element.name, type); 1850 world.registerFieldGetter(node.element.name, type);
1843 } 1851 }
1844 } 1852 }
(...skipping 12 matching lines...) Expand all
1857 } 1865 }
1858 1866
1859 visitFieldSet(HFieldSet node) { 1867 visitFieldSet(HFieldSet node) {
1860 if (work.element.isGenerativeConstructorBody() && 1868 if (work.element.isGenerativeConstructorBody() &&
1861 node.element.enclosingElement.isClass() && 1869 node.element.enclosingElement.isClass() &&
1862 node.value.hasGuaranteedType() && 1870 node.value.hasGuaranteedType() &&
1863 node.block.dominates(currentGraph.exit)) { 1871 node.block.dominates(currentGraph.exit)) {
1864 backend.updateFieldConstructorSetters(node.element, 1872 backend.updateFieldConstructorSetters(node.element,
1865 node.value.guaranteedType); 1873 node.value.guaranteedType);
1866 } 1874 }
1867 String name = compiler.namer.getName(node.element); 1875 String name =
1876 compiler.namer.instanceFieldName(node.library, node.fieldName);
1868 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 1877 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
1869 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 1878 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
1870 buffer.add('.'); 1879 buffer.add('.');
1871 buffer.add(name); 1880 buffer.add(name);
1872 Type type = node.receiver.propagatedType.computeType(compiler); 1881 Type type = node.receiver.propagatedType.computeType(compiler);
1873 if (type != null) { 1882 if (type != null) {
1874 if (!work.element.isGenerativeConstructorBody()) { 1883 if (!work.element.isGenerativeConstructorBody()) {
1875 world.registerFieldSetter(node.element.name, type); 1884 world.registerFieldSetter(node.element.name, type);
1876 } 1885 }
1877 // Determine the types seen so far for the field. If only number 1886 // Determine the types seen so far for the field. If only number
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
3183 if (leftType.canBeNull() && rightType.canBeNull()) { 3192 if (leftType.canBeNull() && rightType.canBeNull()) {
3184 if (left.isConstantNull() || right.isConstantNull() || 3193 if (left.isConstantNull() || right.isConstantNull() ||
3185 (leftType.isPrimitive() && leftType == rightType)) { 3194 (leftType.isPrimitive() && leftType == rightType)) {
3186 return '=='; 3195 return '==';
3187 } 3196 }
3188 return null; 3197 return null;
3189 } else { 3198 } else {
3190 return '==='; 3199 return '===';
3191 } 3200 }
3192 } 3201 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/builder.dart ('k') | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698