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

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

Issue 10872059: Static and top-level methods can be compile time constants. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 6
7 final JavaScriptBackend backend; 7 final JavaScriptBackend backend;
8 8
9 SsaCodeGeneratorTask(JavaScriptBackend backend) 9 SsaCodeGeneratorTask(JavaScriptBackend backend)
10 : this.backend = backend, 10 : this.backend = backend,
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 CodeBuffer buffer = new CodeBuffer(); 1676 CodeBuffer buffer = new CodeBuffer();
1677 handler.writeConstant(buffer, constant); 1677 handler.writeConstant(buffer, constant);
1678 push(new js.LiteralNumber(buffer.toString())); 1678 push(new js.LiteralNumber(buffer.toString()));
1679 } else if (constant.isNull()) { 1679 } else if (constant.isNull()) {
1680 push(new js.LiteralNull()); 1680 push(new js.LiteralNull());
1681 } else if (constant.isString()) { 1681 } else if (constant.isString()) {
1682 // TODO(floitsch): get rid of the code buffer. 1682 // TODO(floitsch): get rid of the code buffer.
1683 CodeBuffer buffer = new CodeBuffer(); 1683 CodeBuffer buffer = new CodeBuffer();
1684 handler.writeConstant(buffer, constant); 1684 handler.writeConstant(buffer, constant);
1685 push(new js.LiteralString(buffer.toString())); 1685 push(new js.LiteralString(buffer.toString()));
1686 } else if (constant.isFunction()) {
1687 FunctionConstant function = constant;
1688 world.registerStaticUse(function.element);
1689 push(new js.VariableUse(
1690 compiler.namer.isolateAccess(function.element)));
1686 } else { 1691 } else {
1687 compiler.internalError("Forgot constant $constant"); 1692 compiler.internalError(
1693 "The compiler does not know how generate code for "
1694 "constant $constant");
1688 } 1695 }
1689 } else { 1696 } else {
1690 js.VariableUse currentIsolateUse = 1697 js.VariableUse currentIsolateUse =
1691 new js.VariableUse(compiler.namer.CURRENT_ISOLATE); 1698 new js.VariableUse(compiler.namer.CURRENT_ISOLATE);
1692 push(new js.PropertyAccess.field(currentIsolateUse, name)); 1699 push(new js.PropertyAccess.field(currentIsolateUse, name));
1693 } 1700 }
1694 } 1701 }
1695 1702
1696 visitConstant(HConstant node) { 1703 visitConstant(HConstant node) {
1697 assert(isGenerateAtUseSite(node)); 1704 assert(isGenerateAtUseSite(node));
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 if (leftType.canBeNull() && rightType.canBeNull()) { 2905 if (leftType.canBeNull() && rightType.canBeNull()) {
2899 if (left.isConstantNull() || right.isConstantNull() || 2906 if (left.isConstantNull() || right.isConstantNull() ||
2900 (leftType.isPrimitive() && leftType == rightType)) { 2907 (leftType.isPrimitive() && leftType == rightType)) {
2901 return '=='; 2908 return '==';
2902 } 2909 }
2903 return null; 2910 return null;
2904 } else { 2911 } else {
2905 return '==='; 2912 return '===';
2906 } 2913 }
2907 } 2914 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698