src/tinyl2c.cpp
//////////////////////////////////////////////////////////////////////////
//L2C lua library / utility functions
//////////////////////////////////////////////////////////////////////////
L2C lua library / utility functions
L2C lua library / utility functions
int l2c_printstack(lua_State* L)
{
	l2c_printf("----------------------------\n");
	l2c_printf("LUA Stack:\n");
	int top = lua_gettop(L);
	lua_getglobal(L, "tostring");
	for (int i = 1; i <= top; i++)
	{
	    lua_pushvalue(L, -1);	
		lua_pushvalue(L,i);		
	    lua_call(L, 1, 1);		
		const char* str = lua_tostring(L,-1);
		if (!str) str = "<unprintable>";
		l2c_printf("[%d] %s\n",i,str);
		lua_pop(L,1);			
	}
	lua_pop(L,1); 
	l2c_printf("----------------------------\n");
	return 0;
}
int l2c_printstack ( lua_State * L ) { l2c_printf ( " \n " ) ; l2c_printf ( " \n " ) ; int top = lua_gettop ( L ) ; lua_getglobal ( L , " " ) ; for ( int i = 1 ; i <= top ; i ++ ) { lua_pushvalue ( L , -1 ) ; lua_pushvalue ( L , i ) ; lua_call ( L , 1 , 1 ) ; const char * str = lua_tostring ( L , -1 ) ; if ( ! str ) str = " " ; l2c_printf ( " \n " , i , str ) ; lua_pop ( L , 1 ) ; } lua_pop ( L , 1 ) ; l2c_printf ( " \n " ) ; return 0 ; }
L2C lua library / utility functions
L2C lua library / utility functions
//tostring //stack[i] //convert to string //remove temp //remove tostring