fastruby 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/CHANGELOG +17 -1
  2. data/Rakefile +1 -1
  3. data/ext/fastruby_base/fastruby_base.inl +81 -3
  4. data/lib/fastruby/fastruby_sexp.rb +21 -0
  5. data/lib/fastruby/getlocals.rb +2 -1
  6. data/lib/fastruby/object.rb +1 -1
  7. data/lib/fastruby/sexp_extension.rb +189 -0
  8. data/lib/fastruby/sexp_extension_edges.rb +210 -0
  9. data/lib/fastruby/translator/modules/block.rb +29 -22
  10. data/lib/fastruby/translator/modules/call.rb +211 -34
  11. data/lib/fastruby/translator/modules/defn.rb +64 -29
  12. data/lib/fastruby/translator/modules/exceptions.rb +1 -1
  13. data/lib/fastruby/translator/modules/flow.rb +93 -31
  14. data/lib/fastruby/translator/modules/iter.rb +277 -340
  15. data/lib/fastruby/translator/modules/literal.rb +97 -20
  16. data/lib/fastruby/translator/modules/logical.rb +40 -5
  17. data/lib/fastruby/translator/modules/method_group.rb +41 -19
  18. data/lib/fastruby/translator/modules/nonlocal.rb +74 -29
  19. data/lib/fastruby/translator/modules/variable.rb +151 -42
  20. data/lib/fastruby/translator/scope_mode_helper.rb +161 -0
  21. data/lib/fastruby/translator/translator.rb +389 -302
  22. data/lib/fastruby.rb +1 -1
  23. data/lib/fastruby.rb~ +36 -0
  24. data/spec/edges_helper.rb +91 -0
  25. data/spec/graph/base_spec.rb +35 -0
  26. data/spec/graph/path_spec.rb +48 -0
  27. data/spec/graph/vertex_spec.rb +58 -0
  28. data/spec/ruby/block/proc_as_block_spec.rb +214 -0
  29. data/spec/ruby/block/redo_spec.rb +133 -0
  30. data/spec/ruby/defn/single_function_spec.rb +50 -0
  31. data/spec/scope_mode/base_spec.rb +55 -0
  32. data/spec/scope_mode/block_spec.rb +105 -0
  33. data/spec/scope_mode/call_spec.rb +24 -0
  34. data/spec/scope_mode/exception_spec.rb +34 -0
  35. data/spec/scope_mode/flow_spec.rb +99 -0
  36. data/spec/scope_mode/optimization_spec.rb +130 -0
  37. data/spec/sexp2graph/base_spec.rb +36 -0
  38. data/spec/sexp2graph/exception_spec.rb +172 -0
  39. data/spec/sexp2graph/flow_spec.rb +67 -0
  40. data/spec/sexp2graph/logical_spec.rb +21 -0
  41. data/spec/sexp2graph/variable_spec.rb +26 -0
  42. metadata +110 -120
  43. data/lib/fastruby/self +0 -82
  44. data/lib/len +0 -280
  45. data/spec/block/proc_as_block_spec.rb +0 -111
  46. data/spec/block/redo_spec.rb +0 -67
  47. /data/spec/{base_spec.rb → ruby/base_spec.rb} +0 -0
  48. /data/spec/{block → ruby/block}/arguments_spec.rb +0 -0
  49. /data/spec/{block → ruby/block}/block_as_proc_spec.rb +0 -0
  50. /data/spec/{block → ruby/block}/break_spec.rb +0 -0
  51. /data/spec/{block → ruby/block}/callcc_spec.rb +0 -0
  52. /data/spec/{block → ruby/block}/lambda_spec.rb +0 -0
  53. /data/spec/{block → ruby/block}/next_spec.rb +0 -0
  54. /data/spec/{block → ruby/block}/proc_spec.rb +0 -0
  55. /data/spec/{block → ruby/block}/retry_spec.rb +0 -0
  56. /data/spec/{block_spec.rb → ruby/block_spec.rb} +0 -0
  57. /data/spec/{call → ruby/call}/base_call_spec.rb +0 -0
  58. /data/spec/{call → ruby/call}/multiple_args_spec.rb +0 -0
  59. /data/spec/{control_spec.rb → ruby/control_spec.rb} +0 -0
  60. /data/spec/{defn → ruby/defn}/default_args_spec.rb +0 -0
  61. /data/spec/{defn → ruby/defn}/multiple_args_spec.rb +0 -0
  62. /data/spec/{defn → ruby/defn}/replacement_spec.rb +0 -0
  63. /data/spec/{exception → ruby/exception}/base_spec.rb +0 -0
  64. /data/spec/{exception → ruby/exception}/ensure_spec.rb +0 -0
  65. /data/spec/{exception → ruby/exception}/exc_trap_spec.rb +0 -0
  66. /data/spec/{exception → ruby/exception}/internal_ex_spec.rb +0 -0
  67. /data/spec/{exception → ruby/exception}/syntaxis_spec.rb +0 -0
  68. /data/spec/{expression_spec.rb → ruby/expression_spec.rb} +0 -0
  69. /data/spec/{flow_control → ruby/flow_control}/case_spec.rb +0 -0
  70. /data/spec/{flow_control → ruby/flow_control}/for_spec.rb +0 -0
  71. /data/spec/{integrity_spec.rb → ruby/integrity_spec.rb} +0 -0
  72. /data/spec/{jump → ruby/jump}/next_spec.rb +0 -0
  73. /data/spec/{literal_spec.rb → ruby/literal_spec.rb} +0 -0
  74. /data/spec/{module_spec.rb → ruby/module_spec.rb} +0 -0
  75. /data/spec/{return_spec.rb → ruby/return_spec.rb} +0 -0
  76. /data/spec/{singleton_spec.rb → ruby/singleton_spec.rb} +0 -0
  77. /data/spec/{sugar_spec.rb → ruby/sugar_spec.rb} +0 -0
  78. /data/spec/{variable_spec.rb → ruby/variable_spec.rb} +0 -0
