aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/lvm.c b/lvm.c
index fc8cb262..29819b1e 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.99 2000/04/04 20:48:44 roberto Exp roberto $ 2** $Id: lvm.c,v 1.100 2000/04/07 13:13:11 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -630,6 +630,34 @@ StkId luaV_execute (lua_State *L, const Closure *cl, register StkId base) {
630 pc++; 630 pc++;
631 break; 631 break;
632 632
633 case OP_FORPREP:
634 if (tonumber(top-1))
635 lua_error(L, "`for' step must be a number");
636 if (tonumber(top-2))
637 lua_error(L, "`for' limit must be a number");
638 if (tonumber(top-3))
639 lua_error(L, "`for' initial value must be a number");
640 nvalue(top-3) -= nvalue(top-1); /* to be undone by first FORLOOP */
641 pc += GETARG_S(i);
642 break;
643
644 case OP_FORLOOP: {
645 Number step = nvalue(top-1);
646 Number limit = nvalue(top-2);
647 Number index;
648 LUA_ASSERT(L, ttype(top-1) == TAG_NUMBER, "invalid step");
649 LUA_ASSERT(L, ttype(top-2) == TAG_NUMBER, "invalid limit");
650 if (tonumber(top-3)) lua_error(L, "`for' index must be a number");
651 index = nvalue(top-3)+step;
652 if ((step>0) ? index<=limit : index>=limit) {
653 nvalue(top-3) = index;
654 pc += GETARG_S(i);
655 }
656 else /* end of `for': remove control variables */
657 top -= 3;
658 break;
659 }
660
633 case OP_CLOSURE: 661 case OP_CLOSURE:
634 L->top = top; 662 L->top = top;
635 luaV_Lclosure(L, tf->kproto[GETARG_A(i)], GETARG_B(i)); 663 luaV_Lclosure(L, tf->kproto[GETARG_A(i)], GETARG_B(i));