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

Unified Diff: lib/compiler/implementation/ssa/ssa.dart

Issue 10232011: Implement simple dynamic type check. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor edits. Created 8 years, 8 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: lib/compiler/implementation/ssa/ssa.dart
diff --git a/lib/compiler/implementation/ssa/ssa.dart b/lib/compiler/implementation/ssa/ssa.dart
index 3f84b30b8866e9f9ecd2a03ae050de8f1f7ea899..c16f0f52c7b50bb427dd02337eb14d721ab0cc8d 100644
--- a/lib/compiler/implementation/ssa/ssa.dart
+++ b/lib/compiler/implementation/ssa/ssa.dart
@@ -24,3 +24,30 @@
#source('types_propagation.dart');
#source('validate.dart');
#source('value_set.dart');
+
+class RuntimeTypeInformation {
+ String asJsString(InterfaceType type) {
+ ClassElement element = type.element;
+ StringBuffer buffer = new StringBuffer();
+ buffer.add('{');
+ Link<Type> arguments = type.arguments;
+ int index = 0;
+ element.typeParameters.forEach((name, _) {
+ buffer.add("${name.slowToString()}: '${arguments.head}'");
+ if (++index < element.typeParameters.length) {
+ buffer.add(', ');
+ }
+ });
+ buffer.add('}');
+ return buffer.toString();
kasperl 2012/04/30 08:48:32 How about adding the { } as part of the return:
karlklose 2012/05/01 11:20:55 Done.
+ }
+
+ bool hasTypeArguments(Type type) {
ngeoffray 2012/04/30 08:51:12 Why is that not on the Type class?
karlklose 2012/05/01 11:20:55 It isn't really used elsewhere, so I did not want
+ if (type is InterfaceType) {
+ InterfaceType interfaceType = type;
+ return (!interfaceType.arguments.isEmpty() &&
+ interfaceType.arguments.tail.isEmpty());
+ }
+ return false;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698