1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-04-12 03:41:51 +00:00
parent e72b71d56a
commit 7b4a171158
8 changed files with 57 additions and 97 deletions

View file

@ -1,3 +1,17 @@
Sat Apr 12 12:41:49 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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@segment7.net>
* lib/rubygems*, test/rubygems*: Update to RubyGems 1.1.1 r1701.

View file

@ -132,6 +132,8 @@ iseq_add_mark_object(rb_iseq_t *iseq, VALUE v)
return COMPILE_OK;
}
#define ruby_sourcefile RSTRING_PTR(iseq->filename)
static int
iseq_add_mark_object_compile_time(rb_iseq_t *iseq, VALUE v)
{

View file

@ -210,7 +210,7 @@ r_value(VALUE value)
break; \
}
#define ERROR_ARGS (node)->nd_file, nd_line(node),
#define ERROR_ARGS ruby_sourcefile, nd_line(node),
#define COMPILE_OK 1

21
eval.c
View file

@ -214,22 +214,19 @@ ruby_cleanup(int ex)
}
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 @@ ruby_stop(int ex)
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

48
gc.c
View file

@ -665,47 +665,6 @@ init_mark_stack(void)
#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 @@ gc_mark_children(VALUE ptr, int lev)
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 @@ gc_sweep(void)
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 @@ Init_GC(void)
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");

View file

@ -325,7 +325,6 @@ void ruby_set_stack_size(size_t);
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*);

51
parse.y
View file

@ -4738,7 +4738,7 @@ yycompile0(VALUE arg, int tracing)
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_newnode(struct parser_params *parser, enum node_type type, VALUE a0, VALUE
{
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 @@ fixpos(NODE *node, NODE *orig)
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 @@ assign_in_cond(struct parser_params *parser, NODE *node)
}
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 @@ range_op(struct parser_params *parser, NODE *node)
{
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 @@ cond0(struct parser_params *parser, NODE *node)
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 @@ cond0(struct parser_params *parser, NODE *node)
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 @@ cond0(struct parser_params *parser, NODE *node)
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_initialize(struct parser_params *parser)
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 @@ parser_mark(void *ptr)
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 @@ parser_free(void *ptr)
prev = local->prev;
xfree(local);
}
#ifndef RIPPER
xfree(p->parser_ruby_sourcefile);
#endif
xfree(p);
}
@ -9784,7 +9784,6 @@ ripper_initialize(int argc, VALUE *argv, VALUE self)
{
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 @@ ripper_initialize(int argc, VALUE *argv, VALUE self)
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;

15
ruby.c
View file

@ -1103,16 +1103,15 @@ process_options(VALUE arg)
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 *