Commit Graph

168 Commits

Author SHA1 Message Date
Ukrainskiy Sergey ddd32d74e1 Changed the assignment of a variable in variable.c 2017-11-17 19:43:57 +09:00
Ukrainskiy Sergey 74714c8fee Changed numbers to TRUE and FALSE for mrb_bool in variable.c 2017-11-17 19:16:29 +09:00
Yukihiro "Matz" Matsumoto ddfb24908c Fixed constant (and class variable) reference bug; fix #3839
Unlike method definition, constant reference should start from
`MRB_PROC_TARGET_CLASS(ci->proc)`, not `ci->target_class`.
In addition, `MRB_PROC_TARGET_CLASS(ci->proc)` is always set.
2017-10-31 09:10:08 +09:00
Yukihiro "Matz" Matsumoto 93f5f22577 Heavily refactored how lexical scope links are implemented; fix #3821
Instead of `irep` links, we added a `upper` link to `struct RProc`.
To make a space for the `upper` link, we moved `target_class` reference.
If a `Proc` does not have `env`, `target_class` is saved in an `union`
shared with `env` (if a `Proc` has env, you can tell it by `MRB_PROC_ENV_P()).
Otherwise `target_class` is referenced from `env->c`. We removed links
in `env` as well.

This change removes 2 members from `mrb_irep` struct, thus saving 2
words per method/proc/block. This also fixes potential memory leaks
due to the circular references caused by a link from `mrb_irep`.
2017-10-28 00:29:30 +09:00
Yukihiro "Matz" Matsumoto c96def7c96 Remove top-level constant lookup; CRuby2.5 2017-10-17 08:45:06 +09:00
Yukihiro "Matz" Matsumoto 3acaa44a70 Restructure irep->outer chain; fix #3804
Instead of `irep -> proc` chain, we use `irep -> irep` chain to
avoid GC bugs like #3804. We added `target_class` reference to
`mrb_irep` struct. That means one more word consumption per `irep`.
2017-09-04 06:51:31 +09:00
Yukihiro "Matz" Matsumoto 43ec918be1 Remove unused mrb_obj_iv_ifnone() from API. 2017-08-26 02:01:50 +09:00
Yukihiro "Matz" Matsumoto 0e10a23d7a Add checks if iv_tbl is NULL. 2017-08-26 02:01:50 +09:00
Yukihiro "Matz" Matsumoto 04dbbff3c1 Use khash for instance variables tables instead of segment list.
For performance reason. Segmented list consumes slightly less memory
but takes a lot of time especially when there are many slots in the
segment lists (e.g. class constants).
2017-08-26 02:01:50 +09:00
Yukihiro "Matz" Matsumoto db098d3e0e Type check before traversing irep->outer; fix #3782 2017-08-19 11:39:42 +09:00
Yukihiro "Matz" Matsumoto 29ad0a7964 capacify' for mrb_str_new_capa should not be 0`. 2017-08-18 23:42:34 +09:00
Yukihiro "Matz" Matsumoto f1767fd079 Separate mrb_str_buf_new and mrb_str_new_capa.
`mrb_str_buf_new` is an old function that ensures capacity size of
`MRB_STR_BUF_MIN_SIZE` minimum. Usually one need to use
`mrb_str_new_capa` instead.
2017-08-18 22:17:48 +09:00
Yukihiro "Matz" Matsumoto da24af34b9 Better class name management.
The change removes several internal instance variables used by
class name management. The variables `__classid__` and `__classpath__`
are no longer available. `__outer__` is used only for unnamed outer
classes/modules (and will be removed after they are named).

[Important note]
Along with this change we removed several public functions.

 - mrb_class_outer_module()
 - mrb_class_sym()

We believe no one have used those functions, but if you do, please
ask us for the workaround.
2017-08-01 22:25:49 +09:00
Yukihiro "Matz" Matsumoto 648e9ea51b Move naming unnamed classes/modules
From `mrb_mod_const_set` to `mrb_const_set`.
2017-08-01 16:25:09 +09:00
Yukihiro "Matz" Matsumoto 3f6a098626 Reimplement constant look-up rule to follow lexical scoping.
This update fix CRuby scoping incompatibility; close #600; close #3200
2017-08-01 15:57:32 +09:00
Yukihiro "Matz" Matsumoto 4696093673 Rename MRB_SEGMENT_SIZE to MRB_IV_SEGMENT_SIZE. 2017-07-27 16:14:03 +09:00
Yukihiro "Matz" Matsumoto 1e41026b28 Always use MRB_USE_IV_SEGLIST. 2017-07-27 16:14:03 +09:00
Kouichi Nakanishi d4205c9b20 Use while statement instead of for statement 2017-04-12 23:27:09 +09:00
Kouichi Nakanishi 4fca570a74 Find Class/Module in nested singleton class; fix #3598 2017-04-12 22:41:36 +09:00
Yukihiro "Matz" Matsumoto 9094415acf An object attached to a singleton class may not be a class; fix #3587
The fix for #3539 was incomplete.
2017-04-10 22:02:51 +09:00
Kouichi Nakanishi 507e00e86f Modify to get constant of parent module in singleton class; fix #3568 2017-03-31 13:43:20 +09:00
Yukihiro "Matz" Matsumoto 952207d243 small cosmetic change; ref #3570 2017-03-30 17:10:44 +09:00
Kouichi Nakanishi 5efe77fede Modify class variable definition in singleton class; fix #3539 2017-03-30 16:29:47 +09:00
Yukihiro "Matz" Matsumoto 38a3b89d39 Small cosmetic change ("* " -> "*"). 2017-03-18 17:38:07 +09:00
Yukihiro "Matz" Matsumoto 761562b65f freeze instance variables; ref #3340 2016-12-12 01:00:24 +09:00
Yukihiro "Matz" Matsumoto f5a86ca530 Add pointer casting from mrb_malloc(); ref #3267 2016-11-24 09:28:00 +09:00
Yukihiro "Matz" Matsumoto 872517dff3 class variables in higher order have a priority; fix #3235 2016-11-08 23:51:15 +09:00
Kouhei Sutou ad492eb9f3 Fix class variable reference in module
Fix #3079
2016-01-11 00:34:15 +09:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
Yukihiro "Matz" Matsumoto d3b323cf2f PR #2521 did not work for singleton classes for non-class objects; fix #3003 2015-11-07 15:51:00 +09:00
cremno 938ed044f4 use mrb_str_cat_str() instead of mrb_str_append()
If the argument is always a string, then mrb_str_cat_str() can be
directly called instead of indirectly by mrb_str_append().

mrb_any_to_s(), mrb_obj_as_string(), mrb_inspect() always return a
string.
2015-07-16 03:56:31 +02:00
Franck Verrot 2588507285 Remove unnecessary backticks.
Dr Markus Kuhn published in 1999 an article [1] explaining in details
why we shouldn't use the ASCII grave accent (0x60) as a left quotation.

Backticks have been used most notably to produce nice-looking LaTeX
documents but it doesn't seem to be an issue on modern platforms and
for the oldest ones, there are workarounds as mentioned by Dr Kuhn.

[1]: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
2015-06-24 13:07:07 +02:00
cremno 2ee84eb3df remove unnecessary including of <ctype.h>
Not needed anymore since 85075bef75
2015-05-28 10:44:20 +02:00
Yukihiro "Matz" Matsumoto 95c7f570e1 change class argument of mrb_const_defined_at from struct RClass* to mrb_value to make it consistent with mrb_const_defined; ref #2593 2014-09-19 02:51:52 +09:00
Yukihiro "Matz" Matsumoto 6b34166ba5 const_defined? to check superclasses; ref #2593 2014-09-19 02:41:20 +09:00
Yukihiro "Matz" Matsumoto 6b302d80a3 instance variable name validation based on <ctype.h>; fix #2584 2014-09-04 18:36:28 +09:00
Yukihiro "Matz" Matsumoto 6c7b0d88e8 refactor valid instance variable name check 2014-09-02 16:37:40 +09:00
Tatsuhiko Kubo 5fa30aeaea Fix mismatches for MRB_API declarations. 2014-08-29 01:06:22 +09:00
Yukihiro "Matz" Matsumoto 2b9e5e751b add write barrier when iv is copied 2014-08-13 22:55:32 +09:00
Yukihiro "Matz" Matsumoto 206f89e209 add MRB_API modifiers to mruby API functions 2014-08-04 00:47:08 +09:00
Jun Hiroe 41fddeded0 Use Boolean macro in variable.c 2014-08-02 13:56:22 +09:00
take_cheeze 3c96602574 Use MRB_TT_EXCEPTION in exception object. 2014-07-21 23:09:13 +09:00
take_cheeze dbece716ea Use mrb_bool as return type of mrb_const_defined_at. 2014-07-14 21:04:22 +09:00
katmutua 17e3203cfc [minor-fix]Minor cleanups on variable.c comments 2014-06-16 14:13:24 -03:00
yui-knk 45305686fe Add a space aftre bracket. 2014-05-18 19:40:17 +09:00
yui-knk 73c370ae52 Fix typo. 2014-05-04 16:43:13 +09:00
Yukihiro "Matz" Matsumoto a5161e76ed Class.constants to take optional argument; close #2133 2014-04-26 23:47:55 +09:00
cremno 649081661a reduce RSTRING_PTR usage 2014-04-14 00:58:34 +02:00
Yukihiro "Matz" Matsumoto 93491caec9 revert b45e99 since a bug in khash.h was fixed 2014-04-10 00:57:21 +09:00
mattn 948ddace20 Fix invalid hash type 2014-04-09 21:48:13 +09:00