1994-11-07 18:20:56 +03:00
|
|
|
/*
|
|
|
|
** fallback.c
|
|
|
|
** TecCGraf - PUC-Rio
|
|
|
|
*/
|
|
|
|
|
1994-11-09 21:12:42 +03:00
|
|
|
char *rcs_fallback="$Id: fallback.c,v 1.2 1994/11/08 19:56:39 roberto Exp roberto $";
|
1994-11-07 18:20:56 +03:00
|
|
|
|
|
|
|
#include <stdio.h>
|
1994-11-08 22:56:39 +03:00
|
|
|
#include <stdlib.h>
|
1994-11-07 18:20:56 +03:00
|
|
|
|
|
|
|
#include "fallback.h"
|
1994-11-08 22:56:39 +03:00
|
|
|
#include "opcode.h"
|
1994-11-09 21:12:42 +03:00
|
|
|
#include "inout.h"
|
1994-11-07 18:20:56 +03:00
|
|
|
#include "lua.h"
|
|
|
|
|
|
|
|
|
|
|
|
void luaI_errorFB (void)
|
|
|
|
{
|
|
|
|
lua_Object o = lua_getparam(1);
|
|
|
|
if (lua_isstring(o))
|
|
|
|
fprintf (stderr, "lua: %s\n", lua_getstring(o));
|
|
|
|
else
|
|
|
|
fprintf(stderr, "lua: unknown error\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void luaI_indexFB (void)
|
|
|
|
{
|
|
|
|
lua_pushnil();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void luaI_gettableFB (void)
|
|
|
|
{
|
1994-11-09 21:12:42 +03:00
|
|
|
lua_reportbug("indexed expression not a table");
|
1994-11-07 18:20:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void luaI_arithFB (void)
|
|
|
|
{
|
1994-11-09 21:12:42 +03:00
|
|
|
lua_reportbug("unexpected type at conversion to number");
|
1994-11-07 18:20:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void luaI_concatFB (void)
|
|
|
|
{
|
1994-11-09 21:12:42 +03:00
|
|
|
lua_reportbug("unexpected type at conversion to string");
|
1994-11-07 18:20:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void luaI_orderFB (void)
|
|
|
|
{
|
1994-11-09 21:12:42 +03:00
|
|
|
lua_reportbug("unexpected type at comparison");
|
1994-11-07 18:20:56 +03:00
|
|
|
}
|
|
|
|
|
1994-11-08 22:56:39 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Lock routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
static Object *lockArray = NULL;
|
|
|
|
static int lockSize = 0;
|
|
|
|
|
|
|
|
int lua_lock (lua_Object object)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int oldSize;
|
|
|
|
if (lua_isnil(object))
|
|
|
|
return -1;
|
|
|
|
for (i=0; i<lockSize; i++)
|
|
|
|
if (tag(&lockArray[i]) == LUA_T_NIL)
|
|
|
|
{
|
|
|
|
lockArray[i] = *luaI_Address(object);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
/* no more empty spaces */
|
|
|
|
oldSize = lockSize;
|
|
|
|
if (lockArray == NULL)
|
|
|
|
{
|
|
|
|
lockSize = 10;
|
|
|
|
lockArray = (Object *)malloc(lockSize);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lockSize = 3*oldSize/2 + 5;
|
|
|
|
lockArray = (Object *)realloc(lockArray, lockSize);
|
|
|
|
}
|
|
|
|
if (lockArray == NULL)
|
|
|
|
{
|
|
|
|
lockSize = 0;
|
|
|
|
lua_error("lock - not enough memory");
|
|
|
|
}
|
|
|
|
for (i=oldSize; i<lockSize; i++)
|
|
|
|
tag(&lockArray[i]) = LUA_T_NIL;
|
|
|
|
lockArray[oldSize] = *luaI_Address(object);
|
|
|
|
return oldSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lua_unlock (int ref)
|
|
|
|
{
|
|
|
|
tag(&lockArray[ref]) = LUA_T_NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Object *luaI_getlocked (int ref)
|
|
|
|
{
|
|
|
|
return &lockArray[ref];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void luaI_travlock (void (*fn)(Object *))
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=0; i<lockSize; i++)
|
|
|
|
fn(&lockArray[i]);
|
|
|
|
}
|
|
|
|
|