| 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 a55e65211c3d229b18e58f8b0ace31d2af8da887..bef20f6d6e9b73d9d3cf9d2dc80c4c398b25418f 100644
|
| --- a/lib/compiler/implementation/dart_backend/backend.dart
|
| +++ b/lib/compiler/implementation/dart_backend/backend.dart
|
| @@ -2,16 +2,15 @@
|
| // 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(compiler, ast, treeElements) {
|
| - final rewriter = new FunctionBodyRewriter(compiler, treeElements);
|
| + factory ElementAst.rewrite(compiler, ast, treeElements, stripAsserts) {
|
| + final rewriter =
|
| + new FunctionBodyRewriter(compiler, treeElements, stripAsserts);
|
| return new ElementAst(rewriter.visit(ast), rewriter.cloneTreeElements);
|
| }
|
|
|
| @@ -63,8 +62,9 @@ class VariableListAst extends ElementAst {
|
|
|
| class FunctionBodyRewriter extends CloningVisitor {
|
| final Compiler compiler;
|
| + final bool stripAsserts;
|
|
|
| - FunctionBodyRewriter(this.compiler, originalTreeElements)
|
| + FunctionBodyRewriter(this.compiler, originalTreeElements, this.stripAsserts)
|
| : super(originalTreeElements);
|
|
|
| visitFunctionExpression(FunctionExpression node) {
|
| @@ -74,7 +74,7 @@ class FunctionBodyRewriter extends CloningVisitor {
|
| Send send = statement.expression.asSend();
|
| if (send !== null) {
|
| Element element = originalTreeElements[send];
|
| - if (REMOVE_ASSERTS && element === compiler.assertMethod) {
|
| + if (stripAsserts && element === compiler.assertMethod) {
|
| return true;
|
| }
|
| }
|
| @@ -114,7 +114,8 @@ class FunctionBodyRewriter extends CloningVisitor {
|
|
|
| class DartBackend extends Backend {
|
| final List<CompilerTask> tasks;
|
| - final bool forceCutDeclarationTypes;
|
| + final bool forceStripTypes;
|
| + final bool stripAsserts;
|
| // TODO(antonm): make available from command-line options.
|
| final bool outputAst = false;
|
|
|
| @@ -187,8 +188,10 @@ class DartBackend extends Backend {
|
| return true;
|
| }
|
|
|
| - DartBackend(Compiler compiler, this.forceCutDeclarationTypes)
|
| + DartBackend(Compiler compiler, List<String> strips)
|
| : tasks = <CompilerTask>[],
|
| + forceStripTypes = strips.indexOf('types') != -1,
|
| + stripAsserts = strips.indexOf('asserts') != -1,
|
| super(compiler);
|
|
|
| void enqueueHelpers(Enqueuer world) {
|
| @@ -306,8 +309,8 @@ class DartBackend extends Backend {
|
| resolvedElements.forEach((element, treeElements) {
|
| if (!shouldOutput(element)) return;
|
|
|
| - var elementAst =
|
| - new ElementAst.rewrite(compiler, parse(element), treeElements);
|
| + var elementAst = new ElementAst.rewrite(
|
| + compiler, parse(element), treeElements, stripAsserts);
|
| if (element.isField()) {
|
| final list = (element as VariableElement).variables;
|
| elementAst = elementAsts.putIfAbsent(
|
| @@ -383,7 +386,7 @@ class DartBackend extends Backend {
|
| // Create renames.
|
| Map<Node, String> renames = new Map<Node, String>();
|
| Map<LibraryElement, String> imports = new Map<LibraryElement, String>();
|
| - bool shouldCutDeclarationTypes = forceCutDeclarationTypes
|
| + bool shouldCutDeclarationTypes = forceStripTypes
|
| || (compiler.enableMinification
|
| && isSafeToRemoveTypeDeclarations(classMembers));
|
| renamePlaceholders(
|
|
|