mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_core.h: constify rb_iseq_constant_body::local_table and
rb_iseq_param_keyword::table and rb_iseq_param_keyword::default_values. * compile.c: catch up this fix. * iseq.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
18f6978625
commit
eed613f4b1
4 changed files with 41 additions and 19 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Thu Jul 23 18:50:43 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* vm_core.h: constify rb_iseq_constant_body::local_table and
|
||||||
|
rb_iseq_param_keyword::table and
|
||||||
|
rb_iseq_param_keyword::default_values.
|
||||||
|
|
||||||
|
* compile.c: catch up this fix.
|
||||||
|
|
||||||
|
* iseq.c: ditto.
|
||||||
|
|
||||||
Thu Jul 23 17:30:43 2015 Koichi Sasada <ko1@atdot.net>
|
Thu Jul 23 17:30:43 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* vm_core.h: constify rb_iseq_constant_body::iseq_encoded and
|
* vm_core.h: constify rb_iseq_constant_body::iseq_encoded and
|
||||||
|
|
42
compile.c
42
compile.c
|
@ -1056,12 +1056,13 @@ static int
|
||||||
iseq_set_exception_local_table(rb_iseq_t *iseq)
|
iseq_set_exception_local_table(rb_iseq_t *iseq)
|
||||||
{
|
{
|
||||||
ID id_dollar_bang;
|
ID id_dollar_bang;
|
||||||
|
ID *ids = (ID *)ALLOC_N(ID, 1);
|
||||||
|
|
||||||
CONST_ID(id_dollar_bang, "#$!");
|
CONST_ID(id_dollar_bang, "#$!");
|
||||||
iseq->body->local_table = (ID *)ALLOC_N(ID, 1);
|
|
||||||
iseq->body->local_table_size = 1;
|
iseq->body->local_table_size = 1;
|
||||||
iseq->body->local_size = iseq->body->local_table_size + 1;
|
iseq->body->local_size = iseq->body->local_table_size + 1;
|
||||||
iseq->body->local_table[0] = id_dollar_bang;
|
ids[0] = id_dollar_bang;
|
||||||
|
iseq->body->local_table = ids;
|
||||||
return COMPILE_OK;
|
return COMPILE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,12 +1280,17 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
|
||||||
}
|
}
|
||||||
iseq->body->param.keyword->required_num = rkw;
|
iseq->body->param.keyword->required_num = rkw;
|
||||||
iseq->body->param.keyword->table = &iseq->body->local_table[iseq->body->param.keyword->bits_start - iseq->body->param.keyword->num];
|
iseq->body->param.keyword->table = &iseq->body->local_table[iseq->body->param.keyword->bits_start - iseq->body->param.keyword->num];
|
||||||
iseq->body->param.keyword->default_values = ALLOC_N(VALUE, RARRAY_LEN(default_values));
|
|
||||||
|
|
||||||
for (i = 0; i < RARRAY_LEN(default_values); i++) {
|
{
|
||||||
VALUE dv = RARRAY_AREF(default_values, i);
|
VALUE *dvs = ALLOC_N(VALUE, RARRAY_LEN(default_values));
|
||||||
if (dv == complex_mark) dv = Qundef;
|
|
||||||
iseq->body->param.keyword->default_values[i] = dv;
|
for (i = 0; i < RARRAY_LEN(default_values); i++) {
|
||||||
|
VALUE dv = RARRAY_AREF(default_values, i);
|
||||||
|
if (dv == complex_mark) dv = Qundef;
|
||||||
|
dvs[i] = dv;
|
||||||
|
}
|
||||||
|
|
||||||
|
iseq->body->param.keyword->default_values = dvs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args->kw_rest_arg) {
|
else if (args->kw_rest_arg) {
|
||||||
|
@ -1349,8 +1355,9 @@ iseq_set_local_table(rb_iseq_t *iseq, const ID *tbl)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
iseq->body->local_table = (ID *)ALLOC_N(ID, size);
|
ID *ids = (ID *)ALLOC_N(ID, size);
|
||||||
MEMCPY(iseq->body->local_table, tbl, ID, size);
|
MEMCPY(ids, tbl, ID, size);
|
||||||
|
iseq->body->local_table = ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
iseq->body->local_size = iseq->body->local_table_size = size;
|
iseq->body->local_size = iseq->body->local_table_size = size;
|
||||||
|
@ -6078,6 +6085,8 @@ iseq_build_kw(rb_iseq_t *iseq, VALUE params, VALUE keywords)
|
||||||
int len = RARRAY_LENINT(keywords);
|
int len = RARRAY_LENINT(keywords);
|
||||||
int default_len;
|
int default_len;
|
||||||
VALUE key, sym, default_val;
|
VALUE key, sym, default_val;
|
||||||
|
VALUE *dvs;
|
||||||
|
ID *ids;
|
||||||
|
|
||||||
iseq->body->param.flags.has_kw = TRUE;
|
iseq->body->param.flags.has_kw = TRUE;
|
||||||
|
|
||||||
|
@ -6086,7 +6095,7 @@ iseq_build_kw(rb_iseq_t *iseq, VALUE params, VALUE keywords)
|
||||||
#define SYM(s) ID2SYM(rb_intern(#s))
|
#define SYM(s) ID2SYM(rb_intern(#s))
|
||||||
(void)int_param(&iseq->body->param.keyword->bits_start, params, SYM(kwbits));
|
(void)int_param(&iseq->body->param.keyword->bits_start, params, SYM(kwbits));
|
||||||
i = iseq->body->param.keyword->bits_start - iseq->body->param.keyword->num;
|
i = iseq->body->param.keyword->bits_start - iseq->body->param.keyword->num;
|
||||||
iseq->body->param.keyword->table = &iseq->body->local_table[i];
|
ids = (VALUE *)&iseq->body->local_table[i];
|
||||||
#undef SYM
|
#undef SYM
|
||||||
|
|
||||||
/* required args */
|
/* required args */
|
||||||
|
@ -6096,17 +6105,17 @@ iseq_build_kw(rb_iseq_t *iseq, VALUE params, VALUE keywords)
|
||||||
if (!SYMBOL_P(val)) {
|
if (!SYMBOL_P(val)) {
|
||||||
goto default_values;
|
goto default_values;
|
||||||
}
|
}
|
||||||
iseq->body->param.keyword->table[i] = SYM2ID(val);
|
ids[i] = SYM2ID(val);
|
||||||
iseq->body->param.keyword->required_num++;
|
iseq->body->param.keyword->required_num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
default_values: /* note: we intentionally preserve `i' from previous loop */
|
default_values: /* note: we intentionally preserve `i' from previous loop */
|
||||||
default_len = len - i;
|
default_len = len - i;
|
||||||
if (default_len == 0) {
|
if (default_len == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
iseq->body->param.keyword->default_values = ALLOC_N(VALUE, default_len);
|
dvs = ALLOC_N(VALUE, default_len);
|
||||||
|
|
||||||
for (j = 0; i < len; i++, j++) {
|
for (j = 0; i < len; i++, j++) {
|
||||||
key = RARRAY_AREF(keywords, i);
|
key = RARRAY_AREF(keywords, i);
|
||||||
|
@ -6126,9 +6135,12 @@ default_values: /* note: we intentionally preserve `i' from previous loop */
|
||||||
"keyword default has unsupported len %+"PRIsVALUE,
|
"keyword default has unsupported len %+"PRIsVALUE,
|
||||||
key);
|
key);
|
||||||
}
|
}
|
||||||
iseq->body->param.keyword->table[i] = SYM2ID(sym);
|
ids[i] = SYM2ID(sym);
|
||||||
iseq->body->param.keyword->default_values[j] = default_val;
|
dvs[j] = default_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iseq->body->param.keyword->table = ids;
|
||||||
|
iseq->body->param.keyword->default_values = dvs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
2
iseq.c
2
iseq.c
|
@ -1365,7 +1365,7 @@ rb_iseq_disasm(const rb_iseq_t *iseq)
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
int i;
|
int i;
|
||||||
long l;
|
long l;
|
||||||
ID *tbl;
|
const ID *tbl;
|
||||||
size_t n;
|
size_t n;
|
||||||
enum {header_minlen = 72};
|
enum {header_minlen = 72};
|
||||||
|
|
||||||
|
|
|
@ -322,8 +322,8 @@ struct rb_iseq_constant_body {
|
||||||
int required_num;
|
int required_num;
|
||||||
int bits_start;
|
int bits_start;
|
||||||
int rest_start;
|
int rest_start;
|
||||||
ID *table;
|
const ID *table;
|
||||||
VALUE *default_values;
|
const VALUE *default_values;
|
||||||
} *keyword;
|
} *keyword;
|
||||||
} param;
|
} param;
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ struct rb_iseq_constant_body {
|
||||||
/* insn info, must be freed */
|
/* insn info, must be freed */
|
||||||
struct iseq_line_info_entry *line_info_table;
|
struct iseq_line_info_entry *line_info_table;
|
||||||
|
|
||||||
ID *local_table; /* must free */
|
const ID *local_table; /* must free */
|
||||||
|
|
||||||
/* catch table */
|
/* catch table */
|
||||||
struct iseq_catch_table *catch_table;
|
struct iseq_catch_table *catch_table;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue