aboutsummaryrefslogtreecommitdiffstats
path: root/vm_core.h
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-02 23:14:21 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-02 23:14:21 +0000
commit831e33c7809a92da6d14f0e518f960034c5dabd0 (patch)
treea0308f28d043d963e8e2b21d68f0633655105693 /vm_core.h
parent5d1f152fa342f6bb5fa9b546e3971843ee81c6b1 (diff)
downloadruby-831e33c7809a92da6d14f0e518f960034c5dabd0.tar.gz
* vm_core.h: change iseq parameter data structure.
https://bugs.ruby-lang.org/issues/10440#change-49694 * change terminology `arg' to `param'. * move rb_iseq_t::arg_* to rb_iseq_t::param. * move rb_iseq_t::arg_size to rb_iseq_t::param::size. * move rb_iseq_t::argc to rb_iseq_t::param::lead_num. * move rb_iseq_t::arg_opts to rb_iseq_t::param::opt_num. * move rb_iseq_t::arg_rest to rb_iseq_t::param::rest_start. * move rb_iseq_t::arg_post_num to rb_iseq_t::param::post_num. * move rb_iseq_t::arg_post_start to rb_iseq_t::param::post_start. * move rb_iseq_t::arg_block to rb_iseq_t::param::block_start. * move rb_iseq_t::arg_keyword* to rb_iseq_t::param::keyword. rb_iseq_t::param::keyword is allocated only when keyword parameters are available. * introduce rb_iseq_t::param::flags to represent parameter availability. For example, rb_iseq_t::param::flags::has_kw represents that this iseq has keyword parameters and rb_iseq_t::param::keyword is allocated. We don't need to compare with -1 to check availability. * remove rb_iseq_t::arg_simple. * compile.c: catch up this change. * iseq.c: ditto. * proc.c: ditto. * vm.c, vm_args.c, vm_dump.c, vm_insnhelper.c: ditto. * iseq.c (iseq_data_to_ary): support keyword argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_core.h')
-rw-r--r--vm_core.h72
1 files changed, 43 insertions, 29 deletions
diff --git a/vm_core.h b/vm_core.h
index f8494d07e6..0daa52f0c3 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -240,7 +240,7 @@ struct rb_iseq_struct {
rb_call_info_t *callinfo_entries;
/**
- * argument information
+ * parameter information
*
* def m(a1, a2, ..., aM, # mandatory
* b1=(...), b2=(...), ..., bN=(...), # optional
@@ -251,36 +251,50 @@ struct rb_iseq_struct {
* &g) # block
* =>
*
- * argc = M // or 0 if no mandatory arg
- * arg_opts = N+1 // or 0 if no optional arg
- * arg_rest = M+N // or -1 if no rest arg
- * arg_opt_table = [ (arg_opts entries) ]
- * arg_post_start = M+N+(*1) // or 0 if no post arguments
- * arg_post_num = O // or 0 if no post arguments
- * arg_keyword_num = K // or 0 if no keyword arg
- * arg_block = M+N+(*1)+O+K // or -1 if no block arg
- * arg_keyword_bits = M+N+(*1)+O+K+(&1) // or -1 if no keyword arg/rest
- * arg_simple = 0 if not simple arguments.
- * = 1 if no opt, rest, post, block.
- * = 2 if ambiguous block parameter ({|a|}).
- * arg_size = M+N+O+(*1)+K+(&1)+(**1) argument size.
+ * lead_num = M
+ * opt_num = N+1
+ * rest_start = M+N
+ * post_start = M+N+(*1)
+ * post_num = O
+ * keyword_num = K
+ * block_start = M+N+(*1)+O+K
+ * keyword_bits = M+N+(*1)+O+K+(&1)
+ * size = M+N+O+(*1)+K+(&1)+(**1) // parameter size.
*/
- int argc;
- int arg_simple;
- int arg_rest;
- int arg_block;
- int arg_opts;
- int arg_post_num;
- int arg_post_start;
- int arg_size;
- VALUE *arg_opt_table;
- int arg_keyword_num;
- int arg_keyword_bits;
- int arg_keyword_rest;
- int arg_keyword_required;
- ID *arg_keyword_table;
- VALUE *arg_keyword_default_values;
+ struct {
+ struct {
+ unsigned int has_lead : 1;
+ unsigned int has_opt : 1;
+ unsigned int has_rest : 1;
+ unsigned int has_post : 1;
+ unsigned int has_kw : 1;
+ unsigned int has_kwrest : 1;
+ unsigned int has_block : 1;
+
+ unsigned int ambiguous_param0 : 1; /* {|a|} */
+ } flags;
+
+ int size;
+
+ int lead_num;
+ int opt_num;
+ int rest_start;
+ int post_start;
+ int post_num;
+ int block_start;
+
+ VALUE *opt_table;
+
+ struct rb_iseq_param_keyword {
+ int num;
+ int required_num;
+ int bits_start;
+ int rest_start;
+ ID *table;
+ VALUE *default_values;
+ } *keyword;
+ } param;
/* catch table */
struct iseq_catch_table *catch_table;