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

Side by Side Diff: runtime/lib/errors_patch.dart

Issue 2220883004: Use metadata annotation @patch for patch classes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: wip Created 4 years, 4 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
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 import 'dart:_internal' as internal; 5 import 'dart:_internal' as internal;
6 import 'dart:convert' show JSON; 6 import 'dart:convert' show JSON;
7 7
8 patch class Error { 8 @patch class Error {
9 /* patch */ static String _objectToString(Object object) { 9 /* @patch */ static String _objectToString(Object object) {
10 return Object._toString(object); 10 return Object._toString(object);
11 } 11 }
12 12
13 /* patch */ static String _stringToSafeString(String string) { 13 /* @patch */ static String _stringToSafeString(String string) {
14 return JSON.encode(string); 14 return JSON.encode(string);
15 } 15 }
16 16
17 /* patch */ StackTrace get stackTrace => _stackTrace; 17 /* @patch */ StackTrace get stackTrace => _stackTrace;
18 18
19 StackTrace _stackTrace; 19 StackTrace _stackTrace;
20 } 20 }
21 21
22 class _AssertionError extends Error implements AssertionError { 22 class _AssertionError extends Error implements AssertionError {
23 _AssertionError._create( 23 _AssertionError._create(
24 this._failedAssertion, this._url, this._line, this._column); 24 this._failedAssertion, this._url, this._line, this._column);
25 25
26 static _throwNew(int assertionStart, int assertionEnd) 26 static _throwNew(int assertionStart, int assertionEnd)
27 native "AssertionError_throwNew"; 27 native "AssertionError_throwNew";
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 String toString() => _errorMsg; 89 String toString() => _errorMsg;
90 90
91 // Fields _url, _line, and _column are only used for debugging purposes. 91 // Fields _url, _line, and _column are only used for debugging purposes.
92 final String _url; 92 final String _url;
93 final int _line; 93 final int _line;
94 final int _column; 94 final int _column;
95 final String _errorMsg; 95 final String _errorMsg;
96 } 96 }
97 97
98 patch class FallThroughError { 98 @patch class FallThroughError {
99 FallThroughError._create(this._url, this._line); 99 FallThroughError._create(this._url, this._line);
100 100
101 static _throwNew(int case_clause_pos) native "FallThroughError_throwNew"; 101 static _throwNew(int case_clause_pos) native "FallThroughError_throwNew";
102 102
103 /* patch */ String toString() { 103 /* @patch */ String toString() {
104 return "'$_url': Switch case fall-through at line $_line."; 104 return "'$_url': Switch case fall-through at line $_line.";
105 } 105 }
106 106
107 // These new fields cannot be declared final, because a constructor exists 107 // These new fields cannot be declared final, because a constructor exists
108 // in the original version of this patched class. 108 // in the original version of this patched class.
109 String _url; 109 String _url;
110 int _line; 110 int _line;
111 } 111 }
112 112
113 class _InternalError { 113 class _InternalError {
114 const _InternalError(this._msg); 114 const _InternalError(this._msg);
115 String toString() => "InternalError: '${_msg}'"; 115 String toString() => "InternalError: '${_msg}'";
116 final String _msg; 116 final String _msg;
117 } 117 }
118 118
119 patch class UnsupportedError { 119 @patch class UnsupportedError {
120 static _throwNew(String msg) { 120 static _throwNew(String msg) {
121 throw new UnsupportedError(msg); 121 throw new UnsupportedError(msg);
122 } 122 }
123 } 123 }
124 124
125 patch class CyclicInitializationError { 125 @patch class CyclicInitializationError {
126 static _throwNew(String variableName) { 126 static _throwNew(String variableName) {
127 throw new CyclicInitializationError(variableName); 127 throw new CyclicInitializationError(variableName);
128 } 128 }
129 } 129 }
130 130
131 patch class AbstractClassInstantiationError { 131 @patch class AbstractClassInstantiationError {
132 AbstractClassInstantiationError._create( 132 AbstractClassInstantiationError._create(
133 this._className, this._url, this._line); 133 this._className, this._url, this._line);
134 134
135 static _throwNew(int case_clause_pos, String className) 135 static _throwNew(int case_clause_pos, String className)
136 native "AbstractClassInstantiationError_throwNew"; 136 native "AbstractClassInstantiationError_throwNew";
137 137
138 /* patch */ String toString() { 138 /* @patch */ String toString() {
139 return "Cannot instantiate abstract class $_className: " 139 return "Cannot instantiate abstract class $_className: "
140 "_url '$_url' line $_line"; 140 "_url '$_url' line $_line";
141 } 141 }
142 142
143 // These new fields cannot be declared final, because a constructor exists 143 // These new fields cannot be declared final, because a constructor exists
144 // in the original version of this patched class. 144 // in the original version of this patched class.
145 String _url; 145 String _url;
146 int _line; 146 int _line;
147 } 147 }
148 148
149 patch class NoSuchMethodError { 149 @patch class NoSuchMethodError {
150 // The compiler emits a call to _throwNew when it cannot resolve a static 150 // The compiler emits a call to _throwNew when it cannot resolve a static
151 // method at compile time. The receiver is actually the literal class of the 151 // method at compile time. The receiver is actually the literal class of the
152 // unresolved method. 152 // unresolved method.
153 static void _throwNew(Object receiver, 153 static void _throwNew(Object receiver,
154 String memberName, 154 String memberName,
155 int invocation_type, 155 int invocation_type,
156 List arguments, 156 List arguments,
157 List argumentNames, 157 List argumentNames,
158 List existingArgumentNames) { 158 List existingArgumentNames) {
159 int numNamedArguments = argumentNames == null ? 0 : argumentNames.length; 159 int numNamedArguments = argumentNames == null ? 0 : argumentNames.length;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 break; 277 break;
278 } 278 }
279 case _InvocationMirror._TOP_LEVEL: { 279 case _InvocationMirror._TOP_LEVEL: {
280 msg = "No top-level $type_str '$memberName'$args_message declared."; 280 msg = "No top-level $type_str '$memberName'$args_message declared.";
281 break; 281 break;
282 } 282 }
283 } 283 }
284 return "$msg\n\n"; 284 return "$msg\n\n";
285 } 285 }
286 286
287 /* patch */ String toString() { 287 /* @patch */ String toString() {
288 StringBuffer actual_buf = new StringBuffer(); 288 StringBuffer actual_buf = new StringBuffer();
289 int i = 0; 289 int i = 0;
290 if (_arguments == null) { 290 if (_arguments == null) {
291 // Actual arguments unknown. 291 // Actual arguments unknown.
292 // TODO(srdjan): Remove once arguments are passed for unresolvable 292 // TODO(srdjan): Remove once arguments are passed for unresolvable
293 // static methods. 293 // static methods.
294 actual_buf.write("..."); 294 actual_buf.write("...");
295 } else { 295 } else {
296 for (; i < _arguments.length; i++) { 296 for (; i < _arguments.length; i++) {
297 if (i > 0) { 297 if (i > 0) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 msg_buf.write( 345 msg_buf.write(
346 "NoSuchMethodError: incorrect number of arguments passed to " 346 "NoSuchMethodError: incorrect number of arguments passed to "
347 "method named '$memberName'\n" 347 "method named '$memberName'\n"
348 "Receiver: $receiver_str\n" 348 "Receiver: $receiver_str\n"
349 "Tried calling: $memberName($actualParameters)\n" 349 "Tried calling: $memberName($actualParameters)\n"
350 "Found: $memberName($formalParameters)"); 350 "Found: $memberName($formalParameters)");
351 } 351 }
352 return msg_buf.toString(); 352 return msg_buf.toString();
353 } 353 }
354 } 354 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698