Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 this.getterFlags, this.setterFlags, | 280 this.getterFlags, this.setterFlags, |
| 281 this.needsCheckedSetter); | 281 this.needsCheckedSetter); |
| 282 | 282 |
| 283 bool get needsGetter => getterFlags != 0; | 283 bool get needsGetter => getterFlags != 0; |
| 284 bool get needsUncheckedSetter => setterFlags != 0; | 284 bool get needsUncheckedSetter => setterFlags != 0; |
| 285 | 285 |
| 286 bool get needsInterceptedGetter => getterFlags > 1; | 286 bool get needsInterceptedGetter => getterFlags > 1; |
| 287 bool get needsInterceptedSetter => setterFlags > 1; | 287 bool get needsInterceptedSetter => setterFlags > 1; |
| 288 } | 288 } |
| 289 | 289 |
| 290 class Method { | 290 abstract class Method { |
| 291 /// The element should only be used during the transition to the new model. | 291 /// The element should only be used during the transition to the new model. |
| 292 /// Uses indicate missing information in the model. | 292 /// Uses indicate missing information in the model. |
| 293 final Element element; | 293 final Element element; |
| 294 | |
| 295 final String name; | 294 final String name; |
| 296 final js.Expression code; | 295 final js.Expression code; |
| 296 | |
| 297 Method(this.element, this.name, this.code); | |
| 298 } | |
| 299 | |
| 300 class DartMethod extends Method { | |
|
floitsch
2015/01/28 16:10:39
Add comment what a "DartMethod" is.
herhut
2015/01/29 10:24:21
Done.
| |
| 297 final bool needsTearOff; | 301 final bool needsTearOff; |
| 302 final String tearOffName; | |
| 303 // TODO(herhut): Directly store stubs instead/ | |
| 304 final bool needsStubs; | |
| 305 // TODO(herhut): Directly store aliases instead. | |
| 306 final bool canBeApplied; | |
| 307 final bool canBeReflected; | |
|
floitsch
2015/01/28 16:10:39
It would be an option to keep the "canBeReflected"
herhut
2015/01/29 10:24:20
I will remove it again later if it can be pushed i
| |
| 298 | 308 |
| 299 Method(this.element, this.name, this.code, {this.needsTearOff}) { | 309 DartMethod(Element element, String name, js.Expression code, |
| 310 {this.needsTearOff, this.tearOffName, this.needsStubs, this.canBeApplied, | |
| 311 this.canBeReflected}) | |
|
floitsch
2015/01/28 16:10:39
nit: indent one less.
herhut
2015/01/29 10:24:20
Done.
| |
| 312 : super(element, name, code) { | |
| 300 assert(needsTearOff != null); | 313 assert(needsTearOff != null); |
| 314 assert(!needsTearOff || tearOffName != null); | |
| 315 assert(canBeApplied != null); | |
| 316 assert(canBeReflected != null); | |
| 317 assert(needsStubs != null); | |
| 318 } | |
| 319 } | |
| 320 | |
| 321 class InstanceMethod extends DartMethod { | |
| 322 // TODO(herhut): Directly store aliases instead. | |
| 323 final bool hasSuperAlias; | |
| 324 final bool isClosure; | |
| 325 | |
| 326 InstanceMethod(element, name, code, | |
| 327 {bool needsTearOff, | |
| 328 String tearOffName, | |
| 329 this.hasSuperAlias, | |
| 330 bool canBeApplied, | |
| 331 bool canBeReflected, | |
| 332 this.isClosure, | |
| 333 bool needsStubs}) | |
| 334 : super(element, name, code, | |
| 335 needsTearOff: needsTearOff, | |
|
floitsch
2015/01/28 16:10:39
I would align with "(".
herhut
2015/01/29 10:24:20
Done.
| |
| 336 tearOffName: tearOffName, | |
| 337 canBeApplied: canBeApplied, | |
| 338 canBeReflected: canBeReflected, | |
| 339 needsStubs: needsStubs) { | |
| 340 assert(hasSuperAlias != null); | |
| 341 assert(isClosure != null); | |
| 301 } | 342 } |
| 302 } | 343 } |
| 303 | 344 |
| 304 class StubMethod extends Method { | 345 class StubMethod extends Method { |
| 305 StubMethod(String name, js.Expression code, | 346 StubMethod(String name, js.Expression code, |
| 306 {bool needsTearOff, Element element }) | 347 {Element element}) |
| 307 : super(element, name, code, needsTearOff: needsTearOff); | 348 : super(element, name, code); |
| 308 } | 349 } |
| 309 | 350 |
| 310 class StaticMethod extends Method { | 351 class StaticMethod extends DartMethod { |
| 311 final Holder holder; | 352 final Holder holder; |
| 312 StaticMethod(Element element, String name, this.holder, js.Expression code, | 353 StaticMethod(Element element, String name, this.holder, js.Expression code, |
| 313 {bool needsTearOff}) | 354 {bool needsTearOff, String tearOffName, bool canBeApplied, |
| 314 : super(element, name, code, needsTearOff: needsTearOff); | 355 bool canBeReflected, bool needsStubs}) |
| 356 : super(element, name, code, | |
| 357 needsTearOff: needsTearOff, | |
|
floitsch
2015/01/28 16:10:39
I would align with the "(".
herhut
2015/01/29 10:24:21
Done.
| |
| 358 tearOffName : tearOffName, | |
| 359 canBeApplied : canBeApplied, | |
| 360 canBeReflected : canBeReflected, | |
| 361 needsStubs : needsStubs); | |
| 315 } | 362 } |
| 316 | 363 |
| 317 class StaticStubMethod extends StaticMethod { | 364 class StaticStubMethod extends StubMethod { |
| 318 StaticStubMethod(String name, Holder holder, js.Expression code, | 365 Holder holder; |
| 319 {bool needsTearOff}) | 366 StaticStubMethod(String name, this.holder, js.Expression code, |
| 320 : super(null, name, holder, code, needsTearOff: needsTearOff); | 367 {bool needsTearOff, String tearOffName}) |
| 368 : super(name, code) { | |
| 369 assert(needsTearOff == false); | |
|
floitsch
2015/01/28 16:10:39
Will this change?
If not, why get it as an argumen
herhut
2015/01/29 10:24:21
The original callsites to this had the tearoff par
| |
| 370 } | |
| 321 } | 371 } |
| OLD | NEW |