1999-12-14 21:31:20 +03:00
|
|
|
/*
|
2000-06-21 21:05:49 +04:00
|
|
|
** $Id: ltests.c,v 1.25 2000/06/12 13:52:05 roberto Exp roberto $
|
1999-12-14 21:31:20 +03:00
|
|
|
** Internal Module for Debugging of the Lua Implementation
|
|
|
|
** See Copyright Notice in lua.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
2000-04-06 21:35:23 +04:00
|
|
|
#include <stdio.h>
|
1999-12-14 21:31:20 +03:00
|
|
|
#include <stdlib.h>
|
2000-02-21 21:30:06 +03:00
|
|
|
#include <string.h>
|
1999-12-14 21:31:20 +03:00
|
|
|
|
|
|
|
|
2000-06-12 17:52:05 +04:00
|
|
|
#include "lua.h"
|
|
|
|
|
1999-12-14 21:31:20 +03:00
|
|
|
#include "lapi.h"
|
|
|
|
#include "lauxlib.h"
|
2000-05-22 22:44:46 +04:00
|
|
|
#include "lcode.h"
|
2000-05-10 20:33:20 +04:00
|
|
|
#include "ldo.h"
|
1999-12-14 21:31:20 +03:00
|
|
|
#include "lmem.h"
|
2000-04-06 21:35:23 +04:00
|
|
|
#include "lopcodes.h"
|
1999-12-14 21:31:20 +03:00
|
|
|
#include "lstate.h"
|
|
|
|
#include "lstring.h"
|
|
|
|
#include "ltable.h"
|
1999-12-23 21:19:57 +03:00
|
|
|
#include "luadebug.h"
|
1999-12-14 21:31:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
void luaB_opentests (lua_State *L);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The whole module only makes sense with DEBUG on
|
|
|
|
*/
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
|
2000-04-06 21:35:23 +04:00
|
|
|
|
2000-06-02 21:06:42 +04:00
|
|
|
static void setnameval (lua_Object t, const char *name, int val) {
|
|
|
|
lua_pushobject(t);
|
|
|
|
lua_pushstring(name);
|
|
|
|
lua_pushnumber(val);
|
|
|
|
lua_settable();
|
2000-04-06 21:35:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
** {======================================================
|
|
|
|
** Disassembler
|
|
|
|
** =======================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2000-06-21 21:05:49 +04:00
|
|
|
static const char *const instrname[NUM_OPCODES] = {
|
2000-05-22 22:44:46 +04:00
|
|
|
"END", "RETURN", "CALL", "TAILCALL", "PUSHNIL", "POP", "PUSHINT",
|
|
|
|
"PUSHSTRING", "PUSHNUM", "PUSHNEGNUM", "PUSHUPVALUE", "GETLOCAL",
|
|
|
|
"GETGLOBAL", "GETTABLE", "GETDOTTED", "GETINDEXED", "PUSHSELF",
|
|
|
|
"CREATETABLE", "SETLOCAL", "SETGLOBAL", "SETTABLE", "SETLIST", "SETMAP",
|
|
|
|
"ADD", "ADDI", "SUB", "MULT", "DIV", "POW", "CONCAT", "MINUS", "NOT",
|
|
|
|
"JMPNE", "JMPEQ", "JMPLT", "JMPLE", "JMPGT", "JMPGE", "JMPT", "JMPF",
|
|
|
|
"JMPONT", "JMPONF", "JMP", "PUSHNILJMP", "FORPREP", "FORLOOP", "LFORPREP",
|
|
|
|
"LFORLOOP", "CLOSURE", "SETLINE"
|
|
|
|
};
|
2000-04-06 21:35:23 +04:00
|
|
|
|
|
|
|
|
2000-06-02 21:06:42 +04:00
|
|
|
static int pushop (Instruction i) {
|
2000-04-06 21:35:23 +04:00
|
|
|
char buff[100];
|
2000-05-22 22:44:46 +04:00
|
|
|
OpCode o = GET_OPCODE(i);
|
|
|
|
const char *name = instrname[o];
|
|
|
|
switch ((enum Mode)luaK_opproperties[o].mode) {
|
|
|
|
case iO:
|
|
|
|
sprintf(buff, "%s", name);
|
|
|
|
break;
|
|
|
|
case iU:
|
|
|
|
sprintf(buff, "%-12s%4u", name, GETARG_U(i));
|
|
|
|
break;
|
|
|
|
case iS:
|
|
|
|
sprintf(buff, "%-12s%4d", name, GETARG_S(i));
|
|
|
|
break;
|
|
|
|
case iAB:
|
|
|
|
sprintf(buff, "%-12s%4d %4d", name, GETARG_A(i), GETARG_B(i));
|
|
|
|
break;
|
2000-04-06 21:35:23 +04:00
|
|
|
}
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushstring(buff);
|
2000-05-22 22:44:46 +04:00
|
|
|
return (o != OP_END);
|
2000-04-06 21:35:23 +04:00
|
|
|
}
|
|
|
|
|
2000-05-22 22:44:46 +04:00
|
|
|
|
2000-06-02 21:06:42 +04:00
|
|
|
static void listcode (void) {
|
|
|
|
lua_Object o = luaL_nonnullarg(1);
|
|
|
|
lua_Object t = lua_createtable();
|
2000-04-06 21:35:23 +04:00
|
|
|
Instruction *pc;
|
|
|
|
Proto *p;
|
|
|
|
int res;
|
2000-06-02 21:06:42 +04:00
|
|
|
luaL_arg_check(ttype(o) == TAG_LCLOSURE, 1, "Lua function expected");
|
2000-04-06 21:35:23 +04:00
|
|
|
p = clvalue(o)->f.l;
|
2000-06-02 21:06:42 +04:00
|
|
|
setnameval(t, "maxstack", p->maxstacksize);
|
|
|
|
setnameval(t, "numparams", p->numparams);
|
2000-04-06 21:35:23 +04:00
|
|
|
pc = p->code;
|
|
|
|
do {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushobject(t);
|
|
|
|
lua_pushnumber(pc - p->code + 1);
|
|
|
|
res = pushop(*pc++);
|
|
|
|
lua_settable();
|
2000-04-06 21:35:23 +04:00
|
|
|
} while (res);
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushobject(t);
|
2000-04-06 21:35:23 +04:00
|
|
|
}
|
|
|
|
|
2000-06-02 23:10:01 +04:00
|
|
|
|
|
|
|
static void liststrings (void) {
|
|
|
|
lua_Object o = luaL_nonnullarg(1);
|
|
|
|
lua_Object t = lua_createtable();
|
|
|
|
Proto *p;
|
|
|
|
int i;
|
|
|
|
luaL_arg_check(ttype(o) == TAG_LCLOSURE, 1, "Lua function expected");
|
|
|
|
p = clvalue(o)->f.l;
|
|
|
|
for (i=0; i<p->nkstr; i++) {
|
|
|
|
lua_pushobject(t);
|
|
|
|
lua_pushnumber(i+1);
|
|
|
|
lua_pushstring(p->kstr[i]->str);
|
|
|
|
lua_settable();
|
|
|
|
}
|
|
|
|
lua_pushobject(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-06 21:35:23 +04:00
|
|
|
/* }====================================================== */
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-06-02 21:06:42 +04:00
|
|
|
static void get_limits (void) {
|
|
|
|
lua_Object t = lua_createtable();
|
|
|
|
setnameval(t, "SIZE_OP", SIZE_OP);
|
|
|
|
setnameval(t, "SIZE_U", SIZE_U);
|
|
|
|
setnameval(t, "SIZE_A", SIZE_A);
|
|
|
|
setnameval(t, "SIZE_B", SIZE_B);
|
|
|
|
setnameval(t, "MAXARG_U", MAXARG_U);
|
|
|
|
setnameval(t, "MAXARG_S", MAXARG_S);
|
|
|
|
setnameval(t, "MAXARG_A", MAXARG_A);
|
|
|
|
setnameval(t, "MAXARG_B", MAXARG_B);
|
|
|
|
setnameval(t, "MAXSTACK", MAXSTACK);
|
|
|
|
setnameval(t, "MAXLOCALS", MAXLOCALS);
|
|
|
|
setnameval(t, "MAXUPVALUES", MAXUPVALUES);
|
|
|
|
setnameval(t, "MAXVARSLH", MAXVARSLH);
|
|
|
|
setnameval(t, "MAXPARAMS", MAXPARAMS);
|
|
|
|
setnameval(t, "LFPF", LFIELDS_PER_FLUSH);
|
|
|
|
setnameval(t, "RFPF", RFIELDS_PER_FLUSH);
|
|
|
|
lua_pushobject(t);
|
2000-04-06 21:35:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-02 21:06:42 +04:00
|
|
|
static void mem_query (void) {
|
|
|
|
lua_pushnumber(memdebug_total);
|
|
|
|
lua_pushnumber(memdebug_numblocks);
|
|
|
|
lua_pushnumber(memdebug_maxmem);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-02 21:06:42 +04:00
|
|
|
static void hash_query (void) {
|
|
|
|
lua_Object o = luaL_nonnullarg(1);
|
|
|
|
if (lua_getparam(2) == LUA_NOOBJECT) {
|
|
|
|
luaL_arg_check(ttype(o) == TAG_STRING, 1, "string expected");
|
|
|
|
lua_pushnumber(tsvalue(o)->u.s.hash);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else {
|
2000-06-08 22:27:13 +04:00
|
|
|
const Hash *t = hvalue(luaL_tablearg(2));
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushnumber(luaH_mainposition(t, o) - t->node);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-02 21:06:42 +04:00
|
|
|
static void table_query (void) {
|
2000-06-08 22:27:13 +04:00
|
|
|
const Hash *t = hvalue(luaL_tablearg(1));
|
2000-06-02 21:06:42 +04:00
|
|
|
int i = luaL_opt_int(2, -1);
|
1999-12-14 21:31:20 +03:00
|
|
|
if (i == -1) {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushnumber(t->size);
|
|
|
|
lua_pushnumber(t->firstfree - t->node);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if (i < t->size) {
|
2000-06-02 21:06:42 +04:00
|
|
|
luaA_pushobject(lua_state, &t->node[i].key);
|
|
|
|
luaA_pushobject(lua_state, &t->node[i].val);
|
1999-12-14 21:31:20 +03:00
|
|
|
if (t->node[i].next)
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushnumber(t->node[i].next - t->node);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-02 21:06:42 +04:00
|
|
|
static void string_query (void) {
|
|
|
|
lua_State *L = lua_state;
|
|
|
|
stringtable *tb = (*luaL_check_string(1) == 's') ? &L->strt : &L->udt;
|
|
|
|
int s = luaL_opt_int(2, 0) - 1;
|
1999-12-14 21:31:20 +03:00
|
|
|
if (s==-1) {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushnumber(tb->nuse);
|
|
|
|
lua_pushnumber(tb->size);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
2000-05-10 20:33:20 +04:00
|
|
|
else if (s < tb->size) {
|
|
|
|
TString *ts;
|
|
|
|
for (ts = tb->hash[s]; ts; ts = ts->nexthash) {
|
|
|
|
ttype(L->top) = TAG_STRING;
|
|
|
|
tsvalue(L->top) = ts;
|
|
|
|
incr_top;
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-06 21:35:23 +04:00
|
|
|
/*
|
|
|
|
** {======================================================
|
|
|
|
** function to test the API with C. It interprets a kind of "assembler"
|
|
|
|
** language with calls to the API, so the test can be driven by Lua code
|
|
|
|
** =======================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const char *const delimits = " \t\n,;";
|
1999-12-14 21:31:20 +03:00
|
|
|
|
|
|
|
static void skip (const char **pc) {
|
|
|
|
while (**pc != '\0' && strchr(delimits, **pc)) (*pc)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int getnum (const char **pc) {
|
|
|
|
int res = 0;
|
|
|
|
skip(pc);
|
|
|
|
while (isdigit(**pc)) res = res*10 + (*(*pc)++) - '0';
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2000-06-02 21:06:42 +04:00
|
|
|
static int getreg (const char **pc) {
|
1999-12-14 21:31:20 +03:00
|
|
|
skip(pc);
|
2000-06-02 21:06:42 +04:00
|
|
|
if (*(*pc)++ != 'r') lua_error("`testC' expecting a register");
|
1999-12-14 21:31:20 +03:00
|
|
|
return getnum(pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *getname (const char **pc) {
|
|
|
|
static char buff[30];
|
|
|
|
int i = 0;
|
|
|
|
skip(pc);
|
|
|
|
while (**pc != '\0' && !strchr(delimits, **pc))
|
|
|
|
buff[i++] = *(*pc)++;
|
|
|
|
buff[i] = '\0';
|
|
|
|
return buff;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define EQ(s1) (strcmp(s1, inst) == 0)
|
|
|
|
|
2000-04-06 21:35:23 +04:00
|
|
|
|
2000-06-02 21:06:42 +04:00
|
|
|
static void testC (void) {
|
1999-12-14 21:31:20 +03:00
|
|
|
lua_Object reg[10];
|
2000-06-02 21:06:42 +04:00
|
|
|
const char *pc = luaL_check_string(1);
|
1999-12-14 21:31:20 +03:00
|
|
|
for (;;) {
|
|
|
|
const char *inst = getname(&pc);
|
|
|
|
if EQ("") return;
|
|
|
|
else if EQ("pushnum") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushnumber(getnum(&pc));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("createtable") {
|
2000-06-02 21:06:42 +04:00
|
|
|
reg[getreg(&pc)] = lua_createtable();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("closure") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_CFunction f = lua_getcfunction(lua_getglobal(getname(&pc)));
|
|
|
|
lua_pushcclosure(f, getnum(&pc));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("pop") {
|
2000-06-02 21:06:42 +04:00
|
|
|
reg[getreg(&pc)] = lua_pop();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("getglobal") {
|
2000-06-02 21:06:42 +04:00
|
|
|
int n = getreg(&pc);
|
|
|
|
reg[n] = lua_getglobal(getname(&pc));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("ref") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushnumber(lua_ref(0));
|
|
|
|
reg[getreg(&pc)] = lua_pop();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("reflock") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushnumber(lua_ref(1));
|
|
|
|
reg[getreg(&pc)] = lua_pop();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("getref") {
|
2000-06-02 21:06:42 +04:00
|
|
|
int n = getreg(&pc);
|
|
|
|
reg[n] = lua_getref((int)lua_getnumber(reg[getreg(&pc)]));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("unref") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_unref((int)lua_getnumber(reg[getreg(&pc)]));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("getparam") {
|
2000-06-02 21:06:42 +04:00
|
|
|
int n = getreg(&pc);
|
|
|
|
reg[n] = lua_getparam(getnum(&pc)+1); /* skips the command itself */
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("getresult") {
|
2000-06-02 21:06:42 +04:00
|
|
|
int n = getreg(&pc);
|
|
|
|
reg[n] = lua_getparam(getnum(&pc));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("setglobal") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_setglobal(getname(&pc));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
2000-05-26 23:17:57 +04:00
|
|
|
else if EQ("pushglobals") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushglobaltable();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("pushstring") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushstring(getname(&pc));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("pushreg") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushobject(reg[getreg(&pc)]);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("call") {
|
2000-06-02 21:06:42 +04:00
|
|
|
if (lua_call(getname(&pc))) lua_error(NULL);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("gettable") {
|
2000-06-02 21:06:42 +04:00
|
|
|
reg[getreg(&pc)] = lua_gettable();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
2000-05-26 23:17:57 +04:00
|
|
|
else if EQ("rawget") {
|
2000-06-02 21:06:42 +04:00
|
|
|
reg[getreg(&pc)] = lua_rawget();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("settable") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_settable();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
2000-05-26 23:17:57 +04:00
|
|
|
else if EQ("rawset") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_rawset();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
1999-12-23 21:19:57 +03:00
|
|
|
else if EQ("tag") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushnumber(lua_tag(reg[getreg(&pc)]));
|
1999-12-23 21:19:57 +03:00
|
|
|
}
|
|
|
|
else if EQ("type") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushstring(lua_type(reg[getreg(&pc)]));
|
1999-12-23 21:19:57 +03:00
|
|
|
}
|
1999-12-14 21:31:20 +03:00
|
|
|
else if EQ("next") {
|
2000-06-02 21:06:42 +04:00
|
|
|
int n = getreg(&pc);
|
|
|
|
n = lua_next(reg[n], (int)lua_getnumber(reg[getreg(&pc)]));
|
|
|
|
lua_pushnumber(n);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("equal") {
|
2000-06-02 21:06:42 +04:00
|
|
|
int n1 = getreg(&pc);
|
|
|
|
int n2 = getreg(&pc);
|
|
|
|
lua_pushnumber(lua_equal(reg[n1], reg[n2]));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("pushusertag") {
|
2000-06-02 21:06:42 +04:00
|
|
|
int val = getreg(&pc);
|
|
|
|
int tag = getreg(&pc);
|
|
|
|
lua_pushusertag((void *)(int)lua_getnumber(reg[val]),
|
|
|
|
(int)lua_getnumber(reg[tag]));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("udataval") {
|
2000-06-02 21:06:42 +04:00
|
|
|
int n = getreg(&pc);
|
|
|
|
lua_pushnumber((int)lua_getuserdata(reg[getreg(&pc)]));
|
|
|
|
reg[n] = lua_pop();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("settagmethod") {
|
2000-06-02 21:06:42 +04:00
|
|
|
int n = getreg(&pc);
|
|
|
|
lua_settagmethod((int)lua_getnumber(reg[n]), getname(&pc));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("beginblock") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_beginblock();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("endblock") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_endblock();
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("newstate") {
|
|
|
|
int stacksize = getnum(&pc);
|
|
|
|
lua_State *L1 = lua_newstate("stack", stacksize,
|
|
|
|
"builtin", getnum(&pc), NULL);
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_pushuserdata(L1);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("closestate") {
|
2000-06-02 21:06:42 +04:00
|
|
|
(lua_close)((lua_State *)lua_getuserdata(reg[getreg(&pc)]));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
else if EQ("doremote") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_Object ol1 = reg[getreg(&pc)];
|
|
|
|
lua_Object str = reg[getreg(&pc)];
|
1999-12-14 21:31:20 +03:00
|
|
|
lua_State *L1;
|
|
|
|
lua_Object temp;
|
|
|
|
int i;
|
2000-06-02 21:06:42 +04:00
|
|
|
if (!lua_isuserdata(ol1) || !lua_isstring(str))
|
|
|
|
lua_error("bad arguments for `doremote'");
|
|
|
|
L1 = (lua_State *)lua_getuserdata(ol1);
|
|
|
|
(lua_dostring)(L1, lua_getstring(str));
|
1999-12-14 21:31:20 +03:00
|
|
|
i = 1;
|
2000-06-02 21:06:42 +04:00
|
|
|
while ((temp = (lua_getresult)(L1, i++)) != LUA_NOOBJECT)
|
|
|
|
lua_pushstring((lua_getstring)(L1, temp));
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
2000-05-26 23:17:57 +04:00
|
|
|
#if LUA_DEPRECATETFUNCS
|
|
|
|
else if EQ("rawsetglobal") {
|
2000-06-02 21:06:42 +04:00
|
|
|
lua_rawsetglobal(getname(&pc));
|
2000-05-26 23:17:57 +04:00
|
|
|
}
|
|
|
|
else if EQ("rawgetglobal") {
|
2000-06-02 21:06:42 +04:00
|
|
|
int n = getreg(&pc);
|
|
|
|
reg[n] = lua_rawgetglobal(getname(&pc));
|
2000-05-26 23:17:57 +04:00
|
|
|
}
|
|
|
|
#endif
|
2000-06-02 21:06:42 +04:00
|
|
|
else luaL_verror(lua_state, "unknown command in `testC': %.20s", inst);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-06 21:35:23 +04:00
|
|
|
/* }====================================================== */
|
|
|
|
|
|
|
|
|
1999-12-14 21:31:20 +03:00
|
|
|
|
|
|
|
static const struct luaL_reg tests_funcs[] = {
|
2000-06-02 21:06:42 +04:00
|
|
|
{"hash", (lua_CFunction)hash_query},
|
|
|
|
{"limits", (lua_CFunction)get_limits},
|
|
|
|
{"listcode", (lua_CFunction)listcode},
|
2000-06-02 23:10:01 +04:00
|
|
|
{"liststrings", (lua_CFunction)liststrings},
|
2000-06-02 21:06:42 +04:00
|
|
|
{"querystr", (lua_CFunction)string_query},
|
|
|
|
{"querytab", (lua_CFunction)table_query},
|
|
|
|
{"testC", (lua_CFunction)testC},
|
|
|
|
{"totalmem", (lua_CFunction)mem_query}
|
1999-12-14 21:31:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void luaB_opentests (lua_State *L) {
|
2000-06-02 21:06:42 +04:00
|
|
|
if (lua_state != NULL) return; /* do not open tests for auxiliar states */
|
|
|
|
lua_state = L;
|
|
|
|
luaL_openl(tests_funcs);
|
1999-12-14 21:31:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|