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

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

Issue 25675002: Generative constructor factories for native objects (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 part of ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 1789
1790 // TODO(sra): Tell world.nativeEnqueuer about the types created here. 1790 // TODO(sra): Tell world.nativeEnqueuer about the types created here.
1791 registerForeignTypes(node); 1791 registerForeignTypes(node);
1792 } 1792 }
1793 1793
1794 visitForeignNew(HForeignNew node) { 1794 visitForeignNew(HForeignNew node) {
1795 String jsClassReference = backend.namer.isolateAccess(node.element); 1795 String jsClassReference = backend.namer.isolateAccess(node.element);
1796 List<js.Expression> arguments = visitArguments(node.inputs, start: 0); 1796 List<js.Expression> arguments = visitArguments(node.inputs, start: 0);
1797 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it 1797 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it
1798 // as if it was a string. 1798 // as if it was a string.
1799 push(new js.New(new js.VariableUse(jsClassReference), arguments), node); 1799 js.Expression constructor = new js.VariableUse(jsClassReference);
ngeoffray 2013/10/17 09:08:59 Why this change?
sra1 2013/10/18 04:09:32 It can be changed back. Original formulation call
1800 push(new js.New(constructor, arguments), node);
1800 registerForeignTypes(node); 1801 registerForeignTypes(node);
1801 if (node.instantiatedTypes == null) { 1802 if (node.instantiatedTypes == null) {
1802 return; 1803 return;
1803 } 1804 }
1804 node.instantiatedTypes.forEach((type) { 1805 node.instantiatedTypes.forEach((type) {
1805 world.registerInstantiatedType(type, work.resolutionTree); 1806 world.registerInstantiatedType(type, work.resolutionTree);
1806 }); 1807 });
1807 } 1808 }
1808 1809
1809 js.Expression newLiteralBool(bool value) { 1810 js.Expression newLiteralBool(bool value) {
1810 if (compiler.enableMinification) { 1811 if (compiler.enableMinification) {
1811 // Use !0 for true, !1 for false. 1812 // Use !0 for true, !1 for false.
1812 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1")); 1813 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1"));
1813 } else { 1814 } else {
1814 return new js.LiteralBool(value); 1815 return new js.LiteralBool(value);
1815 } 1816 }
1816 } 1817 }
1817 1818
1818 void generateConstant(Constant constant) { 1819 void generateConstant(Constant constant) {
1819 if (constant.isFunction()) { 1820 if (constant.isFunction()) {
1820 FunctionConstant function = constant; 1821 FunctionConstant function = constant;
1821 world.registerStaticUse(function.element); 1822 world.registerStaticUse(function.element);
1822 } 1823 }
1824 if (constant.isType()) {
1825 // If the type is a web component, we need to ensure the constructors are
ngeoffray 2013/10/17 09:08:59 There's no check of 'web component' here. Maybe yo
sra1 2013/10/18 04:09:32 We now register the constant with the backend.
1826 // available to 'upgrade' the native object.
1827 TypeConstant type = constant;
1828 Element element = type.representedType.element;
1829 if (element != null && element.isClass()) {
1830 backend.registerEscapingConstructorsOfClass(element, world);
1831 }
1832 }
1823 push(backend.emitter.constantReference(constant)); 1833 push(backend.emitter.constantReference(constant));
1824 } 1834 }
1825 1835
1826 visitConstant(HConstant node) { 1836 visitConstant(HConstant node) {
1827 assert(isGenerateAtUseSite(node)); 1837 assert(isGenerateAtUseSite(node));
1828 generateConstant(node.constant); 1838 generateConstant(node.constant);
1829 1839
1830 backend.registerCompileTimeConstant(node.constant, work.resolutionTree); 1840 backend.registerCompileTimeConstant(node.constant, work.resolutionTree);
1831 compiler.constantHandler.addCompileTimeConstantForEmission(node.constant); 1841 compiler.constantHandler.addCompileTimeConstantForEmission(node.constant);
1832 } 1842 }
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
3043 if (leftType.canBeNull() && rightType.canBeNull()) { 3053 if (leftType.canBeNull() && rightType.canBeNull()) {
3044 if (left.isConstantNull() || right.isConstantNull() || 3054 if (left.isConstantNull() || right.isConstantNull() ||
3045 (leftType.isPrimitive(compiler) && leftType == rightType)) { 3055 (leftType.isPrimitive(compiler) && leftType == rightType)) {
3046 return '=='; 3056 return '==';
3047 } 3057 }
3048 return null; 3058 return null;
3049 } else { 3059 } else {
3050 return '==='; 3060 return '===';
3051 } 3061 }
3052 } 3062 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698