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

Unified Diff: lib/runtime/dart_runtime.js

Issue 1071773002: metalet with postfix improvement (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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
Index: lib/runtime/dart_runtime.js
diff --git a/lib/runtime/dart_runtime.js b/lib/runtime/dart_runtime.js
index 149543b21313802e1b5d86b7c21f6dd22122e3dc..13800059810e039e0326a9ee2269690344d3eb25 100644
--- a/lib/runtime/dart_runtime.js
+++ b/lib/runtime/dart_runtime.js
@@ -302,6 +302,33 @@ var dart, _js_helper;
dart.notNull = notNull;
/**
+ * A null-checking property wrapper.
+ *
+ * Used when we need an assignable expression:
+ *
+ * obj.foo++; // normal variant
+ * prop(obj, 'foo').notNull++; // checking variant
+ *
+ * This checks on read, not on write.
+ */
+ function prop(obj, prop) {
+ return {
+ get notNull() { return notNull(obj[prop]); },
+ set notNull(x) { obj[prop] = x; }
+ };
+ }
+ dart.prop = prop;
+
+ /** A null checking get/set index wrapper. */
+ function index(obj, index) {
+ return {
+ get notNull() { return notNull(obj[core.$get](index)); },
+ set notNull(x) { obj[core.$set](index, x); }
+ };
+ }
+ dart.index = index;
+
+ /**
* Defines a lazy property.
* After initial get or set, it will replace itself with a value property.
*/

Powered by Google App Engine
This is Rietveld 408576698