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

Unified Diff: runtime/vm/dart_api_state.h

Issue 8446009: Add Dart_Null, Dart_True, and Dart_False. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_state.h
===================================================================
--- runtime/vm/dart_api_state.h (revision 1035)
+++ runtime/vm/dart_api_state.h (working copy)
@@ -257,17 +257,25 @@
// basis and destroyed when the isolate is shutdown.
class ApiState {
public:
- ApiState() : top_scope_(NULL), true_(NULL) { }
+ ApiState() : top_scope_(NULL), null_(NULL), true_(NULL), false_(NULL) { }
~ApiState() {
while (top_scope_ != NULL) {
ApiLocalScope* scope = top_scope_;
top_scope_ = top_scope_->previous();
delete scope;
}
+ if (null_ != NULL) {
+ persistent_handles().FreeHandle(null_);
+ null_ = NULL;
+ }
if (true_ != NULL) {
persistent_handles().FreeHandle(true_);
true_ = NULL;
}
+ if (false_ != NULL) {
+ persistent_handles().FreeHandle(false_);
+ false_ = NULL;
+ }
}
// Accessors.
@@ -327,6 +335,17 @@
}
return total;
}
+ PersistentHandle* Null() {
+ if (null_ == NULL) {
+ Zone zone; // Setup a VM zone as we are creating some handles.
+ HandleScope scope; // Setup a VM handle scope.
+
+ Object& null_object = Object::Handle();
+ null_ = persistent_handles().AllocateHandle();
+ null_->set_raw(null_object);
+ }
+ return null_;
+ }
PersistentHandle* True() {
if (true_ == NULL) {
Zone zone; // Setup a VM zone as we are creating some handles.
@@ -338,13 +357,26 @@
}
return true_;
}
+ PersistentHandle* False() {
+ if (false_ == NULL) {
+ Zone zone; // Setup a VM zone as we are creating some handles.
+ HandleScope scope; // Setup a VM handle scope.
+ const Object& false_object = Object::Handle(Bool::False());
+ false_ = persistent_handles().AllocateHandle();
+ false_->set_raw(false_object);
+ }
+ return false_;
+ }
+
private:
PersistentHandles persistent_handles_;
ApiLocalScope* top_scope_;
- // A persistent handle to the "True" object.
+ // Persistent handles to important objects.
+ PersistentHandle* null_;
PersistentHandle* true_;
+ PersistentHandle* false_;
DISALLOW_COPY_AND_ASSIGN(ApiState);
};
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698