dummy_strings.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. --
  2. -- File: LFS_dummy_strings.lua
  3. --[[
  4. luac.cross -f generates a ROM string table which is part of the compiled LFS
  5. image. This table includes all strings referenced in the loaded modules.
  6. If you want to preload other string constants, then one way to achieve this is
  7. to include a dummy module in the LFS that references the strings that you want
  8. to load. You never need to call this module; it's inclusion in the LFS image is
  9. enough to add the strings to the ROM table. Your application can use any strings
  10. in the ROM table without incuring any RAM or Lua Garbage Collector (LGC)
  11. overhead.
  12. The local preload example is a useful starting point. However, if you call the
  13. following code in your application during testing, then this will provide a
  14. listing of the current RAM string table.
  15. do
  16. local a=debug.getstrings'RAM'
  17. for i =1, #a do a[i] = ('%q'):format(a[i]) end
  18. print ('local preload='..table.concat(a,','))
  19. end
  20. This will exclude any strings already in the ROM table, so the output is the list
  21. of putative strings that you should consider adding to LFS ROM table.
  22. ---------------------------------------------------------------------------------]]
  23. local preload = "?.lc;?.lua", "/\n;\n?\n!\n-", "@init.lua", "_G", "_LOADED",
  24. "_LOADLIB", "__add", "__call", "__concat", "__div", "__eq", "__gc", "__index",
  25. "__le", "__len", "__lt", "__mod", "__mode", "__mul", "__newindex", "__pow",
  26. "__sub", "__tostring", "__unm", "collectgarbage", "cpath", "debug", "file",
  27. "file.obj", "file.vol", "flash", "getstrings", "index", "ipairs", "list", "loaded",
  28. "loader", "loaders", "loadlib", "module", "net.tcpserver", "net.tcpsocket",
  29. "net.udpsocket", "newproxy", "package", "pairs", "path", "preload", "reload",
  30. "require", "seeall", "wdclr", "not enough memory", "sjson.decoder","sjson.encoder",
  31. "tmr.timer"