aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ltests.c54
1 files changed, 38 insertions, 16 deletions
diff --git a/ltests.c b/ltests.c
index f2814a23..e0de86f3 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.58 2009/02/19 17:18:25 roberto Exp roberto $ 2** $Id: ltests.c,v 2.59 2009/03/03 18:52:36 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -867,22 +867,10 @@ static int getindex_aux (lua_State *L, const char **pc) {
867#define getindex (getindex_aux(L, &pc)) 867#define getindex (getindex_aux(L, &pc))
868 868
869 869
870static int testC (lua_State *L) { 870static int testC (lua_State *L);
871
872static int runC (lua_State *L, lua_State *L1, const char *pc) {
871 char buff[30]; 873 char buff[30];
872 lua_State *L1;
873 const char *pc;
874 if (lua_isuserdata(L, 1)) {
875 L1 = getstate(L);
876 pc = luaL_checkstring(L, 2);
877 }
878 else if (lua_isthread(L, 1)) {
879 L1 = lua_tothread(L, 1);
880 pc = luaL_checkstring(L, 2);
881 }
882 else {
883 L1 = L;
884 pc = luaL_checkstring(L, 1);
885 }
886 for (;;) { 874 for (;;) {
887 const char *inst = getname; 875 const char *inst = getname;
888 if EQ("") return 0; 876 if EQ("") return 0;
@@ -1058,6 +1046,39 @@ static struct X { int x; } x;
1058 return 0; 1046 return 0;
1059} 1047}
1060 1048
1049
1050static int testC (lua_State *L) {
1051 lua_State *L1;
1052 const char *pc;
1053 if (lua_isuserdata(L, 1)) {
1054 L1 = getstate(L);
1055 pc = luaL_checkstring(L, 2);
1056 }
1057 else if (lua_isthread(L, 1)) {
1058 L1 = lua_tothread(L, 1);
1059 pc = luaL_checkstring(L, 2);
1060 }
1061 else {
1062 L1 = L;
1063 pc = luaL_checkstring(L, 1);
1064 }
1065 return runC(L, L1, pc);
1066}
1067
1068
1069static int Cfunc (lua_State *L) {
1070 return runC(L, L, lua_tostring(L, lua_upvalueindex(1)));
1071}
1072
1073
1074static int makeCfunc (lua_State *L) {
1075 luaL_checkstring(L, 1);
1076 lua_settop(L, 1);
1077 lua_pushcclosure(L, Cfunc, 1);
1078 return 1;
1079}
1080
1081
1061/* }====================================================== */ 1082/* }====================================================== */
1062 1083
1063 1084
@@ -1135,6 +1156,7 @@ static const struct luaL_Reg tests_funcs[] = {
1135 {"setyhook", setyhook}, 1156 {"setyhook", setyhook},
1136 {"stacklevel", stacklevel}, 1157 {"stacklevel", stacklevel},
1137 {"testC", testC}, 1158 {"testC", testC},
1159 {"makeCfunc", makeCfunc},
1138 {"totalmem", mem_query}, 1160 {"totalmem", mem_query},
1139 {"trick", settrick}, 1161 {"trick", settrick},
1140 {"udataval", udataval}, 1162 {"udataval", udataval},