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

Unified Diff: sdk/lib/_internal/js_runtime/lib/core_patch.dart

Issue 2545153002: Handle synthetic nodes use to throw exceptions (Closed)
Patch Set: Also handle malformed type Created 4 years 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: sdk/lib/_internal/js_runtime/lib/core_patch.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/core_patch.dart b/sdk/lib/_internal/js_runtime/lib/core_patch.dart
index 5c5ec252bc1ff4d717b52c53f636819e5f5d2beb..746e4372c0a7cb2678af9044651491587348435d 100644
--- a/sdk/lib/_internal/js_runtime/lib/core_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/core_patch.dart
@@ -20,7 +20,8 @@ import 'dart:_js_helper' show checkInt,
patch_startup,
Primitives,
stringJoinUnchecked,
- getTraceFromException;
+ getTraceFromException,
+ RuntimeError;
import 'dart:_foreign_helper' show JS;
@@ -548,7 +549,7 @@ class StringBuffer {
class NoSuchMethodError {
@patch
String toString() {
- StringBuffer sb = new StringBuffer();
+ StringBuffer sb = new StringBuffer('');
String comma = '';
if (_arguments != null) {
for (var argument in _arguments) {
@@ -558,6 +559,8 @@ class NoSuchMethodError {
}
}
if (_namedArguments != null) {
+ // TODO(sra): Revert this form when kernel FunctionExpressions work.
+ /*
_namedArguments.forEach((Symbol key, var value) {
sb.write(comma);
sb.write(_symbolToString(key));
@@ -565,6 +568,14 @@ class NoSuchMethodError {
sb.write(Error.safeToString(value));
comma = ', ';
});
+ */
+ for (Symbol key in _namedArguments.keys) {
+ sb.write(comma);
+ sb.write(_symbolToString(key));
+ sb.write(": ");
+ sb.write(Error.safeToString(_namedArguments[key]));
+ comma = ', ';
+ }
}
String memberName = _symbolToString(_memberName);
String receiverText = Error.safeToString(_receiver);
@@ -620,7 +631,7 @@ class _Uri {
// Encode the string into bytes then generate an ASCII only string
// by percent encoding selected bytes.
- StringBuffer result = new StringBuffer();
+ StringBuffer result = new StringBuffer('');
var bytes = encoding.encode(text);
for (int i = 0; i < bytes.length; i++) {
int byte = bytes[i];
@@ -667,3 +678,30 @@ class StackTrace {
}
}
}
+
+// Called from kernel generated code.
+_genericNoSuchMethod(receiver, memberName, positionalArguments, namedArguments,
+ existingArguments) {
+ return new NoSuchMethodError(
+ receiver,
+ memberName,
+ positionalArguments,
+ namedArguments);
+}
+
+// Called from kernel generated code.
+_unresolvedConstructorError(receiver, memberName, positionalArguments,
+ namedArguments, existingArguments) {
+ // TODO(sra): Generate an error that reads:
+ //
+ // No constructor '$memberName' declared in class '$receiver'.
+
+ return new NoSuchMethodError(
+ receiver,
+ memberName,
+ positionalArguments,
+ namedArguments);
+}
+
+// Called from kernel generated code.
+_malformedTypeError(message) => new RuntimeError(message);

Powered by Google App Engine
This is Rietveld 408576698