Commit Graph

3922 Commits

Author SHA1 Message Date
dearblue 1997fcf98f Add MRB_IMPROVE_META_PROGRAMMING configuration 2018-09-07 22:32:34 +09:00
dearblue 9b0ef58a48 A class/module name is now defined for meta programing 2018-09-07 22:32:34 +09:00
dearblue 2a24b40d30 Not set a class/module name into anonymous class/module 2018-09-07 22:32:34 +09:00
Yukihiro "Matz" Matsumoto 0b44e802a9 Need to check if merging hash is empty; fix #4107 2018-09-06 23:30:32 +09:00
Yukihiro "Matz" Matsumoto 2a9525caab Add argv and argc check in OP_ENTER; fix #4102
`argv` may be retrieved from an array whose `ptr` is `NULL` when it`s
empty.
2018-09-05 07:06:25 +09:00
Yukihiro "Matz" Matsumoto 9b5910bd0f Revert "Remove top-level constant lookup; CRuby2.5"; fix #4070
This reverts commit c96def7c96.
This change was from my misunderstanding.
2018-09-04 21:19:07 +09:00
Yukihiro "Matz" Matsumoto 7592dfcf7d Need more precise constant name check.
This change was inspired by [ruby-bugs#7573]
2018-09-04 20:50:54 +09:00
Yukihiro "Matz" Matsumoto c2634e18b6 Add type casts to silence MSVC warnings. 2018-09-04 16:22:50 +09:00
Yukihiro "Matz" Matsumoto a657117e4e Avoid warning in MSVC compilation. 2018-09-01 17:36:35 +09:00
Yukihiro "Matz" Matsumoto b80e0ef742 Move Kernel#send to mruby-metaprog gem.
But `BasicObject#__send__` is still available from the core.
2018-09-01 11:20:30 +09:00
Yukihiro "Matz" Matsumoto 593c12a5cd Avoid NoMethodError exception from mrb_func_basic_p. 2018-09-01 11:18:12 +09:00
Yukihiro "Matz" Matsumoto 2be42aef0f Fix ISO/JIS section numbers. 2018-09-01 09:35:46 +09:00
Yukihiro "Matz" Matsumoto 50b840c9de Use mrb_ensure_hash_type() to check if an operand is a Hash; fix #4097 2018-08-30 22:30:36 +09:00
Yukihiro "Matz" Matsumoto f6564dd83e Add new function mrb_ensure_hash_type(); ref #4097
Unlike `mrb_check_hash_type()` that returns `nil` if the argument is
not a `Hash`, `mrb_ensure_hash_type()` raises a `TypeError` exception.
2018-08-30 22:30:36 +09:00
Yukihiro "Matz" Matsumoto e471d37ca5 Separate meta-programming features to mruby-metaprog gem.
We assume meta-programming is less used in embedded environments.
We have moved following methods:

 * Kernel module
   global_variables, local_variables, singleton_class,
   instance_variables, instance_variables_defined?, instance_variable_get,
   instance_variable_set, methods, private_methods, public_methods,
   protected_methods, singleton_methods, define_singleton_methods

 * Module class
   class_variables, class_variables_defined?, class_variable_get,
   class_variable_set, remove_class_variable, included_modules,
   instance_methods, remove_method, method_removed, constants

 * Module class methods
   constants, nesting

Note:
Following meta-programming methods are kept in the core:

 * Module class
   alias_method, undef_method, ancestors, const_defined?, const_get,
   const_set, remove_const, method_defined?, define_method

 * Toplevel object
   define_method

