Commit Graph

73 Commits

Author SHA1 Message Date
ksss a68b568911 Should call initialize method if defined 2016-12-22 10:40:13 +09:00
ksss 3cba13c249 Proc shouldn't have initialize method
Fix #3356
2016-12-21 15:17:05 +09:00
Clayton Smith 1ff4b3f800 Fix segfault in mrb_proc_copy. 2016-12-02 09:36:26 -05:00
Francois Chagnon 1ec5994377 Fix calling .arity on Proc with undefined initialize
Reported by @bouk
2016-11-24 10:23:31 -05:00
Kouhei Sutou 91bd3ebd32 Remove needless MRB_API
ref #3215

If a function (such as mrb_read_irep_file()) is declared without MRB_API
in header file (such as include/mruby/dump.h), implementation of the
function in source file (such as src/load.c) should also defined without
MRB_API.

If MRB_API is mismatch, Visual C++ reports link error with C2375 error
code: https://msdn.microsoft.com/en-us/library/5k6kw95a.aspx
2016-09-25 21:47:49 +09:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
Kouhei Sutou 52db92de53 Fix a crash bug when GC is ran while creating a proc with env
mrb_proc_new_cfunc_with_env() allocates RProc with RProc::env as NULL
then allocates REnv and sets it to RProc::env of the allocated RProc. If
incremental GC is ran before "allocates REnv and sets it to RProc::env
of the allocated RProc", the allocated RProc's GC status is
"marked" (Black) and the allocated REnv's GC status is
"unmarked" (White). The next incremental GC sweeps the allocated REnv
without re-marking the allocated RProc. Because the RProc is Black and
the REnv is White.

We need to implement write barrier for the case.

We can force to cause the above situation by the following patch:

    diff --git a/src/proc.c b/src/proc.c
    index f98998f..4f4e25c 100644
    --- a/src/proc.c
    +++ b/src/proc.c
    @@ -92,6 +92,7 @@ mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t func, mrb_int argc, const
       struct REnv *e;
       int i;

    +  mrb_incremental_gc(mrb);
       p->env = e = env_new(mrb, argc);
       MRB_ENV_UNSHARE_STACK(e);
       e->stack = (mrb_value*)mrb_malloc(mrb, sizeof(mrb_value) * argc);

With this patch, "rake test" causes segmentation fault.
2015-06-29 14:39:30 +09:00
Yukihiro "Matz" Matsumoto 937b5b5462 fix Proc#curry test failure; ref #2848 2015-06-23 14:42:58 +09:00
cremno f0eaf9eaf5 fix arity of lambdas with optional arguments
From the CRuby 2.2.2 Proc#arity documentation:

