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

Unified Diff: vm/flags.cc

Issue 9668034: Fix issue 1950: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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 | « vm/flags.h ('k') | vm/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/flags.cc
===================================================================
--- vm/flags.cc (revision 5257)
+++ vm/flags.cc (working copy)
@@ -24,12 +24,16 @@
kBoolean,
kInteger,
kString,
+ kFunc,
kNumFlagTypes
};
Flag(const char* name, const char* comment, void* addr, FlagType type)
: name_(name), comment_(comment), addr_(addr), type_(type) {
}
+ Flag(const char* name, const char* comment, FlagHandler handler)
+ : name_(name), comment_(comment), handler_(handler), type_(kFunc) {
+ }
void Print() {
if (IsUnrecognized()) {
@@ -54,6 +58,10 @@
}
break;
}
+ case kFunc: {
+ // No value to print here.
regis 2012/03/09 23:16:03 You could maybe print the name of the flag.
Ivan Posva 2012/03/09 23:20:37 Done.
+ break;
+ }
default:
UNREACHABLE();
break;
@@ -72,6 +80,7 @@
bool* bool_ptr_;
int* int_ptr_;
charp* charp_ptr_;
+ FlagHandler handler_;
};
FlagType type_;
};
@@ -129,6 +138,17 @@
}
+bool Flags::Register_func(FlagHandler handler,
+ const char* name,
+ const char* comment) {
+ ASSERT(Lookup(name) == NULL);
+ Flag* flag = new Flag(name, comment, handler);
+ flag->next_ = Flags::flags_;
+ Flags::flags_ = flag;
+ return false;
+}
+
+
static void Normalize(char* s) {
intptr_t len = strlen(s);
for (intptr_t i = 0; i < len; i++) {
@@ -206,6 +226,16 @@
}
break;
}
+ case Flag::kFunc: {
+ if (strcmp(argument, "true") == 0) {
+ (flag->handler_)(true);
+ } else if (strcmp(argument, "false") == 0) {
+ (flag->handler_)(false);
+ } else {
+ OS::Print("Ignoring flag: %s is a bool flag.\n", name);
+ }
+ break;
+ }
default: {
UNREACHABLE();
break;
« no previous file with comments | « vm/flags.h ('k') | vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698