aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-12-06 09:42:18 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-12-06 09:42:18 -0200
commit533beedad254004d627437984d5ea521d2d2fa48 (patch)
tree3d48e0d5be484e3e34d0ff6cf50dc25352d4a0b1
parent968ad49da6522c1cf413bd86323a613176d12c07 (diff)
downloadlua-533beedad254004d627437984d5ea521d2d2fa48.tar.gz
lua-533beedad254004d627437984d5ea521d2d2fa48.tar.bz2
lua-533beedad254004d627437984d5ea521d2d2fa48.zip
new tests for begin/end blocks and multi-state
-rw-r--r--lbuiltin.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/lbuiltin.c b/lbuiltin.c
index a8f16667..2f4c1862 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.80 1999/12/02 16:24:45 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.81 1999/12/03 18:02:54 roberto Exp $
3** Built-in functions 3** Built-in functions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -462,8 +462,8 @@ static void luaB_foreachvar (lua_State *L) {
462 *(L->top++) = gv->value; 462 *(L->top++) = gv->value;
463 luaD_call(L, L->top-3, 1); 463 luaD_call(L, L->top-3, 1);
464 if (ttype(L->top-1) != LUA_T_NIL) { 464 if (ttype(L->top-1) != LUA_T_NIL) {
465 *(L->top-2) = *(L->top-1); /* remove extra name */
465 L->top--; 466 L->top--;
466 *(L->top-1) = *L->top; /* remove extra name */
467 return; 467 return;
468 } 468 }
469 L->top-=2; /* remove result and extra name */ 469 L->top-=2; /* remove result and extra name */
@@ -738,7 +738,11 @@ static void testC (lua_State *L) {
738 else if EQ("unref") { 738 else if EQ("unref") {
739 lua_unref(L, (int)lua_getnumber(L, reg[getreg(L, &pc)])); 739 lua_unref(L, (int)lua_getnumber(L, reg[getreg(L, &pc)]));
740 } 740 }
741 else if (EQ("getparam") || EQ("getresult")) { 741 else if EQ("getparam") {
742 int n = getreg(L, &pc);
743 reg[n] = lua_getparam(L, getnum(&pc)+1); /* skips the commmand itself */
744 }
745 else if EQ("getresult") {
742 int n = getreg(L, &pc); 746 int n = getreg(L, &pc);
743 reg[n] = lua_getparam(L, getnum(&pc)); 747 reg[n] = lua_getparam(L, getnum(&pc));
744 } 748 }
@@ -786,7 +790,7 @@ static void testC (lua_State *L) {
786 int val = getreg(L, &pc); 790 int val = getreg(L, &pc);
787 int tag = getreg(L, &pc); 791 int tag = getreg(L, &pc);
788 lua_pushusertag(L, (void *)(int)lua_getnumber(L, reg[val]), 792 lua_pushusertag(L, (void *)(int)lua_getnumber(L, reg[val]),
789 lua_getnumber(L, reg[tag])); 793 (int)lua_getnumber(L, reg[tag]));
790 } 794 }
791 else if EQ("udataval") { 795 else if EQ("udataval") {
792 int n = getreg(L, &pc); 796 int n = getreg(L, &pc);
@@ -795,7 +799,36 @@ static void testC (lua_State *L) {
795 } 799 }
796 else if EQ("settagmethod") { 800 else if EQ("settagmethod") {
797 int n = getreg(L, &pc); 801 int n = getreg(L, &pc);
798 lua_settagmethod(L, lua_getnumber(L, reg[n]), getname(&pc)); 802 lua_settagmethod(L, (int)lua_getnumber(L, reg[n]), getname(&pc));
803 }
804 else if EQ("beginblock") {
805 lua_beginblock(L);
806 }
807 else if EQ("endblock") {
808 lua_endblock(L);
809 }
810 else if EQ("newstate") {
811 int stacksize = getnum(&pc);
812 lua_State *L1 = lua_newstate("stack", stacksize,
813 "builtin", getnum(&pc), NULL);
814 lua_pushuserdata(L, L1);
815 }
816 else if EQ("closestate") {
817 lua_close(lua_getuserdata(L, reg[getreg(L, &pc)]));
818 }
819 else if EQ("doremote") {
820 lua_Object ol1 = reg[getreg(L, &pc)];
821 lua_Object str = reg[getreg(L, &pc)];
822 lua_State *L1;
823 lua_Object temp;
824 int i;
825 if (!lua_isuserdata(L, ol1) || !lua_isstring(L, str))
826 lua_error(L, "bad arguments for `doremote'");
827 L1 = lua_getuserdata(L, ol1);
828 lua_dostring(L1, lua_getstring(L, str));
829 i = 1;
830 while ((temp = lua_getresult(L1, i++)) != LUA_NOOBJECT)
831 lua_pushstring(L, lua_getstring(L1, temp));
799 } 832 }
800 else luaL_verror(L, "unknown command in `testC': %.20s", inst); 833 else luaL_verror(L, "unknown command in `testC': %.20s", inst);
801 } 834 }