public
Created

  • Download Gist
rubinius_macros_patch.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
diff --git a/kernel/loader.rb b/kernel/loader.rb
index 514453d..767820e 100644
--- a/kernel/loader.rb
+++ b/kernel/loader.rb
@@ -241,14 +241,9 @@ containing the Rubinius standard library files.
options.on "-c", "FILE", "Check the syntax of FILE" do |file|
if File.exists?(file)
- case
- when Rubinius.ruby18?
- parser = Rubinius::Melbourne
- when Rubinius.ruby19?
- parser = Rubinius::Melbourne19
- when Rubinius.ruby20?
- parser = Rubinius::Melbourne20
- else
+ parser = Rubinius::Compiler.default_compiler
+
+ unless parser
raise "no parser available for this ruby version"
end
diff --git a/lib/compiler/stages.rb b/lib/compiler/stages.rb
index 9505c96..a2e216b 100644
--- a/lib/compiler/stages.rb
+++ b/lib/compiler/stages.rb
@@ -2,6 +2,23 @@ module Rubinius
class Compiler
Stages = { }
+ def self.default_processor
+ @default_processor ||= case
+ when Rubinius.ruby18?
+ Rubinius::Melbourne
+ when Rubinius.ruby19?
+ Rubinius::Melbourne19
+ when Rubinius.ruby20?
+ Rubinius::Melbourne20
+ else
+ raise Exception, "no processor is defined for Parser compiler stage."
+ end
+ end
+
+ def self.default_processor=(processor)
+ @default_processor = processor
+ end
+
class Stage
attr_accessor :next_stage, :printer
@@ -163,16 +180,12 @@ module Rubinius
compiler.parser = self
@transforms = []
- case
- when Rubinius.ruby18?
- @processor = Rubinius::Melbourne
- when Rubinius.ruby19?
- @processor = Rubinius::Melbourne19
- when Rubinius.ruby20?
- @processor = Rubinius::Melbourne20
- else
+ @processor = Rubinius::Compiler.default_processor
+
+ unless @processor
raise Exception, "no processor is defined for Parser compiler stage."
end
+
end
def root(klass)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.