Unverified Commit ab4baba2 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #5620 from dearblue/adjust-stacks

Adjusting the stack for after it enters the virtual machine
parents 28ccc664 d3b7601a
...@@ -929,6 +929,13 @@ mrb_block_given_p(mrb_state *mrb) ...@@ -929,6 +929,13 @@ mrb_block_given_p(mrb_state *mrb)
MRB_API mrb_int MRB_API mrb_int
mrb_get_args(mrb_state *mrb, const char *format, ...) mrb_get_args(mrb_state *mrb, const char *format, ...)
{ {
#define ADJUST_STACK() do { \
if (argv_on_stack) { \
ci = mrb->c->ci; \
argv = mrb->c->ci->stack + 1; \
} \
} while (0)
const char *fmt = format; const char *fmt = format;
char c; char c;
int i = 0; int i = 0;
...@@ -1191,6 +1198,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) ...@@ -1191,6 +1198,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p = va_arg(ap, mrb_float*); p = va_arg(ap, mrb_float*);
if (pickarg) { if (pickarg) {
*p = mrb_as_float(mrb, *pickarg); *p = mrb_as_float(mrb, *pickarg);
ADJUST_STACK();
} }
} }
break; break;
...@@ -1202,6 +1210,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) ...@@ -1202,6 +1210,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p = va_arg(ap, mrb_int*); p = va_arg(ap, mrb_int*);
if (pickarg) { if (pickarg) {
*p = mrb_as_int(mrb, *pickarg); *p = mrb_as_int(mrb, *pickarg);
ADJUST_STACK();
} }
} }
break; break;
...@@ -1364,6 +1373,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) ...@@ -1364,6 +1373,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
finish: finish:
va_end(ap); va_end(ap);
return i; return i;
#undef ADJUST_STACK
} }
static struct RClass* static struct RClass*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment