Created
January 2, 2010 19:04
-
-
Save carlosbrando/267618 to your computer and use it in GitHub Desktop.
Apenas o trecho que interessa do arquivo eval.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void | |
rb_load(fname, wrap) | |
VALUE fname; | |
int wrap; | |
{ | |
VALUE tmp; | |
int state; | |
volatile int prohibit_int = rb_prohibit_interrupt; | |
volatile ID last_func; | |
volatile VALUE wrapper = ruby_wrapper; | |
volatile VALUE self = ruby_top_self; | |
NODE *volatile last_node; | |
NODE *saved_cref = ruby_cref; | |
if (wrap && ruby_safe_level >= 4) { | |
StringValue(fname); | |
} | |
else { | |
SafeStringValue(fname); | |
} | |
fname = rb_str_new4(fname); | |
tmp = rb_find_file(fname); | |
if (!tmp) { | |
load_failed(fname); | |
} | |
fname = tmp; | |
ruby_errinfo = Qnil; /* ensure */ | |
PUSH_VARS(); | |
PUSH_CLASS(ruby_wrapper); | |
ruby_cref = ruby_top_cref; | |
if (!wrap) { | |
rb_secure(4); /* should alter global state */ | |
ruby_class = rb_cObject; | |
ruby_wrapper = 0; | |
} | |
else { | |
/* load in anonymous module as toplevel */ | |
ruby_class = ruby_wrapper = rb_module_new(); | |
self = rb_obj_clone(ruby_top_self); | |
rb_extend_object(self, ruby_wrapper); | |
PUSH_CREF(ruby_wrapper); | |
} | |
PUSH_ITER(ITER_NOT); | |
PUSH_FRAME(); | |
ruby_frame->last_func = 0; | |
ruby_frame->last_class = 0; | |
ruby_frame->self = self; | |
PUSH_SCOPE(); | |
/* default visibility is private at loading toplevel */ | |
SCOPE_SET(SCOPE_PRIVATE); | |
PUSH_TAG(PROT_NONE); | |
state = EXEC_TAG(); | |
last_func = ruby_frame->last_func; | |
last_node = ruby_current_node; | |
if (!ruby_current_node && ruby_sourcefile) { | |
last_node = NEW_NEWLINE(0); | |
} | |
ruby_current_node = 0; | |
if (state == 0) { | |
NODE *node; | |
volatile int critical; | |
DEFER_INTS; | |
ruby_in_eval++; | |
critical = rb_thread_critical; | |
rb_thread_critical = Qtrue; | |
rb_load_file(RSTRING(fname)->ptr); | |
ruby_in_eval--; | |
node = ruby_eval_tree; | |
rb_thread_critical = critical; | |
ALLOW_INTS; | |
if (ruby_nerrs == 0) { | |
eval_node(self, node); | |
} | |
} | |
ruby_frame->last_func = last_func; | |
ruby_current_node = last_node; | |
ruby_sourcefile = 0; | |
ruby_set_current_source(); | |
if (ruby_scope->flags == SCOPE_ALLOCA && ruby_class == rb_cObject) { | |
if (ruby_scope->local_tbl) /* toplevel was empty */ | |
free(ruby_scope->local_tbl); | |
} | |
POP_TAG(); | |
rb_prohibit_interrupt = prohibit_int; | |
ruby_cref = saved_cref; | |
POP_SCOPE(); | |
POP_FRAME(); | |
POP_ITER(); | |
POP_CLASS(); | |
POP_VARS(); | |
ruby_wrapper = wrapper; | |
if (ruby_nerrs > 0) { | |
ruby_nerrs = 0; | |
rb_exc_raise(ruby_errinfo); | |
} | |
if (state) jump_tag_but_local_jump(state, Qundef); | |
if (!NIL_P(ruby_errinfo)) /* exception during load */ | |
rb_exc_raise(ruby_errinfo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment