From 7c4d0c7fddd7b2bb676afe3043336bb44f4e8c22 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sun, 8 Nov 2009 07:37:34 +0100 Subject: Opening the jit and bit libraries. --- src/lua-interface.cpp | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'src/lua-interface.cpp') diff --git a/src/lua-interface.cpp b/src/lua-interface.cpp index 93a5fc0..8e8fb99 100644 --- a/src/lua-interface.cpp +++ b/src/lua-interface.cpp @@ -1,6 +1,6 @@ /* * lua-interface - * Copyright (C) 2002-2008 Nicolas "Pixel" Noble + * Copyright (C) 2002-2009 Nicolas "Pixel" Noble * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ #define WIP -#define VERSION "0.7" +#define VERSION "0.8" #include @@ -46,6 +46,7 @@ #include #include #include +#include #ifndef _MSVC // this seems ignored under apple's gcc... dammit. @@ -591,7 +592,8 @@ bool auto_exec = true; CODE_BEGINS /* That's the basic lua starter for non interactive mode */ -Lua * start_basic_lua(void) { +Lua * start_basic_lua(bool nested = false) { + LUAJIT_VERSION_SYM(); Lua * L = new threaded_Lua(); L->lock(); @@ -602,6 +604,8 @@ Lua * start_basic_lua(void) { L->open_table(); L->open_dir(); L->open_debug(); + L->open_bit(); + L->open_jit(); Luabaselua_interface::pushstatics(L); @@ -614,7 +618,7 @@ Lua * start_basic_lua(void) { /* That's the extended stuff for interactive mode */ Lua * start_full_lua(void) { - Lua * L = start_basic_lua(); + Lua * L = start_basic_lua(true); Lualua_interface::pushstatics(L); autoload_exports(L); @@ -626,6 +630,7 @@ void showbanner() { printm(M_BARE, "Lua-Interface" LIGHT " version " VERSION " (c) 2003-2009 Nicolas \"Pixel\" Noble\n" LUA_RELEASE " " LUA_COPYRIGHT "\n" +LUAJIT_VERSION " -- " LUAJIT_COPYRIGHT ". " LUAJIT_URL "\n" #ifdef WIP "Special version Work In Progress, compiled the " __DATE__ " at " __TIME__ "\n" #endif @@ -633,6 +638,34 @@ LUA_RELEASE " " LUA_COPYRIGHT "\n" "\n"); } +void showjitstatus(Lua * L) { +#if 0 + int n; + const char *s; + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, -1, "jit"); /* Get jit.* module table. */ + lua_remove(L, -2); + lua_getfield(L, -1, "status"); + lua_remove(L, -2); + n = lua_gettop(L); + lua_call(L, 0, LUA_MULTRET); + fputs(lua_toboolean(L, n) ? "JIT: ON" : "JIT: OFF", stderr); + for (n++; (s = lua_tostring(L, n)); n++) + fprintf(stderr, " %s", s); + fputs("\n", stdout); + + L->push("_LOADED"); + L->gettable(LUA_REGISTRYINDEX); + L->push("jit"); + L->gettable(); + L->push("status"); + L->gettable(); + n = L->gettop(); + L->call(0, LUA_MULTRET); + printm(M_BARE, L->toboolean(n) ? "JIT: ON", "JIT: OFF"); +#endif +} + void showhelp(bool longhelp = false) { printm(M_BARE, "Usage:\n" @@ -648,9 +681,9 @@ void showhelp(bool longhelp = false) { " -e to execute this single command in LUA.\n" " -b to force the use of the built-in lua-interface.lua\n" " -g to log into a file.\n" -" -m [mp] start the mail server on port mp (2500 by default).\n" -" -s [hp] start the built-in http server on port hp (1500 by default).\n" -" -t [tp] start the telnet server, on port tp (1550 by default).\n" +" -m[mp] start the mail server on port mp (2500 by default).\n" +" -s[hp] start the built-in http server on port hp (1500 by default).\n" +" -t[tp] start the telnet server, on port tp (1550 by default).\n" " -f filename of server code to use (server.lua by default).\n" #ifdef HAVE_FORK " -z daemonize; incompatible with -i; use with -g.\n" -- cgit v1.2.3