`mruby-metaprog` gem is linked by default (specified in default.gembox).
When it is removed, it will save 40KB (stripped:8KB) on x86-64
environment last time I measured.
2018-08-30 22:30:36 +09:00
Yukihiro "Matz" Matsumoto 5addd5db4a Need to clear mrb->c->cibase->ridx (toplevel ridx) at L_STOP; fix #4092
This problem only appears when `mrb` executed multiple times (i.e. `mirb`)
2018-08-30 01:20:59 +09:00
Yukihiro "Matz" Matsumoto 2c93e4a0a8 The operand of OP_ARYDUP may not be an array; fix #4094
This commit also fix #4096.
2018-08-30 00:29:35 +09:00
Yukihiro "Matz" Matsumoto f76cc483d5 Fix off-by-one error in OP_EPUSH and OP_ONERR; fix #4095 2018-08-29 23:59:20 +09:00
Yukihiro "Matz" Matsumoto 98c759e86a Check the size of rescue&ensure stacks; ref #4088
Those small stack indexes can cause integer overflow.
2018-08-29 13:17:18 +09:00
Yukihiro "Matz" Matsumoto 6aa091e5aa Simplified #ifdef nesting in codedump.c; fix #4089
`printf()` and related functions should not be called when
`MRB_DISABLE_STDIO` is defined.
2018-08-29 12:37:07 +09:00
Yukihiro "Matz" Matsumoto 471288f37d Reduce integer casting warnings. 2018-08-25 16:58:01 +09:00
Yukihiro "Matz" Matsumoto d79dbd92f9 fixup! New bytecode implementation of mruby VM. 2018-08-25 09:49:20 +09:00
Yukihiro "Matz" Matsumoto 49d1b16822 Hash splat ** should not be ignored.
Implemented by adding `OP_HASHCAT` that merges hashes.
2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto 306732e02d Fixed a bug in OP_HASHADD. 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto 3554fc54de Add a new function mrb_hash_merge(). 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto b7e56e9d20 Add bytecode support for MRB_WORD_BOXING. 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto eeb6d5658d New bytecode implementation of mruby VM. 2018-08-25 09:41:21 +09:00
pyama86 821135e2df irep is released when Fiber is terminated 2018-08-25 09:17:46 +09:00
Yukihiro "Matz" Matsumoto 9409a2ff6d Rename ambiguous function names.
`mrb_iv_p` -> `mrb_iv_name_sym_p`
`mrb_iv_check` -> `mrb_iv_name_sym_check`
2018-08-25 09:17:46 +09:00
Yukihiro "Matz" Matsumoto 5e469d2b92 Remove utility functions: mrb_vm_iv_{get,set}. 2018-08-25 09:17:46 +09:00
Yukihiro "Matz" Matsumoto c88fd32713 Revert 04dbbff.
Use segment list for instance variable again to reduce memory.
2018-08-25 09:16:01 +09:00
Yukihiro "Matz" Matsumoto f3564a405e Small refactoring of flodivmod(). 2018-08-25 09:16:01 +09:00
Yukihiro "Matz" Matsumoto 6681e22c71 Simply use snprintf instead of custom fmt_fp,
Unless `MRB_DISABLE_STDIO` is set. `snprintf` is used anyway
if mruby is configured to use `stdio`. This change reduces 8KB
of program size on the Linux box.
2018-08-25 09:16:01 +09:00
Yukihiro "Matz" Matsumoto 91c08d7631 Remove nregs member from mrb_callinfo.
This means reducing one word per a call frame.
2018-08-25 09:16:01 +09:00
Yukihiro "Matz" Matsumoto fd086833ff Reorganize flags values for classes; fix #3975
Renamed flag macro names as well:
`MRB_FLAG_IS_FROZEN` -> `MRB_FL_OBJ_FROZEN`
`MRB_FLAG_IS_PREPENDED` -> `MRB_FL_CLASS_IS_PREPENDED`
`MRB_FLAG_IS_ORIGIN` -> `MRB_FL_CLASS_IS_ORIGIN`
`MRB_FLAG_IS_INHERITED` -> `MRB_FL_CLASS_IS_INHERITED`
2018-08-25 09:13:09 +09:00
Yukihiro "Matz" Matsumoto 43173e1299 Removed unused instruction: OP_KDICT. 2018-07-31 03:20:00 +09:00
Yukihiro "Matz" Matsumoto 53e2723fae Fixed a small bug in keyword argument parsing.
def m(a=1,**k) p [a,k] end
m(a: 1)
2018-07-31 03:14:42 +09:00
Yukihiro "Matz" Matsumoto 8c9e712784 Keyword argument implemented. 2018-07-30 22:58:01 +09:00
Yukihiro "Matz" Matsumoto 891839b976 New bytecode implementation of mruby VM. 2018-07-30 22:57:54 +09:00
Yukihiro "Matz" Matsumoto adb1eae912 Use mrb_raise() instead of mrb_raisef(); ref #4062 2018-06-28 22:40:24 +09:00
Yukihiro "Matz" Matsumoto 695f29cd60 Add negative check in mrb_str_resize; fix #4062 2018-06-27 16:32:24 +09:00
Yukihiro "Matz" Matsumoto 7e79840587 initialize a local variable to avoid warning 2018-06-22 12:03:52 +09:00
Yukihiro "Matz" Matsumoto 97933665b6 Restore GC arena after raised exceptions; ref #4042 2018-06-14 11:42:34 +09:00
Yukihiro "Matz" Matsumoto ba090a46af Need to add a write barrier for ranges; fix #4042
Ranges are almost immutable but `initialize` and `initialize_copy`
modify the receiver so that we need to add a write barrier.
2018-06-14 11:25:12 +09:00
Yukihiro "Matz" Matsumoto 23a4e7149d Revert "No longer need to insert write barriers for fibers."
This reverts commit c6736357a7.
The assumption was wrong and caused the issue; fix #4020
2018-06-11 14:50:42 +09:00
Yukihiro "Matz" Matsumoto a9b740b36b Retrieve b operand from the instruction (for debugging); ref #4020 2018-06-11 14:50:03 +09:00
Yukihiro "Matz" Matsumoto faa4eaf680 mrb_class_real() did not work for BasicObject; fix #4037 2018-06-08 14:13:06 +09:00
Yukihiro "Matz" Matsumoto 55edae0226 Allow Object#clone to copy frozen status only; fix #4036
Copying all flags from the original object may overwrite the clone's
flags e.g. the embedded flag.
2018-06-07 16:17:00 +09:00
Yukihiro "Matz" Matsumoto 55dcdd26cc Merge pull request #4039 from i110/i110/fix-broken-lexical-variables
fix broken lexical variables
2018-06-07 16:02:30 +09:00
Yukihiro "Matz" Matsumoto ff0a4f7867 Export stack_extend function (renamed mrb_stack_extend); fix #3219
This change is required to support #4038.
2018-06-07 15:55:20 +09:00