RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
each time.
`bind->env' may update after `eval()'.
[Bug #7536]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
for parser.
reported by whiteleaf at [ruby-list:49085] [ruby-dev:46738]
[Bug #7562]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c (proc_options, process_options, ruby_process_options): take
care of the case argc is 0, and check if argv has NULL.
[ruby-core:49889] [Bug #7423]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c (usage): wrap description lines if options are too long.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* load.c (rb_get_expanded_load_path): cache the expanded load
path. This saves 4KB of allocation and some stats for every
element of the load path (so nearly a MB in my Rails app)
on every require.
* load.c (rb_construct_expanded_load_path): ensure that $LOAD_PATH
entries are frozen strings. The user must mutate $LOAD_PATH
itself rather than its individual entries.
* vm_core.h (rb_vm_struct): add fields.
* vm.c (rb_vm_mark): mark new fields.
* ruby.c (process_options): modify $LOAD_PATH directly rather than
its elements.
Patch by Greg Price.
[ruby-core:47970] [Bug #7158]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c (usage, process_options): show more info in --help.
[EXPREIMENTAL] [ruby-core:48072] [Bug #7184]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.in (LIBDIR_BASENAME): use configured libdir value to fix
--enable-load-relative on systems where libdir is not default value,
overridden in config.site files. [ruby-core:47267] [Bug #6903]
* ruby.c (ruby_init_loadpath_safe): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_find_file_ext_safe, rb_find_file_safe): default to
US-ASCII for encdb and transdb.
* load.c (search_required): keep encoding of feature name. set
loading path to filesystem encoding. [Bug #6377][ruby-core:44750]
* ruby.c (add_modules, require_libraries): assume default external
encoding as well as ARGV.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c (proc_options): show version only once even if -v and
--verbose are given together.
http://twitter.com/d6rkaiz/status/233491797085671424
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
th->base_block is information for (a) parsing, (b) compiling
and (c) setting up the frame to execute the program passed by
`eval' method. For example, (1) parser need to know up-level
variables to detect it is variable or method without paren.
Befor (a), (b) and (c), VM set th->base_block by passed bindng
(or previous frame information). After execute (a), (b) and (c),
VM should clear th->base_block. However, if (a), (b) or (c)
raises an exception, then th->base_block is not cleared.
Problem is that the uncleared value th->balo_block is used for
irrelevant iseq compilation. It causes SEGV or critical error.
I tried to solve this problem: to clear them before exception,
but finally I found out that it is difficult to do it (Ruby
program can be run in many places).
Because of this background, I set th->base_block before
compiling iseq and restore it after compiling.
Basically, th->base_block is dirty hack (similar to global
variable) and this patch is also dirty.
* bootstraptest/test_eval.rb: add a test for above.
* internal.h: remove unused decl.
* iseq.c (rb_iseq_compile_with_option): add base_block parameter.
set th->base_block before compation and restore it after
compilation.
* ruby.c (require_libraries): pass 0 as base_block instead of
setting th->base_block
* tool/compile_prelude.rb (prelude_eval): apply above changes.
* vm.c, vm_eval.c: ditto.
* vm_core.h: add comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h: public symbols must have default visibility.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
for few years because:
* NODE is no longer accessible.
* rb_iseq_eval_main crashes without preparing with rb_thread_t.
* some existing APIs calls exit(3) without giving the opportunity to
finalize or handle errors to the client.
* No general-purpose function to compile a source to an iseq are
published in the public headers.
This commit solves the problems.
* include/ruby/ruby.h: Grouped APIs for embedding CRuby interpreter.
(ruby_setup, ruby_compile_main_from_file,
ruby_compile_main_from_string, ruby_eval_main,
ruby_set_script_name): new APIs to embed CRuby.
(ruby_opaque_t) Opaque pointer to an internal data, to NODE or iseq
in particular.
* eval.c (ruby_setup): Similar to ruby_init but returns an error code
instead of exit(3) on error.
(ruby_eval_main): Similar to ruby_exec_node but returns the
evaluation result.
(ruby_eval_main_internal): renamed from ruby_exec_internal.
* ruby.c (toplevel_context): new helper function.
(PREPARE_EVAL_MAIN): moved.
(process_options): refactored with new functions.
(parse_and_compile_main) new helper funciton.
(ruby_compile_main_from_file, ruby_compile_main_from_string) new API
(ruby_set_script_name): new API.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Fixes --with-static-linked-ext.
Patch by Google Inc. [ruby-core:45073].
* Makefile.in (ENCOBJS, EXTOBJS): New variables to specify static
linked libraries. Also reintroduces extinit.o, introduces encinit.o
introduces encinit.o
* common.mk: Builds static libraries rather than shared objects if
specified.
* configure.in (LD): new substitution.
Avoids PIE if s
* enc/depend: Supports static linked libraries
(libencs, libenc, libtrans): New target.
* enc/encinit.c.erb: new template to generate the initialization of
statically linked encodings.
* enc/make_encmake.rb (--module): new flag to specify whether static
or dynamic.
* transcode_data.h (TRANS_INIT): New macro to get rid of the name
collision of encoding initializers and transcoder initializers.
* ext/extmk.rb: Fixes the behavior on $extstatic is true.
* lib/mkmf.rb (clean-static): new target to clean up static linked
libraries.
* ruby.c (process_options): New initializes statically linked
encodings here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
not to use S_ISDIR(). [Feature #2408][ruby-core:26925]
* ruby.c (load_file_internal): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (rb_load_fail): use path as a string, not char*.
* internal.h: (rb_load_fail): moved from ruby/intern.h.
* ruby.c (load_file_internal): fname cannot be NULL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
instance variable to the LoadError exception.
* load.c: call rb_loaderror_with_path so that the missing path is
added to the exception.
* ruby.c: call rb_loaderror rather than raising our own LoadError
exception.
* include/ruby/intern.h: add declaration for rb_loaderror_with_path.
* test/ruby/test_require.rb: add supporting test for LoadError#path
method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
needed by platform. calling open() was replaced by rb_cloexec_open()
at r33549, but the function expected UTF-8 pathname on Windows.
(open() expected "locale" pathname.)
reported by taco via IRC.
* ruby.c (load_file): change the type of the 2nd parameter to pass its
encoding to load_file_internal().
* ruby.c (process_options, rb_load_file): follow above change.
NOTE: we should pass encoding information to rb_load_file().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
for MinGW. reported by Luis Lavena. [ruby-core:40526] [Bug #5516]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e