Showing with 694 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +6 −0 lapi.c
  3. +17 −0 lauxlib.c
  4. +11 −0 lauxlib.h
  5. +6 −0 lbaselib.c
  6. +45 −0 lcode.c
  7. +4 −0 lcode.h
  8. +2 −0 lcorolib.c
  9. +2 −0 lctype.c
  10. +2 −0 lctype.h
  11. +6 −0 ldblib.c
  12. +2 −0 ldebug.c
  13. +2 −0 ldo.c
  14. +4 −0 ldump.c
  15. +2 −0 lfunc.c
  16. +2 −0 lgc.c
  17. +4 −0 linit.c
  18. +6 −0 ljumptab.h
  19. +33 −0 llex.c
  20. +6 −0 llex.h
  21. +4 −0 llimits.h
  22. +24 −0 lmathlib.c
  23. +2 −0 lmem.c
  24. +2 −0 lmem.h
  25. +24 −0 loadlib.c
  26. +30 −0 lobject.c
  27. +16 −0 lobject.h
  28. +6 −0 lopcodes.c
  29. +6 −0 lopcodes.h
  30. +8 −0 lopnames.h
  31. +12 −0 lparser.c
  32. +2 −0 lparser.h
  33. +2 −0 lprefix.h
  34. +4 −0 lstate.c
  35. +2 −0 lstring.c
  36. +28 −0 lstrlib.c
  37. +14 −0 ltable.c
  38. +2 −0 ltablib.c
  39. +9 −0 ltm.c
  40. +2 −0 ltm.h
  41. +38 −0 lua.h
  42. +177 −0 luaconf.h
  43. +2 −0 lualib.h
  44. +4 −0 lundump.c
  45. +2 −0 lutf8lib.c
  46. +96 −0 lvm.c
  47. +9 −0 lvm.h
  48. +2 −0 lzio.c
@@ -13,3 +13,6 @@ testes/libs/all

temp
lua

#lunatik
*.o.cmd
6 lapi.c
@@ -10,9 +10,11 @@
#include "lprefix.h"


#ifndef _KERNEL
#include <limits.h>
#include <stdarg.h>
#include <string.h>
#endif /* _KERNEL */

#include "lua.h"

@@ -380,6 +382,7 @@ LUA_API size_t lua_stringtonumber (lua_State *L, const char *s) {
}


#ifndef _KERNEL
LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *pisnum) {
lua_Number n = 0;
const TValue *o = index2value(L, idx);
@@ -388,6 +391,7 @@ LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *pisnum) {
*pisnum = isnum;
return n;
}
#endif /* _KERNEL */


LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *pisnum) {
@@ -506,12 +510,14 @@ LUA_API void lua_pushnil (lua_State *L) {
}


#ifndef _KERNEL
LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
lua_lock(L);
setfltvalue(s2v(L->top), n);
api_incr_top(L);
lua_unlock(L);
}
#endif /* _KERNEL */


LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
@@ -10,11 +10,13 @@
#include "lprefix.h"


#ifndef _KERNEL
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif /* _KERNEL */


/*
@@ -242,6 +244,7 @@ LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
}


#ifndef _KERNEL
LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) {
int en = errno; /* calls to Lua API may change this value */
if (stat) {
@@ -258,6 +261,7 @@ LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) {
return 3;
}
}
#endif /* _KERNEL */


#if !defined(l_inspectstat) /* { */
@@ -282,6 +286,7 @@ LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) {
#endif /* } */


#ifndef _KERNEL
LUALIB_API int luaL_execresult (lua_State *L, int stat) {
if (stat != 0 && errno != 0) /* error with an 'errno'? */
return luaL_fileresult(L, 0, NULL);
@@ -297,6 +302,7 @@ LUALIB_API int luaL_execresult (lua_State *L, int stat) {
return 3; /* return true/fail,what,code */
}
}
#endif /* _KERNEL */

/* }====================================================== */

@@ -431,6 +437,7 @@ LUALIB_API lua_Number luaL_optnumber (lua_State *L, int arg, lua_Number def) {
}


#ifndef _KERNEL
static void interror (lua_State *L, int arg) {
if (lua_isnumber(L, arg))
luaL_argerror(L, arg, "number has no integer representation");
@@ -453,6 +460,7 @@ LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int arg,
lua_Integer def) {
return luaL_opt(L, luaL_checkinteger, arg, def);
}
#endif /* _KERNEL */

/* }====================================================== */

@@ -705,6 +713,7 @@ LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
** =======================================================
*/

#ifndef _KERNEL
typedef struct LoadF {
int n; /* number of pre-read characters */
FILE *f; /* file being read */
@@ -807,6 +816,7 @@ LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename,
lua_remove(L, fnameindex);
return status;
}
#endif /* _KERNEL */


typedef struct LoadS {
@@ -891,8 +901,10 @@ LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
case LUA_TNUMBER: {
if (lua_isinteger(L, idx))
lua_pushfstring(L, "%I", (LUAI_UACINT)lua_tointeger(L, idx));
#ifndef _KERNEL
else
lua_pushfstring(L, "%f", (LUAI_UACNUMBER)lua_tonumber(L, idx));
#endif /* _KERNEL */
break;
}
case LUA_TSTRING:
@@ -1100,7 +1112,12 @@ LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver, size_t sz) {
if (sz != LUAL_NUMSIZES) /* check numeric types */
luaL_error(L, "core and library have incompatible numeric types");
else if (v != ver)
#ifndef _KERNEL
luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f",
#else
luaL_error(L, "version mismatch: app. needs "LUA_NUMBER_FMT
", Lua core provides "LUA_NUMBER_FMT,
#endif /* _KERNEL */
(LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)v);
}

@@ -9,8 +9,10 @@
#define lauxlib_h


#ifndef _KERNEL
#include <stddef.h>
#include <stdio.h>
#endif /* _KERNEL */

#include "luaconf.h"
#include "lua.h"
@@ -59,9 +61,14 @@ LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,
LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg);
LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def);

#ifndef _KERNEL
LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg);
LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg,
lua_Integer def);
#else /* _KERNEL */
#define luaL_checkinteger luaL_checknumber
#define luaL_optinteger(L,a,d) luaL_optnumber(L, (a), (lua_Number)(d))
#endif /* _KERNEL */

LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t);
@@ -78,8 +85,10 @@ LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
const char *const lst[]);

#ifndef _KERNEL
LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
#endif /* _KERNEL */


/* predefined references */
@@ -227,6 +236,7 @@ LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);



#ifndef _KERNEL
/*
** {======================================================
** File handles for IO library
@@ -272,6 +282,7 @@ typedef struct luaL_Stream {
#endif

/* }================================================================== */
#endif /* _KERNEL */


/*
@@ -10,10 +10,12 @@
#include "lprefix.h"


#ifndef _KERNEL
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif /* _KERNEL */

#include "lua.h"

@@ -209,7 +211,11 @@ static int luaB_collectgarbage (lua_State *L) {
int k = lua_gc(L, o);
int b = lua_gc(L, LUA_GCCOUNTB);
checkvalres(k);
#ifndef _KERNEL
lua_pushnumber(L, (lua_Number)k + ((lua_Number)b/1024));
#else /* return "count" in bytes, instead of Kbytes */
lua_pushinteger(L, ((lua_Integer)k << 10) + b);
#endif
return 1;
}
case LUA_GCSTEP: {