Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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("dart:core"); | 5 #library("dart:core"); |
| 6 #import("dart:coreimpl"); | 6 #import("dart:coreimpl"); |
| 7 | 7 |
| 8 // TODO(jimhug): Better way to map in standard corelib | 8 // TODO(jimhug): Better way to map in standard corelib |
| 9 #source("../../corelib/src/bool.dart"); | 9 #source("../../corelib/src/bool.dart"); |
| 10 #source("../../corelib/src/collection.dart"); | 10 #source("../../corelib/src/collection.dart"); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 write('\n'); | 61 write('\n'); |
| 62 }''' { | 62 }''' { |
| 63 // ensure toString is generated | 63 // ensure toString is generated |
| 64 obj.toString(); | 64 obj.toString(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Exceptions thrown by the generated JS code. | 67 // Exceptions thrown by the generated JS code. |
| 68 | 68 |
| 69 class AssertError { | 69 class AssertError { |
| 70 final String failedAssertion; | 70 final String failedAssertion; |
| 71 | |
| 72 // TODO(jmesserly): I don't think these should be here. They are properties of | |
| 73 // the stack trace | |
| 71 final String url; | 74 final String url; |
| 72 final int line; | 75 final int line; |
| 73 final int column; | 76 final int column; |
| 74 | 77 |
| 75 AssertError(this.failedAssertion, this.url, this.line, this.column); | 78 AssertError._internal(this.failedAssertion, this.url, this.line, this.column); |
| 76 | 79 |
| 77 String toString() { | 80 String toString() { |
| 78 return "Failed assertion: '$failedAssertion' is not true " + | 81 return "Failed assertion: '$failedAssertion' is not true " + |
| 79 "in $url at line $line, column $column."; | 82 "in $url at line $line, column $column."; |
| 80 } | 83 } |
| 81 } | 84 } |
| 82 | 85 |
| 83 class TypeError extends AssertError { | 86 // TODO(jmesserly): fix the strange interaction with JS TypeError, such as |
| 87 // toString(). Ideally this would generate to a different JS name but I'm not | |
| 88 // sure how to force that. | |
| 89 class TypeError extends AssertError native 'TypeError' { | |
| 84 final String srcType; | 90 final String srcType; |
| 85 final String dstType; | 91 final String dstType; |
| 86 | 92 |
| 87 TypeError(this.srcType, this.dstType) : super(null, null, null, null); | 93 TypeError._internal(Object src, String dstType) native @''' |
| 88 | 94 this.srcType = (src == null ? "Null" : src.$typeNameOf()); |
| 89 String toString() { | 95 this.destType = destType; |
|
sra1
2011/11/30 23:12:49
BUG: dstType vs destType.
You should add a test t
Jennifer Messerly
2011/12/01 00:38:07
Good catch! Hopefully we can make this entire meth
| |
| 90 return "Failed type check: type $srcType is not assignable to type " + | 96 this.toString = function() { |
| 91 "$dstType"; | 97 return ("Failed type check: type " + this.srcType + |
| 92 } | 98 " is not assignable to type" + this.dstType); |
| 99 }'''; | |
| 93 } | 100 } |
| 94 | 101 |
| 95 class FallThroughError { | 102 class FallThroughError { |
| 96 | |
| 97 const FallThroughError(); | 103 const FallThroughError(); |
| 98 | 104 |
| 99 String toString() { | 105 String toString() => "Switch case fall-through."; |
| 100 return "Switch case fall-through."; | |
| 101 } | |
| 102 } | 106 } |
| 103 | 107 |
| 104 // Dart core library. | 108 // Dart core library. |
| 105 | 109 |
| 106 class Object native "Object" { | 110 class Object native "Object" { |
| 107 | 111 |
| 108 const Object() native; | 112 const Object() native; |
| 109 | 113 |
| 110 bool operator ==(Object other) native; | 114 bool operator ==(Object other) native; |
| 111 String toString() native; | 115 String toString() native; |
| 112 | 116 |
| 113 // TODO(jmesserly): optimize this. No need to call it. | 117 // TODO(jmesserly): optimize this. No need to call it. |
| 114 get dynamic() => this; | 118 get dynamic() => this; |
| 115 | 119 |
| 116 // TODO(jmesserly): add named args. For now stay compatible with the VM. | 120 // TODO(jmesserly): add named args. For now stay compatible with the VM. |
| 117 noSuchMethod(String name, List args) { | 121 noSuchMethod(String name, List args) { |
| 118 throw new NoSuchMethodException(this, name, args); | 122 throw new NoSuchMethodException(this, name, args); |
| 119 } | 123 } |
| 120 } | 124 } |
| OLD | NEW |