Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: frog/type.dart

Issue 8334035: Reduces code generated by dynamic calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« frog/gen.dart ('K') | « frog/member.dart ('k') | frog/value.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/type.dart
diff --git a/frog/type.dart b/frog/type.dart
index 6cb7a0455b678e2e93f37f4ce9237f2072e91e5c..ad18acfc2e1f9fd6cc28872d22c142e290e71eb3 100644
--- a/frog/type.dart
+++ b/frog/type.dart
@@ -16,6 +16,7 @@ class Type implements Named, Hashable {
Type(this.name): isTested = false;
void markUsed() {}
+ abstract void genMethod(Member method);
TypeMember get typeMember() {
if (_typeMember == null) {
@@ -297,6 +298,10 @@ class ParameterType extends Type {
MethodMember getCallMethod() => extendsType.getCallMethod();
+ void genMethod(Member method) {
+ extendsType.genMethod(method);
+ }
+
// TODO(jmesserly): should be like this:
//bool isSubtypeOf(Type child) => extendsType.isSubtypeOf(child);
bool isSubtypeOf(Type child) => true;
@@ -408,6 +413,10 @@ class ConcreteType extends Type {
void markUsed() {
genericType.markUsed();
}
+ void genMethod(Member method) {
+ genericType.genMethod(method);
+ }
+
getFactory(Type type, String constructorName) {
return genericType.getFactory(type, constructorName);
@@ -508,6 +517,9 @@ class DefinedType extends Type {
Map<String, ConcreteType> _concreteTypes;
+ /** Methods to be generated once we know for sure that the type is used. */
+ Map<String, Member> _lazyGenMethods;
+
bool isUsed = false;
bool isNativeType = false;
@@ -591,9 +603,26 @@ class DefinedType extends Type {
if (isUsed) return;
isUsed = true;
+
+ if (_lazyGenMethods != null) {
+ for (var method in orderValuesByKeys(_lazyGenMethods)) {
+ world.gen.genMethod(method);
+ }
+ _lazyGenMethods = null;
+ }
+
if (parent != null) parent.markUsed();
}
+ void genMethod(Member method) {
+ if (isUsed) {
+ world.gen.genMethod(method);
+ } else if (isClass) {
+ if (_lazyGenMethods == null) _lazyGenMethods = {};
+ _lazyGenMethods[method.name] = method;
+ }
+ }
+
List<Type> _resolveInterfaces(List<TypeReference> types) {
if (types == null) return [];
var interfaces = [];
« frog/gen.dart ('K') | « frog/member.dart ('k') | frog/value.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698