rubyjs 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/rubyjs +1 -1
- data/rubyjs.gemspec +1 -1
- data/src/rubyjs/compiler.rb +41 -0
- data/test/browser.test.html +618 -328
- data/test/browser.test.js +2000 -1797
- data/test/test_hot_ruby.rb +146 -0
- data/test/test_insertion_sort.rb +25 -0
- data/test/test_range.rb +17 -0
- metadata +126 -124
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:
|
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
data/src/rubyjs/compiler.rb
CHANGED
@@ -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
|
#
|