rubyjs 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/rubyjs CHANGED
@@ -26,7 +26,7 @@ def show_options
26
26
  end
27
27
 
28
28
  opts = OptionParser.new do |opts|
29
- opts.banner = "Usage: rubyjs_gen [options] [file, [file, ...]]"
29
+ opts.banner = "Usage: rubyjs [options] [file, [file, ...]]"
30
30
  opts.on("-r", "--require LIBRARY",
31
31
  "Require the LIBRARY before executing your script") do |lib|
32
32
  options.library << lib
data/rubyjs.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = 'rubyjs'
5
- s.version = '0.7.0'
5
+ s.version = '0.7.1'
6
6
  s.summary = 'RubyJS is a Ruby to Javascript Compiler.'
7
7
 
8
8
  s.files = Dir['**/*']
@@ -625,6 +625,47 @@ class MethodCompiler < SexpProcessor
625
625
  resultify(str)
626
626
  end
627
627
 
628
+ #
629
+ # for var in expr do ... end
630
+ #
631
+ def process_for(exp)
632
+ receiver = exp.shift
633
+ asgn = exp.shift
634
+ block = exp.shift
635
+
636
+ new_exp = [:iter,
637
+ [:call, receiver, :each],
638
+ asgn,
639
+ block]
640
+
641
+ process(new_exp)
642
+ end
643
+
644
+ def process_dot2(exp)
645
+ range(exp, false)
646
+ end
647
+
648
+ def process_dot3(exp)
649
+ range(exp, true)
650
+ end
651
+
652
+ def range(exp, exclude_end)
653
+ from = exp.shift
654
+ to = exp.shift
655
+
656
+ without_result do
657
+ want_expression do
658
+ from = process(from)
659
+ to = process(to)
660
+ end
661
+ end
662
+
663
+ range = @model.lookup_constant('::Range')
664
+ @model.add_method_call(m = @model.encode_method("new"))
665
+ res = "#{range}.#{m}(#{@model.encode_nil},#{from},#{to},#{exclude_end})"
666
+ resultify(res)
667
+ end
668
+
628
669
  #
629
670
  # EXPRESSION
630
671
  #