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

Unified Diff: runtime/lib/errors_patch.dart

Issue 2805903004: Working implementation of #29153 range check in as-casts. (Closed)
Patch Set: Incorporate @rmacnak's feedback: ZoneHandle, position, symbol null. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/aot_optimizer.cc » ('j') | runtime/vm/aot_optimizer.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/errors_patch.dart
diff --git a/runtime/lib/errors_patch.dart b/runtime/lib/errors_patch.dart
index f26d4d4e238feb6c54a9618a043040da2ff5bd8e..595f6f8620bcde3ab34e253f191b7a08fa6cdd59 100644
--- a/runtime/lib/errors_patch.dart
+++ b/runtime/lib/errors_patch.dart
@@ -395,3 +395,21 @@ class _CompileTimeError extends Error {
_CompileTimeError(this._errorMsg);
String toString() => _errorMsg;
}
+
+dynamic _classRangeAssert(int position, dynamic instance, _Type type, int cid,
+ int lowerLimit, int upperLimit) {
+ if ((cid < lowerLimit || cid > upperLimit) && instance != null) {
+ _TypeError._throwNew(position, instance, type, " in type cast", null);
+ }
+
+ return instance;
+}
+
+dynamic _classIdEqualsAssert(
+ int position, dynamic instance, _Type type, int cid, int otherCid) {
+ if (cid != otherCid && instance != null) {
+ _TypeError._throwNew(position, instance, type, " in type cast", null);
+ }
+
+ return instance;
+}
« no previous file with comments | « no previous file | runtime/vm/aot_optimizer.cc » ('j') | runtime/vm/aot_optimizer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698