diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-11 03:25:16 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-11 03:25:16 +0000 |
commit | 64ef091a64d61dc0cef4508b70e64f91e4db865d (patch) | |
tree | 61c91ecf6b79271ce664a0bd02d43125cebbc680 /eval.c | |
parent | 7bca2f031ae387f979397f73640f0c5b07dc313d (diff) | |
download | ruby-64ef091a64d61dc0cef4508b70e64f91e4db865d.tar.gz |
Reverts a half of r36079. As we discussed on ruby-dev@ and IRC,
we do not need to disclose intermediate representation of program.
The program embedding CRuby should use rb_eval_string family.
* include/ruby/ruby.h (ruby_opaque_t): removed.
(ruby_compile_main_from_file, ruby_compile_main_from_string,
ruby_eval_main): removed.
* eval.c (ruby_eval_main_internal): became ruby_exec_internal() again.
(ruby_eval_main): removed.
* ruby.c (PREPARE_PARSE_MAIN) reverted.
(parse_and_compile_main, ruby_compile_main_from_file,
ruby_compile_main_from_string): removed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 71 |
1 files changed, 25 insertions, 46 deletions
@@ -84,7 +84,7 @@ ruby_init(void) * @return an opaque pointer to the compiled source or an internal special value. * @sa ruby_executable_node(). */ -ruby_opaque_t +void * ruby_options(int argc, char **argv) { int state; @@ -230,6 +230,26 @@ ruby_cleanup(volatile int ex) return ex; } +static int +ruby_exec_internal(void *n) +{ + volatile int state; + VALUE iseq = (VALUE)n; + rb_thread_t *th = GET_THREAD(); + + if (!n) return 0; + + PUSH_TAG(); + if ((state = EXEC_TAG()) == 0) { + SAVE_ROOT_JMPBUF(th, { + th->base_block = 0; + rb_iseq_eval_main(iseq); + }); + } + POP_TAG(); + return state; +} + /*! Calls ruby_cleanup() and exits the process */ void ruby_stop(int ex) @@ -250,7 +270,7 @@ ruby_stop(int ex) * @retval 0 if the given value is such a special value. */ int -ruby_executable_node(ruby_opaque_t n, int *status) +ruby_executable_node(void *n, int *status) { VALUE v = (VALUE)n; int s; @@ -266,36 +286,12 @@ ruby_executable_node(ruby_opaque_t n, int *status) return FALSE; } -static int -ruby_eval_main_internal(VALUE iseqval, VALUE* result) -{ - volatile int state; - volatile VALUE retval; - rb_thread_t *th = GET_THREAD(); - - if (!iseqval) { - *result = Qnil; - return 0; - } - - PUSH_TAG(); - if ((state = EXEC_TAG()) == 0) { - SAVE_ROOT_JMPBUF(th, { - th->base_block = 0; - retval = rb_iseq_eval_main(iseqval); - }); - } - POP_TAG(); - *result = state ? th->errinfo : retval; - return state; -} - /*! Runs the given compiled source and exits this process. * @retval 0 if successfully run thhe source * @retval non-zero if an error occurred. */ int -ruby_run_node(ruby_opaque_t n) +ruby_run_node(void *n) { int status; if (!ruby_executable_node(n, &status)) { @@ -307,27 +303,10 @@ ruby_run_node(ruby_opaque_t n) /*! Runs the given compiled source */ int -ruby_exec_node(ruby_opaque_t n) +ruby_exec_node(void *n) { - VALUE dummy; ruby_init_stack((void *)&n); - return ruby_eval_main_internal((VALUE)n, &dummy); -} - - -/*! - * Evaluates the given iseq in the main (toplevel) context. - * - * @param iseqval a VALUE that wraps an iseq. - * @param result Stores the evaluated value if succeeded, - * or an exception if failed. - * @retval 0 if succeeded - * @retval non-zero if failed. - */ -int -ruby_eval_main(ruby_opaque_t n, VALUE *result) -{ - return !!ruby_eval_main_internal((VALUE)n, result); + return ruby_exec_internal(n); } /* |