fastruby 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -75,8 +75,6 @@ module FastRuby
75
75
  "
76
76
 
77
77
  extra_code << "
78
- #include \"node.h\"
79
-
80
78
  #define FASTRUBY_TAG_RETURN 0x80
81
79
  #define FASTRUBY_TAG_NEXT 0x81
82
80
  #define FASTRUBY_TAG_BREAK 0x82
@@ -99,18 +97,35 @@ module FastRuby
99
97
  init_extra << "
100
98
  rb_eval_string(#{ruby_code.inspect});
101
99
  "
100
+
101
+
102
+ if RUBY_VERSION =~ /^1\.8/
102
103
 
103
104
  @lambda_node_gvar = add_global_name("NODE*", 0);
104
105
  @proc_node_gvar = add_global_name("NODE*", 0);
105
106
  @procnew_node_gvar = add_global_name("NODE*", 0);
106
107
  @callcc_node_gvar = add_global_name("NODE*", 0);
107
-
108
+
108
109
  init_extra << "
109
110
  #{@lambda_node_gvar} = rb_method_node(rb_cObject, #{intern_num :lambda});
110
111
  #{@proc_node_gvar} = rb_method_node(rb_cObject, #{intern_num :proc});
111
112
  #{@procnew_node_gvar} = rb_method_node(CLASS_OF(rb_cProc), #{intern_num :new});
112
113
  #{@callcc_node_gvar} = rb_method_node(rb_mKernel, #{intern_num :callcc});
113
114
  "
115
+ elsif RUBY_VERSION =~ /^1\.9/
116
+
117
+ @lambda_node_gvar = add_global_name("void*", 0);
118
+ @proc_node_gvar = add_global_name("void*", 0);
119
+ @procnew_node_gvar = add_global_name("void*", 0);
120
+ @callcc_node_gvar = add_global_name("void*", 0);
121
+
122
+ init_extra << "
123
+ #{@lambda_node_gvar} = rb_method_entry(rb_cObject, #{intern_num :lambda});
124
+ #{@proc_node_gvar} = rb_method_entry(rb_cObject, #{intern_num :proc});
125
+ #{@procnew_node_gvar} = rb_method_entry(CLASS_OF(rb_const_get(rb_cObject, #{intern_num :Proc})), #{intern_num :new});
126
+ #{@callcc_node_gvar} = rb_method_entry(rb_mKernel, #{intern_num :callcc});
127
+ "
128
+ end
114
129
 
115
130
  @common_func = common_func
116
131
  if common_func
@@ -137,7 +152,15 @@ module FastRuby
137
152
  "
138
153
 
139
154
  extra_code << "static VALUE __rb_cvar_set(VALUE recv,ID idvar, VALUE value, int warn) {
140
- rb_cvar_set(recv,idvar,value,warn);
155
+ #{if RUBY_VERSION =~ /^1\.9/
156
+ "rb_cvar_set(recv,idvar,value);"
157
+ elsif RUBY_VERSION =~ /^1\.8/
158
+ "rb_cvar_set(recv,idvar,value,warn);"
159
+ else
160
+ raise RuntimeError, "unsupported ruby version #{RUBY_VERSION}"
161
+ end
162
+ }
163
+
141
164
  return value;
142
165
  }
143
166
  "
@@ -270,7 +293,7 @@ module FastRuby
270
293
  #{literal_value signature}
271
294
  );
272
295
 
273
- ID id = rb_intern(RSTRING(method_name)->ptr);
296
+ ID id = rb_intern(RSTRING_PTR(method_name));
274
297
 
