63 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 181f980b6c Need to clear stack region for local variables in eval; fix #3844 2017-11-10 21:53:12 +09:00
Yukihiro "Matz" Matsumoto c7c9543bed Fixed UPVAR gotchas; fix #3835
Both `uvenv` function and `env` generation in `create_proc_from_string`
function have bugs to handling enclosed environment objects.
2017-10-28 23:08:31 +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
Tomasz Dąbrowski f632baddb1 fix: mrbgems\mruby-eval\src\eval.c(301): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 14:42:27 +02:00
Tomasz Dąbrowski 49db1db81f fix: mrbgems\mruby-eval\src\eval.c(214): warning C4244: '=': conversion from 'mrb_int' to 'short', possible loss of data 2017-09-27 14:42:27 +02:00
Yukihiro "Matz" Matsumoto 8bf492f127 Reduce integer type mismatch warnings in VC. 2017-08-12 09:35:35 +09:00
Yukihiro "Matz" Matsumoto 25a0a6b038 Need to patch OP_GETUPVAR and OP_SETUPVAR; fix #3732 2017-07-20 22:47:20 +09:00
Yukihiro "Matz" Matsumoto a18904a4c2 Use "$!" specifier of mrb_get_args. 2017-07-12 14:49:55 +09:00
Yukihiro "Matz" Matsumoto 0de7eec628 Fixed disclosure of local variables by eval; ref #3710
This patch fixes the latter part of #3710. We need to change
`struct REnv` to fix the former part of the issue.
2017-06-19 22:00:16 +09:00
Yukihiro "Matz" Matsumoto d7e09ffa5f Print the file name along with line number on syntax errors; fix #3698 2017-06-15 15:46:03 +09:00
Yukihiro "Matz" Matsumoto 88cd807379 Avoid use of snprintf() when DISABLE_STDIO is set; fix #3632
ref #3492 #3515 #3517
2017-04-25 10:41:50 +09:00
Yukihiro "Matz" Matsumoto 5513fcee22 Keep reference to mrb_context from env; fix #3619 2017-04-22 14:35:36 +09:00
Yukihiro "Matz" Matsumoto fca17b41c7 Avoid trampoline when #eval is called from mrb_funcall(); fix #3522 2017-03-17 15:55:18 +09:00
Yukihiro "Matz" Matsumoto f8b31a0db6 instance_eval method does not introduce C function boundary; fix #3508 2017-03-15 09:00:03 +09:00
Yukihiro "Matz" Matsumoto 73e5a19c39 Configure callinfo target_class as CRuby; ref #3429 2017-02-16 23:43:02 +09:00
Yukihiro "Matz" Matsumoto 097da2399a Avoid executing OP_STOP in eval(); fix #3429 2017-02-16 22:40:31 +09:00
Yukihiro "Matz" Matsumoto 5e3c329c98 Adjust callinfo env and target_class; ref #3429 2017-02-16 22:38:47 +09:00
Yukihiro "Matz" Matsumoto 48e0bbbfee Make eval to use trampoline technique; fix #3415
Now `eval()` can call Fiber.yield etc.
2017-02-04 16:19:31 +09:00
ksss e66b35c6ee Fix SEGV when unshared env 2016-09-06 17:11:18 +09:00
ksss ada264a513 instance_eval env should remake Fix #3191 2016-08-08 12:41:19 +09:00
Yukihiro "Matz" Matsumoto 8c67e915b4 mruby-eval: instance_eval should keep target_class; close #3141 2016-04-11 14:28:44 +09:00
Kouhei Sutou e5cce388ff Suppress a warning
mrbgems/mruby-eval/src/eval.c: In function ‘create_proc_from_string’:
    mrbgems/mruby-eval/src/eval.c:152:10: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
         file = "(eval)";
              ^
