mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
aspec bits should be packed in Ax; ref #1209
This commit is contained in:
+6
-6
@@ -170,20 +170,20 @@ struct RClass * mrb_define_class_under(mrb_state *mrb, struct RClass *outer, con
|
||||
struct RClass * mrb_define_module_under(mrb_state *mrb, struct RClass *outer, const char *name);
|
||||
|
||||
/* required arguments */
|
||||
#define MRB_ARGS_REQ(n) ((mrb_aspec)((n)&0x1f) << 19)
|
||||
#define MRB_ARGS_REQ(n) ((mrb_aspec)((n)&0x1f) << 18)
|
||||
/* optional arguments */
|
||||
#define MRB_ARGS_OPT(n) ((mrb_aspec)((n)&0x1f) << 14)
|
||||
#define MRB_ARGS_OPT(n) ((mrb_aspec)((n)&0x1f) << 13)
|
||||
/* mandatory and optinal arguments */
|
||||
#define MRB_ARGS_ARG(n1,n2) (MRB_ARGS_REQ(n1)|MRB_ARGS_OPT(n2))
|
||||
|
||||
/* rest argument */
|
||||
#define MRB_ARGS_REST() ((mrb_aspec)(1 << 13))
|
||||
#define MRB_ARGS_REST() ((mrb_aspec)(1 << 12))
|
||||
/* required arguments after rest */
|
||||
#define MRB_ARGS_POST(n) ((mrb_aspec)((n)&0x1f) << 8)
|
||||
#define MRB_ARGS_POST(n) ((mrb_aspec)((n)&0x1f) << 7)
|
||||
/* keyword arguments (n of keys, kdict) */
|
||||
#define MRB_ARGS_KEY(n1,n2) ((mrb_aspec)((((n1)&0x1f) << 3) | ((n2)?(1<<2):0)))
|
||||
#define MRB_ARGS_KEY(n1,n2) ((mrb_aspec)((((n1)&0x1f) << 2) | ((n2)?(1<<1):0)))
|
||||
/* block argument */
|
||||
#define MRB_ARGS_BLOCK() ((mrb_aspec)(1 << 1))
|
||||
#define MRB_ARGS_BLOCK() ((mrb_aspec)1)
|
||||
|
||||
/* accept any number of arguments */
|
||||
#define MRB_ARGS_ANY() ARGS_REST()
|
||||
|
||||
@@ -31,13 +31,13 @@ struct RProc {
|
||||
};
|
||||
|
||||
/* aspec access */
|
||||
#define MRB_ASPEC_REQ(a) (((a) >> 19) & 0x1f)
|
||||
#define MRB_ASPEC_OPT(a) (((a) >> 14) & 0x1f)
|
||||
#define MRB_ASPEC_REST(a) ((a) & (1<<13))
|
||||
#define MRB_ASPEC_POST(a) (((a) >> 8) & 0x1f)
|
||||
#define MRB_ASPEC_KEY(a) (((a) >> 3) & 0x1f)
|
||||
#define MRB_ASPEC_KDICT(a) ((a) & (1<<2))
|
||||
#define MRB_ASPEC_BLOCK(a) ((a) & (1<<1))
|
||||
#define MRB_ASPEC_REQ(a) (((a) >> 18) & 0x1f)
|
||||
#define MRB_ASPEC_OPT(a) (((a) >> 13) & 0x1f)
|
||||
#define MRB_ASPEC_REST(a) ((a) & (1<<12))
|
||||
#define MRB_ASPEC_POST(a) (((a) >> 7) & 0x1f)
|
||||
#define MRB_ASPEC_KEY(a) (((a) >> 2) & 0x1f)
|
||||
#define MRB_ASPEC_KDICT(a) ((a) & (1<<1))
|
||||
#define MRB_ASPEC_BLOCK(a) ((a) & 1)
|
||||
|
||||
#define MRB_PROC_CFUNC 128
|
||||
#define MRB_PROC_CFUNC_P(p) ((p)->flags & MRB_PROC_CFUNC)
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ mrb_proc_arity(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
struct RProc *p = mrb_proc_ptr(self);
|
||||
mrb_code *iseq = mrb_proc_iseq(mrb, p);
|
||||
mrb_aspec aspec = *iseq >> 6;
|
||||
mrb_aspec aspec = GETARG_Ax(*iseq);
|
||||
int ma, ra, pa, arity;
|
||||
|
||||
ma = MRB_ASPEC_REQ(aspec);
|
||||
|
||||
Reference in New Issue
Block a user