| 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 expressions.add(code); | 418 expressions.add(code); |
| 419 | 419 |
| 420 List tearOffInfo = [new jsAst.LiteralString(callSelectorString)]; | 420 List tearOffInfo = [new jsAst.LiteralString(callSelectorString)]; |
| 421 | 421 |
| 422 if (needsStubs || canTearOff) { | 422 if (needsStubs || canTearOff) { |
| 423 addParameterStubs(member, (Selector selector, jsAst.Fun function) { | 423 addParameterStubs(member, (Selector selector, jsAst.Fun function) { |
| 424 expressions.add(function); | 424 expressions.add(function); |
| 425 if (member.isInstanceMember()) { | 425 if (member.isInstanceMember()) { |
| 426 Set invokedSelectors = | 426 Set invokedSelectors = |
| 427 compiler.codegenWorld.invokedNames[member.name]; | 427 compiler.codegenWorld.invokedNames[member.name]; |
| 428 //if (invokedSelectors != null && invokedSelectors.contains(selector))
{ |
| 428 expressions.add(js.string(namer.invocationName(selector))); | 429 expressions.add(js.string(namer.invocationName(selector))); |
| 430 //} else { |
| 431 // // Don't add a stub for calling this as a regular instance method, |
| 432 // // we only need the "call" stub for implicit closures of this |
| 433 // // method. |
| 434 // expressions.add("null"); |
| 435 //} |
| 429 } else { | 436 } else { |
| 437 // Static methods don't need "named" stubs as the default arguments |
| 438 // are inlined at call sites. But static methods might need "call" |
| 439 // stubs for implicit closures. |
| 430 expressions.add("null"); | 440 expressions.add("null"); |
| 431 // TOOD(ahe): Since we know when reading static data versus instance | 441 // TOOD(ahe): Since we know when reading static data versus instance |
| 432 // data, we can eliminate this element. | 442 // data, we can eliminate this element. |
| 433 } | 443 } |
| 434 Set<Selector> callSelectors = compiler.codegenWorld.invokedNames[ | 444 Set<Selector> callSelectors = compiler.codegenWorld.invokedNames[ |
| 435 namer.closureInvocationSelectorName]; | 445 namer.closureInvocationSelectorName]; |
| 436 Selector callSelector = selector.toCallSelector(); | 446 Selector callSelector = selector.toCallSelector(); |
| 437 String callSelectorString = 'null'; | 447 String callSelectorString = 'null'; |
| 438 if (canTearOff && callSelectors != null && | 448 if (canTearOff && callSelectors != null && |
| 439 callSelectors.contains(callSelector)) { | 449 callSelectors.contains(callSelector)) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 467 expressions | 477 expressions |
| 468 ..addAll(tearOffInfo) | 478 ..addAll(tearOffInfo) |
| 469 ..add((tearOffName == null || member.isAccessor()) | 479 ..add((tearOffName == null || member.isAccessor()) |
| 470 ? js("null") : js.string(tearOffName)) | 480 ? js("null") : js.string(tearOffName)) |
| 471 ..add(requiredParameterCount) | 481 ..add(requiredParameterCount) |
| 472 ..add(optionalParameterCount) | 482 ..add(optionalParameterCount) |
| 473 ..add(memberTypeExpression) | 483 ..add(memberTypeExpression) |
| 474 ..addAll(task.metadataEmitter.reifyDefaultArguments(member)); | 484 ..addAll(task.metadataEmitter.reifyDefaultArguments(member)); |
| 475 | 485 |
| 476 if (canBeReflected || canBeApplied) { | 486 if (canBeReflected || canBeApplied) { |
| 477 parameters.forEachParameter((Element parameter) { | 487 parameters.orderedForEachParameter((Element parameter) { |
| 478 expressions.add(task.metadataEmitter.reifyName(parameter.name)); | 488 expressions.add(task.metadataEmitter.reifyName(parameter.name)); |
| 479 List<MetadataAnnotation> annotations = parameter.metadata.toList(); | 489 List<MetadataAnnotation> annotations = parameter.metadata.toList(); |
| 480 Iterable<int> metadataIndices = annotations.map((MetadataAnnotation a) { | 490 Iterable<int> metadataIndices = annotations.map((MetadataAnnotation a) { |
| 481 compiler.constantHandler.addCompileTimeConstantForEmission(a.value); | 491 compiler.constantHandler.addCompileTimeConstantForEmission(a.value); |
| 482 return task.metadataEmitter.reifyMetadata(a); | 492 return task.metadataEmitter.reifyMetadata(a); |
| 483 }); | 493 }); |
| 484 expressions.add(metadataIndices.isNotEmpty ? metadataIndices.toList() | 494 expressions.add(metadataIndices.isNotEmpty ? metadataIndices.toList() |
| 485 : js('[]')); | 495 : js('[]')); |
| 486 }); | 496 }); |
| 487 } | 497 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 502 expressions.add(js.string(member.name)); | 512 expressions.add(js.string(member.name)); |
| 503 } | 513 } |
| 504 | 514 |
| 505 builder.addProperty(name, js.toExpression(expressions)); | 515 builder.addProperty(name, js.toExpression(expressions)); |
| 506 } | 516 } |
| 507 | 517 |
| 508 void addMemberField(VariableElement member, ClassBuilder builder) { | 518 void addMemberField(VariableElement member, ClassBuilder builder) { |
| 509 // For now, do nothing. | 519 // For now, do nothing. |
| 510 } | 520 } |
| 511 } | 521 } |
| OLD | NEW |