If the block has optional arguments, returns -n-1, where n is the number
of mandatory arguments, with the exception for blocks that are not
lambdas and have only a finite number of optional arguments; in this
latter case, returns n.
2015-06-22 13:34:24 +02:00
Carson McDonald a797d45e90 Verify that proc_lambda is passed a proc 2015-05-22 10:34:28 -04:00
Yukihiro "Matz" Matsumoto 83992ee163 cast MRB_ENV_STACK_LEN to (mrb_int); ref #2600 2014-10-02 17:59:01 +09:00
Hiroshi Mimaki ed15477c74 Pacify MSVC warnings for numeric.c, proc.c, and symbol.c 2014-10-02 13:37:49 +09:00
Yukihiro "Matz" Matsumoto 471c43ff96 move mrb_proc_new_cfunc_with_env() to the core 2014-09-02 13:03:32 +09:00
Tatsuhiko Kubo 5fa30aeaea Fix mismatches for MRB_API declarations. 2014-08-29 01:06:22 +09:00
Yukihiro "Matz" Matsumoto 7477d0c18c revert 6c1dfc9; ref #2525 #2565 2014-08-29 01:06:22 +09:00
Yukihiro "Matz" Matsumoto 6c1dfc9566 need to add space for receiver to proc env; fix #2525 2014-08-13 23:58:32 +09:00
Yukihiro "Matz" Matsumoto 206f89e209 add MRB_API modifiers to mruby API functions 2014-08-04 00:47:08 +09:00
Tatsuhiko Kubo 5b5313ec97 use C style comments instead of C++ style comments 2014-07-13 00:24:45 +09:00
ksss 19b82944f8 Proc#arity return 0 when opcode was not OP_ENTER 2014-06-25 08:48:08 +09:00
ksss 907a299790 arity for cfunc is not implemented yet 2014-06-15 22:38:22 +09:00
ksss 1cced27a79 Proc class define before a first method
mrb_define_method setting mrb->proc_class for method proc
2014-06-15 22:34:46 +09:00
Jun Hiroe 0388e373d0 Delete unnecessary semicolon 2014-05-17 00:52:00 +09:00
Yukihiro "Matz" Matsumoto 2be348a0f1 mv opcode.h -> include/mruby/opcode.h and remove duplication from mruby-eval gem 2014-05-14 23:14:08 +09:00
Nobuyoshi Nakada 345f172bba adjust indent 2014-04-30 09:50:02 +09:00
Yukihiro "Matz" Matsumoto 2ca5bed901 make cioff in struct REnv from int to ptrdiff_t; close #2149 2014-04-29 12:25:15 +09:00
Yukihiro "Matz" Matsumoto 5138f62d6b resolve conflict 2014-04-15 10:55:46 +09:00
take_cheeze 80534b6d14 Use MRB_ENV_STACK_LEN instead of accessing flags directly to get REnv's stack length. 2014-04-01 01:13:39 +09:00
Yukihiro "Matz" Matsumoto 306b1d3c51 Merge pull request #1948 from monaka/pr-remove-unused-null-check
Remove redundant NULL checks.
2014-03-26 13:32:18 +09:00
Masaki Muranaka dcff9012e3 Remove redundant NULL checks.
mrb_malloc causes an exception when memory was empty.
2014-03-26 11:21:20 +09:00
Yukihiro "Matz" Matsumoto b4dd3564ef REnv uses obj->c as env link; no super 2014-03-25 11:50:11 +09:00
Yukihiro "Matz" Matsumoto 07e8f80040 adjust proc->target_class according to surrounding proc->target_class; based on a patch from @Fleurer; close #1627 2014-01-06 14:04:50 +09:00
take_cheeze df780ae5e9 add mrb_intern_lit for creating symbol from string literal 2013-12-01 10:38:59 +09:00
Yukihiro "Matz" Matsumoto 9c6398a444 rename mrb_intern2() to mrb_intern(); huge API incompatibility; close #1513 2013-11-29 08:47:28 +09:00
Yukihiro "Matz" Matsumoto de790bdc27 allow irep to be GCed 2013-11-08 20:39:50 +09:00
Yukihiro "Matz" Matsumoto b6a73f99bf call_iseq will never be NULL 2013-11-07 08:53:14 +09:00
Yukihiro "Matz" Matsumoto e92d4e2680 modified to use irep->reps to reference child ireps. preparation for
removing irep array from mrb_state.  note that instructions OP_LAMBDA,
OP_EXEC and OP_EPUSH are incompatible, and dumped mrb format has changed.
2013-11-07 03:54:22 +09:00
Jun Hiroe 883c45b931 Replace mrb_intern() func with mrb_intern2() func or mrb_intern_cstr() func. 2013-07-12 01:00:50 +09:00
Daniel Bovensiepen 373122a299 Merge upstream 2013-06-15 03:53:50 +08:00
Daniel Bovensiepen 3c34eb61cb Add ISO Number to Proc 2013-06-17 04:50:31 +08:00
Yukihiro "Matz" Matsumoto 5c0b9b703c primary mruby fiber implementation 2013-05-20 17:54:07 +09:00
Yukihiro "Matz" Matsumoto 62ca4c1738 aspec bits should be packed in Ax; ref #1209 2013-04-25 12:04:29 +09:00
Yukihiro "Matz" Matsumoto 30d580ecbc rename every ARGS_XXX to MRB_ARGS_XXX; ref #1206 2013-04-25 09:47:36 +09:00
Yukihiro "Matz" Matsumoto 953eec60db rename MRB_ARGS_XXX to MRB_ASPEC_XXX; ref #1206 2013-04-25 08:00:48 +09:00
Yukihiro "Matz" Matsumoto 4faaef437d rename ARGS_GETXXX macros to avoid potential name conflict; close #1206 2013-04-25 07:50:01 +09:00
h2so5 b1ffb3b3b8 Add Proc#arity 2013-04-16 16:03:36 +09:00
Masaki Muranaka 2b5b161f8b Sort include files. Some redundant includes are removed. 2013-03-29 10:22:31 +09:00
Yukihiro Matz Matsumoto b6c9a25866 remove return at the bottom of void function 2012-12-10 23:28:04 +09:00
Yukihiro "Matz" Matsumoto 64d577b0a2 Merge pull request #611 from tricknotes/stop-warning-of-proc
Stop warning in compiling proc.c
2012-12-10 06:09:16 -08:00
Yukihiro Matz Matsumoto 83f41c9ee7 add inline declaration 2012-12-10 23:08:28 +09:00
Ryunosuke SATO 85dac05cf3 Stop warning in compiling proc.c
proc.c:46: warning: ‘return’ with a value, in function returning void

introduced in f312af11.
2012-12-10 17:59:41 +09:00