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

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

Issue 928203003: Implement Function.apply in the new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor fix 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, Statement; 7 import '../js/js.dart' as js show Expression, Statement;
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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 /// A method that corresponds to a method in the original Dart program. 343 /// A method that corresponds to a method in the original Dart program.
344 class DartMethod extends Method { 344 class DartMethod extends Method {
345 final bool needsTearOff; 345 final bool needsTearOff;
346 final String tearOffName; 346 final String tearOffName;
347 final List<ParameterStubMethod> parameterStubs; 347 final List<ParameterStubMethod> parameterStubs;
348 final bool canBeApplied; 348 final bool canBeApplied;
349 final bool canBeReflected; 349 final bool canBeReflected;
350 final DartType type; 350 final DartType type;
351 351
352 // Signature information for this method. This is only required and stored
353 // here if the method [canBeApplied] or [canBeReflected]
354 final int requiredParameterCount;
355 final /* Map | List */ optionalParameterDefaultValues;
356
352 // If this method can be torn off, contains the name of the corresponding 357 // If this method can be torn off, contains the name of the corresponding
353 // call method. For example, for the member `foo$1$name` it would be 358 // call method. For example, for the member `foo$1$name` it would be
354 // `call$1$name` (in unminified mode). 359 // `call$1$name` (in unminified mode).
355 final String callName; 360 final String callName;
356 361
357 DartMethod(Element element, String name, js.Expression code, 362 DartMethod(Element element, String name, js.Expression code,
358 this.parameterStubs, this.callName, this.type, 363 this.parameterStubs, this.callName, this.type,
359 {this.needsTearOff, this.tearOffName, this.canBeApplied, 364 {this.needsTearOff, this.tearOffName, this.canBeApplied,
360 this.canBeReflected}) 365 this.canBeReflected, this.requiredParameterCount,
366 this.optionalParameterDefaultValues})
361 : super(element, name, code) { 367 : super(element, name, code) {
362 assert(needsTearOff != null); 368 assert(needsTearOff != null);
363 assert(!needsTearOff || tearOffName != null); 369 assert(!needsTearOff || tearOffName != null);
364 assert(canBeApplied != null); 370 assert(canBeApplied != null);
365 assert(canBeReflected != null); 371 assert(canBeReflected != null);
372 assert((!canBeReflected && !canBeApplied) ||
373 (requiredParameterCount != null &&
374 optionalParameterDefaultValues != null));
366 } 375 }
367 } 376 }
368 377
369 class InstanceMethod extends DartMethod { 378 class InstanceMethod extends DartMethod {
370 /// An alternative name for this method. This is used to model calls to 379 /// An alternative name for this method. This is used to model calls to
371 /// a method via `super`. If [aliasName] is non-null, the emitter has to 380 /// a method via `super`. If [aliasName] is non-null, the emitter has to
372 /// ensure that this method is registered on the prototype under both [name] 381 /// ensure that this method is registered on the prototype under both [name]
373 /// and [aliasName]. 382 /// and [aliasName].
374 final String aliasName; 383 final String aliasName;
375 final bool isClosure; 384 final bool isClosure;
376 385
377 386
378 InstanceMethod(Element element, String name, js.Expression code, 387 InstanceMethod(Element element, String name, js.Expression code,
379 List<ParameterStubMethod> parameterStubs, 388 List<ParameterStubMethod> parameterStubs,
380 String callName, DartType type, 389 String callName, DartType type,
381 {bool needsTearOff, 390 {bool needsTearOff,
382 String tearOffName, 391 String tearOffName,
383 this.aliasName, 392 this.aliasName,
384 bool canBeApplied, 393 bool canBeApplied,
385 bool canBeReflected, 394 bool canBeReflected,
386 this.isClosure}) 395 int requiredParameterCount,
396 /* List | Map */ optionalParameterDefaultValues,
397 this.isClosure})
387 : super(element, name, code, parameterStubs, callName, type, 398 : super(element, name, code, parameterStubs, callName, type,
388 needsTearOff: needsTearOff, 399 needsTearOff: needsTearOff,
389 tearOffName: tearOffName, 400 tearOffName: tearOffName,
390 canBeApplied: canBeApplied, 401 canBeApplied: canBeApplied,
391 canBeReflected: canBeReflected) { 402 canBeReflected: canBeReflected,
403 requiredParameterCount: requiredParameterCount,
404 optionalParameterDefaultValues: optionalParameterDefaultValues) {
392 assert(isClosure != null); 405 assert(isClosure != null);
393 } 406 }
394 } 407 }
395 408
396 /// A method that is generated by the backend and has not direct correspondence 409 /// A method that is generated by the backend and has not direct correspondence
397 /// to a method in the original Dart program. Examples are getter and setter 410 /// to a method in the original Dart program. Examples are getter and setter
398 /// stubs and stubs to dispatch calls to methods with optional parameters. 411 /// stubs and stubs to dispatch calls to methods with optional parameters.
399 class StubMethod extends Method { 412 class StubMethod extends Method {
400 StubMethod(String name, js.Expression code, 413 StubMethod(String name, js.Expression code,
401 {Element element}) 414 {Element element})
(...skipping 25 matching lines...) Expand all
427 Holder get holder; 440 Holder get holder;
428 } 441 }
429 442
430 class StaticDartMethod extends DartMethod implements StaticMethod { 443 class StaticDartMethod extends DartMethod implements StaticMethod {
431 final Holder holder; 444 final Holder holder;
432 445
433 StaticDartMethod(Element element, String name, this.holder, 446 StaticDartMethod(Element element, String name, this.holder,
434 js.Expression code, List<ParameterStubMethod> parameterStubs, 447 js.Expression code, List<ParameterStubMethod> parameterStubs,
435 String callName, DartType type, 448 String callName, DartType type,
436 {bool needsTearOff, String tearOffName, bool canBeApplied, 449 {bool needsTearOff, String tearOffName, bool canBeApplied,
437 bool canBeReflected}) 450 bool canBeReflected, int requiredParameterCount,
451 /* List | Map */ optionalParameterDefaultValues})
438 : super(element, name, code, parameterStubs, callName, type, 452 : super(element, name, code, parameterStubs, callName, type,
439 needsTearOff: needsTearOff, 453 needsTearOff: needsTearOff,
440 tearOffName : tearOffName, 454 tearOffName : tearOffName,
441 canBeApplied : canBeApplied, 455 canBeApplied : canBeApplied,
442 canBeReflected : canBeReflected); 456 canBeReflected : canBeReflected,
457 requiredParameterCount: requiredParameterCount,
458 optionalParameterDefaultValues: optionalParameterDefaultValues);
443 } 459 }
444 460
445 class StaticStubMethod extends StubMethod implements StaticMethod { 461 class StaticStubMethod extends StubMethod implements StaticMethod {
446 Holder holder; 462 Holder holder;
447 StaticStubMethod(String name, this.holder, js.Expression code) 463 StaticStubMethod(String name, this.holder, js.Expression code)
448 : super(name, code); 464 : super(name, code);
449 } 465 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698