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

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

Issue 10915083: Change assert implementation to not depend on a top-level function called 'assert'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. 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
« no previous file with comments | « lib/compiler/implementation/resolver.dart ('k') | lib/compiler/implementation/universe.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 for (int i = 0; i < inputs.length; i++) { 1707 for (int i = 0; i < inputs.length; i++) {
1708 use(inputs[i]); 1708 use(inputs[i]);
1709 arguments.add(pop()); 1709 arguments.add(pop());
1710 } 1710 }
1711 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it 1711 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it
1712 // as if it was a string. 1712 // as if it was a string.
1713 push(new js.New(new js.VariableUse(jsClassReference), arguments), node); 1713 push(new js.New(new js.VariableUse(jsClassReference), arguments), node);
1714 } 1714 }
1715 1715
1716 void generateConstant(Constant constant) { 1716 void generateConstant(Constant constant) {
1717 Namer namer = backend.namer; 1717 ConstantHandler handler = compiler.constantHandler;
1718 if (!constant.isObject()) { 1718 String name = handler.getNameForConstant(constant);
1719 if (name === null) {
1720 assert(!constant.isObject());
1719 if (constant.isBool()) { 1721 if (constant.isBool()) {
1720 push(new js.LiteralBool((constant as BoolConstant).value)); 1722 push(new js.LiteralBool((constant as BoolConstant).value));
1721 } else if (constant.isNum()) { 1723 } else if (constant.isNum()) {
1722 // TODO(floitsch): get rid of the code buffer. 1724 // TODO(floitsch): get rid of the code buffer.
1723 CodeBuffer buffer = new CodeBuffer(); 1725 CodeBuffer buffer = new CodeBuffer();
1724 backend.emitter.writeConstantToBuffer(constant, buffer); 1726 handler.writeConstant(buffer, constant);
1725 push(new js.LiteralNumber(buffer.toString())); 1727 push(new js.LiteralNumber(buffer.toString()));
1726 } else if (constant.isNull()) { 1728 } else if (constant.isNull()) {
1727 push(new js.LiteralNull()); 1729 push(new js.LiteralNull());
1728 } else if (constant.isString()) { 1730 } else if (constant.isString()) {
1729 // TODO(floitsch): get rid of the code buffer. 1731 // TODO(floitsch): get rid of the code buffer.
1730 CodeBuffer buffer = new CodeBuffer(); 1732 CodeBuffer buffer = new CodeBuffer();
1731 backend.emitter.writeConstantToBuffer(constant, buffer); 1733 handler.writeConstant(buffer, constant);
1732 push(new js.LiteralString(buffer.toString())); 1734 push(new js.LiteralString(buffer.toString()));
1733 } else if (constant.isFunction()) { 1735 } else if (constant.isFunction()) {
1734 FunctionConstant function = constant; 1736 FunctionConstant function = constant;
1735 world.registerStaticUse(function.element); 1737 world.registerStaticUse(function.element);
1736 push(new js.VariableUse(namer.isolateAccess(function.element))); 1738 push(new js.VariableUse(
1739 backend.namer.isolateAccess(function.element)));
1737 } else if (constant.isSentinel()) { 1740 } else if (constant.isSentinel()) {
1738 // TODO(floitsch): get rid of the code buffer. 1741 // TODO(floitsch): get rid of the code buffer.
1739 CodeBuffer buffer = new CodeBuffer(); 1742 CodeBuffer buffer = new CodeBuffer();
1740 backend.emitter.writeConstantToBuffer(constant, buffer); 1743 handler.writeConstant(buffer, constant);
1741 push(new js.VariableUse(buffer.toString())); 1744 push(new js.VariableUse(buffer.toString()));
1742 } else { 1745 } else {
1743 compiler.internalError( 1746 compiler.internalError(
1744 "The compiler does not know how generate code for " 1747 "The compiler does not know how generate code for "
1745 "constant $constant"); 1748 "constant $constant");
1746 } 1749 }
1747 } else { 1750 } else {
1748 String name = namer.constantName(constant);
1749 js.VariableUse currentIsolateUse = 1751 js.VariableUse currentIsolateUse =
1750 new js.VariableUse(backend.namer.CURRENT_ISOLATE); 1752 new js.VariableUse(backend.namer.CURRENT_ISOLATE);
1751 push(new js.PropertyAccess.field(currentIsolateUse, name)); 1753 push(new js.PropertyAccess.field(currentIsolateUse, name));
1752 } 1754 }
1753 } 1755 }
1754 1756
1755 visitConstant(HConstant node) { 1757 visitConstant(HConstant node) {
1756 assert(isGenerateAtUseSite(node)); 1758 assert(isGenerateAtUseSite(node));
1757 generateConstant(node.constant); 1759 generateConstant(node.constant);
1758 } 1760 }
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2933 if (leftType.canBeNull() && rightType.canBeNull()) { 2935 if (leftType.canBeNull() && rightType.canBeNull()) {
2934 if (left.isConstantNull() || right.isConstantNull() || 2936 if (left.isConstantNull() || right.isConstantNull() ||
2935 (leftType.isPrimitive() && leftType == rightType)) { 2937 (leftType.isPrimitive() && leftType == rightType)) {
2936 return '=='; 2938 return '==';
2937 } 2939 }
2938 return null; 2940 return null;
2939 } else { 2941 } else {
2940 return '==='; 2942 return '===';
2941 } 2943 }
2942 } 2944 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/resolver.dart ('k') | lib/compiler/implementation/universe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698