зеркало из https://github.com/github/ruby.git
* eval.c: remove ruby_current_node and change eval() prototype.
fix to use rb_sourcefile/line() instead of ruby_sourcefile/line. * error.c, eval_error.ci, eval_load.c, eval_safe.ci, gc.c, include/ruby/intern.h, parse.y, process.c, ruby.c: ditto. * vm.c: fix spaces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6bd0345627
Коммит
f58eb1e276
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Mon Jun 25 05:27:54 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* eval.c: remove ruby_current_node and change eval() prototype.
|
||||
fix to use rb_sourcefile/line() instead of ruby_sourcefile/line.
|
||||
|
||||
* error.c, eval_error.ci, eval_load.c, eval_safe.ci, gc.c,
|
||||
include/ruby/intern.h, parse.y, process.c, ruby.c: ditto.
|
||||
|
||||
* vm.c: fix spaces.
|
||||
|
||||
Mon Jun 25 04:20:14 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* eval_*.h: rename to eval_*.ci.
|
||||
|
|
5
error.c
5
error.c
|
@ -26,9 +26,6 @@
|
|||
extern const char ruby_version[], ruby_release_date[], ruby_platform[];
|
||||
int ruby_nerrs;
|
||||
|
||||
const char *rb_sourcefile(void);
|
||||
int rb_sourceline(void);
|
||||
|
||||
static int
|
||||
err_position_0(char *buf, long len, const char *file, long line)
|
||||
{
|
||||
|
@ -52,7 +49,7 @@ err_position(char *buf, long len)
|
|||
static int
|
||||
compile_position(char *buf, long len)
|
||||
{
|
||||
return err_position_0(buf, len, ruby_sourcefile, ruby_sourceline);
|
||||
return err_position_0(buf, len, rb_sourcefile(), rb_sourceline());
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
59
eval.c
59
eval.c
|
@ -22,8 +22,6 @@ VALUE rb_f_block_given_p(void);
|
|||
ID rb_frame_callee(void);
|
||||
static VALUE rb_frame_self(void);
|
||||
|
||||
NODE *ruby_current_node;
|
||||
|
||||
static ID removed, singleton_removed, undefined, singleton_undefined;
|
||||
static ID init, eqq, each, aref, aset, match, missing;
|
||||
static ID added, singleton_added;
|
||||
|
@ -35,7 +33,7 @@ VALUE rb_eSysStackError;
|
|||
extern int ruby_nerrs;
|
||||
extern VALUE ruby_top_self;
|
||||
|
||||
static VALUE eval(VALUE, VALUE, VALUE, char *, int);
|
||||
static VALUE eval(VALUE, VALUE, VALUE, const char *, int);
|
||||
|
||||
static inline VALUE rb_yield_0(int argc, VALUE *argv);
|
||||
static VALUE rb_call(VALUE, VALUE, ID, int, const VALUE *, int);
|
||||
|
@ -270,15 +268,7 @@ ruby_run(void)
|
|||
VALUE
|
||||
rb_eval_string(const char *str)
|
||||
{
|
||||
VALUE v;
|
||||
NODE *oldsrc = ruby_current_node;
|
||||
|
||||
ruby_current_node = 0;
|
||||
ruby_sourcefile = rb_source_filename("(eval)");
|
||||
v = eval(ruby_top_self, rb_str_new2(str), Qnil, 0, 0);
|
||||
ruby_current_node = oldsrc;
|
||||
|
||||
return v;
|
||||
return eval(ruby_top_self, rb_str_new2(str), Qnil, "(eval)", 0);
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
@ -324,14 +314,13 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level)
|
|||
if (OBJ_TAINTED(cmd)) {
|
||||
level = 4;
|
||||
}
|
||||
if (TYPE(cmd) != T_STRING) {
|
||||
|
||||
if (TYPE(cmd) != T_STRING) {
|
||||
PUSH_TAG();
|
||||
rb_set_safe_level_force(level);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
val =
|
||||
rb_funcall2(cmd, rb_intern("call"), RARRAY_LEN(arg),
|
||||
RARRAY_PTR(arg));
|
||||
val = rb_funcall2(cmd, rb_intern("call"), RARRAY_LEN(arg),
|
||||
RARRAY_PTR(arg));
|
||||
}
|
||||
POP_TAG();
|
||||
|
||||
|
@ -712,7 +701,7 @@ rb_longjmp(int tag, VALUE mesg)
|
|||
e = rb_obj_as_string(e);
|
||||
warn_printf("Exception `%s' at %s:%d - %s\n",
|
||||
rb_obj_classname(GET_THREAD()->errinfo),
|
||||
ruby_sourcefile, ruby_sourceline, RSTRING_PTR(e));
|
||||
rb_sourcefile(), rb_sourceline(), RSTRING_PTR(e));
|
||||
}
|
||||
POP_TAG();
|
||||
if (status == TAG_FATAL && GET_THREAD()->errinfo == exception_error) {
|
||||
|
@ -1295,7 +1284,6 @@ rb_method_missing(int argc, const VALUE *argv, VALUE obj)
|
|||
ID id;
|
||||
VALUE exc = rb_eNoMethodError;
|
||||
char *format = 0;
|
||||
NODE *cnode = ruby_current_node;
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
int last_call_status = th->method_missing_reason;
|
||||
if (argc == 0 || !SYMBOL_P(argv[0])) {
|
||||
|
@ -1323,7 +1311,6 @@ rb_method_missing(int argc, const VALUE *argv, VALUE obj)
|
|||
format = "undefined method `%s' for %s";
|
||||
}
|
||||
|
||||
ruby_current_node = cnode;
|
||||
{
|
||||
int n = 0;
|
||||
VALUE args[3];
|
||||
|
@ -1667,36 +1654,8 @@ rb_frame_self(void)
|
|||
return GET_THREAD()->cfp->self;
|
||||
}
|
||||
|
||||
const char *
|
||||
rb_sourcefile(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
|
||||
|
||||
if (cfp) {
|
||||
return RSTRING_PTR(cfp->iseq->filename);
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
rb_sourceline(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
|
||||
|
||||
if (cfp) {
|
||||
return vm_get_sourceline(cfp);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
eval(VALUE self, VALUE src, VALUE scope, char *file, int line)
|
||||
eval(VALUE self, VALUE src, VALUE scope, const char *file, int line)
|
||||
{
|
||||
int state;
|
||||
VALUE result = Qundef;
|
||||
|
@ -1707,8 +1666,8 @@ eval(VALUE self, VALUE src, VALUE scope, char *file, int line)
|
|||
NODE *stored_cref_stack = 0;
|
||||
|
||||
if (file == 0) {
|
||||
file = ruby_sourcefile;
|
||||
line = ruby_sourceline;
|
||||
file = rb_sourcefile();
|
||||
line = rb_sourceline();
|
||||
}
|
||||
|
||||
PUSH_TAG();
|
||||
|
|
|
@ -2,6 +2,34 @@
|
|||
* included by eval.c
|
||||
*/
|
||||
|
||||
const char *
|
||||
rb_sourcefile(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
|
||||
|
||||
if (cfp) {
|
||||
return RSTRING_PTR(cfp->iseq->filename);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
rb_sourceline(void)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
|
||||
|
||||
if (cfp) {
|
||||
return vm_get_sourceline(cfp);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
warn_printf(const char *fmt, ...)
|
||||
{
|
||||
|
@ -20,16 +48,19 @@ warn_printf(const char *fmt, ...)
|
|||
static void
|
||||
error_pos(void)
|
||||
{
|
||||
if (ruby_sourcefile) {
|
||||
if (ruby_sourceline == 0) {
|
||||
warn_printf("%s", ruby_sourcefile);
|
||||
const char *sourcefile = rb_sourcefile();
|
||||
int sourceline = rb_sourceline();
|
||||
|
||||
if (sourcefile) {
|
||||
if (sourceline == 0) {
|
||||
warn_printf("%s", sourcefile);
|
||||
}
|
||||
else if (rb_frame_callee()) {
|
||||
warn_printf("%s:%d:in `%s'", ruby_sourcefile, ruby_sourceline,
|
||||
warn_printf("%s:%d:in `%s'", sourcefile, sourceline,
|
||||
rb_id2name(rb_frame_callee()));
|
||||
}
|
||||
else {
|
||||
warn_printf("%s:%d", ruby_sourcefile, ruby_sourceline);
|
||||
warn_printf("%s:%d", sourcefile, sourceline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,10 +103,10 @@ error_print(void)
|
|||
if (EXEC_TAG())
|
||||
goto error;
|
||||
if (NIL_P(errat)) {
|
||||
if (ruby_sourcefile)
|
||||
warn_printf("%s:%d", ruby_sourcefile, ruby_sourceline);
|
||||
if (rb_sourcefile())
|
||||
warn_printf("%s:%d", rb_sourcefile(), rb_sourceline());
|
||||
else
|
||||
warn_printf("%d", ruby_sourceline);
|
||||
warn_printf("%d", rb_sourceline());
|
||||
}
|
||||
else if (RARRAY_LEN(errat) == 0) {
|
||||
error_pos();
|
||||
|
|
|
@ -183,9 +183,6 @@ extern VALUE sysstack_error;
|
|||
void rb_thread_cleanup _((void));
|
||||
void rb_thread_wait_other_threads _((void));
|
||||
|
||||
int rb_sourceline(void);
|
||||
const char *rb_sourcefile(void);
|
||||
|
||||
int thread_set_raised(rb_thread_t *th);
|
||||
int thread_reset_raised(rb_thread_t *th);
|
||||
|
||||
|
|
|
@ -423,13 +423,11 @@ rb_require_safe(VALUE fname, int safe)
|
|||
volatile VALUE errinfo = th->errinfo;
|
||||
int state;
|
||||
struct {
|
||||
NODE *node;
|
||||
int safe;
|
||||
} volatile saved;
|
||||
char *volatile ftptr = 0;
|
||||
|
||||
PUSH_TAG();
|
||||
saved.node = ruby_current_node;
|
||||
saved.safe = rb_safe_level();
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
VALUE path;
|
||||
|
@ -452,7 +450,6 @@ rb_require_safe(VALUE fname, int safe)
|
|||
break;
|
||||
|
||||
case 's':
|
||||
ruby_current_node = 0;
|
||||
ruby_sourcefile = rb_source_filename(RSTRING_PTR(path));
|
||||
ruby_sourceline = 0;
|
||||
handle = (long)rb_vm_call_cfunc(ruby_top_self, load_ext,
|
||||
|
@ -468,7 +465,6 @@ rb_require_safe(VALUE fname, int safe)
|
|||
POP_TAG();
|
||||
load_unlock(ftptr);
|
||||
|
||||
ruby_current_node = saved.node;
|
||||
rb_set_safe_level_force(saved.safe);
|
||||
if (state) {
|
||||
JUMP_TAG(state);
|
||||
|
@ -502,9 +498,9 @@ init_ext_call(VALUE arg)
|
|||
void
|
||||
ruby_init_ext(const char *name, void (*init)(void))
|
||||
{
|
||||
ruby_current_node = 0;
|
||||
ruby_sourcefile = rb_source_filename(name);
|
||||
ruby_sourceline = 0;
|
||||
|
||||
if (load_lock(name)) {
|
||||
rb_vm_call_cfunc(ruby_top_self, init_ext_call, (VALUE)init, 0, rb_str_new2(name));
|
||||
rb_provide(name);
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#define SAFE_LEVEL_MAX 4
|
||||
|
||||
/* $SAFE accessor */
|
||||
|
||||
int
|
||||
rb_safe_level(void)
|
||||
{
|
||||
|
@ -24,7 +26,6 @@ rb_set_safe_level_force(int safe)
|
|||
GET_THREAD()->safe_level = safe;
|
||||
}
|
||||
|
||||
/* $SAFE accessor */
|
||||
void
|
||||
rb_set_safe_level(int level)
|
||||
{
|
||||
|
|
6
gc.c
6
gc.c
|
@ -475,8 +475,8 @@ rb_newobj_from_heap(void)
|
|||
|
||||
MEMZERO((void*)obj, RVALUE, 1);
|
||||
#ifdef GC_DEBUG
|
||||
RANY(obj)->file = ruby_sourcefile;
|
||||
RANY(obj)->line = ruby_sourceline;
|
||||
RANY(obj)->file = rb_sourcefile();
|
||||
RANY(obj)->line = rb_sourceline();
|
||||
#endif
|
||||
return obj;
|
||||
}
|
||||
|
@ -1376,8 +1376,6 @@ garbage_collect(void)
|
|||
|
||||
init_mark_stack();
|
||||
|
||||
gc_mark((VALUE)ruby_current_node, 0);
|
||||
|
||||
th->vm->self ? rb_gc_mark(th->vm->self) : rb_vm_mark(th->vm);
|
||||
|
||||
if (finalizer_table) {
|
||||
|
|
|
@ -173,6 +173,9 @@ NORETURN(void rb_load_fail(const char*));
|
|||
NORETURN(void rb_error_frozen(const char*));
|
||||
void rb_check_frozen(VALUE);
|
||||
/* eval.c */
|
||||
int rb_sourceline(void);
|
||||
const char *rb_sourcefile(void);
|
||||
|
||||
#if defined(NFDBITS) && defined(HAVE_RB_FD_INIT)
|
||||
typedef struct {
|
||||
int maxfd;
|
||||
|
|
1
parse.y
1
parse.y
|
@ -4622,7 +4622,6 @@ yycompile(struct parser_params *parser, const char *f, int line)
|
|||
}
|
||||
|
||||
kcode_save = rb_get_kcode();
|
||||
ruby_current_node = 0;
|
||||
ruby_sourcefile = rb_source_filename(f);
|
||||
ruby_sourceline = line - 1;
|
||||
parser_prepare(parser);
|
||||
|
|
|
@ -1295,7 +1295,7 @@ rb_exec(const struct rb_exec_arg *e)
|
|||
#ifndef FD_CLOEXEC
|
||||
preserving_errno({
|
||||
fprintf(stderr, "%s:%d: command not found: %s\n",
|
||||
ruby_sourcefile, ruby_sourceline, prog);
|
||||
rb_sourcefile(), rb_sourceline(), prog);
|
||||
});
|
||||
#endif
|
||||
return -1;
|
||||
|
|
5
ruby.c
5
ruby.c
|
@ -373,14 +373,11 @@ require_libraries(void)
|
|||
save[0] = ruby_eval_tree;
|
||||
save[1] = NEW_BEGIN(0);
|
||||
ruby_eval_tree = 0;
|
||||
ruby_current_node = 0;
|
||||
Init_ext(); /* should be called here for some reason :-( */
|
||||
ruby_current_node = save[1];
|
||||
req_list_last = 0;
|
||||
while (list) {
|
||||
int state;
|
||||
|
||||
ruby_current_node = 0;
|
||||
rb_protect((VALUE (*)(VALUE))rb_require, (VALUE)list->name, &state);
|
||||
if (state)
|
||||
rb_jump_tag(state);
|
||||
|
@ -388,12 +385,10 @@ require_libraries(void)
|
|||
free(list->name);
|
||||
free(list);
|
||||
list = tmp;
|
||||
ruby_current_node = save[1];
|
||||
}
|
||||
req_list_head.next = 0;
|
||||
ruby_eval_tree = save[0];
|
||||
rb_gc_force_recycle((VALUE)save[1]);
|
||||
ruby_current_node = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
1
vm.c
1
vm.c
|
@ -1501,6 +1501,7 @@ rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, rb_block_t *blockp
|
|||
vm_push_frame(th, DATA_PTR(iseq), FRAME_MAGIC_TOP,
|
||||
recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 1);
|
||||
val = (*func)(arg);
|
||||
|
||||
vm_pop_frame(th);
|
||||
return val;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче