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

Unified Diff: compiler/java/com/google/dart/compiler/backend/js/JsConstructExpressionVisitor.java

Issue 9479013: Remove backends. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More clean up Created 8 years, 10 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
Index: compiler/java/com/google/dart/compiler/backend/js/JsConstructExpressionVisitor.java
diff --git a/compiler/java/com/google/dart/compiler/backend/js/JsConstructExpressionVisitor.java b/compiler/java/com/google/dart/compiler/backend/js/JsConstructExpressionVisitor.java
deleted file mode 100644
index 8d70657a31e7d925580abfc62d3328972735f045..0000000000000000000000000000000000000000
--- a/compiler/java/com/google/dart/compiler/backend/js/JsConstructExpressionVisitor.java
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// 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.
-
-package com.google.dart.compiler.backend.js;
-
-import com.google.dart.compiler.backend.js.ast.JsArrayAccess;
-import com.google.dart.compiler.backend.js.ast.JsArrayLiteral;
-import com.google.dart.compiler.backend.js.ast.JsContext;
-import com.google.dart.compiler.backend.js.ast.JsExpression;
-import com.google.dart.compiler.backend.js.ast.JsFunction;
-import com.google.dart.compiler.backend.js.ast.JsInvocation;
-import com.google.dart.compiler.backend.js.ast.JsNameRef;
-import com.google.dart.compiler.backend.js.ast.JsNew;
-import com.google.dart.compiler.backend.js.ast.JsObjectLiteral;
-import com.google.dart.compiler.backend.js.ast.JsVisitable;
-import com.google.dart.compiler.backend.js.ast.JsVisitor;
-
-/**
- * Searches for method invocations in constructor expressions that would not
- * normally be surrounded by parentheses.
- */
-public class JsConstructExpressionVisitor extends JsVisitor {
-
- public static boolean exec(JsExpression expression) {
- if (JsPrecedenceVisitor.exec(expression) < JsPrecedenceVisitor.PRECEDENCE_NEW) {
- return true;
- }
- JsConstructExpressionVisitor visitor = new JsConstructExpressionVisitor();
- visitor.accept(expression);
- return visitor.containsInvocation;
- }
-
- private boolean containsInvocation = false;
-
- private JsConstructExpressionVisitor() {
- }
-
- /**
- * We only look at the array expression since the index has its own scope.
- */
- @Override
- public boolean visit(JsArrayAccess x, JsContext ctx) {
- accept(x.getArrayExpr());
- return false;
- }
-
- /**
- * Array literals have their own scoping.
- */
- @Override
- public boolean visit(JsArrayLiteral x, JsContext ctx) {
- return false;
- }
-
- /**
- * Functions have their own scoping.
- */
- @Override
- public boolean visit(JsFunction x, JsContext ctx) {
- return false;
- }
-
- @Override
- public boolean visit(JsInvocation x, JsContext ctx) {
- containsInvocation = true;
- return false;
- }
-
- @Override
- public boolean visit(JsNameRef x, JsContext ctx) {
- if (!x.isLeaf()) {
- accept(x.getQualifier());
- }
- return false;
- }
-
- /**
- * New constructs bind to the nearest set of parentheses.
- */
- @Override
- public boolean visit(JsNew x, JsContext ctx) {
- return false;
- }
-
- /**
- * Object literals have their own scope.
- */
- @Override
- public boolean visit(JsObjectLiteral x, JsContext ctx) {
- return false;
- }
-
- /**
- * We only look at nodes that would not normally be surrounded by parentheses.
- */
- @Override
- protected <T extends JsVisitable> T doAccept(T node) {
- // Assign to Object to prevent 'inconvertible types' compile errors due
- // to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6548436
- // reproducible in jdk1.6.0_02.
- Object o = node;
- if (o instanceof JsExpression) {
- JsExpression expression = (JsExpression) o;
- int precedence = JsPrecedenceVisitor.exec(expression);
- // Only visit expressions that won't automatically be surrounded by
- // parentheses
- if (precedence < JsPrecedenceVisitor.PRECEDENCE_NEW) {
- return node;
- }
- }
- return super.doAccept(node);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698