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

Unified Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1325843003: Add optional message to assert in Dart2js. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Reintroduce assertHelper for asserts without messages. Created 5 years, 3 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
Index: pkg/compiler/lib/src/js_backend/backend.dart
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index fbcbb0f49d601ea04a8f45557114bdc9e1c390ff..edce918b67714f55ed4bea8a5d388163a0e34ef7 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -278,7 +278,9 @@ class JavaScriptBackend extends Backend {
ClassElement closureClass;
ClassElement boundClosureClass;
- Element assertMethod;
+ Element assertTestMethod;
+ Element assertThrowMethod;
+ Element assertHelperMethod;
Element invokeOnMethod;
ClassElement jsInterceptorClass;
@@ -1354,8 +1356,6 @@ class JavaScriptBackend extends Backend {
}
}
- bool isAssertMethod(Element element) => element == assertMethod;
-
void registerRequiredType(DartType type, Element enclosingElement) {
// If [argument] has type variables or is a type variable, this method
// registers a RTI dependency between the class where the type variable is
@@ -2129,7 +2129,9 @@ class JavaScriptBackend extends Backend {
jsMutableIndexableClass = findClass('JSMutableIndexable');
} else if (uri == DART_JS_HELPER) {
initializeHelperClasses();
- assertMethod = findHelper('assertHelper');
+ assertTestMethod = findHelper('assertTest');
+ assertThrowMethod = findHelper('assertThrow');
+ assertHelperMethod = findHelper('assertHelper');
typeLiteralClass = findClass('TypeImpl');
constMapLiteralClass = findClass('ConstantMap');
@@ -2926,8 +2928,13 @@ class JavaScriptResolutionCallbacks extends ResolutionCallbacks {
registry.registerInstantiation(element.rawType);
}
- void onAssert(Send node, Registry registry) {
- registerBackendStaticInvocation(backend.assertMethod, registry);
+ void onAssert(bool hasMessage, Registry registry) {
+ if (hasMessage) {
+ registerBackendStaticInvocation(backend.assertTestMethod, registry);
+ registerBackendStaticInvocation(backend.assertThrowMethod, registry);
+ } else {
+ registerBackendStaticInvocation(backend.assertHelperMethod, registry);
+ }
}
void onAsyncForIn(AsyncForIn node, Registry registry) {

Powered by Google App Engine
This is Rietveld 408576698