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

Unified Diff: lib/compiler/implementation/dart_backend/backend.dart

Issue 10918278: Remove asserts from minified program. (Closed) Base URL: https://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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/dart_backend/backend.dart
diff --git a/lib/compiler/implementation/dart_backend/backend.dart b/lib/compiler/implementation/dart_backend/backend.dart
index f8436915f549084f126612d43627f88d6f351c85..9861c5b8a18e054b3a18d9a33d0b3de989cd4c35 100644
--- a/lib/compiler/implementation/dart_backend/backend.dart
+++ b/lib/compiler/implementation/dart_backend/backend.dart
@@ -2,14 +2,16 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+const bool REMOVE_ASSERTS = false;
+
class ElementAst {
final Node ast;
final TreeElements treeElements;
ElementAst(this.ast, this.treeElements);
- factory ElementAst.rewrite(ast, treeElements) {
- final rewriter = new FunctionBodyRewriter(treeElements);
+ factory ElementAst.rewrite(compiler, ast, treeElements) {
+ final rewriter = new FunctionBodyRewriter(compiler, treeElements);
return new ElementAst(rewriter.visit(ast), rewriter.cloneTreeElements);
}
@@ -60,10 +62,25 @@ class VariableListAst extends ElementAst {
}
class FunctionBodyRewriter extends CloningVisitor {
- FunctionBodyRewriter(originalTreeElements) : super(originalTreeElements);
+ final Compiler compiler;
+
+ FunctionBodyRewriter(this.compiler, originalTreeElements)
+ : super(originalTreeElements);
visitFunctionExpression(FunctionExpression node) {
- shouldOmit(Statement statement) => statement is EmptyStatement;
+ shouldOmit(Statement statement) {
+ if (statement is EmptyStatement) return true;
+ if (statement is ExpressionStatement) {
+ Send send = statement.expression.asSend();
+ if (send !== null) {
+ Element element = originalTreeElements[send];
+ if (REMOVE_ASSERTS && element === compiler.assertMethod) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
rewriteBody(Statement body) {
if (body is !Block) return visit(body);
@@ -198,7 +215,7 @@ class DartBackend extends Backend {
resolvedElements.forEach((element, treeElements) {
if (!shouldOutput(element)) return;
- var elementAst = new ElementAst.rewrite(parse(element), treeElements);
+ var elementAst = new ElementAst.rewrite(compiler, parse(element), treeElements);
Roman 2012/09/18 09:57:43 80 chars
if (element.isField()) {
final list = (element as VariableElement).variables;
elementAst = elementAsts.putIfAbsent(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698