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

Side by Side Diff: pkg/compiler/lib/src/js_backend/constant_handler_javascript.dart

Issue 1093363002: Refactor DartTypeVisitor and ElementVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 5 years, 8 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of js_backend; 5 part of js_backend;
6 6
7 /// [ConstantCompilerTask] for compilation of constants for the JavaScript 7 /// [ConstantCompilerTask] for compilation of constants for the JavaScript
8 /// backend. 8 /// backend.
9 /// 9 ///
10 /// Since this task needs to distinguish between frontend and backend constants 10 /// Since this task needs to distinguish between frontend and backend constants
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 ConstantExpression createTypeConstant(TypeDeclarationElement element) { 206 ConstantExpression createTypeConstant(TypeDeclarationElement element) {
207 DartType elementType = element.rawType; 207 DartType elementType = element.rawType;
208 DartType constantType = 208 DartType constantType =
209 compiler.backend.typeImplementation.computeType(compiler); 209 compiler.backend.typeImplementation.computeType(compiler);
210 return new TypeConstantExpression( 210 return new TypeConstantExpression(
211 new TypeConstantValue(elementType, constantType), elementType); 211 new TypeConstantValue(elementType, constantType), elementType);
212 } 212 }
213 213
214 void forgetElement(Element element) { 214 void forgetElement(Element element) {
215 super.forgetElement(element); 215 super.forgetElement(element);
216 element.accept(new ForgetConstantElementVisitor(this)); 216 const ForgetConstantElementVisitor().visit(element, this);
217 if (element is AstElement && element.hasNode) { 217 if (element is AstElement && element.hasNode) {
218 element.node.accept(new ForgetConstantNodeVisitor(this)); 218 element.node.accept(new ForgetConstantNodeVisitor(this));
219 } 219 }
220 } 220 }
221 } 221 }
222 222
223 class ForgetConstantElementVisitor extends ElementVisitor { 223 class ForgetConstantElementVisitor
224 final JavaScriptConstantCompiler constants; 224 extends BaseElementVisitor<dynamic, JavaScriptConstantCompiler> {
225 const ForgetConstantElementVisitor();
225 226
226 ForgetConstantElementVisitor(this.constants); 227 void visitElement(Element e, JavaScriptConstantCompiler constants) {
227
228 void visitElement(Element e) {
229 for (MetadataAnnotation data in e.metadata) { 228 for (MetadataAnnotation data in e.metadata) {
230 constants.metadataConstantMap.remove(data); 229 constants.metadataConstantMap.remove(data);
231 if (data.hasNode) { 230 if (data.hasNode) {
232 data.node.accept(new ForgetConstantNodeVisitor(constants)); 231 data.node.accept(new ForgetConstantNodeVisitor(constants));
233 } 232 }
234 } 233 }
235 } 234 }
236 235
237 void visitFunctionElement(FunctionElement e) { 236 void visitFunctionElement(FunctionElement e,
238 super.visitFunctionElement(e); 237 JavaScriptConstantCompiler constants) {
238 super.visitFunctionElement(e, constants);
239 if (e.hasFunctionSignature) { 239 if (e.hasFunctionSignature) {
240 e.functionSignature.forEachParameter(this.visit); 240 e.functionSignature.forEachParameter((p) => visit(p, constants));
241 } 241 }
242 } 242 }
243 } 243 }
244 244
245 class ForgetConstantNodeVisitor extends Visitor { 245 class ForgetConstantNodeVisitor extends Visitor {
246 final JavaScriptConstantCompiler constants; 246 final JavaScriptConstantCompiler constants;
247 247
248 ForgetConstantNodeVisitor(this.constants); 248 ForgetConstantNodeVisitor(this.constants);
249 249
250 void visitNode(Node node) { 250 void visitNode(Node node) {
251 node.visitChildren(this); 251 node.visitChildren(this);
252 constants.nodeConstantMap.remove(node); 252 constants.nodeConstantMap.remove(node);
253 253
254 // TODO(ahe): This doesn't belong here. Rename this class and generalize. 254 // TODO(ahe): This doesn't belong here. Rename this class and generalize.
255 var closureClassMap = 255 var closureClassMap =
256 constants.compiler.closureToClassMapper.closureMappingCache 256 constants.compiler.closureToClassMapper.closureMappingCache
257 .remove(node); 257 .remove(node);
258 if (closureClassMap != null) { 258 if (closureClassMap != null) {
259 closureClassMap.removeMyselfFrom( 259 closureClassMap.removeMyselfFrom(
260 constants.compiler.enqueuer.codegen.universe); 260 constants.compiler.enqueuer.codegen.universe);
261 } 261 }
262 } 262 }
263 } 263 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/elements/visitor.dart ('k') | pkg/compiler/lib/src/js_backend/js_backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698