LuaCompiler.cs 1.2 KB

12345678910111213141516171819202122232425262728
  1. using Lua.Runtime;
  2. namespace Lua.CodeAnalysis.Compilation
  3. {
  4. public static class LuaCompiler
  5. {
  6. /// <summary>
  7. /// Lua bytecode signature. If the bytes start with this signature, they are considered as Lua bytecode.
  8. /// </summary>
  9. public static ReadOnlySpan<byte> LuaByteCodeSignature => Header.LuaSignature;
  10. /// <summary>
  11. /// Converts a Lua bytecode to a Prototype object.
  12. /// </summary>
  13. /// <param name="span">binary bytecode</param>
  14. /// <param name="name">chunk name</param>
  15. /// <returns></returns>
  16. public static Prototype UnDump(ReadOnlySpan<byte> span, ReadOnlySpan<char> name) => Parser.UnDump(span, name);
  17. /// <summary>
  18. /// Converts a Prototype object to a Lua bytecode.
  19. /// </summary>
  20. /// <param name="prototype">Prototype object</param>
  21. /// <param name="useLittleEndian">true if the bytecode should be in little endian format, false if it should be in big endian format</param>
  22. /// <returns>binary bytecode</returns>
  23. public static byte[] Dump(Prototype prototype, bool useLittleEndian = true) => Parser.Dump(prototype, useLittleEndian);
  24. }
  25. }