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

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

Issue 1229923005: dart2js: support tear-offs in the startup emitter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix bad assert. Created 5 years, 4 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
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, Statement, Name, Literal, 7 import '../js/js.dart' as js show Expression, Statement, Name, Literal,
8 TokenFinalizer; 8 TokenFinalizer;
9 import '../constants/values.dart' show ConstantValue; 9 import '../constants/values.dart' show ConstantValue;
10 10
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 /// The element should only be used during the transition to the new model. 373 /// The element should only be used during the transition to the new model.
374 /// Uses indicate missing information in the model. 374 /// Uses indicate missing information in the model.
375 final Element element; 375 final Element element;
376 final js.Name name; 376 final js.Name name;
377 final js.Expression code; 377 final js.Expression code;
378 378
379 Method(this.element, this.name, this.code); 379 Method(this.element, this.name, this.code);
380 } 380 }
381 381
382 /// A method that corresponds to a method in the original Dart program. 382 /// A method that corresponds to a method in the original Dart program.
383 class DartMethod extends Method { 383 abstract class DartMethod extends Method {
384 final bool needsTearOff; 384 final bool needsTearOff;
385 final js.Name tearOffName; 385 final js.Name tearOffName;
386 final List<ParameterStubMethod> parameterStubs; 386 final List<ParameterStubMethod> parameterStubs;
387 final bool canBeApplied; 387 final bool canBeApplied;
388 final bool canBeReflected; 388 final bool canBeReflected;
389 389
390 // Is non-null if [needsTearOff] or [canBeReflected]. 390 // Is non-null if [needsTearOff] or [canBeReflected].
391 // 391 //
392 // If the type is encoded in the metadata table this field contains an index 392 // If the type is encoded in the metadata table this field contains an index
393 // into the table. Otherwise the type contains type variables in which case 393 // into the table. Otherwise the type contains type variables in which case
(...skipping 17 matching lines...) Expand all
411 this.optionalParameterDefaultValues, this.functionType}) 411 this.optionalParameterDefaultValues, this.functionType})
412 : super(element, name, code) { 412 : super(element, name, code) {
413 assert(needsTearOff != null); 413 assert(needsTearOff != null);
414 assert(!needsTearOff || tearOffName != null); 414 assert(!needsTearOff || tearOffName != null);
415 assert(canBeApplied != null); 415 assert(canBeApplied != null);
416 assert(canBeReflected != null); 416 assert(canBeReflected != null);
417 assert((!canBeReflected && !canBeApplied) || 417 assert((!canBeReflected && !canBeApplied) ||
418 (requiredParameterCount != null && 418 (requiredParameterCount != null &&
419 optionalParameterDefaultValues != null)); 419 optionalParameterDefaultValues != null));
420 } 420 }
421
422 bool get isStatic;
421 } 423 }
422 424
423 class InstanceMethod extends DartMethod { 425 class InstanceMethod extends DartMethod {
424 /// An alternative name for this method. This is used to model calls to 426 /// An alternative name for this method. This is used to model calls to
425 /// a method via `super`. If [aliasName] is non-null, the emitter has to 427 /// a method via `super`. If [aliasName] is non-null, the emitter has to
426 /// ensure that this method is registered on the prototype under both [name] 428 /// ensure that this method is registered on the prototype under both [name]
427 /// and [aliasName]. 429 /// and [aliasName].
428 final js.Name aliasName; 430 final js.Name aliasName;
429 final bool isClosure; 431 final bool isClosure;
430 432
(...skipping 13 matching lines...) Expand all
444 : super(element, name, code, parameterStubs, callName, 446 : super(element, name, code, parameterStubs, callName,
445 needsTearOff: needsTearOff, 447 needsTearOff: needsTearOff,
446 tearOffName: tearOffName, 448 tearOffName: tearOffName,
447 canBeApplied: canBeApplied, 449 canBeApplied: canBeApplied,
448 canBeReflected: canBeReflected, 450 canBeReflected: canBeReflected,
449 requiredParameterCount: requiredParameterCount, 451 requiredParameterCount: requiredParameterCount,
450 optionalParameterDefaultValues: optionalParameterDefaultValues, 452 optionalParameterDefaultValues: optionalParameterDefaultValues,
451 functionType: functionType) { 453 functionType: functionType) {
452 assert(isClosure != null); 454 assert(isClosure != null);
453 } 455 }
456
457 bool get isStatic => false;
454 } 458 }
455 459
456 /// A method that is generated by the backend and has not direct correspondence 460 /// A method that is generated by the backend and has not direct correspondence
457 /// to a method in the original Dart program. Examples are getter and setter 461 /// to a method in the original Dart program. Examples are getter and setter
458 /// stubs and stubs to dispatch calls to methods with optional parameters. 462 /// stubs and stubs to dispatch calls to methods with optional parameters.
459 class StubMethod extends Method { 463 class StubMethod extends Method {
460 StubMethod(js.Name name, js.Expression code, 464 StubMethod(js.Name name, js.Expression code,
461 {Element element}) 465 {Element element})
462 : super(element, name, code); 466 : super(element, name, code);
463 } 467 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 /* List | Map */ optionalParameterDefaultValues, 503 /* List | Map */ optionalParameterDefaultValues,
500 js.Expression functionType}) 504 js.Expression functionType})
501 : super(element, name, code, parameterStubs, callName, 505 : super(element, name, code, parameterStubs, callName,
502 needsTearOff: needsTearOff, 506 needsTearOff: needsTearOff,
503 tearOffName : tearOffName, 507 tearOffName : tearOffName,
504 canBeApplied : canBeApplied, 508 canBeApplied : canBeApplied,
505 canBeReflected : canBeReflected, 509 canBeReflected : canBeReflected,
506 requiredParameterCount: requiredParameterCount, 510 requiredParameterCount: requiredParameterCount,
507 optionalParameterDefaultValues: optionalParameterDefaultValues, 511 optionalParameterDefaultValues: optionalParameterDefaultValues,
508 functionType: functionType); 512 functionType: functionType);
513
514 bool get isStatic => true;
509 } 515 }
510 516
511 class StaticStubMethod extends StubMethod implements StaticMethod { 517 class StaticStubMethod extends StubMethod implements StaticMethod {
512 Holder holder; 518 Holder holder;
513 StaticStubMethod(js.Name name, this.holder, js.Expression code) 519 StaticStubMethod(js.Name name, this.holder, js.Expression code)
514 : super(name, code); 520 : super(name, code);
515 } 521 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698