Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 /// This class should morph into something that makes it easy to build | 7 /// This class should morph into something that makes it easy to build |
| 8 /// JavaScript representations of libraries, class-sides, and instance-sides. | 8 /// JavaScript representations of libraries, class-sides, and instance-sides. |
| 9 /// Initially, it is just a placeholder for code that is moved from | 9 /// Initially, it is just a placeholder for code that is moved from |
| 10 /// [CodeEmitterTask]. | 10 /// [CodeEmitterTask]. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 void addMemberMethod(DartMethod method, ClassBuilder builder) { | 245 void addMemberMethod(DartMethod method, ClassBuilder builder) { |
| 246 final FunctionElement member = method.element; | 246 final FunctionElement member = method.element; |
| 247 String name = method.name; | 247 String name = method.name; |
| 248 final FunctionSignature parameters = member.functionSignature; | 248 final FunctionSignature parameters = member.functionSignature; |
| 249 jsAst.Expression code = method.code; | 249 jsAst.Expression code = method.code; |
| 250 final bool needsStubs = method.needsStubs; | 250 final bool needsStubs = method.needsStubs; |
| 251 final bool canBeApplied = method.canBeApplied; | 251 final bool canBeApplied = method.canBeApplied; |
| 252 bool canTearOff = method.needsTearOff; | 252 bool canTearOff = method.needsTearOff; |
| 253 String tearOffName = method.tearOffName; | 253 String tearOffName = method.tearOffName; |
| 254 final bool isClosure = method is InstanceMethod && method.isClosure; | 254 final bool isClosure = method is InstanceMethod && method.isClosure; |
| 255 final bool hasSuperAlias = method is InstanceMethod && method.hasSuperAlias; | 255 final String superAlias = method is InstanceMethod ? method.aliasName |
|
floitsch
2015/01/29 15:24:35
Remove the `final` if that makes it fit on one lin
herhut
2015/02/03 10:20:16
Removed them all.
| |
| 256 : null; | |
| 257 final bool hasSuperAlias = superAlias != null; | |
| 256 | 258 |
| 257 bool canBeReflected = backend.isAccessibleByReflection(member); | 259 bool canBeReflected = backend.isAccessibleByReflection(member); |
| 258 // During incremental compilation, we have to assume that reflection | 260 // During incremental compilation, we have to assume that reflection |
| 259 // *might* get enabled. | 261 // *might* get enabled. |
| 260 if (compiler.hasIncrementalSupport) canBeReflected = true; | 262 if (compiler.hasIncrementalSupport) canBeReflected = true; |
| 261 | 263 |
| 262 if (canBeReflected) { | 264 if (canBeReflected) { |
| 263 // Patch the effects of reflection into the received information. | 265 // Patch the effects of reflection into the received information. |
| 264 bool isNotApplyTarget = member.isConstructor || | 266 bool isNotApplyTarget = member.isConstructor || |
| 265 member.isAccessor || | 267 member.isAccessor || |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 // ... | 317 // ... |
| 316 // P. Unmangled name (if reflectable). | 318 // P. Unmangled name (if reflectable). |
| 317 // P+1. First metadata (if reflectable). | 319 // P+1. First metadata (if reflectable). |
| 318 // ... | 320 // ... |
| 319 // TODO(ahe): Consider one of the parameter counts can be replaced by the | 321 // TODO(ahe): Consider one of the parameter counts can be replaced by the |
| 320 // length property of the JavaScript function object. | 322 // length property of the JavaScript function object. |
| 321 | 323 |
| 322 List<jsAst.Expression> expressions = <jsAst.Expression>[]; | 324 List<jsAst.Expression> expressions = <jsAst.Expression>[]; |
| 323 | 325 |
| 324 // Create the optional aliasing entry if this method is called via super. | 326 // Create the optional aliasing entry if this method is called via super. |
| 325 if (backend.isAliasedSuperMember(member)) { | 327 if (hasSuperAlias) { |
| 326 expressions.add(new jsAst.LiteralString( | 328 expressions.add(new jsAst.LiteralString('"${superAlias}"')); |
| 327 '"${namer.getNameOfAliasedSuperMember(member)}"')); | |
| 328 } | 329 } |
| 329 | 330 |
| 330 expressions.add(code); | 331 expressions.add(code); |
| 331 | 332 |
| 332 final bool onlyNeedsSuperAlias = | 333 final bool onlyNeedsSuperAlias = |
| 333 !(canTearOff || canBeReflected || canBeApplied || needsStubs); | 334 !(canTearOff || canBeReflected || canBeApplied || needsStubs); |
| 334 | 335 |
| 335 if (onlyNeedsSuperAlias) { | 336 if (onlyNeedsSuperAlias) { |
| 336 jsAst.ArrayInitializer arrayInit = | 337 jsAst.ArrayInitializer arrayInit = |
| 337 new jsAst.ArrayInitializer(expressions); | 338 new jsAst.ArrayInitializer(expressions); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 jsAst.ArrayInitializer arrayInit = | 452 jsAst.ArrayInitializer arrayInit = |
| 452 new jsAst.ArrayInitializer(expressions.toList()); | 453 new jsAst.ArrayInitializer(expressions.toList()); |
| 453 compiler.dumpInfoTask.registerElementAst(member, | 454 compiler.dumpInfoTask.registerElementAst(member, |
| 454 builder.addProperty(name, arrayInit)); | 455 builder.addProperty(name, arrayInit)); |
| 455 } | 456 } |
| 456 | 457 |
| 457 void addMemberField(Field field, ClassBuilder builder) { | 458 void addMemberField(Field field, ClassBuilder builder) { |
| 458 // For now, do nothing. | 459 // For now, do nothing. |
| 459 } | 460 } |
| 460 } | 461 } |
| OLD | NEW |