data/lib/len DELETED
@@ -1,280 +0,0 @@
1
- fastruby/builder.rb 78| (1..signature.size-1).each do |i|
2
- fastruby/builder.rb 109| RbConfig::CONFIG['CFLAGS'] << " -DRUBY_1_8 -Wno-clobbered"
3
- fastruby/builder.rb 111| RbConfig::CONFIG['CFLAGS'] << " -DRUBY_1_9 -Wno-clobbered"
4
- fastruby/getlocals.rb 40| tree[1..-1].each do |subtree|
5
- fastruby/object.rb 28|system("rm -fr #{ENV["HOME"]}/.ruby_inline/*")
6
- fastruby/translator/modules/flow.rb 30| code = tree[2..-2].map{|subtree|
7
- fastruby/translator/modules/flow.rb 33| subtree[1][1..-1].map{|subsubtree|
8
- fastruby/translator/modules/flow.rb 52| return #{to_c tree[-1]};
9
- fastruby/translator/modules/variable.rb 27| "rb_cvar_get(CLASS_OF(plocals->self) != rb_cClass ? CLASS_OF(plocals->self) : plocals->self,#{intern_num tree[1]})"
10
- fastruby/translator/modules/variable.rb 31| "__rb_cvar_set(CLASS_OF(plocals->self) != rb_cClass ? CLASS_OF(plocals->self) : plocals->self,#{intern_num tree[1]},#{to_c tree[2]},Qfalse)"
11
- fastruby/translator/modules/variable.rb 36| "pframe->thread_data->exception"
12
- fastruby/translator/modules/variable.rb 55| "rb_const_get(CLASS_OF(plocals->self), #{intern_num(tree[1])})"
13
- fastruby/translator/modules/variable.rb 156| 'rb_str_new2("local-variable")'
14
- fastruby/translator/modules/variable.rb 158| "rb_gvar_defined((struct global_entry*)#{global_entry(tree[1][1])}) ? #{literal_value "global-variable"} : Qnil"
15
- fastruby/translator/modules/variable.rb 170| "rb_ivar_defined(plocals->self,#{intern_num tree[1][1]}) ? #{literal_value "instance-variable"} : Qnil"
16
- fastruby/translator/modules/exceptions.rb 38| if tree[-1]
17
- fastruby/translator/modules/exceptions.rb 39| if tree[-1][0] != :resbody
18
- fastruby/translator/modules/exceptions.rb 40| else_tree = tree[-1]
19
- fastruby/translator/modules/exceptions.rb 50| tree[1..-1].each do |resbody_tree|
20
- fastruby/translator/modules/exceptions.rb 61| resbody_tree[1][1..-1].each do |xtree|
21
- fastruby/translator/modules/exceptions.rb 69| catch_condition_array << "(rb_obj_is_kind_of(frame.thread_data->exception,#{trapcode}) == Qtrue)"
22
- fastruby/translator/modules/exceptions.rb 119| pframe->thread_data->exception = rb_funcall(#{class_tree}, #{intern_num :exception},1,#{message_tree});
23
- fastruby/translator/modules/exceptions.rb 120| longjmp(pframe->jmp, FASTRUBY_TAG_RAISE);
24
- fastruby/translator/modules/exceptions.rb 125| pframe->thread_data->exception = rb_funcall(#{class_tree}, #{intern_num :exception},0);
25
- fastruby/translator/modules/exceptions.rb 126| longjmp(pframe->jmp, FASTRUBY_TAG_RAISE);
26
- fastruby/translator/modules/defn.rb 46| rb_define_method(plocals->self, #{method_name.to_s.inspect}, #{anonymous_method_name}, -1);
27
- fastruby/translator/modules/defn.rb 48| #{global_klass_variable} = plocals->self;
28
- fastruby/translator/modules/defn.rb 84| rb_define_singleton_method(obj, #{method_name.to_s.inspect}, #{anonymous_method_name}, -1 );
29
- fastruby/translator/modules/defn.rb 210| rb_funcall(self, #{intern_num :raise}, 1, frame.thread_data->exception);
30
- fastruby/translator/modules/method_group.rb 91| VALUE rb_stack_chunk = frame.thread_data->rb_stack_chunk;
31
- fastruby/translator/modules/method_group.rb 104| frame.thread_data->rb_stack_chunk = rb_stack_chunk;
32
- fastruby/translator/modules/method_group.rb 115| plocals->parent_locals = LONG2FIX(frame.thread_data->last_plocals);
33
- fastruby/translator/modules/method_group.rb 116| void* old_parent_locals = frame.thread_data->last_plocals;
34
- fastruby/translator/modules/method_group.rb 117| frame.thread_data->last_plocals = plocals;
35
- fastruby/translator/modules/method_group.rb 120| plocals->active = Qtrue;
36
- fastruby/translator/modules/method_group.rb 121| plocals->self = self;
37
- fastruby/translator/modules/method_group.rb 122| plocals->targetted = Qfalse;
38
- fastruby/translator/modules/method_group.rb 123| plocals->call_frame = LONG2FIX(0);
39
- fastruby/translator/modules/method_group.rb 131| frame.thread_data->rb_stack_chunk = rb_previous_stack_chunk;
40
- fastruby/translator/modules/method_group.rb 134| plocals->active = Qfalse;
41
- fastruby/translator/modules/method_group.rb 136| frame.thread_data->last_plocals = old_parent_locals;
42
- fastruby/translator/modules/iter.rb 57| call_args_tree[1..-1].each do |arg|
43
- fastruby/translator/modules/iter.rb 72| plocals = (void*)pframe->plocals;
44
- fastruby/translator/modules/iter.rb 83| str_impl = anonymous_impl[1..-2].map{ |subtree|
45
- fastruby/translator/modules/iter.rb 87| if anonymous_impl[-1][0] != :return and anonymous_impl[-1][0] != :break and anonymous_impl[-1][0] != :next
46
- fastruby/translator/modules/iter.rb 88| str_impl = str_impl + ";last_expression = (#{to_c(anonymous_impl[-1])});"
47
- fastruby/translator/modules/iter.rb 90| str_impl = str_impl + ";#{to_c(anonymous_impl[-1])};"
48
- fastruby/translator/modules/iter.rb 106| str_arg_initialization << "plocals->#{args_tree[1]} = arg;"
49
- fastruby/translator/modules/iter.rb 117| } else if (RARRAY(arg)->len <= 1) {
50
- fastruby/translator/modules/iter.rb 123| arguments = args_tree[1][1..-1]
51
- fastruby/translator/modules/iter.rb 125| (0..arguments.size-1).each do |i|
52
- fastruby/translator/modules/iter.rb 128| str_arg_initialization << "plocals->#{arguments[i].last} = rb_ary_entry(arg,#{i});\n"
53
- fastruby/translator/modules/iter.rb 130| str_arg_initialization << "plocals->#{arg.last.last} = rb_ary_new2(RARRAY(arg)->len-#{i});\n
54
- fastruby/translator/modules/iter.rb 133| for (i=#{i};i<RARRAY(arg)->len;i++){
55
- fastruby/translator/modules/iter.rb 134| rb_ary_store(plocals->#{arg.last.last},i-#{i},rb_ary_entry(arg,i));
56
- fastruby/translator/modules/iter.rb 144| str_recv = "pframe->next_recv"
57
- fastruby/translator/modules/iter.rb 146| str_recv = "plocals->self" unless recv_tree
58
- fastruby/translator/modules/iter.rb 160| int argc = #{call_args_tree.size-2};
59
- fastruby/translator/modules/iter.rb 161| VALUE argv[#{call_args_tree.size} + RARRAY(array)->len];
60
- fastruby/translator/modules/iter.rb 164| i = -1
61
- fastruby/translator/modules/iter.rb 165| call_args_tree[1..-2].map {|arg|
62
- fastruby/translator/modules/iter.rb 171| int array_len = RARRAY(array)->len;
63
- fastruby/translator/modules/iter.rb 184| str_called_code_args = call_args_tree[1..-1].map{ |subtree| to_c subtree }.join(",")
64
- fastruby/translator/modules/iter.rb 190| return rb_funcall(#{str_recv}, #{intern_num call_tree[2]}, #{call_args_tree.size-1}, #{str_called_code_args});
65
- fastruby/translator/modules/iter.rb 198| str_recv = "pframe->next_recv"
66
- fastruby/translator/modules/iter.rb 199| str_recv = "plocals->self" unless recv_tree
67
- fastruby/translator/modules/iter.rb 220| VALUE rb_stack_chunk = thread_data->rb_stack_chunk;
68
- fastruby/translator/modules/iter.rb 260| VALUE old_call_frame = ((typeof(plocals))(pframe->plocals))->call_frame;
69
- fastruby/translator/modules/iter.rb 261| ((typeof(plocals))(pframe->plocals))->call_frame = LONG2FIX(pframe);
70
- fastruby/translator/modules/iter.rb 268| return pframe->thread_data->accumulator;
71
- fastruby/translator/modules/iter.rb 272| rb_funcall(((typeof(plocals))(pframe->plocals))->self, #{intern_num :raise}, 1, frame.thread_data->exception);
72
- fastruby/translator/modules/iter.rb 276| if (plocals->targetted == 1) {
73
- fastruby/translator/modules/iter.rb 277| ((typeof(plocals))(pframe->plocals))->call_frame = old_call_frame;
74
- fastruby/translator/modules/iter.rb 278| return ((typeof(plocals))(pframe->plocals))->return_value;
75
- fastruby/translator/modules/iter.rb 286| ((typeof(plocals))(pframe->plocals))->call_frame = old_call_frame;
76
- fastruby/translator/modules/iter.rb 295| ((typeof(plocals))(pframe->plocals))->call_frame = old_call_frame;
77
- fastruby/translator/modules/iter.rb 318| VALUE old_call_frame = ((typeof(plocals))(pframe->plocals))->call_frame;
78
- fastruby/translator/modules/iter.rb 319| ((typeof(plocals))(pframe->plocals))->call_frame = LONG2FIX(pframe);
79
- fastruby/translator/modules/iter.rb 324| return pframe->thread_data->accumulator;
80
- fastruby/translator/modules/iter.rb 328| rb_funcall(((typeof(plocals))(pframe->plocals))->self, #{intern_num :raise}, 1, frame.thread_data->exception);
81
- fastruby/translator/modules/iter.rb 331| if (plocals->targetted == 1) {
82
- fastruby/translator/modules/iter.rb 332| if (plocals->active == Qfalse) {
83
- fastruby/translator/modules/iter.rb 333| rb_raise(rb_eLocalJumpError,\"return from proc-closure\");
84
- fastruby/translator/modules/iter.rb 335| ((typeof(plocals))(pframe->plocals))->call_frame = old_call_frame;
85
- fastruby/translator/modules/iter.rb 347| ((typeof(plocals))(pframe->plocals))->call_frame = old_call_frame;
86
- fastruby/translator/modules/iter.rb 375| return pframe->thread_data->accumulator;
87
- fastruby/translator/modules/iter.rb 413| return pframe->thread_data->accumulator;
88
- fastruby/translator/modules/iter.rb 424| rb_ivar_set(arg,#{intern_num :__stack_chunk},thread_data->rb_stack_chunk);
89
- fastruby/translator/modules/iter.rb 441| fastruby_str_arg_initialization = "plocals->#{args_tree[1]} = argv[0];"
90
- fastruby/translator/modules/iter.rb 443| arguments = args_tree[1][1..-1]
91
- fastruby/translator/modules/iter.rb 445| (0..arguments.size-1).each do |i|
92
- fastruby/translator/modules/iter.rb 448| fastruby_str_arg_initialization << "plocals->#{arg.last} = #{i} < argc ? argv[#{i}] : Qnil;\n"
93
- fastruby/translator/modules/iter.rb 450| fastruby_str_arg_initialization << "plocals->#{arg.last.last} = rb_ary_new2(#{arguments.size-1-i});\n
94
- fastruby/translator/modules/iter.rb 454| rb_ary_store(plocals->#{arg.last.last},i-#{i},argv[i]);
95
- fastruby/translator/modules/iter.rb 476| frame.thread_data = parent_frame->thread_data;
96
- fastruby/translator/modules/iter.rb 483| if (pframe->targetted == 0) {
97
- fastruby/translator/modules/iter.rb 485| return pframe->thread_data->accumulator;
98
- fastruby/translator/modules/iter.rb 489| longjmp(((typeof(pframe))_parent_frame)->jmp,aux);
99
- fastruby/translator/modules/iter.rb 503| str_recv = "plocals->self"
100
- fastruby/translator/modules/iter.rb 527| VALUE old_call_frame = plocals->call_frame;
101
- fastruby/translator/modules/iter.rb 528| plocals->call_frame = LONG2FIX(&call_frame);
102
- fastruby/translator/modules/iter.rb 538| longjmp(pframe_->jmp,aux);
103
- fastruby/translator/modules/iter.rb 541| plocals->call_frame = old_call_frame;
104
- fastruby/translator/modules/iter.rb 551| pframe->next_recv = #{recv_tree ? to_c(recv_tree) : "plocals->self"};
105
- fastruby/translator/modules/iter.rb 553| NODE* node = rb_method_node(CLASS_OF(pframe->next_recv), #{intern_num mname});
106
- fastruby/translator/modules/iter.rb 561| VALUE rb_stack_chunk = thread_data->rb_stack_chunk;
107
- fastruby/translator/modules/iter.rb 581| thread_data->rb_stack_chunk = saved_rb_stack_chunk;
108
- fastruby/translator/modules/iter.rb 596| if (pframe->thread_data == 0) pframe->thread_data = rb_current_thread_data();
109
- fastruby/translator/modules/iter.rb 597| void* last_plocals = pframe->thread_data->last_plocals;
110
- fastruby/translator/modules/iter.rb 600| NODE* node = rb_method_node(CLASS_OF(pframe->next_recv), #{intern_num mname});
111
- fastruby/translator/modules/iter.rb 609| } else if (node == #{@procnew_node_gvar} && pframe->next_recv == rb_cProc) {
112
- fastruby/translator/modules/iter.rb 634| current_plocals = pframe->thread_data->last_plocals;
113
- fastruby/translator/modules/iter.rb 636| current_plocals->active = Qfalse;
114
- fastruby/translator/modules/iter.rb 637| current_plocals = (typeof(current_plocals))FIX2LONG(current_plocals->parent_locals);
115
- fastruby/translator/modules/iter.rb 641| pframe->thread_data->last_plocals = last_plocals;
116
- fastruby/translator/modules/iter.rb 647| current_plocals->active = Qtrue;
117
- fastruby/translator/modules/iter.rb 648| current_plocals = (typeof(current_plocals))FIX2LONG(current_plocals->parent_locals);
118
- fastruby/translator/modules/iter.rb 675| plocals->call_frame = old_call_frame;
119
- fastruby/translator/modules/iter.rb 684| plocals->call_frame = old_call_frame;
120
- fastruby/translator/modules/call.rb 70| argnum = args.size - 1
121
- fastruby/translator/modules/call.rb 88| int argc = #{args.size-2};
122
- fastruby/translator/modules/call.rb 89| VALUE argv[#{args.size} + RARRAY(array)->len];
123
- fastruby/translator/modules/call.rb 92| i = -1
124
- fastruby/translator/modules/call.rb 93| args[1..-2].map {|arg|
125
- fastruby/translator/modules/call.rb 99| int array_len = RARRAY(array)->len;
126
- fastruby/translator/modules/call.rb 113| strargs = args[1..-1].map{|arg| to_c arg}.join(",")
127
- fastruby/translator/modules/call.rb 123| args[1..-1].each do |arg|
128
- fastruby/translator/modules/block.rb 34| plocals = (void*)pframe->plocals;
129
- fastruby/translator/modules/block.rb 36| if (FIX2LONG(plocals->block_function_address) == 0) {
130
- fastruby/translator/modules/block.rb 39| return ((VALUE(*)(int,VALUE*,VALUE,VALUE))FIX2LONG(plocals->block_function_address))(size, block_args, FIX2LONG(plocals->block_function_param), (VALUE)pframe);
131
- fastruby/translator/modules/block.rb 52| VALUE block_args[RARRAY(splat_array)->len + #{tree.size}];
132
- fastruby/translator/modules/block.rb 55| (0..tree.size-3).map{|i|
133
- fastruby/translator/modules/block.rb 60| for (i=0; i<RARRAY(splat_array)->len; i++) {
134
- fastruby/translator/modules/block.rb 61| block_args[i+#{tree.size-2}] = rb_ary_entry(splat_array,i);
135
- fastruby/translator/modules/block.rb 64| return #{anonymous_function(&block_code)}((VALUE)pframe, block_args, RARRAY(splat_array)->len + #{tree.size-2});
136
- fastruby/translator/modules/block.rb 68| (0..tree.size-3).map{|i|
137
- fastruby/translator/modules/block.rb 73| block_args[#{tree.size-2}] = splat_array;
138
- fastruby/translator/modules/block.rb 74| return #{anonymous_function(&block_code)}((VALUE)pframe, block_args, #{tree.size-1});
139
- fastruby/translator/modules/block.rb 80| anonymous_function(&block_code)+"((VALUE)pframe, (VALUE[]){#{tree[1..-1].map{|subtree| to_c subtree}.join(",")}},#{tree.size-1})"
140
- fastruby/translator/modules/block.rb 82| anonymous_function(&block_code)+"((VALUE)pframe, (VALUE[]){}, #{tree.size-1})"
141
- fastruby/translator/modules/block.rb 95| str = tree[1..-2].map{ |subtree|
142
- fastruby/translator/modules/block.rb 99| if tree[-1]
143
- fastruby/translator/modules/block.rb 101| if tree[-1][0] != :return
144
- fastruby/translator/modules/block.rb 102| str = str + ";last_expression = #{to_c(tree[-1])};"
145
- fastruby/translator/modules/block.rb 104| str = str + ";#{to_c(tree[-1])};"
146
- fastruby/translator/modules/nonlocal.rb 27| plocals->return_value = #{to_c(tree[1])};
147
- fastruby/translator/modules/nonlocal.rb 28| plocals->targetted = 1;
148
- fastruby/translator/modules/nonlocal.rb 29| longjmp(pframe->jmp, FASTRUBY_TAG_RETURN);
149
- fastruby/translator/modules/nonlocal.rb 41| target_frame_ = (void*)FIX2LONG(plocals->call_frame);
150
- fastruby/translator/modules/nonlocal.rb 47| plocals->call_frame = LONG2FIX(0);
151
- fastruby/translator/modules/nonlocal.rb 49| target_frame_->return_value = value;
152
- fastruby/translator/modules/nonlocal.rb 50| target_frame_->targetted = 1;
153
- fastruby/translator/modules/nonlocal.rb 51| pframe->thread_data->exception = Qnil;
154
- fastruby/translator/modules/nonlocal.rb 52| longjmp(pframe->jmp,FASTRUBY_TAG_BREAK);"
155
- fastruby/translator/modules/nonlocal.rb 60| target_frame_ = (void*)FIX2LONG(plocals->call_frame);
156
- fastruby/translator/modules/nonlocal.rb 66| target_frame_->targetted = 1;
157
- fastruby/translator/modules/nonlocal.rb 67| longjmp(pframe->jmp,FASTRUBY_TAG_RETRY);"
158
- fastruby/translator/modules/nonlocal.rb 74| longjmp(pframe->jmp,FASTRUBY_TAG_REDO);
159
- fastruby/translator/modules/nonlocal.rb 85| pframe->thread_data->accumulator = #{tree[1] ? to_c(tree[1]) : "Qnil"};
160
- fastruby/translator/modules/nonlocal.rb 86| longjmp(pframe->jmp,FASTRUBY_TAG_NEXT);
161
- fastruby/translator/modules/literal.rb 40| (0..(tree.size-3)/2).each do |i|
162
- fastruby/translator/modules/literal.rb 51| plocals = (void*)pframe->plocals;
163
- fastruby/translator/modules/literal.rb 62| strargs = tree[1..-1].map{|subtree| to_c subtree}.join(",")
164
- fastruby/translator/modules/literal.rb 63| "rb_ary_new3(#{tree.size-1}, #{strargs})"
165
- fastruby/translator/translator.rb 197| call_frame.thread_data = old_pframe->thread_data;
166
- fastruby/translator/translator.rb 200| VALUE old_call_frame = plocals->call_frame;
167
- fastruby/translator/translator.rb 201| plocals->call_frame = LONG2FIX(&call_frame);
168
- fastruby/translator/translator.rb 209| longjmp(old_pframe->jmp,aux);
169
- fastruby/translator/translator.rb 213| plocals->call_frame = old_call_frame;
170
- fastruby/translator/translator.rb 219| plocals->call_frame = old_call_frame;
171
- fastruby/translator/translator.rb 230| plocals->call_frame = old_call_frame;
172
- fastruby/translator/translator.rb 341| "VALUE self, VALUE block, VALUE _parent_frame, #{(0..signature.size-1).map{|x| "VALUE arg#{x}"}.join(",")}"
173
- fastruby/translator/translator.rb 361| VALUE rb_stack_chunk = frame.thread_data->rb_stack_chunk;
174
- fastruby/translator/translator.rb 374| frame.thread_data->rb_stack_chunk = rb_stack_chunk;
175
- fastruby/translator/translator.rb 385| plocals->parent_locals = LONG2FIX(frame.thread_data->last_plocals);
176
- fastruby/translator/translator.rb 386| void* old_parent_locals = frame.thread_data->last_plocals;
177
- fastruby/translator/translator.rb 387| frame.thread_data->last_plocals = plocals;
178
- fastruby/translator/translator.rb 389| plocals->active = Qtrue;
179
- fastruby/translator/translator.rb 390| plocals->targetted = Qfalse;
180
- fastruby/translator/translator.rb 391| plocals->pframe = LONG2FIX(&frame);
181
- fastruby/translator/translator.rb 398| int aux = setjmp(pframe->jmp);
182
- fastruby/translator/translator.rb 404| frame.thread_data->rb_stack_chunk = rb_previous_stack_chunk;
183
- fastruby/translator/translator.rb 407| plocals->active = Qfalse;
184
- fastruby/translator/translator.rb 408| frame.thread_data->last_plocals = old_parent_locals;
185
- fastruby/translator/translator.rb 409| return plocals->return_value;
186
- fastruby/translator/translator.rb 412| plocals->self = self;
187
- fastruby/translator/translator.rb 414| #{args_tree[1..-1].map { |arg|
188
- fastruby/translator/translator.rb 417| "plocals->#{arg} = #{arg};\n"
189
- fastruby/translator/translator.rb 420| plocals->block_function_address = LONG2FIX(0);
190
- fastruby/translator/translator.rb 421| plocals->block_function_param = LONG2FIX(Qnil);
191
- fastruby/translator/translator.rb 422| plocals->call_frame = LONG2FIX(0);
192
- fastruby/translator/translator.rb 429| frame.thread_data->rb_stack_chunk = rb_previous_stack_chunk;
193
- fastruby/translator/translator.rb 432| plocals->active = Qfalse;
194
- fastruby/translator/translator.rb 434| frame.thread_data->last_plocals = old_parent_locals;
195
- fastruby/translator/translator.rb 447| splat_arg = args_tree[1..-1].find{|x| x.to_s.match(/\*/) }
196
- fastruby/translator/translator.rb 449| maxargnum = args_tree[1..-1].count{ |x|
197
- fastruby/translator/translator.rb 459| args_tree[1..-1].each do |subtree|
198
- fastruby/translator/translator.rb 462| minargnum = minargnum - (subtree.size-1)
199
- fastruby/translator/translator.rb 467| if args_tree[1..-1].find{|x| x.to_s.match(/\*/)}
200
- fastruby/translator/translator.rb 474| validate_arguments_code = if signature.size-1 < minargnum
201
- fastruby/translator/translator.rb 476| rb_raise(rb_eArgError, \"wrong number of arguments (#{signature.size-1} for #{minargnum})\");
202
- fastruby/translator/translator.rb 478| elsif signature.size-1 > maxargnum
203
- fastruby/translator/translator.rb 480| rb_raise(rb_eArgError, \"wrong number of arguments (#{signature.size-1} for #{maxargnum})\");
204
- fastruby/translator/translator.rb 484| default_block_tree = args_tree[1..-1].find{|subtree|
205
- fastruby/translator/translator.rb 494| i = -1
206
- fastruby/translator/translator.rb 496| normalargsnum = args_tree[1..-1].count{|subtree|
207
- fastruby/translator/translator.rb 506| read_arguments_code = args_tree[1..-1].map { |arg_|
208
- fastruby/translator/translator.rb 511| if i < signature.size-1
209
- fastruby/translator/translator.rb 512| "plocals->#{arg} = argv[#{i}];\n"
210
- fastruby/translator/translator.rb 516| initialize_tree = default_block_tree[1..-1].find{|subtree| subtree[1] == arg_}
211
- fastruby/translator/translator.rb 532| if signature.size-1 < normalargsnum then
212
- fastruby/translator/translator.rb 534| plocals->#{splat_arg.to_s.gsub("*","")} = rb_ary_new3(0);
213
- fastruby/translator/translator.rb 538| plocals->#{splat_arg.to_s.gsub("*","")} = rb_ary_new4(
214
- fastruby/translator/translator.rb 539| #{(signature.size-1) - (normalargsnum)}, argv+#{normalargsnum}
215
- fastruby/translator/translator.rb 557| plocals->#{block_argument.to_s.gsub("&","")} = #{to_c FastRuby::FastRubySexp.from_sexp(proc_reyield_block_tree)};
216
- fastruby/translator/translator.rb 571| frame.thread_data = ((typeof(pframe))_parent_frame)->thread_data;
217
- fastruby/translator/translator.rb 576| VALUE rb_stack_chunk = frame.thread_data->rb_stack_chunk;
218
- fastruby/translator/translator.rb 589| frame.thread_data->rb_stack_chunk = rb_stack_chunk;
219
- fastruby/translator/translator.rb 603| plocals->parent_locals = LONG2FIX(frame.thread_data->last_plocals);
220
- fastruby/translator/translator.rb 604| void* old_parent_locals = frame.thread_data->last_plocals;
221
- fastruby/translator/translator.rb 605| frame.thread_data->last_plocals = plocals;
222
- fastruby/translator/translator.rb 608| plocals->active = Qtrue;
223
- fastruby/translator/translator.rb 609| plocals->targetted = Qfalse;
224
- fastruby/translator/translator.rb 610| plocals->pframe = LONG2FIX(&frame);
225
- fastruby/translator/translator.rb 611| plocals->call_frame = LONG2FIX(0);
226
- fastruby/translator/translator.rb 618| int aux = setjmp(pframe->jmp);
227
- fastruby/translator/translator.rb 620| plocals->active = Qfalse;
228
- fastruby/translator/translator.rb 626| frame.thread_data->rb_stack_chunk = rb_previous_stack_chunk;
229
- fastruby/translator/translator.rb 629| if (plocals->targetted == Qfalse || aux != FASTRUBY_TAG_RETURN) {
230
- fastruby/translator/translator.rb 630| frame.thread_data->last_plocals = old_parent_locals;
231
- fastruby/translator/translator.rb 632| longjmp(((typeof(pframe))_parent_frame)->jmp,aux);
232
- fastruby/translator/translator.rb 635| frame.thread_data->last_plocals = old_parent_locals;
233
- fastruby/translator/translator.rb 637| return plocals->return_value;
234
- fastruby/translator/translator.rb 640| plocals->self = self;
235
- fastruby/translator/translator.rb 646| plocals->block_function_address = LONG2FIX(pblock->block_function_address);
236
- fastruby/translator/translator.rb 647| plocals->block_function_param = LONG2FIX(pblock->block_function_param);
237
- fastruby/translator/translator.rb 649| plocals->block_function_address = LONG2FIX(0);
238
- fastruby/translator/translator.rb 650| plocals->block_function_param = LONG2FIX(Qnil);
239
- fastruby/translator/translator.rb 658| frame.thread_data->rb_stack_chunk = rb_previous_stack_chunk;
240
- fastruby/translator/translator.rb 661| plocals->active = Qfalse;
241
- fastruby/translator/translator.rb 663| frame.thread_data->last_plocals = old_parent_locals;
242
- fastruby/translator/translator.rb 680| "plocals->"
243
- fastruby/translator/translator.rb 746| return "FIX2LONG(plocals->block_function_address) == 0 ? Qfalse : Qtrue"
244
- fastruby/translator/translator.rb 755| #{@locals_struct} *plocals = (void*)pframe->plocals;
245
- fastruby/translator/translator.rb 786| #{nolocals ? "" : "#{@locals_struct} *plocals = (void*)pframe->plocals;"}
246
- fastruby/translator/translator.rb 801| #{nolocals ? "" : "#{@locals_struct} *plocals = (void*)pframe->plocals;"}
247
- fastruby/translator/translator.rb 837| frame.thread_data = parent_frame->thread_data;
248
- fastruby/translator/translator.rb 838| frame.next_recv = parent_frame->next_recv;
249
- fastruby/translator/translator.rb 844| nolocals ? "frame.plocals = 0;" : "#{@locals_struct}* plocals = parent_frame->plocals;
250
- fastruby/translator/translator.rb 877| longjmp(pframe->jmp, str.state);
251
- fastruby/translator/translator.rb 881| pframe->thread_data->exception = str.last_error;
252
- fastruby/translator/translator.rb 882| longjmp(pframe->jmp, FASTRUBY_TAG_RAISE);
253
- fastruby/translator/translator.rb 899| pstr->state = FIX2INT(rb_funcall(err, #{intern_num :state}, 0));
254
- fastruby/translator/translator.rb 901| pstr->last_error = err;
255
- fastruby/translator/translator.rb 918| pframe->last_error = Qnil;
256
- fastruby/translator/translator.rb 933| pframe->last_error = Qnil;
257
- fastruby/translator/translator.rb 935| if (pframe->rescue) {
258
- fastruby/translator/translator.rb 964| container_str = value.to_s.split("::")[0..-2].join("::")
259
- fastruby/translator/translator.rb 974| container_str = value.to_s.split("::")[0..-2].join("::")
260
- fastruby/translator/translator.rb 1033| strargs_signature = (0..args_tree.size-2).map{|x| "VALUE arg#{x}"}.join(",")
261
- fastruby/translator/translator.rb 1034| strargs = (0..args_tree.size-2).map{|x| "arg#{x}"}.join(",")
262
- fastruby/translator/translator.rb 1035| inprocstrargs = (1..args_tree.size-1).map{|x| "((VALUE*)method_arguments)[#{x}]"}.join(",")
263
- fastruby/translator/translator.rb 1061| protected_block "rb_funcall(((VALUE*)method_arguments)[0], #{intern_num mname.to_sym}, #{args_tree.size-1}#{inprocstrargs});", false, "method_arguments"
264
- fastruby/translator/translator.rb 1095| VALUE params[2] = {self,LONG2FIX(#{args_tree.size-1})};
265
- fastruby/translator/translator.rb 1105| protected_block "rb_funcall(((VALUE*)method_arguments)[0], #{intern_num mname.to_sym}, #{args_tree.size-1}#{inprocstrargs});", false, "method_arguments"
266
- fastruby/translator/translator.rb 1108| return ( (VALUE(*)(VALUE,VALUE,VALUE,int,VALUE*)) (fptr) )(self,(VALUE)block,(VALUE)frame,#{args_tree.size-1},method_arguments+1);
267
- fastruby/translator/translator.rb 1197| if (body->nd_argc == #{args_tree.size-1}) {
268
- fastruby/translator/translator.rb 1199| #{cfunc_real_address_name} = (void*)body->nd_cfnc;
269
- fastruby/translator/translator.rb 1200| } else if (body->nd_argc == -1) {
270
- fastruby/translator/translator.rb 1202| #{cfunc_real_address_name} = (void*)body->nd_cfnc;
271
- fastruby/translator/translator.rb 1203| } else if (body->nd_argc == -2) {
272
- fastruby/translator/translator.rb 1205| #{cfunc_real_address_name} = (void*)body->nd_cfnc;
273
- fastruby/translator/translator.rb 1301| frame.plocals = parent_frame->plocals;
274
- fastruby/translator/translator.rb 1302| frame.rescue = #{rescued ? rescued : "parent_frame->rescue"};
275
- fastruby/translator/translator.rb 1304| frame.thread_data = parent_frame->thread_data;
276
- fastruby/translator/translator.rb 1312| last_expression = pframe->return_value;
277
- fastruby/translator/translator.rb 1320| if (original_frame->targetted == 0) {
278
- fastruby/translator/translator.rb 1321| longjmp(pframe->jmp,aux);
279
- fastruby/cache/cache.rb 69| @base_path + "/#{hash[0..1]}/#{hash[2..-1]}/"
280
- fastruby/cache/cache.rb 74| create_dir_if_not_exists(@base_path + "/#{hash[0..1]}/#{hash[2..-1]}/")
@@ -1,111 +0,0 @@
1
- require "fastruby"
2
-
3
- describe FastRuby, "fastruby" do
4
- class ::VY1
5
- fastruby "
6
- def foo
7
- yield
8
- end
9
- "
10
- end
11
-
12
- it "should allow block as proc when calling from normal ruby" do
13
- executed = 0
14
-
15
- block = proc do
16
- executed = 1
17
- end
18
-
19
- ::VY1.new.foo(&block)
20
-
21
- executed.should be == 1
22
- end
23
-
24
- class ::VY2
25
- fastruby "
26
- def foo
27
- yield
28
- end
29
-
30
- def bar(block)
31
- foo(&block)
32
- end
33
- "
34
- end
35
-
36
- it "should allow block as proc when calling from fastruby" do
37
- executed = 0
38
-
39
- block = proc do
40
- executed = 1
41
- end
42
-
43
- ::VY2.new.bar(block)
44
-
45
- executed.should be == 1
46
- end
47
-
48
- class ::VY3
49
- fastruby "
50
- def foo
51
- yield(1)
52
- end
53
-
54
- def bar(block)
55
- foo(&block)
56
- end
57
- "
58
- end
59
-
60
- it "should allow block as proc when calling from fastruby with arguments" do
61
- executed = 0
62
- recv_x = nil
63
-
64
- block = proc do |x|
65
- recv_x = x
66
- executed = 1
67
- end
68
-
69
- ::VY3.new.bar(block)
70
-
71
- recv_x.should be == 1
72
- executed.should be == 1
73
- end
74
-
75
-
76
- class ::VY4
77
- def foo(a,b,c)
78
- yield(a,b,c)
79
- end
80
-
81
-
82
- fastruby "
83
- def bar(x,block)
84
- foo(*x,&block)
85
- end
86
- "
87
- end
88
-
89
- it "should allow block as proc when calling from fastruby with splat arguments" do
90
- executed = 0
91
- recv_a = nil
92
- recv_b = nil
93
- recv_c = nil
94
-
95
- block = proc do |a,b,c|
96
- recv_a = a
97
- recv_b = b
98
- recv_c = c
99
- executed = 1
100
- end
101
-
102
- ::VY4.new.bar([1,2,3],block)
103
-
104
- recv_a.should be == 1
105
- recv_b.should be == 2
106
- recv_c.should be == 3
107
- executed.should be == 1
108
- end
109
-
110
-
111
- end
@@ -1,67 +0,0 @@
1
- require "fastruby"
2
-
3
- describe FastRuby, "fastruby redo statement" do
4
- class ::WB1
5
- fastruby "
6
- def bar
7
- yield
8
- end
9
-
10
- def foo
11
- sum = 0
12
- bar do
13
- sum = sum + 1
14
- redo if sum<10
15
- end
16
-
17
- sum
18
- end
19
- "
20
- end
21
-
22
- it "should execute basic redo" do
23
- wb1 = ::WB1.new
24
- wb1.foo.should be == 10
25
- end
26
-
27
- class ::WB2
28
- def bar
29
- yield
30
- end
31
-
32
- fastruby "
33
-
34
- def foo
35
- sum = 0
36
- bar do
37
- sum = sum + 1
38
- redo if sum<10
39
- end
40
-
41
- sum
42
- end
43
- "
44
- end
45
-
46
- it "should execute basic redo (called method is in ruby)" do
47
- wb2 = ::WB2.new
48
- wb2.foo.should be == 10
49
- end
50
-
51
- class ::WB3
52
- fastruby "
53
- def foo
54
- redo
55
- end
56
- "
57
- end
58
-
59
- it "should raise LocalJumpError when invoked illegal redo" do
60
- wb3 = ::WB3.new
61
-
62
- lambda {
63
- wb3.foo
64
- }.should raise_error(LocalJumpError)
65
- end
66
-
67
- end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes