| Index: dart/frog/leg/emitter.dart
|
| diff --git a/dart/frog/leg/emitter.dart b/dart/frog/leg/emitter.dart
|
| index 960fb8a133e53aaa437eb2c1a59eaafa762b75ed..e91aa7098e7dc2a107cd31362251d041c8f475ec 100644
|
| --- a/dart/frog/leg/emitter.dart
|
| +++ b/dart/frog/leg/emitter.dart
|
| @@ -134,7 +134,7 @@ function(child, parent) {
|
| member, invocationName, arguments, buffer);
|
| } else {
|
| buffer.add(' return this.${namer.getName(member)}($arguments)');
|
| - }
|
| + }
|
| buffer.add('\n}\n');
|
| }
|
|
|
| @@ -262,19 +262,29 @@ function(child, parent) {
|
| }
|
| }
|
| buffer.add('$prototype.${namer.operatorIs(classElement)} = true;\n');
|
| - for (Type ifc in classElement.interfaces) {
|
| - buffer.add('$prototype.${namer.operatorIs(ifc.element)} = true;\n');
|
| - }
|
| + generateInterfacesIsTests(buffer, prototype, classElement);
|
| if (superclass === null) {
|
| - // JS "toString" wrapper. This gives better exceptions.
|
| - buffer.add('$prototype.toString = function() {\n');
|
| - buffer.add(' try {');
|
| - buffer.add(' return ${namer.CURRENT_ISOLATE}');
|
| - buffer.add('.builtin\$toString\$0\$1(this);');
|
| - buffer.add(' } catch (ex) {');
|
| - buffer.add(' return "uncaught exception in toString";');
|
| - buffer.add(' }');
|
| - buffer.add('};\n');
|
| + // JS "toString" wrapper. This gives better exceptions. The
|
| + // function must handle the situation where builtin$toString$0
|
| + // is not generated.
|
| + buffer.add('''
|
| +$prototype.toString = function() {
|
| + try {
|
| + if (typeof ${namer.CURRENT_ISOLATE}.builtin\$toString\$0\$1 == 'function') {
|
| + return ${namer.CURRENT_ISOLATE}.builtin\$toString\$0\$1(this);
|
| + } else {
|
| + var name = this.constructor.name;
|
| + if (typeof name != 'string') {
|
| + name = this.constructor.toString();
|
| + name = name.match(/^\s*function\s*(\S*)\s*\(/)[1];
|
| + }
|
| + return "Instance of '" + name +"'";
|
| + }
|
| + } catch (ex) {
|
| + return "uncaught exception in toString";
|
| + }
|
| +};
|
| +''');
|
|
|
| // Emit the noSuchMethods on the Object prototype now, so that
|
| // the code in the dynamicMethod can find them. Note that the
|
| @@ -284,6 +294,14 @@ function(child, parent) {
|
| }
|
| }
|
|
|
| + void generateInterfacesIsTests(StringBuffer buffer, String prototype,
|
| + ClassElement cls) {
|
| + for (Type ifc in cls.interfaces) {
|
| + buffer.add('$prototype.${namer.operatorIs(ifc.element)} = true;\n');
|
| + generateInterfacesIsTests(buffer, prototype, ifc.element);
|
| + }
|
| + }
|
| +
|
| void emitClasses(StringBuffer buffer) {
|
| Set seenClasses = new Set<ClassElement>();
|
| for (ClassElement element in compiler.universe.instantiatedClasses) {
|
| @@ -473,7 +491,7 @@ function(child, parent) {
|
| }
|
| }
|
| }
|
| - }
|
| + }
|
| }
|
|
|
| void emitStaticNonFinalFieldInitializations(StringBuffer buffer) {
|
|
|