Feature #15915 ยป local_variable_get-for-numparam.patch
| internal.h | ||
|---|---|---|
|
PUREFUNC(int rb_is_local_sym(VALUE sym));
|
||
|
PUREFUNC(int rb_is_method_sym(VALUE sym));
|
||
|
PUREFUNC(int rb_is_junk_sym(VALUE sym));
|
||
|
int rb_is_numparam_id(ID id);
|
||
|
int rb_is_numparam_name(VALUE name);
|
||
|
ID rb_make_internal_id(void);
|
||
|
void rb_gc_free_dsymbol(VALUE);
|
||
|
ID rb_id_attrget(ID id);
|
||
| proc.c | ||
|---|---|---|
|
}
|
||
|
}
|
||
|
else {
|
||
|
int num = rb_is_numparam_name(name);
|
||
|
if (num >= 0) {
|
||
|
*pname = INT2FIX(num);
|
||
|
return -1;
|
||
|
}
|
||
|
if (!rb_is_local_name(name)) {
|
||
|
rb_name_err_raise("wrong local variable name `%1$s' for %2$s",
|
||
|
bindval, name);
|
||
| ... | ... | |
|
GetBindingPtr(bindval, bind);
|
||
|
if (lid == (ID)-1) {
|
||
|
int numparam = FIX2INT(sym);
|
||
|
env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
|
||
|
if (!VM_ENV_FLAGS(env->ep, VM_FRAME_FLAG_CFRAME)) {
|
||
|
const rb_iseq_t *iseq = env->iseq;
|
||
|
if (numparam <= iseq->body->param.lead_num) {
|
||
|
if (rb_is_junk_id(iseq->body->local_table[numparam - 1])) {
|
||
|
return env->env[numparam - 1];
|
||
|
}
|
||
|
else {
|
||
|
rb_name_err_raise("numbered parameter is not used in this block", bindval, sym);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
goto undefined;
|
||
|
}
|
||
|
env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
|
||
|
if ((ptr = get_local_variable_ptr(&env, lid)) == NULL) {
|
||
|
sym = ID2SYM(lid);
|
||
| symbol.c | ||
|---|---|---|
|
++m;
|
||
|
type = ID_CLASS;
|
||
|
}
|
||
|
if (ISDIGIT(*m)) {
|
||
|
if (!m[1] || (ISDIGIT(m[1]) && !m[2])) {
|
||
|
return ID_NUMPARAM;
|
||
|
}
|
||
|
}
|
||
|
goto id;
|
||
|
case '<':
|
||
| ... | ... | |
|
return is_junk_id(id);
|
||
|
}
|
||
|
int
|
||
|
rb_is_numparam_id(ID id)
|
||
|
{
|
||
|
return is_numparam_id(id);
|
||
|
}
|
||
|
int
|
||
|
rb_is_const_sym(VALUE sym)
|
||
|
{
|
||
| ... | ... | |
|
return rb_str_symname_type(name, IDSET_ATTRSET_FOR_SYNTAX) == -1;
|
||
|
}
|
||
|
int
|
||
|
rb_is_numparam_name(VALUE name)
|
||
|
{
|
||
|
if (rb_str_symname_type(name, 0) == ID_NUMPARAM) {
|
||
|
const char *ptr = StringValuePtr(name);
|
||
|
return atoi(ptr+1);
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
#include "id_table.c"
|
||
| symbol.h | ||
|---|---|---|
|
#define is_const_id(id) (id_type(id)==ID_CONST)
|
||
|
#define is_class_id(id) (id_type(id)==ID_CLASS)
|
||
|
#define is_junk_id(id) (id_type(id)==ID_JUNK)
|
||
|
#define is_numparam_id(id) (id_type(id)==ID_NUMPARAM)
|
||
|
static inline int
|
||
|
id_type(ID id)
|
||
| template/id.h.tmpl | ||
|---|---|---|
|
RUBY_ID_STATIC_SYM = 0x01,
|
||
|
RUBY_ID_LOCAL = 0x00,
|
||
|
RUBY_ID_INSTANCE = (0x01<<1),
|
||
|
RUBY_ID_NUMPARAM = (0x02<<1),
|
||
|
RUBY_ID_GLOBAL = (0x03<<1),
|
||
|
RUBY_ID_ATTRSET = (0x04<<1),
|
||
|
RUBY_ID_CONST = (0x05<<1),
|
||
| ... | ... | |
|
#define ID_ATTRSET RUBY_ID_ATTRSET
|
||
|
#define ID_CONST RUBY_ID_CONST
|
||
|
#define ID_CLASS RUBY_ID_CLASS
|
||
|
#define ID_NUMPARAM RUBY_ID_NUMPARAM
|
||
|
#define ID_JUNK RUBY_ID_JUNK
|
||
|
#define ID_INTERNAL RUBY_ID_INTERNAL
|
||