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

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

Issue 889693003: dart2js: Use stub instances when generating ParameterStubs (adapterStubMethods). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove unused field. 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
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 // TODO(herhut): Directly store stubs instead/ 334 // TODO(herhut): Directly store stubs instead/
337 final bool needsStubs; 335 final bool needsStubs;
338 // TODO(herhut): Directly store aliases instead. 336 // TODO(herhut): Directly store aliases instead.
339 final bool canBeApplied; 337 final bool canBeApplied;
340 final bool canBeReflected; 338 final bool canBeReflected;
341 339
342 DartMethod(Element element, String name, js.Expression code, 340 DartMethod(Element element, String name, js.Expression code,
(...skipping 25 matching lines...) Expand all
368 needsTearOff: needsTearOff, 366 needsTearOff: needsTearOff,
369 tearOffName: tearOffName, 367 tearOffName: tearOffName,
370 canBeApplied: canBeApplied, 368 canBeApplied: canBeApplied,
371 canBeReflected: canBeReflected, 369 canBeReflected: canBeReflected,
372 needsStubs: needsStubs) { 370 needsStubs: needsStubs) {
373 assert(hasSuperAlias != null); 371 assert(hasSuperAlias != null);
374 assert(isClosure != null); 372 assert(isClosure != null);
375 } 373 }
376 } 374 }
377 375
378 /** 376 /// A method that is generated by the backend and has not direct correspondence
379 * A method that is generated by the backend and has not direct correspondence 377 /// to a method in the original Dart program. Examples are getter and setter
380 * to a method in the original Dart program. Examples are getter and setter 378 /// stubs and stubs to dispatch calls to methods with optional parameters.
381 * stubs and stubs to dispatch calls to methods with optional parameters.
382 */
383 class StubMethod extends Method { 379 class StubMethod extends Method {
384 StubMethod(String name, js.Expression code, 380 StubMethod(String name, js.Expression code,
385 {Element element}) 381 {Element element})
386 : super(element, name, code); 382 : super(element, name, code);
387 } 383 }
388 384
385
386 /// A method that adapts a call to the methods calling convention.
387 ///
388 /// For example, given a method `foo$2(x, [y: 499])` a possible adapter
389 /// stub-method could be `foo$1(x) => foo$2(x, 499)`.
390 ///
391 /// AdapterStubMethods are always attached to (static or instance) methods.
392 class AdapterStubMethod extends StubMethod {
393 /// The `call` name of this adapter.
394 ///
395 /// When an instance method is torn off, it is invoked as a `call` member and
396 /// not it's original name anymore. The [callName] provides the adapter's
397 /// name when it is used this way.
398 ///
399 /// If an adapter's member can not be torn off, the [callName] is `null`.
400 String callName;
401
402 AdapterStubMethod(String name, this.callName, js.Expression code)
403 : super(name, code);
404 }
405
389 abstract class StaticMethod implements Method { 406 abstract class StaticMethod implements Method {
390 Holder get holder; 407 Holder get holder;
391 } 408 }
392 409
393 class StaticDartMethod extends DartMethod implements StaticMethod { 410 class StaticDartMethod extends DartMethod implements StaticMethod {
394 final Holder holder; 411 final Holder holder;
395 412
396 StaticDartMethod(Element element, String name, this.holder, 413 StaticDartMethod(Element element, String name, this.holder,
397 js.Expression code, 414 js.Expression code,
398 {bool needsTearOff, String tearOffName, bool canBeApplied, 415 {bool needsTearOff, String tearOffName, bool canBeApplied,
399 bool canBeReflected, bool needsStubs}) 416 bool canBeReflected, bool needsStubs})
400 : super(element, name, code, 417 : super(element, name, code,
401 needsTearOff: needsTearOff, 418 needsTearOff: needsTearOff,
402 tearOffName : tearOffName, 419 tearOffName : tearOffName,
403 canBeApplied : canBeApplied, 420 canBeApplied : canBeApplied,
404 canBeReflected : canBeReflected, 421 canBeReflected : canBeReflected,
405 needsStubs : needsStubs); 422 needsStubs : needsStubs);
406 } 423 }
407 424
408 class StaticStubMethod extends StubMethod implements StaticMethod { 425 class StaticStubMethod extends StubMethod implements StaticMethod {
409 Holder holder; 426 Holder holder;
410 StaticStubMethod(String name, this.holder, js.Expression code) 427 StaticStubMethod(String name, this.holder, js.Expression code)
411 : super(name, code); 428 : super(name, code);
412 } 429 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698