Permalink
Browse files

Switch the version config to a radio button

  • Loading branch information...
1 parent 52b3992 commit fa7724a82214d1db8454ce441026f29804944472 @evanphx evanphx committed Jul 1, 2011
Showing with 103 additions and 55 deletions.
  1. +24 −23 vm/configuration.hpp
  2. +0 −20 vm/environment.cpp
  3. +1 −3 vm/llvm/jit_block.cpp
  4. +1 −3 vm/llvm/jit_inline_block.cpp
  5. +1 −5 vm/llvm/jit_visit.hpp
  6. +76 −1 vm/util/configuration.hpp
View
@@ -20,23 +20,22 @@ namespace rubinius {
config::Bytes gc_malloc_threshold;
// Language
+ config::Radio version;
+
#ifdef RBX_ENABLED_18
- config::Bool version_18;
-#define LANGUAGE_18_ENABLED(state) ((state)->shared.config.version_18)
+#define LANGUAGE_18_ENABLED(state) ((state)->shared.config.version >= 18)
#else
#define LANGUAGE_18_ENABLED(state) (false)
#endif
#ifdef RBX_ENABLED_19
- config::Bool version_19;
-#define LANGUAGE_19_ENABLED(state) ((state)->shared.config.version_19)
+#define LANGUAGE_19_ENABLED(state) ((state)->shared.config.version >= 19)
#else
#define LANGUAGE_19_ENABLED(state) (false)
#endif
#ifdef RBX_ENABLED_20
- config::Bool version_20;
-#define LANGUAGE_20_ENABLED(state) ((state)->shared.config.version_20)
+#define LANGUAGE_20_ENABLED(state) ((state)->shared.config.version >= 20)
#else
#define LANGUAGE_20_ENABLED(state) (false)
#endif
@@ -106,17 +105,7 @@ namespace rubinius {
, gc_malloc_threshold(this, "gc.malloc_threshold",
default_gc_malloc_threshold)
-#ifdef RBX_ENABLED_18
- , version_18(this, "18", false)
-#endif
-
-#ifdef RBX_ENABLED_19
- , version_19(this, "19", false)
-#endif
-
-#ifdef RBX_ENABLED_20
- , version_20(this, "20", false)
-#endif
+ , version(this, "version")
, dynamic_interpreter_enabled(this, "interpreter.dynamic")
, jit_dump_code(this, "jit.dump_code", default_jit_dump_code)
@@ -176,19 +165,31 @@ namespace rubinius {
"How many bytes allocated by C extensions til the GC is run");
#ifdef RBX_ENABLED_18
- version_18.set_description(
- "Set the supported language version to 1.8");
+#if RBX_DEFAULT_18
+ version.add("18", 18, true);
+#else
+ version.add("18", 18);
+#endif
#endif
#ifdef RBX_ENABLED_19
- version_19.set_description(
- "Set the supported language version to 1.9");
+#if RBX_DEFAULT_19
+ version.add("19", 19, true);
+#else
+ version.add("19", 19);
+#endif
#endif
#ifdef RBX_ENABLED_20
- version_20.set_description(
- "Set the supported language version to 2.0");
+#if RBX_DEFAULT_20
+ version.add("20", 20, true);
+#else
+ version.add("20", 20);
#endif
+#endif
+
+ version.set_description(
+ "Which version of ruby should we run");
jit_dump_code.set_description(
"1 == show simple IR, 2 == show optimized IR, 4 == show machine code");
View
@@ -360,26 +360,6 @@ namespace rubinius {
}
config_parser.update_configuration(config);
-
- // TODO: Add configuration type radio button.
- if(!(LANGUAGE_18_ENABLED(state) ||
- LANGUAGE_19_ENABLED(state) ||
- LANGUAGE_20_ENABLED(state))) {
-#ifdef RBX_ENABLED_18
- if(RBX_DEFAULT_18)
- state->shared.config.version_18.set("true");
-#endif
-
-#ifdef RBX_ENABLED_19
- if(RBX_DEFAULT_19)
- state->shared.config.version_19.set("true");
-#endif
-
-#ifdef RBX_ENABLED_20
- if(RBX_DEFAULT_20)
- state->shared.config.version_20.set("true");
-#endif
- }
}
void Environment::load_argv(int argc, char** argv) {
View
@@ -107,11 +107,9 @@ namespace jit {
setup_block_scope();
-#ifdef RBX_ENABLED_19
- if(ls_->config().version_19) {
+ if(ls_->config().version >= 19) {
import_args_19_style();
}
-#endif
if(ls_->include_profiling()) {
Value* test = b().CreateLoad(ls_->profiling(), "profiling");
@@ -91,8 +91,7 @@ namespace jit {
setup_inline_scope(self, constant(Qnil, obj_type), mod);
-#ifdef RBX_ENABLED_19
- if(ls_->config().version_19) {
+ if(ls_->config().version >= 19) {
// We don't support splat in an block method!
assert(vmm_->splat_position < 0);
@@ -117,7 +116,6 @@ namespace jit {
// No argument handling, there are bytecodes in the body that
// do that. We just have to make stack_args available.
}
-#endif
b().CreateBr(body);
b().SetInsertPoint(body);
View
@@ -1703,15 +1703,11 @@ namespace rubinius {
// Run the policy on the block code here, if we're not going to
// inline it, don't inline this either.
InlineOptions opts;
-#ifdef RBX_ENABLED_19
- if(ls_->config().version_19) {
+ if(ls_->config().version >= 19) {
opts.inlining_block_19();
} else {
opts.inlining_block();
}
-#else
- opts.inlining_block();
-#endif
InlineDecision decision = inline_policy()->inline_p(
block_code->backend_method(), opts);
View
@@ -55,7 +55,7 @@ namespace config {
virtual void set(const char* str) = 0;
virtual void print_value(std::ostream& stream) = 0;
- bool set_maybe(const char* key, const char* val) {
+ virtual bool set_maybe(const char* key, const char* val) {
if(strcmp(name_, key) != 0) return false;
set(val);
@@ -208,6 +208,81 @@ namespace config {
}
};
+ class Radio : public ConfigItem {
+ public:
+ int value;
+ int which;
+
+ private:
+ std::vector<const char*> names_;
+ std::vector<int> values_;
+
+ public:
+ Radio(Configuration* config, const char* name)
+ : ConfigItem(config, name)
+ {
+ value = 0;
+ which = -1;
+ }
+
+ int add(const char* name, int v, bool def=false) {
+ int w = names_.size();
+ names_.push_back(name);
+ values_.push_back(v);
+
+ if(def) {
+ value = v;
+ which = w;
+ }
+
+ return w;
+ }
+
+ virtual bool set_maybe(const char* key, const char* val) {
+ for(size_t i = 0; i < names_.size(); i++) {
+ if(strcmp(names_[i], key) == 0) {
+ which = i;
+ value = values_[i];
+ return true;
+ }
+ }
+
+ return ConfigItem::set_maybe(key, val);
+ }
+
+ virtual void set(const char* str) {
+ for(size_t i = 0; i < names_.size(); i++) {
+ if(strcmp(names_[i], str) == 0) {
+ which = i;
+ value = values_[i];
+ return;
+ }
+ }
+
+ which = -1;
+ value = 0;
+ }
+
+ virtual void print_value(std::ostream& stream) {
+ if(which < 0) {
+ stream << "<no value>";
+ } else {
+ stream << names_[which];
+ }
+
+ stream << " (possible:";
+ for(size_t i = 0; i < names_.size(); i++) {
+ stream << " " << names_[i];
+ }
+
+ stream << ")";
+ }
+
+ operator int() const {
+ return value;
+ }
+ };
+
class BoolSet : public Bool {
std::vector<Bool*> sub_bools_;

0 comments on commit fa7724a

Please sign in to comment.