ruby-changes:4490
From: ko1@a...
Date: Sat, 12 Apr 2008 12:42:10 +0900 (JST)
Subject: [ruby-changes:4490] nobu - Ruby:r15983 (trunk): * eval.c (ruby_exec_node, ruby_run_node), ruby.c (process_options):
nobu 2008-04-12 12:41:51 +0900 (Sat, 12 Apr 2008)
New Revision: 15983
Modified files:
trunk/ChangeLog
trunk/compile.c
trunk/compile.h
trunk/eval.c
trunk/gc.c
trunk/include/ruby/intern.h
trunk/parse.y
trunk/ruby.c
Log:
* eval.c (ruby_exec_node, ruby_run_node), ruby.c (process_options):
use iseq instead of NODE.
* gc.c (source_filenames): removed.
* include/ruby/intern.h, parse.y (yycompile, parser_mark, parser_free,
ripper_initialize): rb_source_filename() is no longer used.
* compile.c, compile.h (ERROR_ARGS), parse.y (node_newnode, fixpos,
parser_warn, e_option_supplied, warn_unless_e_option, range_op,
cond0): nd_file is no longer used.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/compile.c?r1=15983&r2=15982&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=15983&r2=15982&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=15983&r2=15982&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15983&r2=15982&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/gc.c?r1=15983&r2=15982&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval.c?r1=15983&r2=15982&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/compile.h?r1=15983&r2=15982&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/intern.h?r1=15983&r2=15982&diff_format=u
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h (revision 15982)
+++ include/ruby/intern.h (revision 15983)
@@ -325,7 +325,6 @@
NORETURN(void rb_memerror(void));
int ruby_stack_check(void);
int ruby_stack_length(VALUE**);
-char *rb_source_filename(const char*);
void rb_gc_mark_locations(VALUE*, VALUE*);
void rb_mark_tbl(struct st_table*);
void rb_mark_set(struct st_table*);
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15982)
+++ ChangeLog (revision 15983)
@@ -1,3 +1,17 @@
+Sat Apr 12 12:41:49 2008 Nobuyoshi Nakada <nobu@r...>
+
+ * eval.c (ruby_exec_node, ruby_run_node), ruby.c (process_options):
+ use iseq instead of NODE.
+
+ * gc.c (source_filenames): removed.
+
+ * include/ruby/intern.h, parse.y (yycompile, parser_mark, parser_free,
+ ripper_initialize): rb_source_filename() is no longer used.
+
+ * compile.c, compile.h (ERROR_ARGS), parse.y (node_newnode, fixpos,
+ parser_warn, e_option_supplied, warn_unless_e_option, range_op,
+ cond0): nd_file is no longer used.
+
Sat Apr 12 05:55:57 2008 Eric Hodel <drbrain@s...>
* lib/rubygems*, test/rubygems*: Update to RubyGems 1.1.1 r1701.
Index: compile.c
===================================================================
--- compile.c (revision 15982)
+++ compile.c (revision 15983)
@@ -132,6 +132,8 @@
return COMPILE_OK;
}
+#define ruby_sourcefile RSTRING_PTR(iseq->filename)
+
static int
iseq_add_mark_object_compile_time(rb_iseq_t *iseq, VALUE v)
{
Index: compile.h
===================================================================
--- compile.h (revision 15982)
+++ compile.h (revision 15983)
@@ -210,7 +210,7 @@
break; \
}
-#define ERROR_ARGS (node)->nd_file, nd_line(node),
+#define ERROR_ARGS ruby_sourcefile, nd_line(node),
#define COMPILE_OK 1
Index: eval.c
===================================================================
--- eval.c (revision 15982)
+++ eval.c (revision 15983)
@@ -214,22 +214,19 @@
}
int
-ruby_exec_node(void *n, char *file)
+ruby_exec_node(void *n, const char *file)
{
int state;
- VALUE val;
- NODE *node = n;
+ VALUE iseq = (VALUE)n;
rb_thread_t *th = GET_THREAD();
- if (!node) return 0;
+ if (!n) return 0;
PUSH_TAG();
if ((state = EXEC_TAG()) == 0) {
- VALUE iseq = rb_iseq_new(n, rb_str_new2("<main>"),
- rb_str_new2(file), Qfalse, ISEQ_TYPE_TOP);
SAVE_ROOT_JMPBUF(th, {
th->base_block = 0;
- val = rb_iseq_eval(iseq);
+ rb_iseq_eval(iseq);
});
}
POP_TAG();
@@ -245,17 +242,17 @@
int
ruby_run_node(void *n)
{
- NODE *node = (NODE *)n;
+ VALUE v = (VALUE)n;
- switch ((VALUE)n) {
+ switch (v) {
case Qtrue: return EXIT_SUCCESS;
case Qfalse: return EXIT_FAILURE;
}
- if (FIXNUM_P((VALUE)n)) {
- return FIX2INT((VALUE)n);
+ if (FIXNUM_P(v)) {
+ return FIX2INT(v);
}
Init_stack((void *)&n);
- return ruby_cleanup(ruby_exec_node(node, node->nd_file));
+ return ruby_cleanup(ruby_exec_node(n, 0));
}
VALUE
Index: gc.c
===================================================================
--- gc.c (revision 15982)
+++ gc.c (revision 15983)
@@ -665,47 +665,6 @@
#define MARK_STACK_EMPTY (mark_stack_ptr == mark_stack)
-static st_table *source_filenames;
-
-char *
-rb_source_filename(const char *f)
-{
- st_data_t name;
-
- if (!st_lookup(source_filenames, (st_data_t)f, &name)) {
- long len = strlen(f) + 1;
- char *ptr = ALLOC_N(char, len + 1);
-
- name = (st_data_t)ptr;
- *ptr++ = 0;
- MEMCPY(ptr, f, char, len);
- st_add_direct(source_filenames, (st_data_t)ptr, name);
- return ptr;
- }
- return (char *)name + 1;
-}
-
-void
-rb_mark_source_filename(char *f)
-{
- if (f) {
- f[-1] = 1;
- }
-}
-
-static int
-sweep_source_filename(char *key, char *value)
-{
- if (*value) {
- *value = 0;
- return ST_CONTINUE;
- }
- else {
- free(value);
- return ST_DELETE;
- }
-}
-
static void gc_mark(VALUE ptr, int lev);
static void gc_mark_children(VALUE ptr, int lev);
@@ -924,7 +883,6 @@
break;
case T_NODE:
- rb_mark_source_filename(obj->as.node.nd_file);
switch (nd_type(obj)) {
case NODE_IF: /* 1,2,3 */
case NODE_FOR:
@@ -1221,10 +1179,6 @@
if (free_min < FREE_MIN)
free_min = FREE_MIN;
- if (source_filenames) {
- st_foreach(source_filenames, sweep_source_filename, 0);
- }
-
freelist = 0;
final_list = deferred_final_list;
deferred_final_list = 0;
@@ -2335,8 +2289,6 @@
rb_gc_unregister_address(&rb_mObSpace);
finalizers = rb_ary_new();
- source_filenames = st_init_strtable();
-
rb_global_variable(&nomem_error);
nomem_error = rb_exc_new2(rb_eNoMemError, "failed to allocate memory");
Index: parse.y
===================================================================
--- parse.y (revision 15982)
+++ parse.y (revision 15983)
@@ -4738,7 +4738,7 @@
static NODE*
yycompile(struct parser_params *parser, const char *f, int line)
{
- ruby_sourcefile = rb_source_filename(f);
+ ruby_sourcefile = ruby_strdup(f);
ruby_sourceline = line - 1;
return (NODE *)ruby_suppress_tracing(yycompile0, (VALUE)parser, Qtrue);
}
@@ -7316,7 +7316,6 @@
{
NODE *n = (rb_node_newnode)(type, a0, a1, a2);
nd_set_line(n, ruby_sourceline);
- n->nd_file = ruby_sourcefile;
return n;
}
@@ -7348,21 +7347,22 @@
if (!node) return;
if (!orig) return;
if (orig == (NODE*)1) return;
- node->nd_file = orig->nd_file;
nd_set_line(node, nd_line(orig));
}
static void
-parser_warning(NODE *node, const char *mesg)
+parser_warning(struct parser_params *parser, NODE *node, const char *mesg)
{
- rb_compile_warning(node->nd_file, nd_line(node), "%s", mesg);
+ rb_compile_warning(ruby_sourcefile, nd_line(node), "%s", mesg);
}
+#define parser_warning(node, mesg) parser_warning(parser, node, mesg)
static void
-parser_warn(NODE *node, const char *mesg)
+parser_warn(struct parser_params *parser, NODE *node, const char *mesg)
{
- rb_compile_warn(node->nd_file, nd_line(node), "%s", mesg);
+ rb_compile_warn(ruby_sourcefile, nd_line(node), "%s", mesg);
}
+#define parser_warn(node, mesg) parser_warn(parser, node, mesg)
static NODE*
block_append_gen(struct parser_params *parser, NODE *head, NODE *tail)
@@ -8144,23 +8144,23 @@
}
static int
-e_option_supplied(NODE *node)
+e_option_supplied(struct parser_params *parser)
{
- if (strcmp(node->nd_file, "-e") == 0)
+ if (strcmp(ruby_sourcefile, "-e") == 0)
return Qtrue;
return Qfalse;
}
static void
-warn_unless_e_option(NODE *node, const char *str)
+warn_unless_e_option(struct parser_params *parser, NODE *node, const char *str)
{
- if (!e_option_supplied(node)) parser_warn(node, str);
+ if (!e_option_supplied(parser)) parser_warn(node, str);
}
static void
-warning_unless_e_option(NODE *node, const char *str)
+warning_unless_e_option(struct parser_params *parser, NODE *node, const char *str)
{
- if (!e_option_supplied(node)) parser_warning(node, str);
+ if (!e_option_supplied(parser)) parser_warning(node, str);
}
static NODE *cond0(struct parser_params*,NODE*);
@@ -8170,14 +8170,14 @@
{
enum node_type type;
- if (!e_option_supplied(node)) return node;
+ if (!e_option_supplied(parser)) return node;
if (node == 0) return 0;
value_expr(node);
node = cond0(parser, node);
type = nd_type(node);
if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) {
- warn_unless_e_option(node, "integer literal in conditional range");
+ warn_unless_e_option(parser, node, "integer literal in conditional range");
return NEW_CALL(node, tEQ, NEW_LIST(NEW_GVAR(rb_intern("$."))));
}
return node;
@@ -8219,7 +8219,7 @@
case NODE_DREGX:
case NODE_DREGX_ONCE:
- warning_unless_e_option(node, "regex literal in condition");
+ warning_unless_e_option(parser, node, "regex literal in condition");
return NEW_MATCH2(node, NEW_GVAR(rb_intern("$_")));
case NODE_AND:
@@ -8234,7 +8234,7 @@
node->nd_end = range_op(parser, node->nd_end);
if (nd_type(node) == NODE_DOT2) nd_set_type(node,NODE_FLIP2);
else if (nd_type(node) == NODE_DOT3) nd_set_type(node, NODE_FLIP3);
- if (!e_option_supplied(node)) {
+ if (!e_option_supplied(parser)) {
int b = literal_node(node->nd_beg);
int e = literal_node(node->nd_end);
if ((b == 1 && e == 1) || (b + e >= 2 && RTEST(ruby_verbose))) {
@@ -8249,7 +8249,7 @@
case NODE_LIT:
if (TYPE(node->nd_lit) == T_REGEXP) {
- warn_unless_e_option(node, "regex literal in condition");
+ warn_unless_e_option(parser, node, "regex literal in condition");
nd_set_type(node, NODE_MATCH);
}
else {
@@ -9311,8 +9311,6 @@
parser->enc = rb_usascii_encoding();
}
-extern void rb_mark_source_filename(char *);
-
#ifdef RIPPER
#define parser_mark ripper_parser_mark
#define parser_free ripper_parser_free
@@ -9331,7 +9329,6 @@
rb_gc_mark((VALUE)p->parser_eval_tree_begin) ;
rb_gc_mark((VALUE)p->parser_eval_tree) ;
rb_gc_mark(p->debug_lines);
- rb_mark_source_filename(p->parser_ruby_sourcefile);
#else
rb_gc_mark(p->parser_ruby_sourcefile_string);
rb_gc_mark(p->delayed);
@@ -9358,6 +9355,9 @@
prev = local->prev;
xfree(local);
}
+#ifndef RIPPER
+ xfree(p->parser_ruby_sourcefile);
+#endif
xfree(p);
}
@@ -9784,7 +9784,6 @@
{
struct parser_params *parser;
VALUE src, fname, lineno;
- VALUE fname2;
Data_Get_Struct(self, struct parser_params, parser);
rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
@@ -9798,17 +9797,15 @@
parser->parser_lex_input = src;
parser->eofp = Qfalse;
if (NIL_P(fname)) {
- fname2 = STR_NEW2(" (ripper)");
+ fname = STR_NEW2("(ripper)");
}
else {
StringValue(fname);
- fname2 = rb_usascii_str_new2(" ");
- rb_str_append(fname2, fname);
}
parser_initialize(parser);
- parser->parser_ruby_sourcefile_string = fname2;
- parser->parser_ruby_sourcefile = RSTRING_PTR(fname2)+1;
+ parser->parser_ruby_sourcefile_string = fname;
+ parser->parser_ruby_sourcefile = RSTRING_PTR(fname);
parser->parser_ruby_sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
return Qnil;
Index: ruby.c
===================================================================
--- ruby.c (revision 15982)
+++ ruby.c (revision 15983)
@@ -1103,16 +1103,15 @@
return Qtrue;
}
- if (tree) {
- if (opt->do_print) {
- tree = rb_parser_append_print(parser, tree);
- }
- if (opt->do_loop) {
- tree = rb_parser_while_loop(parser, tree, opt->do_line, opt->do_split);
- }
+ if (opt->do_print) {
+ tree = rb_parser_append_print(parser, tree);
}
+ if (opt->do_loop) {
+ tree = rb_parser_while_loop(parser, tree, opt->do_line, opt->do_split);
+ }
- return (VALUE)tree;
+ return rb_iseq_new(tree, rb_str_new2("<main>"),
+ rb_str_new2(opt->script), Qfalse, ISEQ_TYPE_TOP);
}
static NODE *
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/