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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart

Issue 12334070: Support runtime check of function types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Register dependency Created 7 years, 9 months 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
Index: sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart b/sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
index e38cc6e4ec5cdfb227c73e01e26746629a831e3e..f400d3b6818c073f9d0757124b429ff442df34e0 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
@@ -207,6 +207,25 @@ class RuntimeTypeInformation {
}
}
+ String getTypeEncoding(DartType type,
+ {bool alwaysGenerateFunction: false}) {
+ TypeVariableType typeVariable = type.typeVariableOccurrence;
+ String onVariable(TypeVariableType v) {
+ return v.toString();
+ };
+ String encoding = _getTypeRepresentation(type, onVariable);
+ if (typeVariable == null && !alwaysGenerateFunction) {
+ return encoding;
+ } else {
+ ClassElement cls = typeVariable != null ?
+ typeVariable.element.enclosingElement : null;
+ String parameters = cls != null
+ ? cls.typeVariables.toList().join(', ')
+ : '';
+ return 'function ($parameters) { return $encoding; }';
+ }
+ }
+
String getTypeRepresentation(DartType type, void onVariable(variable)) {
// Create a type representation. For type variables call the original
// callback for side effects and return a template placeholder.

Powered by Google App Engine
This is Rietveld 408576698