2016-03-06 10:05:14 +09:00
Yusuke Endoh 668cc1b435 Fix segfault when eval("__FILE__") is executed 2016-02-15 23:57:18 +09:00
Yukihiro "Matz" Matsumoto fb2e0b721f fixed a problem with upvar access from instance_eval; ref #3072 2016-01-08 09:07:58 +09:00
Yukihiro "Matz" Matsumoto 258cb2093c mruby-eval: fixed receiver value in eval context; close #3072 2016-01-07 22:37:58 +09:00
Yukihiro "Matz" Matsumoto 7c82bfa7fe mruby-sprintf to use mrb_int formatting macros; ref #3076 2016-01-07 12:23:17 +09:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
INOUE Yasuyuki 49bfaca6c7 Add regression test for #2933 2015-10-04 18:22:34 +09:00
Yukihiro "Matz" Matsumoto e8f88daa9c instance_eval should set target_class; close #2936
target_class should be singleton class of the receiver
2015-09-14 15:56:54 +09:00
take_cheeze 6460ef77bc Compile mruby compiler as mrbgem.
Compiler codes is moved to "mruby-compiler".
Executable `mrbc` is moved to "mruby-bin-mrbc".
2015-06-01 21:53:55 +09:00
sdottaka 79f703ecba mruby-eval: fix typo 2014-12-23 22:17:07 +09:00
Yukihiro "Matz" Matsumoto 10e9a1a167 now retrieves number of arguments of blocks from OP_ENTER op code; close #2671 2014-12-19 19:45:20 +09:00
Yukihiro "Matz" Matsumoto 5b203ead1e mruby-eval: proc from env may be NULL; close #2676 2014-12-17 12:35:19 +09:00
Yukihiro "Matz" Matsumoto ed56d56dab avoid out-of-bounds access of irep->lv; ref #2671, fix #2675
allocation size of irep->iv is irep->nlocals-1.
2014-12-17 11:14:14 +09:00
Yukihiro "Matz" Matsumoto ab72410456 eval() should preserve stack in env properly; fix #2671 2014-12-17 01:10:19 +09:00
Yukihiro "Matz" Matsumoto 3f06307317 need addtional type check to avoid SEGV; ref #2609 2014-10-18 11:26:30 +09:00
Yukihiro "Matz" Matsumoto 3ff5081650 context proc may be cfunc; fix #2609 2014-10-17 15:48:58 +09:00
Yukihiro "Matz" Matsumoto 3e3048ddd1 Merge pull request #2599 from SatoshiOdawara/fix_target_class_in_instance_eval
target_class should not be TT_ICLASS in instance_eval(string); ref #1152
2014-09-30 10:14:25 +09:00
Satoshi Odawara a10d36e0a2 target_class should not be TT_ICLASS in instance_eval(string); ref #1152 2014-09-29 17:53:08 +09:00
Satoshi Odawara 2551d14ff1 fixed. closures scope in eval(string) 2014-09-29 16:41:51 +09:00
Tatsuhiko Kubo 2b283393c6 Remove empty lines. 2014-08-20 12:07:36 +09:00
Tatsuhiko Kubo e035508efd Fix error handling for mrb_generate_code().
The return value of mrb_generate_code()
must be null-checked before referencing.
2014-08-19 17:50:07 +09:00
Satoshi Odawara 432e8e9ea9 fixed evaluation context of eval(string) and instance_eval(string) 2014-08-08 16:59:40 +09:00
Yukihiro "Matz" Matsumoto 4b69121284 restore mrb_get_args() in f_instance_eval to check arguments type 2014-07-22 08:38:38 +09:00
Yukihiro "Matz" Matsumoto 7457da6aa1 exception in instance_eval should not exit mrb_run; fix #2483 2014-07-22 07:29:26 +09:00
Yukihiro "Matz" Matsumoto abf52c7773 remove unused local variables; ref #2473 2014-07-16 05:21:55 +09:00
take_cheeze dd34decdfc Implement string compiling instance_eval method. 2014-07-15 22:33:14 +09:00
take_cheeze c6ce43303d Add SyntaxError test and don't print compilation error to stderr in eval. 2014-07-12 20:36:44 +09:00
take_cheeze d1eea450bf Use mrb_parse_nstring instead in eval. 2014-07-12 20:36:44 +09:00
take_cheeze 8106760077 Use MRB_ARGS_ARG(n, o) instead of MRB_ARGS_REQ(n) | MRB_ARGS_OPT(o). 2014-07-02 21:11:12 +09:00