| Index: sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/runtime_types.dart b/sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
|
| similarity index 75%
|
| rename from sdk/lib/_internal/compiler/implementation/runtime_types.dart
|
| rename to sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
|
| index 3f7967a2809f62dd4f77037207c9f77fa6c79945..e4b8122b9ccb05e3f61488b4786b28afcbd855d4 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/runtime_types.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
|
| @@ -4,11 +4,11 @@
|
|
|
| library runtime_types;
|
|
|
| -import 'dart2jslib.dart';
|
| -import 'elements/elements.dart';
|
| -import 'tree/tree.dart';
|
| -import 'universe/universe.dart';
|
| -import 'util/util.dart';
|
| +import '../dart2jslib.dart';
|
| +import '../elements/elements.dart';
|
| +import '../tree/tree.dart';
|
| +import '../universe/universe.dart';
|
| +import '../util/util.dart';
|
|
|
| class RuntimeTypeInformation {
|
| /**
|
| @@ -17,8 +17,16 @@ class RuntimeTypeInformation {
|
| */
|
| final Map<String, Element> usedNames = new Map<String, Element>();
|
|
|
| + final Compiler compiler;
|
| +
|
| + RuntimeTypeInformation(this.compiler) {
|
| + // Reserve the name 'dynamic' for the dynamic type.
|
| + usedNames['dynamic'] = compiler.dynamicClass;
|
| + }
|
| +
|
| /** Get a unique name for the element. */
|
| String getName(Element element) {
|
| + if (element == compiler.dynamicClass) return 'dynamic';
|
| String guess = element.name.slowToString();
|
| String name = guess;
|
| int id = 0;
|
| @@ -30,6 +38,31 @@ class RuntimeTypeInformation {
|
| return name;
|
| }
|
|
|
| + // TODO(karlklose): remove when using type representations.
|
| + String buildStringRepresentation(DartType type) {
|
| + StringBuffer builder = new StringBuffer();
|
| + void build(DartType t) {
|
| + builder.add(getName(t.element));
|
| + if (t is InterfaceType) {
|
| + InterfaceType interface = t;
|
| + if (interface.arguments.isEmpty) return;
|
| + bool firstArgument = true;
|
| + builder.add('<');
|
| + for (DartType argument in interface.arguments) {
|
| + if (firstArgument) {
|
| + firstArgument = false;
|
| + } else {
|
| + builder.add(', ');
|
| + }
|
| + build(argument);
|
| + }
|
| + builder.add('>');
|
| + }
|
| + }
|
| + build(type);
|
| + return builder.toString();
|
| + }
|
| +
|
| bool hasTypeArguments(DartType type) {
|
| if (type is InterfaceType) {
|
| InterfaceType interfaceType = type;
|
|
|