summaryrefslogtreecommitdiff
path: root/internal.h
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-04 14:31:52 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-04 14:31:52 +0000
commit568472906b178607ee569bff0d3074c27515719e (patch)
tree2aa58a2e021f7a30b7091f5b1417782ec0d3e485 /internal.h
parent91b51140d7f2b79f8fb7d0ea8901de89fa0304d6 (diff)
merge revision(s) 59357,59358: [Backport #13391] [Backport #13404]
proc.c: rb_block_min_max_arity * proc.c (rb_block_min_max_arity): new function to get arity range from the current block. vm_eval.c: rb_lambda_call * enum.c (enum_collect): make the block arity same as the given block. [Bug #13391] * internal.h (vm_ifunc): store arity instead of unused id. * proc.c (rb_vm_block_min_max_arity): return ifunc arity. * vm_eval.c (rb_lambda_call): call method with lambda block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'internal.h')
-rw-r--r--internal.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/internal.h b/internal.h
index d05d5366dd..a789fd887e 100644
--- a/internal.h
+++ b/internal.h
@@ -790,15 +790,30 @@ struct vm_throw_data {
/* IFUNC */
+struct vm_ifunc_argc {
+#if SIZEOF_INT * 2 > SIZEOF_VALUE
+ int min: (SIZEOF_VALUE * CHAR_BIT) / 2;
+ int max: (SIZEOF_VALUE * CHAR_BIT) / 2;
+#else
+ int min, max;
+#endif
+};
+
struct vm_ifunc {
VALUE flags;
VALUE reserved;
VALUE (*func)(ANYARGS);
const void *data;
- ID id;
+ struct vm_ifunc_argc argc;
};
#define IFUNC_NEW(a, b, c) ((struct vm_ifunc *)rb_imemo_new(imemo_ifunc, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
+struct vm_ifunc *rb_vm_ifunc_new(VALUE (*func)(ANYARGS), const void *data, int min_argc, int max_argc);
+static inline struct vm_ifunc *
+rb_vm_ifunc_proc_new(VALUE (*func)(ANYARGS), const void *data)
+{
+ return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
+}
/* MEMO */
@@ -1335,8 +1350,9 @@ ID rb_id_attrget(ID id);
VALUE rb_proc_location(VALUE self);
st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
int rb_block_arity(void);
+int rb_block_min_max_arity(int *max);
VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val);
-VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val);
+VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_argc);
/* process.c */
#define RB_MAX_GROUPS (65536)
@@ -1596,6 +1612,9 @@ VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr);
VALUE rb_yield_1(VALUE val);
VALUE rb_yield_lambda(VALUE values);
+VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv,
+ rb_block_call_func_t bl_proc, int min_argc, int max_argc,
+ VALUE data2);
/* vm_insnhelper.c */
VALUE rb_equal_opt(VALUE obj1, VALUE obj2);