Exemplo n.º 1
0
static void do_compile(ZIO* z)
{
 TProtoFunc* Main;
 if (optimizing) L->debug=0;
 if (debugging)  L->debug=1;
 Main=luaY_parser(z);
 if (optimizing) luaU_optchunk(Main);
 if (listing) luaU_printchunk(Main);
 if (testing) luaU_testchunk(Main);
 if (dumping) luaU_dumpchunk(Main,D,native);
}
Exemplo n.º 2
0
static void do_undump(ZIO* z)
{
 for (;;)
 {
  TProtoFunc* Main=luaU_undump1(z);
  if (Main==NULL) break;
  if (optimizing) luaU_optchunk(Main);
  if (listing) luaU_printchunk(Main);
  if (testing) luaU_testchunk(Main);
 }
}
Exemplo n.º 3
0
Arquivo: luac.c Projeto: jcubic/ToME
/*
 * Compiles src lua source to dest lua bytecode
 * Bytecode is quicker to load as it is preparsed and optimized.
 * This function does NOT understands ToME virtual paths they
 * need to be converted first, this is intentionnal
 */
s32b tome_compile_lua(char *src)
{
	char *split;
	char dest[2048];
	Proto *tf;
	PHYSFS_file *dump;

	/* Clear error state */
	PHYSFS_getLastError();

        /* A new empty lua state */
	compile_lua_state = lua_open(0);

	tf = load(src);

        /* If we dump we need to optimize */
	if (tome_compile_lua_optimizing) luaU_optchunk(tf);

	/* Dump to a file */

	if (tome_compile_lua_stripping) strip(tf);

	/* Make up the destination file .lua => .lb */
	strncpy(dest, src, 2048);
	dest[strlen(dest) - 2] = 'b';
	dest[strlen(dest) - 1] = '\0';

	/* Make sure distination exists */
	split = strrchr(dest, '/');
	*split = '\0';
	PHYSFS_mkdir(dest);
	*split = '/';

	dump = efopen(dest, "wb");
	if (dump == NULL)
		quit("Could not compile lua: error writting");
	PHYSFS_getLastError();
	luaU_dumpchunk_file(tf, dump);
	my_fclose(dump);

	/* Clean up */
/* For a strange reasons this totaly panics lua ... 	lua_close(compile_lua_state); */

	return 0;
}
Exemplo n.º 4
0
int main(int argc, const char* argv[])
{
 Proto** P,*tf;
 int i=doargs(argc,argv);
 argc-=i; argv+=i;
 if (argc<=0) usage("no input files given",NULL);
 L=lua_open(0);
 P=luaM_newvector(L,argc,Proto*);
 for (i=0; i<argc; i++)
  P[i]=load(IS("-")? NULL : argv[i]);
 tf=combine(P,argc);
 if (dumping) luaU_optchunk(tf);
 if (listing) luaU_printchunk(tf);
 if (testing) luaU_testchunk(tf);
 if (dumping)
 {
  if (stripping) strip(tf);
  luaU_dumpchunk(tf,efopen(output,"wb"));
 }
 return 0;
}