ruby-changes:34707
From: nobu <ko1@a...>
Date: Fri, 11 Jul 2014 23:10:55 +0900 (JST)
Subject: [ruby-changes:34707] nobu:r46790 (trunk): symbol.c: remove dependency on parse.h
nobu 2014-07-11 23:10:50 +0900 (Fri, 11 Jul 2014) New Revision: 46790 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46790 Log: symbol.c: remove dependency on parse.h * symbol.c (op_tbl): remove non-regular symbols. * symbol.c (global_symbols): start from the next of the preserved ID. * symbol.c: (rb_id2str): op_tbl does not exceed tLAST_OP_ID. Modified files: trunk/common.mk trunk/symbol.c trunk/symbol.h trunk/template/id.h.tmpl Index: symbol.c =================================================================== --- symbol.c (revision 46789) +++ symbol.c (revision 46790) @@ -14,7 +14,6 @@ https://github.com/ruby/ruby/blob/trunk/symbol.c#L14 #include "ruby/encoding.h" #include "internal.h" #include "node.h" -#include "parse.h" #include "symbol.h" #include "gc.h" #include "probes.h" @@ -26,6 +25,24 @@ static ID register_static_symid_str(ID, https://github.com/ruby/ruby/blob/trunk/symbol.c#L25 #define is_identchar(p,e,enc) (rb_enc_isalnum((unsigned char)(*(p)),(enc)) || (*(p)) == '_' || !ISASCII(*(p))) +#define tUPLUS RUBY_TOKEN(UPLUS) +#define tUMINUS RUBY_TOKEN(UMINUS) +#define tPOW RUBY_TOKEN(POW) +#define tCMP RUBY_TOKEN(CMP) +#define tEQ RUBY_TOKEN(EQ) +#define tEQQ RUBY_TOKEN(EQQ) +#define tNEQ RUBY_TOKEN(NEQ) +#define tGEQ RUBY_TOKEN(GEQ) +#define tLEQ RUBY_TOKEN(LEQ) +#define tMATCH RUBY_TOKEN(MATCH) +#define tNMATCH RUBY_TOKEN(NMATCH) +#define tDOT2 RUBY_TOKEN(DOT2) +#define tDOT3 RUBY_TOKEN(DOT3) +#define tAREF RUBY_TOKEN(AREF) +#define tASET RUBY_TOKEN(ASET) +#define tLSHFT RUBY_TOKEN(LSHFT) +#define tRSHFT RUBY_TOKEN(RSHFT) + static const struct { unsigned short token; const char name[3], term; @@ -33,7 +50,6 @@ static const struct { https://github.com/ruby/ruby/blob/trunk/symbol.c#L50 {tDOT2, ".."}, {tDOT3, "..."}, {tPOW, "**"}, - {tDSTAR, "**"}, {tUPLUS, "+@"}, {tUMINUS, "-@"}, {tCMP, "<=>"}, @@ -48,7 +64,6 @@ static const struct { https://github.com/ruby/ruby/blob/trunk/symbol.c#L64 {tASET, "[]="}, {tLSHFT, "<<"}, {tRSHFT, ">>"}, - {tCOLON2, "::"}, }; #define op_tbl_count numberof(op_tbl) @@ -60,7 +75,7 @@ static struct symbols { https://github.com/ruby/ruby/blob/trunk/symbol.c#L75 st_table *str_id; st_table *id_str; VALUE dsymbol_fstr_hash; -} global_symbols = {tLAST_TOKEN}; +} global_symbols = {tNEXT_ID-1}; static const struct st_hash_type symhash = { rb_str_hash_cmp, @@ -769,7 +784,7 @@ rb_id2str(ID id) https://github.com/ruby/ruby/blob/trunk/symbol.c#L784 { st_data_t data; - if (id < tLAST_TOKEN) { + if (id < tLAST_OP_ID) { int i = 0; if (id < INT_MAX && rb_ispunct((int)id)) { Index: symbol.h =================================================================== --- symbol.h (revision 46789) +++ symbol.h (revision 46790) @@ -14,7 +14,7 @@ https://github.com/ruby/ruby/blob/trunk/symbol.h#L14 #include "id.h" -#define ID_DYNAMIC_SYM_P(id) (!(id&ID_STATIC_SYM)&&id>tLAST_TOKEN) +#define ID_DYNAMIC_SYM_P(id) (!(id&ID_STATIC_SYM)&&id>tLAST_OP_ID) #define STATIC_SYM2ID(sym) RSHIFT((unsigned long)(sym), RUBY_SPECIAL_SHIFT) #define STATIC_ID2SYM(id) (((VALUE)(id)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG) Index: common.mk =================================================================== --- common.mk (revision 46789) +++ common.mk (revision 46790) @@ -780,7 +780,7 @@ string.$(OBJEXT): {$(VPATH)}string.c $(R https://github.com/ruby/ruby/blob/trunk/common.mk#L780 {$(VPATH)}regex.h $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h $(PROBES_H_INCLUDES) struct.$(OBJEXT): {$(VPATH)}struct.c $(RUBY_H_INCLUDES) {$(VPATH)}internal.h symbol.$(OBJEXT): {$(VPATH)}symbol.c $(RUBY_H_INCLUDES) $(ENCODING_H_INCLUDES) \ - {$(VPATH)}internal.h {$(VPATH)}node.h {$(VPATH)}parse.h {$(VPATH)}id.h {$(VPATH)}symbol.h \ + {$(VPATH)}internal.h {$(VPATH)}node.h {$(VPATH)}id.h {$(VPATH)}symbol.h \ $(PROBES_H_INCLUDES) thread.$(OBJEXT): {$(VPATH)}thread.c {$(VPATH)}eval_intern.h \ $(RUBY_H_INCLUDES) {$(VPATH)}gc.h $(VM_CORE_H_INCLUDES) \ Index: template/id.h.tmpl =================================================================== --- template/id.h.tmpl (revision 46789) +++ template/id.h.tmpl (revision 46790) @@ -98,6 +98,7 @@ enum ruby_method_ids { https://github.com/ruby/ruby/blob/trunk/template/id.h.tmpl#L98 % ids.values_at(*types).flatten.each do |token| t<%=token%>, % end + tNEXT_ID, % types.each do |type| % types = ids[type] or next % types.empty? and next -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/