275
298
  rb_funcall(
276
299
  #{literal_value FastRuby},
@@ -540,8 +563,10 @@ module FastRuby
540
563
 
541
564
  proc_reyield_block_tree = s(:iter, s(:call, nil, :proc, s(:arglist)), s(:masgn, s(:array, s(:splat, s(:lasgn, :__xproc_arguments)))), s(:yield, s(:splat, s(:lvar, :__xproc_arguments))))
542
565
 
566
+ require "fastruby/sexp_extension"
567
+
543
568
  read_arguments_code << "
544
- plocals->#{block_argument.to_s.gsub("&","")} = #{to_c proc_reyield_block_tree.to_fastruby_sexp};
569
+ plocals->#{block_argument.to_s.gsub("&","")} = #{to_c FastRuby::FastRubySexp.from_sexp(proc_reyield_block_tree)};
545
570
  "
546
571
  end
547
572
 
@@ -741,6 +766,7 @@ module FastRuby
741
766
  #{@frame_struct} *pframe = (void*)param;
742
767
  #{@locals_struct} *plocals = (void*)pframe->plocals;
743
768
  #{code};
769
+
744
770
  return Qnil;
745
771
  }
746
772
  "
@@ -971,10 +997,18 @@ module FastRuby
971
997
  rb_funcall(#{name},#{intern_num :gc_register_object},0);
972
998
  "
973
999
  else
1000
+
1001
+ require "base64"
974
1002
 
975
1003
  init_extra << "
976
- #{name} = rb_marshal_load(rb_str_new(#{c_escape str}, #{str.size}));
977
- rb_funcall(#{name},#{intern_num :gc_register_object},0);
1004
+
1005
+ {
1006
+ VALUE encoded_str = rb_str_new2(#{Base64.encode64(str).inspect});
1007
+ VALUE str = rb_funcall(rb_cObject, #{intern_num :decode64}, 1, encoded_str);
1008
+ #{name} = rb_marshal_load(str);
1009
+
1010
+ rb_funcall(#{name},#{intern_num :gc_register_object},0);
1011
+ }
978
1012
 
979
1013
  "
980
1014
  end
@@ -1063,7 +1097,7 @@ module FastRuby
1063
1097
  fptr = *#{address_name};
1064
1098
 
1065
1099
  #{
1066
- if args_tree.size < 25
1100
+ if args_tree.size < 25 and RUBY_VERSION =~ /^1\.8/
1067
1101
  "
1068
1102
  if (fptr == 0) {
1069
1103
  fptr = *#{cfunc_address_name};
@@ -1144,7 +1178,7 @@ module FastRuby
1144
1178
  VALUE rb_method_hash;
1145
1179
  void** address = 0;
1146
1180
  void** default_address = 0;
1147
- id = rb_intern(RSTRING(rb_str_signature)->ptr);
1181
+ id = rb_intern(RSTRING_PTR(rb_str_signature));
1148
1182
  rb_method_hash = rb_funcall(recvtype, #{intern_num :method_hash},1,mname);
1149
1183
 
1150
1184
  if (rb_method_hash != Qnil) {
@@ -1161,9 +1195,13 @@ module FastRuby
1161
1195
 
1162
1196
  if (default_address==0) {
1163
1197
  default_address = malloc(sizeof(void*));
1164
- NODE* body = rb_method_node(recvtype,#{intern_num mname});
1165
1198
  *default_address = 0;
1166
-
1199
+
1200
+ #ifdef RUBY_1_8
1201
+
1202
+ // this only works with ruby1.8
1203
+
1204
+ NODE* body = rb_method_node(recvtype,#{intern_num mname});
1167
1205
  if (body != 0) {
1168
1206
  if (nd_type(body) == NODE_CFUNC) {
1169
1207
  if (body->nd_argc == #{args_tree.size-1}) {
@@ -1178,7 +1216,8 @@ module FastRuby
1178
1216
  }
1179
1217
  }
1180
1218
  }
1181
-
1219
+ #endif
1220
+
1182
1221
  if (recvtype != Qnil) {
1183
1222
  rb_funcall(
1184
1223
  recvtype,
@@ -1262,7 +1301,7 @@ module FastRuby
1262
1301
 
1263
1302
  anonymous_function{ |name| "
1264
1303
  static VALUE #{name}(VALUE param) {
1265
- VALUE last_expression;
1304
+ VALUE last_expression = Qnil;
1266
1305
  #{@frame_struct} frame, *pframe, *parent_frame;
1267
1306
  #{@locals_struct} *plocals;
1268
1307
 
data/lib/fastruby.rb CHANGED
@@ -23,7 +23,14 @@ require "fastruby/object"
23
23
  require "fastruby/exceptions"
24
24
  require "fastruby/custom_require"
25
25
  require "fastruby/set_tree"
26
+ require "base64"
27
+
28
+ class Object
29
+ def self.decode64(value)
30
+ Base64.decode64(value)
31
+ end
32
+ end
26
33
 
27
34
  module FastRuby
28
- VERSION = "0.0.15" unless defined? FastRuby::VERSION
35
+ VERSION = "0.0.16" unless defined? FastRuby::VERSION
29
36
  end
data/lib/len ADDED
@@ -0,0 +1,280 @@
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,4 +1,7 @@
1
1
  require "fastruby"
2
+ if RUBY_VERSION =~ /^1\.9/
3
+ require "continuation"
4
+ end
2
5
 
3
6
  describe FastRuby, "fastruby" do
4
7
  class ::N1
data/spec/block_spec.rb CHANGED
@@ -56,6 +56,22 @@ describe FastRuby, "fastruby" do
56
56
  it "should compile blocks with code inside refering multiple block arguments" do
57
57
  ::X9.new.foo({1 => 2, 3 => 4}).sort.should be == [3,7]
58
58
  end
59
+
60
+ class ::X9_11
61
+ fastruby "
62
+ def foo
63
+ proc do |k,v|
64
+ k+v
65
+ end
66
+ end
67
+ "
68
+ end
69
+
70
+ it "should compile blocks with code inside refering multiple block arguments (proc)" do
71
+ pr = ::X9_11.new.foo
72
+ {1 => 2, 3 => 4}.map(&pr).sort.should be == [3,7]
73
+ end
74
+
59
75
 
60
76
  class ::Y10
61
77
  def bar(arg1)
@@ -272,12 +272,12 @@ describe FastRuby, "fastruby" do
272
272
  fastruby "
273
273
  class ::CF18
274
274
  def foo(*x)
275
- x.to_s
275
+ x
276
276
  end
277
277
  end
278
278
  "
279
279
 
280
- ::CF18.new.foo(1,2,3,4,5).should be == "12345"
280
+ ::CF18.new.foo(1,2,3,4,5).should be == [1,2,3,4,5]
281
281
  end
282
282
 
283
283
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
5
- prerelease: false
4
+ hash: 63
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 15
10
- version: 0.0.15
9
+ - 16
10
+ version: 0.0.16
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dario Seminara
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-01 00:00:00 -03:00
19
- default_executable:
18
+ date: 2011-11-20 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: RubyInline
@@ -26,12 +25,12 @@ dependencies:
26
25
  requirements:
27
26
  - - "="
28
27
  - !ruby/object:Gem::Version
29
- hash: 35
28
+ hash: 43
30
29
  segments:
31
30
  - 3
32
- - 9
31
+ - 11
33
32
  - 0
34
- version: 3.9.0
33
+ version: 3.11.0
35
34
  type: :runtime
36
35
  version_requirements: *id001
37
36
  - !ruby/object:Gem::Dependency
@@ -95,9 +94,10 @@ files:
95
94
  - lib/fastruby/translator/translator.rb
96
95
  - lib/fastruby/fastruby_sexp.rb
97
96
  - lib/fastruby/method_extension.rb
97
+ - lib/fastruby/self
98
98
  - lib/fastruby/cache/cache.rb
99
99
  - lib/fastruby.rb
100
- - lib/targetted
100
+ - lib/len
101
101
  - spec/variable_spec.rb
102
102
  - spec/control_spec.rb
103
103
  - spec/return_spec.rb
@@ -141,7 +141,6 @@ files:
141
141
  - Rakefile
142
142
  - TODO
143
143
  - CHANGELOG
144
- has_rdoc: true
145
144
  homepage: http://github.com/tario/fastruby
146
145
  licenses: []
147
146
 
@@ -171,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
170
  requirements: []
172
171
 
173
172
  rubyforge_project:
174
- rubygems_version: 1.3.7
173
+ rubygems_version: 1.8.11
175
174
  signing_key:
176
175
  specification_version: 3
177
176
  summary: fast execution of ruby code