* include/ruby/encoding.h (rb_enc_ispunct): added.
* common.mk (COMMONOBJS), inits.c (rb_call_inits): id.c is now included from parse.c. * id.c (Init_id), id.h (ruby_method_ids): added IDs used by VM. * parse.y (global_symbols): added rooms for VM IDs. * parse.y (rb_intern3, rb_id2str): single puctuation symbol is now same as char code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c710140216
commit
dc02325fd8
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
Thu Aug 14 17:57:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* include/ruby/encoding.h (rb_enc_ispunct): added.
|
||||||
|
|
||||||
|
* common.mk (COMMONOBJS), inits.c (rb_call_inits): id.c is now
|
||||||
|
included from parse.c.
|
||||||
|
|
||||||
|
* id.c (Init_id), id.h (ruby_method_ids): added IDs used by VM.
|
||||||
|
|
||||||
|
* parse.y (global_symbols): added rooms for VM IDs.
|
||||||
|
|
||||||
|
* parse.y (rb_intern3, rb_id2str): single puctuation symbol is now
|
||||||
|
same as char code.
|
||||||
|
|
||||||
Thu Aug 14 17:46:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Aug 14 17:46:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* parse.y (union tmpyystype): no longer needed, since YYSTYPE is
|
* parse.y (union tmpyystype): no longer needed, since YYSTYPE is
|
||||||
|
@ -79,7 +79,6 @@ COMMONOBJS = array.$(OBJEXT) \
|
|||||||
vm_dump.$(OBJEXT) \
|
vm_dump.$(OBJEXT) \
|
||||||
thread.$(OBJEXT) \
|
thread.$(OBJEXT) \
|
||||||
cont.$(OBJEXT) \
|
cont.$(OBJEXT) \
|
||||||
id.$(OBJEXT) \
|
|
||||||
$(BUILTIN_ENCOBJS) \
|
$(BUILTIN_ENCOBJS) \
|
||||||
$(MISSING)
|
$(MISSING)
|
||||||
|
|
||||||
|
65
id.c
65
id.c
@ -11,49 +11,40 @@
|
|||||||
|
|
||||||
#include "ruby/ruby.h"
|
#include "ruby/ruby.h"
|
||||||
|
|
||||||
#define YYSTYPE_IS_DECLARED
|
|
||||||
#define extern
|
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
#undef extern
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
Init_id(void)
|
Init_id(void)
|
||||||
{
|
{
|
||||||
#undef rb_intern
|
#undef rb_intern
|
||||||
|
#define rb_intern(str) rb_intern2(str, strlen(str))
|
||||||
|
rb_encoding *enc = rb_usascii_encoding();
|
||||||
|
|
||||||
/* Symbols */
|
REGISTER_SYMID(idNULL, "");
|
||||||
symIFUNC = ID2SYM(rb_intern("<IFUNC>"));
|
REGISTER_SYMID(idIFUNC, "<IFUNC>"),
|
||||||
symCFUNC = ID2SYM(rb_intern("<CFUNC>"));
|
REGISTER_SYMID(idCFUNC, "<CFUNC>"),
|
||||||
|
REGISTER_SYMID(idRespond_to, "respond_to?"),
|
||||||
|
REGISTER_SYMID(idThrowState, "#__ThrowState__"),
|
||||||
|
|
||||||
/* IDs */
|
REGISTER_SYMID(id_core_set_method_alias, "core#set_method_alias"),
|
||||||
idEach = rb_intern("each");
|
REGISTER_SYMID(id_core_set_variable_alias, "core#set_variable_alias"),
|
||||||
idTimes = rb_intern("times");
|
REGISTER_SYMID(id_core_undef_method, "core#undef_method"),
|
||||||
idLength = rb_intern("length");
|
REGISTER_SYMID(id_core_define_method, "core#define_method"),
|
||||||
idLambda = rb_intern("lambda");
|
REGISTER_SYMID(id_core_define_singleton_method, "core#define_singleton_method"),
|
||||||
idIntern = rb_intern("intern");
|
REGISTER_SYMID(id_core_set_postexe, "core#set_postexe"),
|
||||||
idGets = rb_intern("gets");
|
|
||||||
idSucc = rb_intern("succ");
|
|
||||||
idEnd = rb_intern("end");
|
|
||||||
idRangeEachLT = rb_intern("Range#each#LT");
|
|
||||||
idRangeEachLE = rb_intern("Range#each#LE");
|
|
||||||
idArrayEach = rb_intern("Array#each");
|
|
||||||
idMethodMissing = rb_intern("method_missing");
|
|
||||||
|
|
||||||
idThrowState = rb_intern("#__ThrowState__");
|
REGISTER_SYMID(idEach, "each");
|
||||||
|
REGISTER_SYMID(idLength, "length");
|
||||||
idBitblt = rb_intern("bitblt");
|
REGISTER_SYMID(idLambda, "lambda");
|
||||||
idAnswer = rb_intern("the_answer_to_life_the_universe_and_everything");
|
REGISTER_SYMID(idIntern, "intern");
|
||||||
|
REGISTER_SYMID(idGets, "gets");
|
||||||
idSend = rb_intern("send");
|
REGISTER_SYMID(idSucc, "succ");
|
||||||
id__send__ = rb_intern("__send__");
|
REGISTER_SYMID(idMethodMissing, "method_missing");
|
||||||
|
#if SUPPORT_JOKE
|
||||||
idRespond_to = rb_intern("respond_to?");
|
REGISTER_SYMID(idBitblt, "bitblt");
|
||||||
idInitialize = rb_intern("initialize");
|
REGISTER_SYMID(idAnswer, "the_answer_to_life_the_universe_and_everything");
|
||||||
|
#endif
|
||||||
id_core_set_method_alias = rb_intern("core_set_method_alias");
|
REGISTER_SYMID(idSend, "send");
|
||||||
id_core_set_variable_alias = rb_intern("core_set_variable_alias");
|
REGISTER_SYMID(id__send__, "__send__");
|
||||||
id_core_undef_method = rb_intern("core_undef_method");
|
REGISTER_SYMID(idInitialize, "initialize");
|
||||||
id_core_define_method = rb_intern("core_define_method");
|
|
||||||
id_core_define_singleton_method = rb_intern("core_define_singleton_method");
|
|
||||||
id_core_set_postexe = rb_intern("core_set_postexe");
|
|
||||||
}
|
}
|
||||||
|
72
id.h
72
id.h
@ -12,10 +12,21 @@
|
|||||||
#ifndef RUBY_ID_H
|
#ifndef RUBY_ID_H
|
||||||
#define RUBY_ID_H
|
#define RUBY_ID_H
|
||||||
|
|
||||||
|
#define ID_SCOPE_SHIFT 3
|
||||||
|
#define ID_SCOPE_MASK 0x07
|
||||||
|
#define ID_LOCAL 0x00
|
||||||
|
#define ID_INSTANCE 0x01
|
||||||
|
#define ID_GLOBAL 0x03
|
||||||
|
#define ID_ATTRSET 0x04
|
||||||
|
#define ID_CONST 0x05
|
||||||
|
#define ID_CLASS 0x06
|
||||||
|
#define ID_JUNK 0x07
|
||||||
|
#define ID_INTERNAL ID_JUNK
|
||||||
|
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
|
|
||||||
extern VALUE symIFUNC;
|
#define symIFUNC ID2SYM(idIFUNC)
|
||||||
extern VALUE symCFUNC;
|
#define symCFUNC ID2SYM(idCFUNC)
|
||||||
|
|
||||||
enum ruby_method_ids {
|
enum ruby_method_ids {
|
||||||
idPLUS = '+',
|
idPLUS = '+',
|
||||||
@ -36,34 +47,37 @@ enum ruby_method_ids {
|
|||||||
idEqTilde = tMATCH,
|
idEqTilde = tMATCH,
|
||||||
idAREF = tAREF,
|
idAREF = tAREF,
|
||||||
idASET = tASET,
|
idASET = tASET,
|
||||||
idDummy
|
idLAST_TOKEN = tLAST_TOKEN >> ID_SCOPE_SHIFT,
|
||||||
|
tIntern,
|
||||||
|
tMethodMissing,
|
||||||
|
tLength,
|
||||||
|
tGets,
|
||||||
|
tSucc,
|
||||||
|
tEach,
|
||||||
|
tLambda,
|
||||||
|
tSend,
|
||||||
|
t__send__,
|
||||||
|
tInitialize,
|
||||||
|
#if SUPPORT_JOKE
|
||||||
|
tBitblt,
|
||||||
|
tAnswer,
|
||||||
|
#endif
|
||||||
|
tLAST_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ID idThrowState;
|
#define idIntern ((tIntern<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idIntern;
|
#define idMethodMissing ((tMethodMissing<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idMethodMissing;
|
#define idLength ((tLength<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idLength;
|
#define idGets ((tGets<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idGets;
|
#define idSucc ((tSucc<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idSucc;
|
#define idEach ((tEach<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idEach;
|
#define idLambda ((tLambda<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idLambda;
|
#define idSend ((tSend<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idRangeEachLT;
|
#define id__send__ ((t__send__<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idRangeEachLE;
|
#define idInitialize ((tInitialize<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idArrayEach;
|
#if SUPPORT_JOKE
|
||||||
extern ID idTimes;
|
#define idBitblt ((tBitblt<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idEnd;
|
#define idAnswer ((tAnswer<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
extern ID idBitblt;
|
#endif
|
||||||
extern ID idAnswer;
|
|
||||||
extern ID idSend;
|
|
||||||
extern ID id__send__;
|
|
||||||
extern ID idRespond_to;
|
|
||||||
extern ID idInitialize;
|
|
||||||
|
|
||||||
extern ID id_core_set_method_alias;
|
|
||||||
extern ID id_core_set_variable_alias;
|
|
||||||
extern ID id_core_undef_method;
|
|
||||||
extern ID id_core_define_method;
|
|
||||||
extern ID id_core_define_singleton_method;
|
|
||||||
extern ID id_core_set_postexe;
|
|
||||||
|
|
||||||
#endif /* RUBY_ID_H */
|
#endif /* RUBY_ID_H */
|
||||||
|
@ -143,6 +143,7 @@ int rb_enc_codelen(int code, rb_encoding *enc);
|
|||||||
#define rb_enc_isalpha(c,enc) ONIGENC_IS_CODE_ALPHA(enc,c)
|
#define rb_enc_isalpha(c,enc) ONIGENC_IS_CODE_ALPHA(enc,c)
|
||||||
#define rb_enc_islower(c,enc) ONIGENC_IS_CODE_LOWER(enc,c)
|
#define rb_enc_islower(c,enc) ONIGENC_IS_CODE_LOWER(enc,c)
|
||||||
#define rb_enc_isupper(c,enc) ONIGENC_IS_CODE_UPPER(enc,c)
|
#define rb_enc_isupper(c,enc) ONIGENC_IS_CODE_UPPER(enc,c)
|
||||||
|
#define rb_enc_ispunct(c,enc) ONIGENC_IS_CODE_PUNCT(enc,c)
|
||||||
#define rb_enc_isalnum(c,enc) ONIGENC_IS_CODE_ALNUM(enc,c)
|
#define rb_enc_isalnum(c,enc) ONIGENC_IS_CODE_ALNUM(enc,c)
|
||||||
#define rb_enc_isprint(c,enc) ONIGENC_IS_CODE_PRINT(enc,c)
|
#define rb_enc_isprint(c,enc) ONIGENC_IS_CODE_PRINT(enc,c)
|
||||||
#define rb_enc_isspace(c,enc) ONIGENC_IS_CODE_SPACE(enc,c)
|
#define rb_enc_isspace(c,enc) ONIGENC_IS_CODE_SPACE(enc,c)
|
||||||
|
2
inits.c
2
inits.c
@ -36,7 +36,6 @@ void Init_Object(void);
|
|||||||
void Init_pack(void);
|
void Init_pack(void);
|
||||||
void Init_Precision(void);
|
void Init_Precision(void);
|
||||||
void Init_sym(void);
|
void Init_sym(void);
|
||||||
void Init_id(void);
|
|
||||||
void Init_process(void);
|
void Init_process(void);
|
||||||
void Init_RandomSeed(void);
|
void Init_RandomSeed(void);
|
||||||
void Init_Random(void);
|
void Init_Random(void);
|
||||||
@ -61,7 +60,6 @@ rb_call_inits()
|
|||||||
{
|
{
|
||||||
Init_RandomSeed();
|
Init_RandomSeed();
|
||||||
Init_sym();
|
Init_sym();
|
||||||
Init_id();
|
|
||||||
Init_var_tables();
|
Init_var_tables();
|
||||||
Init_Object();
|
Init_Object();
|
||||||
Init_top_self();
|
Init_top_self();
|
||||||
|
95
parse.y
95
parse.y
@ -35,16 +35,11 @@
|
|||||||
#define calloc YYCALLOC
|
#define calloc YYCALLOC
|
||||||
#define free YYFREE
|
#define free YYFREE
|
||||||
|
|
||||||
#define ID_SCOPE_SHIFT 3
|
#ifndef RIPPER
|
||||||
#define ID_SCOPE_MASK 0x07
|
static ID register_symid(ID, const char *, long, rb_encoding *);
|
||||||
#define ID_LOCAL 0x00
|
#define REGISTER_SYMID(id, name) register_symid(id, name, strlen(name), enc)
|
||||||
#define ID_INSTANCE 0x01
|
#include "id.c"
|
||||||
#define ID_GLOBAL 0x03
|
#endif
|
||||||
#define ID_ATTRSET 0x04
|
|
||||||
#define ID_CONST 0x05
|
|
||||||
#define ID_CLASS 0x06
|
|
||||||
#define ID_JUNK 0x07
|
|
||||||
#define ID_INTERNAL ID_JUNK
|
|
||||||
|
|
||||||
#define is_notop_id(id) ((id)>tLAST_TOKEN)
|
#define is_notop_id(id) ((id)>tLAST_TOKEN)
|
||||||
#define is_local_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL)
|
#define is_local_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL)
|
||||||
@ -495,6 +490,10 @@ static VALUE ripper_dispatch5(struct parser_params*,ID,VALUE,VALUE,VALUE,VALUE,V
|
|||||||
|
|
||||||
static VALUE ripper_intern(const char*);
|
static VALUE ripper_intern(const char*);
|
||||||
static VALUE ripper_id2sym(ID);
|
static VALUE ripper_id2sym(ID);
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define ripper_id2sym(id) ((id) < 256 && rb_ispunct(id) ? \
|
||||||
|
ID2SYM(id) : ripper_id2sym(id))
|
||||||
|
#endif
|
||||||
|
|
||||||
#define arg_new() dispatch0(args_new)
|
#define arg_new() dispatch0(args_new)
|
||||||
#define arg_add(l,a) dispatch2(args_add, l, a)
|
#define arg_add(l,a) dispatch2(args_add, l, a)
|
||||||
@ -732,6 +731,18 @@ static void ripper_compile_error(struct parser_params*, const char *fmt, ...);
|
|||||||
%right tPOW
|
%right tPOW
|
||||||
%right '!' '~' tUPLUS
|
%right '!' '~' tUPLUS
|
||||||
|
|
||||||
|
%nonassoc idNULL
|
||||||
|
%nonassoc idRespond_to
|
||||||
|
%nonassoc idIFUNC
|
||||||
|
%nonassoc idCFUNC
|
||||||
|
%nonassoc idThrowState
|
||||||
|
%nonassoc id_core_set_method_alias
|
||||||
|
%nonassoc id_core_set_variable_alias
|
||||||
|
%nonassoc id_core_undef_method
|
||||||
|
%nonassoc id_core_define_method
|
||||||
|
%nonassoc id_core_define_singleton_method
|
||||||
|
%nonassoc id_core_set_postexe
|
||||||
|
|
||||||
%token tLAST_TOKEN
|
%token tLAST_TOKEN
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@ -8796,41 +8807,28 @@ static const struct {
|
|||||||
} op_tbl[] = {
|
} op_tbl[] = {
|
||||||
{tDOT2, ".."},
|
{tDOT2, ".."},
|
||||||
{tDOT3, "..."},
|
{tDOT3, "..."},
|
||||||
{'+', "+"},
|
|
||||||
{'-', "-"},
|
|
||||||
{'+', "+(binary)"},
|
{'+', "+(binary)"},
|
||||||
{'-', "-(binary)"},
|
{'-', "-(binary)"},
|
||||||
{'*', "*"},
|
|
||||||
{'/', "/"},
|
|
||||||
{'%', "%"},
|
|
||||||
{tPOW, "**"},
|
{tPOW, "**"},
|
||||||
{tUPLUS, "+@"},
|
{tUPLUS, "+@"},
|
||||||
{tUMINUS, "-@"},
|
{tUMINUS, "-@"},
|
||||||
{'|', "|"},
|
|
||||||
{'^', "^"},
|
|
||||||
{'&', "&"},
|
|
||||||
{'!', "!"},
|
|
||||||
{tCMP, "<=>"},
|
{tCMP, "<=>"},
|
||||||
{'>', ">"},
|
|
||||||
{tGEQ, ">="},
|
{tGEQ, ">="},
|
||||||
{'<', "<"},
|
|
||||||
{tLEQ, "<="},
|
{tLEQ, "<="},
|
||||||
{tEQ, "=="},
|
{tEQ, "=="},
|
||||||
{tEQQ, "==="},
|
{tEQQ, "==="},
|
||||||
{tNEQ, "!="},
|
{tNEQ, "!="},
|
||||||
{tMATCH, "=~"},
|
{tMATCH, "=~"},
|
||||||
{tNMATCH, "!~"},
|
{tNMATCH, "!~"},
|
||||||
{'~', "~"},
|
|
||||||
{'!', "!"},
|
|
||||||
{tAREF, "[]"},
|
{tAREF, "[]"},
|
||||||
{tASET, "[]="},
|
{tASET, "[]="},
|
||||||
{tLSHFT, "<<"},
|
{tLSHFT, "<<"},
|
||||||
{tRSHFT, ">>"},
|
{tRSHFT, ">>"},
|
||||||
{tCOLON2, "::"},
|
{tCOLON2, "::"},
|
||||||
{'`', "`"},
|
|
||||||
{0, 0}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define op_tbl_count (sizeof(op_tbl) / sizeof(op_tbl[0]))
|
||||||
|
|
||||||
static struct symbols {
|
static struct symbols {
|
||||||
ID last_id;
|
ID last_id;
|
||||||
st_table *sym_id;
|
st_table *sym_id;
|
||||||
@ -8838,7 +8836,7 @@ static struct symbols {
|
|||||||
st_table *ivar2_id;
|
st_table *ivar2_id;
|
||||||
st_table *id_ivar2;
|
st_table *id_ivar2;
|
||||||
VALUE op_sym[tLAST_TOKEN];
|
VALUE op_sym[tLAST_TOKEN];
|
||||||
} global_symbols = {tLAST_TOKEN >> ID_SCOPE_SHIFT};
|
} global_symbols = {tLAST_ID};
|
||||||
|
|
||||||
static const struct st_hash_type symhash = {
|
static const struct st_hash_type symhash = {
|
||||||
rb_str_hash_cmp,
|
rb_str_hash_cmp,
|
||||||
@ -8877,7 +8875,8 @@ Init_sym(void)
|
|||||||
global_symbols.id_str = st_init_numtable_with_size(1000);
|
global_symbols.id_str = st_init_numtable_with_size(1000);
|
||||||
global_symbols.ivar2_id = st_init_table_with_size(&ivar2_hash_type, 1000);
|
global_symbols.ivar2_id = st_init_table_with_size(&ivar2_hash_type, 1000);
|
||||||
global_symbols.id_ivar2 = st_init_numtable_with_size(1000);
|
global_symbols.id_ivar2 = st_init_numtable_with_size(1000);
|
||||||
rb_intern2("", 0);
|
|
||||||
|
Init_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -9022,11 +9021,22 @@ rb_enc_symname2_p(const char *name, int len, rb_encoding *enc)
|
|||||||
return *m ? Qfalse : Qtrue;
|
return *m ? Qfalse : Qtrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ID
|
||||||
|
register_symid(ID id, const char *name, long len, rb_encoding *enc)
|
||||||
|
{
|
||||||
|
VALUE str = rb_enc_str_new(name, len, enc);
|
||||||
|
OBJ_FREEZE(str);
|
||||||
|
st_add_direct(global_symbols.sym_id, (st_data_t)str, id);
|
||||||
|
st_add_direct(global_symbols.id_str, id, (st_data_t)str);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
ID
|
ID
|
||||||
rb_intern3(const char *name, long len, rb_encoding *enc)
|
rb_intern3(const char *name, long len, rb_encoding *enc)
|
||||||
{
|
{
|
||||||
const char *m = name;
|
const char *m = name;
|
||||||
const char *e = m + len;
|
const char *e = m + len;
|
||||||
|
unsigned char c;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
ID id;
|
ID id;
|
||||||
int last;
|
int last;
|
||||||
@ -9068,12 +9078,16 @@ rb_intern3(const char *name, long len, rb_encoding *enc)
|
|||||||
m++;
|
m++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (m[0] != '_' && rb_enc_isascii((unsigned char)m[0], enc)
|
c = m[0];
|
||||||
&& !rb_enc_isalnum(m[0], enc)) {
|
if (c != '_' && rb_enc_isascii(c, enc) && rb_enc_ispunct(c, enc)) {
|
||||||
/* operators */
|
/* operators */
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0; op_tbl[i].token; i++) {
|
if (len == 1) {
|
||||||
|
id = c;
|
||||||
|
goto id_register;
|
||||||
|
}
|
||||||
|
for (i = 0; i < op_tbl_count; i++) {
|
||||||
if (*op_tbl[i].name == *m &&
|
if (*op_tbl[i].name == *m &&
|
||||||
strcmp(op_tbl[i].name, m) == 0) {
|
strcmp(op_tbl[i].name, m) == 0) {
|
||||||
id = op_tbl[i].token;
|
id = op_tbl[i].token;
|
||||||
@ -9129,11 +9143,7 @@ rb_intern3(const char *name, long len, rb_encoding *enc)
|
|||||||
new_id:
|
new_id:
|
||||||
id |= ++global_symbols.last_id << ID_SCOPE_SHIFT;
|
id |= ++global_symbols.last_id << ID_SCOPE_SHIFT;
|
||||||
id_register:
|
id_register:
|
||||||
str = rb_enc_str_new(name, len, enc);
|
return register_symid(id, name, len, enc);
|
||||||
OBJ_FREEZE(str);
|
|
||||||
st_add_direct(global_symbols.sym_id, (st_data_t)str, id);
|
|
||||||
st_add_direct(global_symbols.id_str, id, (st_data_t)str);
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ID
|
ID
|
||||||
@ -9174,7 +9184,19 @@ rb_id2str(ID id)
|
|||||||
if (id < tLAST_TOKEN) {
|
if (id < tLAST_TOKEN) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (i=0; op_tbl[i].token; i++) {
|
if (rb_ispunct(id)) {
|
||||||
|
VALUE str = global_symbols.op_sym[i = (int)id];
|
||||||
|
if (!str) {
|
||||||
|
char name[2];
|
||||||
|
name[0] = (char)id;
|
||||||
|
name[1] = 0;
|
||||||
|
str = rb_usascii_str_new(name, 1);
|
||||||
|
OBJ_FREEZE(str);
|
||||||
|
global_symbols.op_sym[i] = str;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
for (i = 0; i < op_tbl_count; i++) {
|
||||||
if (op_tbl[i].token == id) {
|
if (op_tbl[i].token == id) {
|
||||||
VALUE str = global_symbols.op_sym[i];
|
VALUE str = global_symbols.op_sym[i];
|
||||||
if (!str) {
|
if (!str) {
|
||||||
@ -9694,6 +9716,7 @@ keyword_id_to_str(ID id)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef ripper_id2sym
|
||||||
static VALUE
|
static VALUE
|
||||||
ripper_id2sym(ID id)
|
ripper_id2sym(ID id)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user