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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/model.dart

Issue 886053004: dart2js: Refactor how parameter stubs are handled. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/old_emitter/container_builder.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library dart2js.new_js_emitter.model; 5 library dart2js.new_js_emitter.model;
6 6
7 import '../js/js.dart' as js show Expression; 7 import '../js/js.dart' as js show Expression;
8 import '../constants/values.dart' show ConstantValue; 8 import '../constants/values.dart' show ConstantValue;
9 9
10 import '../deferred_load.dart' show OutputUnit; 10 import '../deferred_load.dart' show OutputUnit;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 abstract class Method { 320 abstract class Method {
321 /// The element should only be used during the transition to the new model. 321 /// The element should only be used during the transition to the new model.
322 /// Uses indicate missing information in the model. 322 /// Uses indicate missing information in the model.
323 final Element element; 323 final Element element;
324 final String name; 324 final String name;
325 final js.Expression code; 325 final js.Expression code;
326 326
327 Method(this.element, this.name, this.code); 327 Method(this.element, this.name, this.code);
328 } 328 }
329 329
330 /** 330 /// A method that corresponds to a method in the original Dart program.
331 * A method that corresponds to a method in the original Dart program.
332 */
333 class DartMethod extends Method { 331 class DartMethod extends Method {
334 final bool needsTearOff; 332 final bool needsTearOff;
335 final String tearOffName; 333 final String tearOffName;
336 final List<ParameterStubMethod> parameterStubs; 334 final List<ParameterStubMethod> parameterStubs;
337 // TODO(herhut): Directly store aliases instead. 335 // TODO(herhut): Directly store aliases instead.
338 final bool canBeApplied; 336 final bool canBeApplied;
339 final bool canBeReflected; 337 final bool canBeReflected;
340 338
339 // If this method can be torn off, contains the name of the corresponding
340 // call method. For example, for the member `foo$1$name` it would be
341 // `call$1$name` (in unminified mode).
342 final String callName;
343
341 DartMethod(Element element, String name, js.Expression code, 344 DartMethod(Element element, String name, js.Expression code,
342 this.parameterStubs, 345 this.parameterStubs, this.callName,
343 {this.needsTearOff, this.tearOffName, this.canBeApplied, 346 {this.needsTearOff, this.tearOffName, this.canBeApplied,
344 this.canBeReflected}) 347 this.canBeReflected})
345 : super(element, name, code) { 348 : super(element, name, code) {
346 assert(needsTearOff != null); 349 assert(needsTearOff != null);
347 assert(!needsTearOff || tearOffName != null); 350 assert(!needsTearOff || tearOffName != null);
348 assert(canBeApplied != null); 351 assert(canBeApplied != null);
349 assert(parameterStubs != null);
350 assert(canBeReflected != null); 352 assert(canBeReflected != null);
351 } 353 }
352 } 354 }
353 355
354 class InstanceMethod extends DartMethod { 356 class InstanceMethod extends DartMethod {
355 // TODO(herhut): Directly store aliases instead. 357 // TODO(herhut): Directly store aliases instead.
356 final bool hasSuperAlias; 358 final bool hasSuperAlias;
357 final bool isClosure; 359 final bool isClosure;
358 360
359 InstanceMethod(element, name, code, List<ParameterStubMethod> parameterStubs, 361 InstanceMethod(Element element, String name, js.Expression code,
360 {bool needsTearOff, 362 List<ParameterStubMethod> parameterStubs,
361 String tearOffName, 363 String callName,
362 this.hasSuperAlias, 364 {bool needsTearOff,
363 bool canBeApplied, 365 String tearOffName,
364 bool canBeReflected, 366 this.hasSuperAlias,
367 bool canBeApplied,
368 bool canBeReflected,
365 this.isClosure}) 369 this.isClosure})
366 : super(element, name, code, parameterStubs, 370 : super(element, name, code, parameterStubs, callName,
367 needsTearOff: needsTearOff, 371 needsTearOff: needsTearOff,
368 tearOffName: tearOffName, 372 tearOffName: tearOffName,
369 canBeApplied: canBeApplied, 373 canBeApplied: canBeApplied,
370 canBeReflected: canBeReflected) { 374 canBeReflected: canBeReflected) {
371 assert(hasSuperAlias != null); 375 assert(hasSuperAlias != null);
372 assert(isClosure != null); 376 assert(isClosure != null);
373 } 377 }
374 } 378 }
375 379
376 /** 380 /// A method that is generated by the backend and has not direct correspondence
377 * A method that is generated by the backend and has not direct correspondence 381 /// to a method in the original Dart program. Examples are getter and setter
378 * to a method in the original Dart program. Examples are getter and setter 382 /// stubs and stubs to dispatch calls to methods with optional parameters.
379 * stubs and stubs to dispatch calls to methods with optional parameters.
380 */
381 class StubMethod extends Method { 383 class StubMethod extends Method {
382 StubMethod(String name, js.Expression code, 384 StubMethod(String name, js.Expression code,
383 {Element element}) 385 {Element element})
384 : super(element, name, code); 386 : super(element, name, code);
385 } 387 }
386 388
387 /// A method that is generated for the different versions of method calls of 389 /// A stub that adapts and redirects to the main method (the one containing)
388 /// methods with named parameters, 390 /// the actual code.
389 /// 391 ///
390 /// For example, for a method foo(a, b, {c, d}) that is called as 392 /// For example, given a method `foo$2(x, [y: 499])` a possible parameter
391 /// foo(1, 2, c: 3), we have the stub 393 /// stub-method could be `foo$1(x) => foo$2(x, 499)`.
392 /// foo$3$c(a, b, c) => foo$4$c$d(a, b, c, null); 394 ///
395 /// ParameterStubMethods are always attached to (static or instance) methods.
393 class ParameterStubMethod extends StubMethod { 396 class ParameterStubMethod extends StubMethod {
394 final Selector selector; 397 /// The `call` name of this stub.
395 ParameterStubMethod(String name, js.Expression code, this.selector, 398 ///
396 {Element element}) 399 /// When an instance method is torn off, it is invoked as a `call` member and
397 : super(name, code, element: element); 400 /// not it's original name anymore. The [callName] provides the stub's
401 /// name when it is used this way.
402 ///
403 /// If a stub's member can not be torn off, the [callName] is `null`.
404 String callName;
405
406 ParameterStubMethod(String name, this.callName, js.Expression code)
407 : super(name, code);
398 } 408 }
399 409
400 abstract class StaticMethod implements Method { 410 abstract class StaticMethod implements Method {
401 Holder get holder; 411 Holder get holder;
402 } 412 }
403 413
404 class StaticDartMethod extends DartMethod implements StaticMethod { 414 class StaticDartMethod extends DartMethod implements StaticMethod {
405 final Holder holder; 415 final Holder holder;
406 416
407 StaticDartMethod(Element element, String name, this.holder, 417 StaticDartMethod(Element element, String name, this.holder,
408 js.Expression code, parameterStubs, 418 js.Expression code, List<ParameterStubMethod> parameterStubs,
419 String callName,
409 {bool needsTearOff, String tearOffName, bool canBeApplied, 420 {bool needsTearOff, String tearOffName, bool canBeApplied,
410 bool canBeReflected}) 421 bool canBeReflected})
411 : super(element, name, code, parameterStubs, 422 : super(element, name, code, parameterStubs, callName,
412 needsTearOff: needsTearOff, 423 needsTearOff: needsTearOff,
413 tearOffName : tearOffName, 424 tearOffName : tearOffName,
414 canBeApplied : canBeApplied, 425 canBeApplied : canBeApplied,
415 canBeReflected : canBeReflected); 426 canBeReflected : canBeReflected);
416 } 427 }
417 428
418 class StaticStubMethod extends StubMethod implements StaticMethod { 429 class StaticStubMethod extends StubMethod implements StaticMethod {
419 Holder holder; 430 Holder holder;
420 StaticStubMethod(String name, this.holder, js.Expression code) 431 StaticStubMethod(String name, this.holder, js.Expression code)
421 : super(name, code); 432 : super(name, code);
422 } 433 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/old_emitter/container_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698