opal 0.3.21 → 0.3.22
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -4
- data/Gemfile +9 -4
- data/README.md +10 -589
- data/Rakefile +51 -19
- data/config.ru +17 -0
- data/core/array.rb +42 -34
- data/core/basic_object.rb +4 -4
- data/core/browser.js +31 -0
- data/core/class.rb +7 -7
- data/core/enumerable.rb +65 -69
- data/core/erb.rb +30 -0
- data/core/error.rb +2 -3
- data/core/hash.rb +47 -18
- data/core/kernel.rb +15 -16
- data/core/load_order +2 -1
- data/core/module.rb +19 -37
- data/core/numeric.rb +4 -2
- data/core/object.rb +4 -0
- data/core/proc.rb +6 -3
- data/core/racc.rb +215 -0
- data/core/regexp.rb +16 -21
- data/core/runtime.js +141 -153
- data/core/string.rb +41 -19
- data/core/strscan.rb +61 -0
- data/core/time.rb +1 -5
- data/docs/index.md +616 -0
- data/docs/post.html +2 -8
- data/docs/pre.html +29 -26
- data/docs/try.html +52 -0
- data/lib/opal.rb +33 -3
- data/lib/opal/builder.rb +14 -34
- data/lib/opal/erb_parser.rb +19 -0
- data/lib/opal/grammar.rb +7 -3
- data/lib/opal/grammar.y +3 -0
- data/lib/opal/lexer.rb +16 -8
- data/lib/opal/parser.rb +156 -119
- data/lib/opal/rake_task.rb +2 -2
- data/lib/opal/scope.rb +9 -10
- data/lib/opal/version.rb +1 -1
- data/{test → spec}/core/array/allocate_spec.rb +0 -0
- data/{test → spec}/core/array/append_spec.rb +0 -0
- data/{test → spec}/core/array/assoc_spec.rb +0 -0
- data/{test → spec}/core/array/at_spec.rb +0 -0
- data/{test → spec}/core/array/clear_spec.rb +0 -0
- data/{test → spec}/core/array/clone_spec.rb +0 -0
- data/{test → spec}/core/array/collect_spec.rb +0 -0
- data/{test → spec}/core/array/compact_spec.rb +0 -0
- data/{test → spec}/core/array/concat_spec.rb +0 -0
- data/{test → spec}/core/array/constructor_spec.rb +0 -0
- data/{test → spec}/core/array/count_spec.rb +0 -0
- data/{test → spec}/core/array/delete_at_spec.rb +0 -0
- data/{test → spec}/core/array/delete_if_spec.rb +0 -0
- data/{test → spec}/core/array/delete_spec.rb +0 -0
- data/{test → spec}/core/array/each_index_spec.rb +0 -0
- data/{test → spec}/core/array/each_spec.rb +0 -0
- data/{test → spec}/core/array/element_reference_spec.rb +0 -0
- data/{test → spec}/core/array/empty_spec.rb +0 -0
- data/{test → spec}/core/array/eql_spec.rb +0 -0
- data/{test → spec}/core/array/fetch_spec.rb +0 -0
- data/{test → spec}/core/array/first_spec.rb +0 -0
- data/{test → spec}/core/array/flatten_spec.rb +0 -0
- data/{test → spec}/core/array/include_spec.rb +0 -0
- data/{test → spec}/core/array/insert_spec.rb +0 -0
- data/{test → spec}/core/array/last_spec.rb +0 -0
- data/{test → spec}/core/array/length_spec.rb +0 -0
- data/{test → spec}/core/array/map_spec.rb +0 -0
- data/{test → spec}/core/array/minus_spec.rb +0 -0
- data/{test → spec}/core/array/plus_spec.rb +0 -0
- data/{test → spec}/core/array/pop_spec.rb +0 -0
- data/{test → spec}/core/array/push_spec.rb +0 -0
- data/{test → spec}/core/array/rassoc_spec.rb +0 -0
- data/{test → spec}/core/array/reject_spec.rb +0 -0
- data/{test → spec}/core/array/replace_spec.rb +0 -0
- data/{test → spec}/core/array/reverse_each_spec.rb +0 -0
- data/{test → spec}/core/array/reverse_spec.rb +0 -0
- data/{test → spec}/core/array/size_spec.rb +0 -0
- data/{test → spec}/core/array/to_ary_spec.rb +0 -0
- data/{test → spec}/core/array/uniq_spec.rb +0 -0
- data/{test → spec}/core/array/zip_spec.rb +0 -0
- data/{test → spec}/core/class/fixtures/classes.rb +0 -0
- data/{test → spec}/core/class/new_spec.rb +3 -0
- data/{test → spec}/core/enumerable/all_spec.rb +3 -0
- data/{test → spec}/core/enumerable/any_spec.rb +0 -0
- data/{test → spec}/core/enumerable/collect_spec.rb +0 -0
- data/{test → spec}/core/enumerable/count_spec.rb +0 -0
- data/{test → spec}/core/enumerable/detect_spec.rb +0 -0
- data/{test → spec}/core/enumerable/drop_spec.rb +0 -0
- data/{test → spec}/core/enumerable/drop_while_spec.rb +0 -0
- data/{test → spec}/core/enumerable/each_with_index_spec.rb +0 -0
- data/{test → spec}/core/enumerable/each_with_object_spec.rb +0 -0
- data/{test → spec}/core/enumerable/entries_spec.rb +0 -0
- data/{test → spec}/core/enumerable/find_all_spec.rb +0 -0
- data/{test → spec}/core/enumerable/find_index_spec.rb +0 -0
- data/{test → spec}/core/enumerable/find_spec.rb +0 -0
- data/{test → spec}/core/enumerable/first_spec.rb +0 -0
- data/{test → spec}/core/enumerable/fixtures/classes.rb +0 -0
- data/{test → spec}/core/enumerable/grep_spec.rb +0 -0
- data/{test → spec}/core/enumerable/take_spec.rb +0 -0
- data/{test → spec}/core/enumerable/to_a_spec.rb +0 -0
- data/{test → spec}/core/false/and_spec.rb +0 -0
- data/{test → spec}/core/false/inspect_spec.rb +0 -0
- data/{test → spec}/core/false/or_spec.rb +0 -0
- data/{test → spec}/core/false/to_s_spec.rb +0 -0
- data/{test → spec}/core/false/xor_spec.rb +0 -0
- data/{test → spec}/core/hash/allocate_spec.rb +0 -0
- data/{test → spec}/core/hash/assoc_spec.rb +0 -0
- data/{test → spec}/core/hash/clear_spec.rb +0 -0
- data/{test → spec}/core/hash/clone_spec.rb +0 -0
- data/{test → spec}/core/hash/default_spec.rb +0 -0
- data/{test → spec}/core/hash/delete_if_spec.rb +0 -0
- data/{test → spec}/core/hash/each_key_spec.rb +0 -0
- data/{test → spec}/core/hash/each_pair_spec.rb +0 -0
- data/{test → spec}/core/hash/each_spec.rb +0 -0
- data/{test → spec}/core/hash/each_value_spec.rb +0 -0
- data/{test → spec}/core/hash/element_reference_spec.rb +14 -1
- data/{test → spec}/core/hash/element_set_spec.rb +0 -0
- data/{test → spec}/core/hash/empty_spec.rb +0 -0
- data/{test → spec}/core/hash/fetch_spec.rb +0 -0
- data/{test → spec}/core/hash/flatten_spec.rb +0 -0
- data/{test → spec}/core/hash/has_key_spec.rb +0 -0
- data/{test → spec}/core/hash/has_value_spec.rb +0 -0
- data/{test → spec}/core/hash/include_spec.rb +0 -0
- data/{test → spec}/core/hash/index_spec.rb +0 -0
- data/{test → spec}/core/hash/indexes_spec.rb +0 -0
- data/{test → spec}/core/hash/indices_spec.rb +0 -0
- data/{test → spec}/core/hash/invert_spec.rb +0 -0
- data/{test → spec}/core/hash/keep_if_spec.rb +0 -0
- data/{test → spec}/core/hash/key_spec.rb +0 -0
- data/{test → spec}/core/hash/keys_spec.rb +0 -0
- data/{test → spec}/core/hash/length_spec.rb +0 -0
- data/{test → spec}/core/hash/member_spec.rb +0 -0
- data/{test → spec}/core/hash/merge_spec.rb +0 -0
- data/{test → spec}/core/hash/new_spec.rb +8 -0
- data/{test → spec}/core/hash/rassoc_spec.rb +0 -0
- data/{test → spec}/core/hash/replace_spec.rb +0 -0
- data/{test → spec}/core/hash/select_spec.rb +0 -0
- data/{test → spec}/core/hash/shift_spec.rb +0 -0
- data/{test → spec}/core/hash/size_spec.rb +0 -0
- data/{test → spec}/core/hash/update_spec.rb +0 -0
- data/{test → spec}/core/hash/value_spec.rb +0 -0
- data/{test → spec}/core/hash/values_at_spec.rb +0 -0
- data/{test → spec}/core/hash/values_spec.rb +0 -0
- data/{test → spec}/core/kernel/define_singleton_method_spec.rb +0 -0
- data/{test → spec}/core/kernel/eql_spec.rb +0 -0
- data/{test → spec}/core/kernel/equal_value_spec.rb +0 -0
- data/{test → spec}/core/kernel/loop_spec.rb +0 -0
- data/{test → spec}/core/kernel/nil_spec.rb +0 -0
- data/{test → spec}/core/kernel/proc_spec.rb +4 -0
- data/{test → spec}/core/kernel/rand_spec.rb +0 -0
- data/{test → spec}/core/kernel/respond_to_spec.rb +0 -0
- data/{test → spec}/core/kernel/send_spec.rb +0 -0
- data/{test → spec}/core/kernel/tap_spec.rb +0 -0
- data/{test → spec}/core/kernel/to_s_spec.rb +0 -0
- data/{test → spec}/core/matchdata/to_a_spec.rb +0 -0
- data/{test → spec}/core/nil/and_spec.rb +0 -0
- data/{test → spec}/core/nil/inspect_spec.rb +0 -0
- data/{test → spec}/core/nil/nil_spec.rb +0 -0
- data/{test → spec}/core/nil/or_spec.rb +0 -0
- data/{test → spec}/core/nil/to_a_spec.rb +0 -0
- data/{test → spec}/core/nil/to_f_spec.rb +0 -0
- data/{test → spec}/core/nil/to_i_spec.rb +0 -0
- data/{test → spec}/core/nil/to_s_spec.rb +0 -0
- data/{test → spec}/core/nil/xor_spec.rb +0 -0
- data/{test → spec}/core/numeric/equal_value_spec.rb +0 -0
- data/spec/core/proc/proc_tricks_spec.rb +7 -0
- data/{test → spec}/core/range/begin_spec.rb +0 -0
- data/{test → spec}/core/range/case_compare_spec.rb +0 -0
- data/{test → spec}/core/range/end_spec.rb +0 -0
- data/{test → spec}/core/regexp/match_spec.rb +0 -0
- data/{test → spec}/core/string/capitalize_spec.rb +0 -0
- data/{test → spec}/core/string/casecmp_spec.rb +0 -0
- data/{test → spec}/core/string/chomp_spec.rb +0 -0
- data/{test → spec}/core/string/chop_spec.rb +0 -0
- data/{test → spec}/core/string/chr_spec.rb +0 -0
- data/{test → spec}/core/string/comparison_spec.rb +0 -0
- data/{test → spec}/core/string/downcase_spec.rb +0 -0
- data/{test → spec}/core/string/element_reference_spec.rb +14 -2
- data/{test → spec}/core/string/empty_spec.rb +0 -0
- data/{test → spec}/core/string/end_with_spec.rb +0 -0
- data/{test → spec}/core/string/fixtures/classes.rb +0 -0
- data/{test → spec}/core/string/gsub_spec.rb +0 -0
- data/{test → spec}/core/string/include_spec.rb +0 -0
- data/{test → spec}/core/string/intern_spec.rb +0 -0
- data/{test → spec}/core/string/length_spec.rb +0 -0
- data/{test → spec}/core/string/lstrip_spec.rb +0 -0
- data/{test → spec}/core/string/match_spec.rb +0 -0
- data/{test → spec}/core/string/next_spec.rb +0 -0
- data/{test → spec}/core/string/ord_spec.rb +0 -0
- data/{test → spec}/core/string/partition_spec.rb +0 -0
- data/{test → spec}/core/string/reverse_spec.rb +0 -0
- data/{test → spec}/core/string/rstrip_spec.rb +0 -0
- data/{test → spec}/core/string/size_spec.rb +0 -0
- data/{test → spec}/core/string/slice_spec.rb +4 -1
- data/{test → spec}/core/string/split_spec.rb +0 -0
- data/{test → spec}/core/string/start_with_spec.rb +0 -0
- data/{test → spec}/core/string/strip_spec.rb +0 -0
- data/{test → spec}/core/string/sub_spec.rb +0 -0
- data/{test → spec}/core/string/succ_spec.rb +0 -0
- data/{test → spec}/core/string/sum_spec.rb +0 -0
- data/{test → spec}/core/string/swapcase_spec.rb +0 -0
- data/{test → spec}/core/string/to_a_spec.rb +0 -0
- data/{test → spec}/core/string/to_f_spec.rb +0 -0
- data/{test → spec}/core/string/to_i_spec.rb +0 -0
- data/{test → spec}/core/string/to_s_spec.rb +0 -0
- data/{test → spec}/core/string/to_str_spec.rb +0 -0
- data/{test → spec}/core/string/to_sym_spec.rb +0 -0
- data/{test → spec}/core/string/upcase_spec.rb +0 -0
- data/{test → spec}/core/symbol/to_proc_spec.rb +0 -0
- data/{test → spec}/core/time/at_spec.rb +0 -0
- data/{test → spec}/core/time/day_spec.rb +0 -0
- data/{test → spec}/core/time/friday_spec.rb +0 -0
- data/{test → spec}/core/time/hour_spec.rb +0 -0
- data/{test → spec}/core/time/min_spec.rb +0 -0
- data/{test → spec}/core/time/monday_spec.rb +0 -0
- data/{test → spec}/core/time/month_spec.rb +0 -0
- data/{test → spec}/core/time/now_spec.rb +0 -0
- data/{test → spec}/core/time/saturday_spec.rb +0 -0
- data/{test → spec}/core/true/and_spec.rb +0 -0
- data/{test → spec}/core/true/inspect_spec.rb +0 -0
- data/{test → spec}/core/true/or_spec.rb +0 -0
- data/{test → spec}/core/true/to_s_spec.rb +0 -0
- data/{test → spec}/core/true/xor_spec.rb +0 -0
- data/spec/grammar/lvar_spec.rb +2 -1
- data/spec/grammar/str_spec.rb +1 -1
- data/spec/grammar/xstr_spec.rb +1 -1
- data/{test → spec}/index.html +3 -3
- data/{test → spec}/language/alias_spec.rb +0 -0
- data/{test → spec}/language/and_spec.rb +0 -0
- data/{test → spec}/language/array_spec.rb +0 -0
- data/{test → spec}/language/block_spec.rb +0 -0
- data/{test → spec}/language/break_spec.rb +0 -0
- data/{test → spec}/language/case_spec.rb +0 -0
- data/{test → spec}/language/defined_spec.rb +0 -0
- data/{test → spec}/language/ensure_spec.rb +2 -2
- data/{test → spec}/language/fixtures/next.rb +0 -0
- data/{test → spec}/language/fixtures/yield.rb +0 -0
- data/{test → spec}/language/hash_spec.rb +0 -0
- data/{test → spec}/language/if_spec.rb +0 -0
- data/{test → spec}/language/literal_lambda_spec.rb +0 -0
- data/{test → spec}/language/loop_spec.rb +0 -0
- data/{test → spec}/language/metaclass_spec.rb +0 -0
- data/{test → spec}/language/next_spec.rb +2 -0
- data/{test → spec}/language/or_spec.rb +0 -0
- data/{test → spec}/language/predefined_spec.rb +0 -0
- data/{test → spec}/language/regexp_spec.rb +0 -0
- data/{test → spec}/language/send_spec.rb +0 -0
- data/{test → spec}/language/singleton_class_spec.rb +0 -0
- data/{test → spec}/language/super_spec.rb +0 -0
- data/{test → spec}/language/symbol_spec.rb +0 -0
- data/{test → spec}/language/undef_spec.rb +0 -0
- data/{test → spec}/language/unless_spec.rb +0 -0
- data/{test → spec}/language/until_spec.rb +0 -0
- data/{test → spec}/language/variables_spec.rb +0 -0
- data/{test → spec}/language/while_spec.rb +0 -0
- data/{test → spec}/language/yield_spec.rb +2 -0
- data/{test → spec}/opal/array/subclassing_spec.rb +0 -0
- data/{test → spec}/opal/array/to_json_spec.rb +0 -0
- data/{test → spec}/opal/boolean/singleton_class_spec.rb +0 -0
- data/{test → spec}/opal/boolean/to_json_spec.rb +0 -0
- data/{test → spec}/opal/class/bridge_class_spec.rb +0 -0
- data/spec/opal/erb/erb_spec.rb +15 -0
- data/{test → spec}/opal/exception/subclassing_spec.rb +0 -0
- data/{test → spec}/opal/hash/to_json_spec.rb +0 -0
- data/spec/opal/hash/to_native_spec.rb +5 -0
- data/{test → spec}/opal/json/parse_spec.rb +0 -0
- data/{test → spec}/opal/kernel/to_json_spec.rb +0 -0
- data/{test → spec}/opal/nil/to_json_spec.rb +0 -0
- data/{test → spec}/opal/numeric/to_json_spec.rb +0 -0
- data/{test → spec}/opal/runtime/call_spec.rb +0 -0
- data/{test → spec}/opal/runtime/class_hierarchy_spec.rb +0 -0
- data/{test → spec}/opal/runtime/def_spec.rb +0 -0
- data/{test → spec}/opal/runtime/defined_spec.rb +0 -0
- data/{test → spec}/opal/runtime/method_missing_spec.rb +3 -3
- data/{test → spec}/opal/runtime/super_spec.rb +0 -0
- data/{test → spec}/opal/string/subclassing_spec.rb +0 -0
- data/{test → spec}/opal/string/to_json_spec.rb +0 -0
- data/spec/opal/strscan/check_spec.rb +13 -0
- data/spec/opal/strscan/scan_spec.rb +33 -0
- data/spec/parser/simple_spec.rb +44 -0
- data/spec/spec_helper.rb +7 -7
- metadata +487 -497
- data/core/dir.rb +0 -89
- data/core/file.rb +0 -85
- data/spec/browser_spec.rb +0 -28
- data/spec/builder/fixtures/build_source/adam.rb +0 -0
- data/spec/builder/fixtures/build_source/bar/a.rb +0 -0
- data/spec/builder/fixtures/build_source/bar/wow/b.rb +0 -0
- data/spec/builder/fixtures/build_source/bar/wow/cow/c.rb +0 -0
- data/spec/builder/fixtures/build_source/beynon.rb +0 -0
- data/spec/builder/fixtures/build_source/charles.js +0 -0
- data/spec/builder/fixtures/build_source/foo/a.rb +0 -0
- data/spec/builder/fixtures/build_source/foo/b.rb +0 -0
- data/spec/builder/fixtures/build_source/foo/x.js +0 -0
- data/spec/builder/fixtures/build_source/foo/y.js +0 -0
- data/spec/builder/lib_name_for_spec.rb +0 -19
- data/test/index.min.html +0 -12
- data/test/spec_helper.rb +0 -4
data/core/object.rb
CHANGED
data/core/proc.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
class Proc < `Function`
|
2
2
|
%x{
|
3
3
|
Proc_prototype._isProc = true;
|
4
|
+
Proc_prototype.is_lambda = true;
|
4
5
|
}
|
5
6
|
|
6
7
|
def self.new(&block)
|
7
8
|
`if (block === nil) no_block_given();`
|
8
|
-
|
9
|
+
`block.is_lambda = false`
|
9
10
|
block
|
10
11
|
end
|
11
12
|
|
@@ -14,7 +15,7 @@ class Proc < `Function`
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def call(*args)
|
17
|
-
`#{self}.apply(
|
18
|
+
`#{self}.apply(#{self}._s, #{args})`
|
18
19
|
end
|
19
20
|
|
20
21
|
def to_proc
|
@@ -22,7 +23,9 @@ class Proc < `Function`
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def lambda?
|
25
|
-
|
26
|
+
# This method should tell the user if the proc tricks are unavailable,
|
27
|
+
# (see Proc#lambda? on ruby docs to find out more).
|
28
|
+
`!!#{self}.is_lambda`
|
26
29
|
end
|
27
30
|
|
28
31
|
def arity
|
data/core/racc.rb
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
# Opal port of racc/parser.rb.
|
2
|
+
#
|
3
|
+
# Original license:
|
4
|
+
#
|
5
|
+
# $originalId: parser.rb,v 1.8 2006/07/06 11:42:07 aamine Exp $
|
6
|
+
#
|
7
|
+
# Copyright (c) 1999-2006 Minero Aoki
|
8
|
+
#
|
9
|
+
# This program is free software.
|
10
|
+
# You can distribute/modify this program under the same terms of ruby.
|
11
|
+
#
|
12
|
+
# As a special exception, when this code is copied by Racc
|
13
|
+
# into a Racc output file, you may use that output file
|
14
|
+
# without restriction.
|
15
|
+
module Racc
|
16
|
+
|
17
|
+
class Parser
|
18
|
+
|
19
|
+
def _racc_setup
|
20
|
+
self.class::Racc_arg
|
21
|
+
end
|
22
|
+
|
23
|
+
def do_parse
|
24
|
+
_racc_do_parse_rb _racc_setup, false
|
25
|
+
end
|
26
|
+
|
27
|
+
def _racc_do_parse_rb(arg, in_debug)
|
28
|
+
action_table = arg[0]
|
29
|
+
action_check = arg[1]
|
30
|
+
action_default = arg[2]
|
31
|
+
action_pointer = arg[3]
|
32
|
+
|
33
|
+
goto_table = arg[4]
|
34
|
+
goto_check = arg[5]
|
35
|
+
goto_default = arg[6]
|
36
|
+
goto_pointer = arg[7]
|
37
|
+
|
38
|
+
nt_base = arg[8]
|
39
|
+
reduce_table = arg[9]
|
40
|
+
token_table = arg[10]
|
41
|
+
shift_n = arg[11]
|
42
|
+
reduce_n = arg[12]
|
43
|
+
|
44
|
+
use_result = arg[13]
|
45
|
+
|
46
|
+
# racc sys vars
|
47
|
+
racc_state = [0]
|
48
|
+
racc_tstack = []
|
49
|
+
racc_vstack = []
|
50
|
+
|
51
|
+
racc_t = nil
|
52
|
+
racc_tok = nil
|
53
|
+
racc_val = nil
|
54
|
+
racc_read_next = true
|
55
|
+
|
56
|
+
racc_user_yyerror = false
|
57
|
+
racc_error_status = 0
|
58
|
+
|
59
|
+
token = nil; act = nil; i = nil; nerr = nil; custate = nil
|
60
|
+
|
61
|
+
while true
|
62
|
+
i = action_pointer[racc_state[-1]]
|
63
|
+
|
64
|
+
if i
|
65
|
+
if racc_read_next
|
66
|
+
if racc_t != 0 # not EOF
|
67
|
+
token = next_token
|
68
|
+
|
69
|
+
racc_tok = token[0]
|
70
|
+
racc_val = token[1]
|
71
|
+
|
72
|
+
if racc_tok == false # EOF
|
73
|
+
racc_t = 0
|
74
|
+
else
|
75
|
+
racc_t = token_table[racc_tok]
|
76
|
+
racc_t = 1 unless racc_t
|
77
|
+
# racc_t ||= 1
|
78
|
+
end
|
79
|
+
|
80
|
+
racc_read_token(racc_t, racc_tok, racc_val) if @yydebug
|
81
|
+
racc_read_next = false
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
i += racc_t
|
86
|
+
|
87
|
+
if (i < 0) || (act = action_table[i]).nil? || (action_check[i] != racc_state[-1])
|
88
|
+
act = action_default[racc_state[-1]]
|
89
|
+
end
|
90
|
+
|
91
|
+
else
|
92
|
+
act = action_default[racc_state[-1]]
|
93
|
+
end
|
94
|
+
|
95
|
+
puts "(act: #{act}, shift_n: #{shift_n}, reduce_n: #{reduce_n})" if @yydebug
|
96
|
+
if act > 0 && act < shift_n
|
97
|
+
if racc_error_status > 0
|
98
|
+
if racc_t != 1
|
99
|
+
racc_error_status -= 1
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
racc_vstack.push racc_val
|
104
|
+
curstate = act
|
105
|
+
racc_state << act
|
106
|
+
racc_read_next = true
|
107
|
+
|
108
|
+
if @yydebug
|
109
|
+
racc_tstack.push racc_t
|
110
|
+
racc_shift racc_t, racc_tstack, racc_vstack
|
111
|
+
end
|
112
|
+
|
113
|
+
elsif act < 0 && act > -reduce_n
|
114
|
+
reduce_i = act * -3
|
115
|
+
reduce_len = reduce_table[reduce_i]
|
116
|
+
reduce_to = reduce_table[reduce_i + 1]
|
117
|
+
method_id = reduce_table[reduce_i + 2]
|
118
|
+
|
119
|
+
tmp_t = racc_tstack.last reduce_len
|
120
|
+
tmp_v = racc_vstack.last reduce_len
|
121
|
+
|
122
|
+
racc_state.pop reduce_len
|
123
|
+
racc_vstack.pop reduce_len
|
124
|
+
racc_tstack.pop reduce_len
|
125
|
+
|
126
|
+
if use_result
|
127
|
+
reduce_call_result = self.__send__ method_id, tmp_v, nil, tmp_v[0]
|
128
|
+
racc_vstack.push reduce_call_result
|
129
|
+
else
|
130
|
+
raise "not using result??"
|
131
|
+
end
|
132
|
+
|
133
|
+
racc_tstack.push reduce_to
|
134
|
+
|
135
|
+
if @yydebug
|
136
|
+
racc_reduce tmp_t, reduce_to, racc_tstack, racc_vstack
|
137
|
+
end
|
138
|
+
|
139
|
+
k1 = reduce_to - nt_base
|
140
|
+
|
141
|
+
if (reduce_i = goto_pointer[k1]) != nil
|
142
|
+
reduce_i += racc_state[-1]
|
143
|
+
|
144
|
+
if (reduce_i >= 0) && ((curstate = goto_table[reduce_i]) != nil) && (goto_check[reduce_i] == k1)
|
145
|
+
racc_state.push curstate
|
146
|
+
else
|
147
|
+
racc_state.push goto_default[k1]
|
148
|
+
end
|
149
|
+
|
150
|
+
else
|
151
|
+
racc_state.push goto_default[k1]
|
152
|
+
end
|
153
|
+
|
154
|
+
elsif act == shift_n
|
155
|
+
# action
|
156
|
+
return racc_vstack[0]
|
157
|
+
|
158
|
+
elsif act == -reduce_n
|
159
|
+
# reduce
|
160
|
+
raise "Opal Syntax Error: unexpected '#{racc_tok.inspect}'"
|
161
|
+
|
162
|
+
else
|
163
|
+
raise "Rac: unknown action: #{act}"
|
164
|
+
end
|
165
|
+
|
166
|
+
if @yydebug
|
167
|
+
racc_next_state racc_state[-1], racc_state
|
168
|
+
end
|
169
|
+
# raise "and finished loop"
|
170
|
+
end
|
171
|
+
|
172
|
+
end # _racc_do_parse_rb
|
173
|
+
|
174
|
+
def racc_read_token(t, tok, val)
|
175
|
+
puts "read #{tok}(#{racc_token2str(t)}) #{val.inspect}"
|
176
|
+
puts "\n"
|
177
|
+
end
|
178
|
+
|
179
|
+
def racc_shift(tok, tstack, vstack)
|
180
|
+
puts "shift #{racc_token2str tok}"
|
181
|
+
racc_print_stacks tstack, vstack
|
182
|
+
puts "\n"
|
183
|
+
end
|
184
|
+
|
185
|
+
def racc_reduce(toks, sim, tstack, vstack)
|
186
|
+
puts "reduce #{toks.empty? ? '<none>' : toks.map { |t| racc_token2str(t) }}"
|
187
|
+
puts " --> #{racc_token2str(sim)}"
|
188
|
+
racc_print_stacks tstack, vstack
|
189
|
+
end
|
190
|
+
|
191
|
+
def racc_next_state(curstate, state)
|
192
|
+
puts "goto #{curstate}"
|
193
|
+
racc_print_states state
|
194
|
+
puts "\n"
|
195
|
+
end
|
196
|
+
|
197
|
+
def racc_token2str(tok)
|
198
|
+
self.class::Racc_token_to_s_table[tok]
|
199
|
+
end
|
200
|
+
|
201
|
+
def racc_print_stacks(t, v)
|
202
|
+
puts ' ['
|
203
|
+
t.each_index do |i|
|
204
|
+
puts " (#{racc_token2str(t[i])} #{v[i].inspect})"
|
205
|
+
end
|
206
|
+
puts ' ]'
|
207
|
+
end
|
208
|
+
|
209
|
+
def racc_print_states(s)
|
210
|
+
puts ' ['
|
211
|
+
s.each { |st| puts " #{st}" }
|
212
|
+
puts ' ]'
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
data/core/regexp.rb
CHANGED
@@ -20,9 +20,9 @@ class Regexp < `RegExp`
|
|
20
20
|
var result = #{self}.exec(string);
|
21
21
|
|
22
22
|
if (result) {
|
23
|
-
|
24
|
-
result.$
|
25
|
-
result
|
23
|
+
result.$to_s = match_to_s;
|
24
|
+
result.$inspect = match_inspect;
|
25
|
+
result._klass = #{MatchData};
|
26
26
|
|
27
27
|
#{$~ = `result`};
|
28
28
|
}
|
@@ -45,9 +45,9 @@ class Regexp < `RegExp`
|
|
45
45
|
var result = #{self}.exec(pattern);
|
46
46
|
|
47
47
|
if (result) {
|
48
|
-
|
49
|
-
result.$
|
50
|
-
result
|
48
|
+
result.$to_s = match_to_s;
|
49
|
+
result.$inspect = match_inspect;
|
50
|
+
result._klass = #{MatchData};
|
51
51
|
|
52
52
|
return #{$~ = `result`};
|
53
53
|
}
|
@@ -60,22 +60,17 @@ class Regexp < `RegExp`
|
|
60
60
|
def to_s
|
61
61
|
`#{self}.source`
|
62
62
|
end
|
63
|
-
end
|
64
|
-
|
65
|
-
class MatchData
|
66
|
-
def [](idx)
|
67
|
-
`#{self}[idx]`
|
68
|
-
end
|
69
63
|
|
70
|
-
|
71
|
-
|
72
|
-
|
64
|
+
%x{
|
65
|
+
function match_to_s() {
|
66
|
+
return this[0];
|
67
|
+
}
|
73
68
|
|
74
|
-
|
75
|
-
|
76
|
-
|
69
|
+
function match_inspect() {
|
70
|
+
return "<#MatchData " + this[0].$inspect() + ">";
|
71
|
+
}
|
72
|
+
}
|
73
|
+
end
|
77
74
|
|
78
|
-
|
79
|
-
self[0]
|
80
|
-
end
|
75
|
+
class MatchData
|
81
76
|
end
|
data/core/runtime.js
CHANGED
@@ -28,12 +28,6 @@ Opal.alloc = TopScope;
|
|
28
28
|
// This is a useful reference to global object inside ruby files
|
29
29
|
Opal.global = this;
|
30
30
|
|
31
|
-
// Root method table (BasicObject inherits from this)
|
32
|
-
function RootMethodTableConstructor() {}
|
33
|
-
|
34
|
-
// The prototype (actual table) for root
|
35
|
-
var RootMethodTable = RootMethodTableConstructor.prototype;
|
36
|
-
|
37
31
|
// Minify common function calls
|
38
32
|
var __hasOwn = Opal.hasOwnProperty;
|
39
33
|
var __slice = Opal.slice = Array.prototype.slice;
|
@@ -47,34 +41,6 @@ Opal.cvars = {};
|
|
47
41
|
// Globals table
|
48
42
|
Opal.gvars = {};
|
49
43
|
|
50
|
-
var method_missing_mid = '';
|
51
|
-
|
52
|
-
function method_missing_handler(self) {
|
53
|
-
var args = __slice.call(arguments, 1);
|
54
|
-
return self.$m.method_missing.apply(null, [self, method_missing_mid].concat(args));
|
55
|
-
}
|
56
|
-
|
57
|
-
Opal.mm = function(mid) {
|
58
|
-
method_missing_mid = mid;
|
59
|
-
return method_missing_handler;
|
60
|
-
};
|
61
|
-
|
62
|
-
Opal.send = function(recv, mid) {
|
63
|
-
var args = __slice.call(arguments, 2);
|
64
|
-
return (recv.$m[mid] || Opal.mm(mid)).apply(null, [recv].concat(args));
|
65
|
-
};
|
66
|
-
|
67
|
-
// define singleton method
|
68
|
-
Opal.defs = function(obj, name, method) {
|
69
|
-
var singleton;
|
70
|
-
|
71
|
-
if (!(singleton = obj._singleton)) {
|
72
|
-
singleton = Opal.send(obj, 'singleton_class');
|
73
|
-
}
|
74
|
-
|
75
|
-
singleton.$m_tbl[name] = method;
|
76
|
-
};
|
77
|
-
|
78
44
|
// Runtime method used to either define a new class, or re-open an old
|
79
45
|
// class. The base may be an object (rather than a class), which is
|
80
46
|
// always the case when defining classes in the top level as the top
|
@@ -110,7 +76,7 @@ Opal.defs = function(obj, name, method) {
|
|
110
76
|
Opal.klass = function(base, superklass, id, constructor) {
|
111
77
|
var klass;
|
112
78
|
if (base._isObject) {
|
113
|
-
base = base
|
79
|
+
base = base._klass;
|
114
80
|
}
|
115
81
|
|
116
82
|
if (superklass === null) {
|
@@ -121,13 +87,14 @@ Opal.klass = function(base, superklass, id, constructor) {
|
|
121
87
|
klass = base._scope[id];
|
122
88
|
}
|
123
89
|
else {
|
124
|
-
if (!superklass
|
90
|
+
if (!superklass._methods) {
|
125
91
|
var bridged = superklass;
|
126
92
|
superklass = Object;
|
127
|
-
|
93
|
+
klass = bridge_class(bridged);
|
94
|
+
}
|
95
|
+
else {
|
96
|
+
klass = boot_class(superklass, constructor);
|
128
97
|
}
|
129
|
-
|
130
|
-
klass = boot_class(superklass, constructor, bridged);
|
131
98
|
|
132
99
|
klass._name = (base === Object ? id : base._name + '::' + id);
|
133
100
|
|
@@ -138,8 +105,8 @@ Opal.klass = function(base, superklass, id, constructor) {
|
|
138
105
|
|
139
106
|
base[id] = base._scope[id] = klass;
|
140
107
|
|
141
|
-
if (superklass.$
|
142
|
-
superklass.$
|
108
|
+
if (superklass.$inherited) {
|
109
|
+
superklass.$inherited(klass);
|
143
110
|
}
|
144
111
|
}
|
145
112
|
|
@@ -150,14 +117,14 @@ Opal.klass = function(base, superklass, id, constructor) {
|
|
150
117
|
Opal.module = function(base, id, constructor) {
|
151
118
|
var klass;
|
152
119
|
if (base._isObject) {
|
153
|
-
base = base
|
120
|
+
base = base._klass;
|
154
121
|
}
|
155
122
|
|
156
123
|
if (__hasOwn.call(base._scope, id)) {
|
157
124
|
klass = base._scope[id];
|
158
125
|
}
|
159
126
|
else {
|
160
|
-
klass =
|
127
|
+
klass = boot_class(Module, constructor);
|
161
128
|
klass._name = (base === Object ? id : base._name + '::' + id);
|
162
129
|
|
163
130
|
klass._isModule = true;
|
@@ -188,139 +155,124 @@ var boot_defclass = function(id, constructor, superklass) {
|
|
188
155
|
constructor.prototype = new ctor();
|
189
156
|
}
|
190
157
|
|
191
|
-
// method table constructor;
|
192
|
-
var m_ctr = function() {};
|
193
|
-
|
194
|
-
if (superklass) {
|
195
|
-
// not BasicObject
|
196
|
-
m_ctr.prototype = new superklass.$m_ctr;
|
197
|
-
}
|
198
|
-
else {
|
199
|
-
// BasicObject
|
200
|
-
m_ctr.prototype = RootMethodTable;
|
201
|
-
}
|
202
|
-
|
203
|
-
var m_tbl = m_ctr.prototype;
|
204
|
-
m_tbl.constructor = m_ctr;
|
205
|
-
|
206
158
|
var prototype = constructor.prototype;
|
207
159
|
|
208
160
|
prototype.constructor = constructor;
|
209
161
|
prototype._isObject = true;
|
210
|
-
prototype
|
211
|
-
|
212
|
-
// method table of instances
|
213
|
-
prototype.$m = m_tbl;
|
214
|
-
|
215
|
-
// constructor._included_in = [];
|
216
|
-
// constructor._isClass = true;
|
217
|
-
// constructor._name = id;
|
218
|
-
// constructor._super = superklass;
|
219
|
-
// constructor._methods = [];
|
220
|
-
// constructor._smethods = [];
|
221
|
-
constructor._isObject = false;
|
222
|
-
|
223
|
-
// method table for class methods
|
224
|
-
// constructor.$m = c_tbl;
|
225
|
-
// method table of instances
|
226
|
-
constructor.$m_tbl = m_tbl;
|
227
|
-
// method table constructor of instances
|
228
|
-
constructor.$m_ctr = m_ctr;
|
229
|
-
|
230
|
-
constructor.$s = superklass;
|
162
|
+
prototype._klass = constructor;
|
231
163
|
|
164
|
+
constructor._included_in = [];
|
165
|
+
constructor._isClass = true;
|
232
166
|
constructor._name = id;
|
167
|
+
constructor._super = superklass;
|
168
|
+
constructor._methods = [];
|
169
|
+
constructor._smethods = [];
|
170
|
+
constructor._isObject = false;
|
233
171
|
|
234
172
|
constructor._donate = __donate;
|
173
|
+
constructor._sdonate = __sdonate;
|
235
174
|
|
236
175
|
Opal[id] = constructor;
|
237
176
|
|
238
177
|
return constructor;
|
239
178
|
};
|
240
179
|
|
241
|
-
|
242
|
-
|
243
|
-
|
180
|
+
// Create generic class with given superclass.
|
181
|
+
var boot_class = function(superklass, constructor) {
|
182
|
+
var ctor = function() {};
|
183
|
+
ctor.prototype = superklass.prototype;
|
184
|
+
|
185
|
+
constructor.prototype = new ctor();
|
186
|
+
var prototype = constructor.prototype;
|
187
|
+
|
188
|
+
prototype._klass = constructor;
|
189
|
+
prototype.constructor = constructor;
|
190
|
+
|
191
|
+
constructor._included_in = [];
|
192
|
+
constructor._isClass = true;
|
193
|
+
constructor._super = superklass;
|
194
|
+
constructor._methods = [];
|
195
|
+
constructor._isObject = false;
|
196
|
+
constructor._klass = Class;
|
197
|
+
constructor._donate = __donate
|
198
|
+
constructor._sdonate = __sdonate;
|
244
199
|
|
245
|
-
|
246
|
-
|
200
|
+
constructor['$==='] = module_eqq;
|
201
|
+
constructor.$to_s = module_to_s;
|
247
202
|
|
248
|
-
|
203
|
+
var smethods;
|
204
|
+
|
205
|
+
smethods = superklass._smethods.slice();
|
206
|
+
|
207
|
+
constructor._smethods = smethods;
|
208
|
+
for (var i = 0, length = smethods.length; i < length; i++) {
|
209
|
+
var m = smethods[i];
|
210
|
+
constructor[m] = superklass[m];
|
211
|
+
}
|
249
212
|
|
250
213
|
return constructor;
|
251
214
|
};
|
252
215
|
|
253
|
-
|
254
|
-
|
255
|
-
// method table constructor
|
256
|
-
function m_ctr(){};
|
257
|
-
m_ctr.prototype = new superklass.$m_tbl.constructor;
|
258
|
-
|
259
|
-
// method table itself
|
260
|
-
var m_tbl = m_ctr.prototype;
|
261
|
-
m_tbl.constructor = m_ctr;
|
216
|
+
var bridge_class = function(constructor) {
|
217
|
+
constructor.prototype._klass = constructor;
|
262
218
|
|
263
|
-
|
219
|
+
constructor._included_in = [];
|
220
|
+
constructor._isClass = true;
|
221
|
+
constructor._super = Object;
|
222
|
+
constructor._klass = Class;
|
223
|
+
constructor._methods = [];
|
224
|
+
constructor._smethods = [];
|
225
|
+
constructor._isObject = false;
|
264
226
|
|
265
|
-
|
266
|
-
|
267
|
-
prototype = constructor.prototype;
|
268
|
-
prototype.constructor = constructor;
|
269
|
-
}
|
227
|
+
constructor._donate = function(){};
|
228
|
+
constructor._sdonate = __sdonate;
|
270
229
|
|
271
|
-
|
272
|
-
|
230
|
+
constructor['$==='] = module_eqq;
|
231
|
+
constructor.$to_s = module_to_s;
|
273
232
|
|
274
|
-
|
233
|
+
var smethods = constructor._smethods = Module._methods.slice();
|
234
|
+
for (var i = 0, length = smethods.length; i < length; i++) {
|
235
|
+
var m = smethods[i];
|
236
|
+
constructor[m] = Object[m];
|
237
|
+
}
|
275
238
|
|
276
|
-
constructor
|
277
|
-
constructor.$m_tbl = m_tbl;
|
239
|
+
bridged_classes.push(constructor);
|
278
240
|
|
279
|
-
|
280
|
-
|
281
|
-
c_ctr.prototype = new superklass.$m.constructor;
|
241
|
+
var allocator = function(initializer) {
|
242
|
+
var result, kls = this, methods = kls._methods, proto = kls.prototype;
|
282
243
|
|
283
|
-
|
284
|
-
|
285
|
-
|
244
|
+
if (initializer == null) {
|
245
|
+
result = new constructor
|
246
|
+
}
|
247
|
+
else {
|
248
|
+
result = new constructor(initializer);
|
249
|
+
}
|
286
250
|
|
251
|
+
if (kls === constructor) {
|
252
|
+
return result;
|
253
|
+
}
|
287
254
|
|
288
|
-
|
289
|
-
constructor.$s = superklass;
|
255
|
+
result._klass = kls;
|
290
256
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
// constructor._methods = [];
|
296
|
-
constructor._isObject = false;
|
297
|
-
// constructor._klass = Class;
|
298
|
-
|
299
|
-
return constructor;
|
300
|
-
};
|
257
|
+
for (var i = 0, length = methods.length; i < length; i++) {
|
258
|
+
var method = methods[i];
|
259
|
+
result[method] = proto[method];
|
260
|
+
}
|
301
261
|
|
302
|
-
|
303
|
-
|
304
|
-
constructor.$m_tbl = {}; // simple method table for modules
|
262
|
+
return result;
|
263
|
+
};
|
305
264
|
|
306
|
-
|
307
|
-
var c_ctr = function(){};
|
308
|
-
c_ctr.prototype = new Module.$m.constructor;
|
309
|
-
|
310
|
-
var c_tbl = c_ctr.prototype;
|
311
|
-
constructor.$m = c_tbl;
|
265
|
+
var table = Object.prototype, methods = Object._methods;
|
312
266
|
|
267
|
+
for (var i = 0, length = methods.length; i < length; i++) {
|
268
|
+
var m = methods[i];
|
269
|
+
constructor.prototype[m] = table[m];
|
270
|
+
}
|
313
271
|
|
314
|
-
constructor.$
|
272
|
+
constructor.$allocate = allocator;
|
273
|
+
|
274
|
+
constructor._smethods.push('$allocate');
|
315
275
|
|
316
|
-
constructor._donate = __donate
|
317
|
-
// constructor._included_in = [];
|
318
|
-
// constructor._isClass = true;
|
319
|
-
// constructor._super = superklass;
|
320
|
-
// constructor._methods = [];
|
321
|
-
constructor._isObject = false;
|
322
|
-
// constructor._klass = Class;
|
323
|
-
|
324
276
|
return constructor;
|
325
277
|
};
|
326
278
|
|
@@ -331,39 +283,75 @@ boot_defclass('BasicObject', BasicObject);
|
|
331
283
|
boot_defclass('Object', Object, BasicObject);
|
332
284
|
boot_defclass('Class', Class, Object);
|
333
285
|
|
334
|
-
|
335
|
-
|
336
|
-
|
286
|
+
Class.prototype = Function.prototype;
|
287
|
+
|
288
|
+
BasicObject._klass = Object._klass = Class._klass = Class;
|
289
|
+
|
290
|
+
Module._donate = function(defined) {
|
291
|
+
// ...
|
292
|
+
};
|
293
|
+
|
294
|
+
// Implementation of Module#===
|
295
|
+
function module_eqq(object) {
|
296
|
+
if (object == null) {
|
297
|
+
return false;
|
298
|
+
}
|
299
|
+
|
300
|
+
var search = object._klass;
|
301
|
+
|
302
|
+
while (search) {
|
303
|
+
if (search === this) {
|
304
|
+
return true;
|
305
|
+
}
|
337
306
|
|
338
|
-
|
307
|
+
search = search._super;
|
308
|
+
}
|
309
|
+
|
310
|
+
return false;
|
311
|
+
}
|
312
|
+
|
313
|
+
// Implementation of Module#to_s
|
314
|
+
function module_to_s() {
|
315
|
+
return this._name;
|
316
|
+
}
|
339
317
|
|
340
318
|
// Donator for all 'normal' classes and modules
|
341
|
-
function __donate(defined) {
|
342
|
-
var
|
319
|
+
function __donate(defined, indirect) {
|
320
|
+
var methods = this._methods, included_in = this.$included_in;
|
321
|
+
|
322
|
+
// if (!indirect) {
|
323
|
+
this._methods = methods.concat(defined);
|
324
|
+
// }
|
343
325
|
|
344
326
|
if (included_in) {
|
345
327
|
for (var i = 0, length = included_in.length; i < length; i++) {
|
346
328
|
var includee = included_in[i];
|
347
|
-
var dest = includee
|
329
|
+
var dest = includee.prototype;
|
348
330
|
|
349
|
-
for (var
|
350
|
-
var method = defined[
|
351
|
-
dest[method] =
|
331
|
+
for (var j = 0, jj = defined.length; j < jj; j++) {
|
332
|
+
var method = defined[j];
|
333
|
+
dest[method] = this.prototype[method];
|
352
334
|
}
|
353
335
|
|
354
336
|
if (includee.$included_in) {
|
355
|
-
|
337
|
+
includee._donate(defined, true);
|
356
338
|
}
|
357
339
|
}
|
358
340
|
|
359
341
|
}
|
360
342
|
}
|
361
343
|
|
344
|
+
// Donator for singleton (class) methods
|
345
|
+
function __sdonate(defined) {
|
346
|
+
this._smethods = this._smethods.concat(defined);
|
347
|
+
}
|
348
|
+
|
362
349
|
var bridged_classes = Object.$included_in = [];
|
363
350
|
BasicObject.$included_in = bridged_classes;
|
364
351
|
|
365
352
|
BasicObject._scope = Object._scope = Opal;
|
366
353
|
Opal.Module = Opal.Class;
|
354
|
+
Opal.Kernel = Object;
|
367
355
|
|
368
356
|
var class_const_alloc = function(){};
|
369
357
|
var class_const_scope = new TopScope();
|
@@ -371,7 +359,7 @@ class_const_scope.alloc = class_const_alloc;
|
|
371
359
|
Class._scope = class_const_scope;
|
372
360
|
|
373
361
|
Object.prototype.toString = function() {
|
374
|
-
return this.$
|
362
|
+
return this.$to_s();
|
375
363
|
};
|
376
364
|
|
377
365
|
Opal.top = new Object;
|