mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge branch 'master' of github.com:mruby/mruby
This commit is contained in:
@@ -158,8 +158,8 @@ mrb_float_value(mrb_float f)
|
||||
|
||||
#define MRB_OBJECT_HEADER \
|
||||
enum mrb_vtype tt:8;\
|
||||
unsigned int color:3;\
|
||||
unsigned int flags:21;\
|
||||
uint32_t color:3;\
|
||||
uint32_t flags:21;\
|
||||
struct RClass *c;\
|
||||
struct RBasic *gcnext
|
||||
|
||||
|
||||
+1
-1
@@ -2050,7 +2050,7 @@ mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck)
|
||||
char *end;
|
||||
char sign = 1;
|
||||
int c;
|
||||
unsigned int n;
|
||||
unsigned long n;
|
||||
mrb_int val;
|
||||
|
||||
#undef ISDIGIT
|
||||
|
||||
@@ -44,7 +44,6 @@ mrb_intern2(mrb_state *mrb, const char *name, size_t len)
|
||||
mrb_sym sym;
|
||||
char *p;
|
||||
|
||||
if (len < 0) len = 0;
|
||||
sname.len = len;
|
||||
sname.name = name;
|
||||
k = kh_get(n2s, h, sname);
|
||||
|
||||
@@ -54,6 +54,27 @@ The value below allows about 60000 recursive calls in the simplest case. */
|
||||
# define DEBUG(x)
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
value_move(mrb_value *s1, const mrb_value *s2, size_t n)
|
||||
{
|
||||
if (s1 > s2 && s1 < s2 + n)
|
||||
{
|
||||
s1 += n;
|
||||
s2 += n;
|
||||
while (n-- > 0) {
|
||||
*--s1 = *--s2;
|
||||
}
|
||||
}
|
||||
else if (s1 != s2) {
|
||||
while (n-- > 0) {
|
||||
*s1++ = *s2++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* nothing to do. */
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
stack_clear(mrb_value *from, size_t count)
|
||||
{
|
||||
@@ -855,7 +876,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
|
||||
mrb_ary_unshift(mrb, regs[a+1], sym);
|
||||
}
|
||||
else {
|
||||
memmove(regs+a+2, regs+a+1, sizeof(mrb_value)*(n+1));
|
||||
value_move(regs+a+2, regs+a+1, n+1);
|
||||
regs[a+1] = sym;
|
||||
n++;
|
||||
}
|
||||
@@ -994,7 +1015,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
|
||||
mrb_ary_unshift(mrb, regs[a+1], mrb_symbol_value(ci->mid));
|
||||
}
|
||||
else {
|
||||
memmove(regs+a+2, regs+a+1, sizeof(mrb_value)*(n+1));
|
||||
value_move(regs+a+2, regs+a+1, n+1);
|
||||
SET_SYM_VALUE(regs[a+1], ci->mid);
|
||||
n++;
|
||||
}
|
||||
@@ -1138,10 +1159,10 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
|
||||
if (argc < len) {
|
||||
regs[len+1] = *blk; /* move block */
|
||||
if (argv0 != argv) {
|
||||
memmove(®s[1], argv, sizeof(mrb_value)*(argc-m2)); /* m1 + o */
|
||||
value_move(®s[1], argv, argc-m2); /* m1 + o */
|
||||
}
|
||||
if (m2) {
|
||||
memmove(®s[len-m2+1], &argv[argc-m2], sizeof(mrb_value)*m2); /* m2 */
|
||||
value_move(®s[len-m2+1], &argv[argc-m2], m2); /* m2 */
|
||||
}
|
||||
if (r) { /* r */
|
||||
regs[m1+o+1] = mrb_ary_new_capa(mrb, 0);
|
||||
@@ -1153,13 +1174,13 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
|
||||
else {
|
||||
if (argv0 != argv) {
|
||||
regs[len+1] = *blk; /* move block */
|
||||
memmove(®s[1], argv, sizeof(mrb_value)*(m1+o)); /* m1 + o */
|
||||
value_move(®s[1], argv, m1+o); /* m1 + o */
|
||||
}
|
||||
if (r) { /* r */
|
||||
regs[m1+o+1] = mrb_ary_new_from_values(mrb, argc-m1-o-m2, argv+m1+o);
|
||||
}
|
||||
if (m2) {
|
||||
memmove(®s[m1+o+r+1], &argv[argc-m2], sizeof(mrb_value)*m2);
|
||||
value_move(®s[m1+o+r+1], &argv[argc-m2], m2);
|
||||
}
|
||||
if (argv0 == argv) {
|
||||
regs[len+1] = *blk; /* move block */
|
||||
@@ -1313,7 +1334,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
|
||||
mrb_ary_unshift(mrb, regs[a+1], sym);
|
||||
}
|
||||
else {
|
||||
memmove(regs+a+2, regs+a+1, sizeof(mrb_value)*(n+1));
|
||||
value_move(regs+a+2, regs+a+1, n+1);
|
||||
regs[a+1] = sym;
|
||||
n++;
|
||||
}
|
||||
@@ -1328,7 +1349,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
|
||||
if (ci->argc == CALL_MAXARGS) ci->argc = -1;
|
||||
|
||||
/* move stack */
|
||||
memmove(mrb->stack, ®s[a], (ci->argc+1)*sizeof(mrb_value));
|
||||
value_move(mrb->stack, ®s[a], ci->argc+1);
|
||||
|
||||
if (MRB_PROC_CFUNC_P(m)) {
|
||||
mrb->stack[0] = m->body.func(mrb, recv);
|
||||
|
||||
Reference in New Issue
Block a user