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

Side by Side Diff: compiler/java/com/google/dart/compiler/backend/js/analysis/TopLevelElementIndexer.java

Issue 8676041: JS tree shaking for incremental builds. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: DartCompilerWarmup doesn't write files ending in *.app.js* Created 9 years 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 package com.google.dart.compiler.backend.js.analysis; 5 package com.google.dart.compiler.backend.js.analysis;
6 6
7 import org.mozilla.javascript.Token; 7 import org.mozilla.javascript.Token;
8 import org.mozilla.javascript.ast.Assignment; 8 import org.mozilla.javascript.ast.Assignment;
9 import org.mozilla.javascript.ast.AstNode; 9 import org.mozilla.javascript.ast.AstNode;
10 import org.mozilla.javascript.ast.ExpressionStatement; 10 import org.mozilla.javascript.ast.ExpressionStatement;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 for (Entry<String, List<JavascriptElement>> entry : entrySet) { 109 for (Entry<String, List<JavascriptElement>> entry : entrySet) {
110 System.out.println("--------"); 110 System.out.println("--------");
111 System.out.println("Name: " + entry.getKey()); 111 System.out.println("Name: " + entry.getKey());
112 for (JavascriptElement javascriptElement : entry.getValue()) { 112 for (JavascriptElement javascriptElement : entry.getValue()) {
113 AstNode node = javascriptElement.getNode(); 113 AstNode node = javascriptElement.getNode();
114 if (node == null) { 114 if (node == null) {
115 continue; 115 continue;
116 } 116 }
117 117
118 System.out.println("Type: " + Token.typeToName(node.getType())); 118 System.out.println("Type: " + Token.typeToName(node.getType()));
119 if (javascriptElement.getInherits() != null) { 119 if (javascriptElement.getInheritsElement() != null) {
120 System.out.println("Inherits: " + javascriptElement.getInherits()); 120 System.out.println("Inherits: " + javascriptElement.getInheritsElement ());
121 } 121 }
122 122
123 try { 123 try {
124 System.out.println(node.toSource()); 124 System.out.println(node.toSource());
125 } catch (Exception e) { 125 } catch (Exception e) {
126 System.out.println("Failed to print node source code"); 126 System.out.println("Failed to print node source code");
127 } 127 }
128 128
129 String name = javascriptElement.getName(); 129 String name = javascriptElement.getName();
130 if (name.endsWith("$named")) { 130 if (name.endsWith("$named")) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (expression.getType() == Token.CALL) { 177 if (expression.getType() == Token.CALL) {
178 FunctionCall functionCall = (FunctionCall) expression; 178 FunctionCall functionCall = (FunctionCall) expression;
179 AstNode target = functionCall.getTarget(); 179 AstNode target = functionCall.getTarget();
180 if (target.getType() == Token.NAME) { 180 if (target.getType() == Token.NAME) {
181 Name targetName = (Name) target; 181 Name targetName = (Name) target;
182 if (RUN_ENTRY_METHOD_NAME.equals(targetName.getIdentifier())) { 182 if (RUN_ENTRY_METHOD_NAME.equals(targetName.getIdentifier())) {
183 // This is a call to an entry point so add it to the known set of en try points. 183 // This is a call to an entry point so add it to the known set of en try points.
184 entryPoints.add(node); 184 entryPoints.add(node);
185 return; 185 return;
186 } else if ("$inherits".equals(targetName.getIdentifier())) { 186 } else if ("$inherits".equals(targetName.getIdentifier())) {
187 // This is an inheirts call so update the element's inheritance hier archy. 187 // This is an inherits call so update the element's inheritance hier archy.
188 List<AstNode> arguments = functionCall.getArguments(); 188 List<AstNode> arguments = functionCall.getArguments();
189 assert (arguments.size() == 2); 189 assert (arguments.size() == 2);
190 assert (arguments.get(0).getType() == Token.NAME); 190 assert (arguments.get(0).getType() == Token.NAME);
191 assert (arguments.get(1).getType() == Token.NAME); 191 assert (arguments.get(1).getType() == Token.NAME);
192 Name subtype = (Name) arguments.get(0); 192 Name subtype = (Name) arguments.get(0);
193 Name supertype = (Name) arguments.get(1); 193 Name supertype = (Name) arguments.get(1);
194 List<JavascriptElement> subTypeFunctions = namesToElements.get(subty pe.getIdentifier()); 194 List<JavascriptElement> subTypeFunctions = namesToElements.get(subty pe.getIdentifier());
195 assert (subTypeFunctions != null && subTypeFunctions.size() == 1); 195 assert (subTypeFunctions != null && subTypeFunctions.size() == 1);
196 JavascriptElement subtypeFunction = subTypeFunctions.get(0); 196 JavascriptElement subtypeFunction = subTypeFunctions.get(0);
197 subtypeFunction.setInheritsNode(node); 197 subtypeFunction.setInheritsNode(node);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 break; 274 break;
275 275
276 default: 276 default:
277 processGlobal(node); 277 processGlobal(node);
278 break; 278 break;
279 } 279 }
280 280
281 return false; 281 return false;
282 } 282 }
283 } 283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698