Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Patch for tags/v0.9.3 to make it work on SDK 1.1 #408

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions lib/core/parser/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,33 @@ class GetterSetter {
return l;
}

_maybeInvoke(instanceMirror, symbol) {
if (instanceMirror.type.members.containsKey(symbol)) {
MethodMirror methodMirror = instanceMirror.type.members[symbol];
return relaxFnArgs(([a0, a1, a2, a3, a4, a5]) {
var args = stripTrailingNulls([a0, a1, a2, a3, a4, a5]);
return instanceMirror.invoke(symbol, args).reflectee;
});
static bool hasMethod(InstanceMirror mirror, Symbol symbol) {
return hasMethodHelper(mirror.type, symbol);
}

static final Function hasMethodHelper = computeHasMethodHelper();
static Function computeHasMethodHelper() {
var objectType = reflect(Object).type;
try {
// Use ClassMirror.instanceMembers if available. It contains local
// as well as inherited members.
objectType.instanceMembers;
return (type, symbol) => type.instanceMembers[symbol] is MethodMirror;
} on NoSuchMethodError catch (e) {
// For SDK 1.0 we fall back to just using the local members.
return (type, symbol) => type.members[symbol] is MethodMirror;
} on UnimplementedError catch (e) {
// For SDK 1.1 we fall back to just using the local declarations.
return (type, symbol) => type.declarations[symbol] is MethodMirror;
}
return null;
}

_maybeInvoke(InstanceMirror mirror, Symbol symbol) {
if (!hasMethod(mirror, symbol)) return null;
return relaxFnArgs(([a0, a1, a2, a3, a4, a5]) {
var args = stripTrailingNulls([a0, a1, a2, a3, a4, a5]);
return mirror.invoke(symbol, args).reflectee;
});
}

Map<String, Function> _getter_cache = {};
Expand Down
5 changes: 4 additions & 1 deletion lib/core/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,9 @@ _toJson(obj) {
// work-around dartbug.com/14130
try {
ret = mirror.function.source;
} on NoSuchMethodError catch (e) {}
} on NoSuchMethodError catch (e) {
} on UnimplementedError catch (e) {
}
}
return true;
})());
Expand All @@ -790,6 +792,7 @@ String _source(obj) {
try {
return "FN: ${m.function.source}";
} on NoSuchMethodError catch (e) {
} on UnimplementedError catch (e) {
}
}
}
Expand Down