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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library('ssa'); 5 #library('ssa');
6 6
7 #import('../leg.dart'); 7 #import('../leg.dart');
8 #import('../native_handler.dart', prefix: 'native'); 8 #import('../native_handler.dart', prefix: 'native');
9 #import('../elements/elements.dart'); 9 #import('../elements/elements.dart');
10 #import('../scanner/scannerlib.dart'); 10 #import('../scanner/scannerlib.dart');
11 #import('../tree/tree.dart'); 11 #import('../tree/tree.dart');
12 #import('../util/util.dart'); 12 #import('../util/util.dart');
13 #import('../util/characters.dart'); 13 #import('../util/characters.dart');
14 14
15 #source('bailout.dart'); 15 #source('bailout.dart');
16 #source('builder.dart'); 16 #source('builder.dart');
17 #source('closure.dart'); 17 #source('closure.dart');
18 #source('codegen.dart'); 18 #source('codegen.dart');
19 #source('codegen_helpers.dart'); 19 #source('codegen_helpers.dart');
20 #source('js_names.dart'); 20 #source('js_names.dart');
21 #source('nodes.dart'); 21 #source('nodes.dart');
22 #source('optimize.dart'); 22 #source('optimize.dart');
23 #source('types.dart'); 23 #source('types.dart');
24 #source('types_propagation.dart'); 24 #source('types_propagation.dart');
25 #source('validate.dart'); 25 #source('validate.dart');
26 #source('value_set.dart'); 26 #source('value_set.dart');
27
28 class RuntimeTypeInformation {
29 String asJsString(InterfaceType type) {
30 ClassElement element = type.element;
31 StringBuffer buffer = new StringBuffer();
32 buffer.add('{');
33 Link<Type> arguments = type.arguments;
34 int index = 0;
35 element.typeParameters.forEach((name, _) {
36 buffer.add("${name.slowToString()}: '${arguments.head}'");
37 if (++index < element.typeParameters.length) {
38 buffer.add(', ');
39 }
40 });
41 buffer.add('}');
42 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.
43 }
44
45 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
46 if (type is InterfaceType) {
47 InterfaceType interfaceType = type;
48 return (!interfaceType.arguments.isEmpty() &&
49 interfaceType.arguments.tail.isEmpty());
50 }
51 return false;
52 }
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698