diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-06 04:00:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-06 04:00:09 +0000 |
commit | ee8f40b5a62a15298c668b57b3504e177289972c (patch) | |
tree | e09b17b58b0cc1e653834a68db6a7432ad03e085 /lib/vm | |
parent | d690c9283c8af8c4714524b0a3e98cdcae36980f (diff) | |
download | ruby-ee8f40b5a62a15298c668b57b3504e177289972c.tar.gz |
* common.mk (INSNS): not chdir to srcdir.
* lib/vm/instruction.rb (RubyVM::SourceCodeGenerator): --destdir
option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/vm')
-rw-r--r-- | lib/vm/instruction.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/vm/instruction.rb b/lib/vm/instruction.rb index 20c0fb41da..ed59af0faa 100644 --- a/lib/vm/instruction.rb +++ b/lib/vm/instruction.rb @@ -97,6 +97,7 @@ module RubyVM @vpath = opts[:VPATH] || File @use_const = opts[:use_const] @verbose = opts[:verbose] + @destdir = opts[:destdir] (@vm_opts = load_vm_opts).each {|k, v| @vm_opts[k] = opts[k] if opts.key?(k) @@ -110,6 +111,7 @@ module RubyVM end attr_reader :vpath + attr_reader :destdir %w[use_const verbose].each do |attr| attr_reader attr @@ -252,11 +254,7 @@ module RubyVM insn_in = true body = '' - if /\/\/(.+)/ =~ rets_str - sp_inc = $1 - else - sp_inc = nil - end + sp_inc = rets_str[%r"//\s*(.+)", 1] raise unless /^\{$/ =~ f.gets.chomp line_no = f.line_no @@ -639,6 +637,12 @@ module RubyVM def use_const? @insns.use_const? end + + def output_path(fn) + d = @insns.destdir + fn = File.join(d, fn) if d + fn + end end ################################################################### @@ -1269,7 +1273,7 @@ module RubyVM args = Files.keys if args.empty? args.each{|fn| s = Files[fn].new(@insns).generate - open(fn, 'w') {|f| f.puts(s)} + open(output_path(fn), 'w') {|f| f.puts(s)} } end @@ -1310,6 +1314,10 @@ module RubyVM "use consts for default operands instead of macros") {|v| opts[:use_const] = v } + opt.on("-d", "--destdir", "--output-directory=DIR", + "make output file underneath DIR") {|v| + opts[:destdir] = v + } opt.on("-V", "--[no-]verbose") {|v| opts[:verbose] = v } |