Store the aliasName of a method in the model.

BUG=
R=floitsch@google.com, zarah@google.com

Review URL: https://codereview.chromium.org//881363006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43387 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
herhut@google.com
2015-02-03 10:30:55 +00:00
parent 93fef72fb3
commit bb07322aa5
3 changed files with 34 additions and 28 deletions
+7 -5
View File
@@ -335,7 +335,6 @@ class DartMethod extends Method {
final bool needsTearOff;
final String tearOffName;
final List<ParameterStubMethod> parameterStubs;
// TODO(herhut): Directly store aliases instead.
final bool canBeApplied;
final bool canBeReflected;
@@ -357,16 +356,20 @@ class DartMethod extends Method {
}
class InstanceMethod extends DartMethod {
// TODO(herhut): Directly store aliases instead.
final bool hasSuperAlias;
/// An alternative name for this method. This is used to model calls to
/// a method via `super`. If [aliasName] is non-null, the emitter has to
/// ensure that this method is registered on the prototype under both [name]
/// and [aliasName].
final String aliasName;
final bool isClosure;
InstanceMethod(Element element, String name, js.Expression code,
List<ParameterStubMethod> parameterStubs,
String callName,
{bool needsTearOff,
String tearOffName,
this.hasSuperAlias,
this.aliasName,
bool canBeApplied,
bool canBeReflected,
this.isClosure})
@@ -375,7 +378,6 @@ class InstanceMethod extends DartMethod {
tearOffName: tearOffName,
canBeApplied: canBeApplied,
canBeReflected: canBeReflected) {
assert(hasSuperAlias != null);
assert(isClosure != null);
}
}
@@ -11,19 +11,20 @@ part of dart2js.js_emitter;
class ContainerBuilder extends CodeEmitterHelper {
void addMemberMethod(DartMethod method, ClassBuilder builder) {
final FunctionElement member = method.element;
FunctionElement member = method.element;
String name = method.name;
final FunctionSignature parameters = member.functionSignature;
FunctionSignature parameters = member.functionSignature;
jsAst.Expression code = method.code;
final bool needsStubs = method.parameterStubs.isNotEmpty;
final bool canTearOff = method.needsTearOff;
final String tearOffName = method.tearOffName;
final bool canBeReflected = method.canBeReflected;
final bool canBeApplied = method.canBeApplied;
final bool isClosure = method is InstanceMethod && method.isClosure;
final bool hasSuperAlias = method is InstanceMethod && method.hasSuperAlias;
bool needsStubs = method.parameterStubs.isNotEmpty;
bool canBeApplied = method.canBeApplied;
bool canBeReflected = method.canBeReflected;
bool canTearOff = method.needsTearOff;
String tearOffName = method.tearOffName;
bool isClosure = method is InstanceMethod && method.isClosure;
String superAlias = method is InstanceMethod ? method.aliasName : null;
bool hasSuperAlias = superAlias != null;
final bool needStructuredInfo =
bool needStructuredInfo =
canTearOff || canBeReflected || canBeApplied || hasSuperAlias;
emitter.interceptorEmitter.recordMangledNameOfMemberMethod(member, name);
@@ -74,14 +75,13 @@ class ContainerBuilder extends CodeEmitterHelper {
List<jsAst.Expression> expressions = <jsAst.Expression>[];
// Create the optional aliasing entry if this method is called via super.
if (backend.isAliasedSuperMember(member)) {
expressions.add(new jsAst.LiteralString(
'"${namer.getNameOfAliasedSuperMember(member)}"'));
if (hasSuperAlias) {
expressions.add(new jsAst.LiteralString('"${superAlias}"'));
}
expressions.add(code);
final bool onlyNeedsSuperAlias =
bool onlyNeedsSuperAlias =
!(canTearOff || canBeReflected || canBeApplied || needsStubs);
if (onlyNeedsSuperAlias) {
@@ -425,9 +425,13 @@ class ProgramBuilder {
bool isClosure = false;
bool isNotApplyTarget = !element.isFunction || element.isAccessor;
final bool canBeReflected = _methodCanBeReflected(element);
final bool canBeApplied = _methodCanBeApplied(element);
final bool hasSuperAlias = backend.isAliasedSuperMember(element);
bool canBeReflected = _methodCanBeReflected(element);
bool needsStubs = _methodNeedsStubs(element);
bool canBeApplied = _methodCanBeApplied(element);
String aliasName = backend.isAliasedSuperMember(element)
? namer.getNameOfAliasedSuperMember(element)
: null;
if (isNotApplyTarget) {
canTearOff = false;
@@ -461,7 +465,7 @@ class ProgramBuilder {
return new InstanceMethod(element, name, code,
_generateParameterStubs(element, canTearOff), callName,
needsTearOff: canTearOff, tearOffName: tearOffName,
isClosure: isClosure, hasSuperAlias: hasSuperAlias,
isClosure: isClosure, aliasName: aliasName,
canBeApplied: canBeApplied, canBeReflected: canBeReflected);
}
@@ -580,15 +584,15 @@ class ProgramBuilder {
String holder = namer.globalObjectFor(element);
js.Expression code = backend.generatedCode[element];
final bool isApplyTarget = !element.isConstructor && !element.isAccessor;
final bool canBeApplied = _methodCanBeApplied(element);
final bool canBeReflected = _methodCanBeReflected(element);
bool isApplyTarget = !element.isConstructor && !element.isAccessor;
bool canBeApplied = _methodCanBeApplied(element);
bool canBeReflected = _methodCanBeReflected(element);
final bool needsTearOff = isApplyTarget &&
bool needsTearOff = isApplyTarget &&
(canBeReflected ||
universe.staticFunctionsNeedingGetter.contains(element));
final String tearOffName =
String tearOffName =
needsTearOff ? namer.getStaticClosureName(element) : null;
String callName = null;