DataType.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. namespace MoonSharp.Interpreter
  7. {
  8. public enum DataType
  9. {
  10. // standard Lua types
  11. Nil,
  12. Boolean,
  13. Number,
  14. String,
  15. Function,
  16. Table,
  17. Tuple,
  18. UserData,
  19. Thread,
  20. ClrFunction,
  21. TailCallRequest,
  22. }
  23. public static class LuaTypeExtensions
  24. {
  25. public static string ToLuaTypeString(this DataType type)
  26. {
  27. switch (type)
  28. {
  29. case DataType.Nil:
  30. return "nil";
  31. case DataType.Boolean:
  32. return "boolean";
  33. case DataType.Number:
  34. return "number";
  35. case DataType.String:
  36. return "string";
  37. case DataType.Function:
  38. return "function";
  39. case DataType.ClrFunction:
  40. return "function";
  41. case DataType.Table:
  42. return "table";
  43. case DataType.UserData:
  44. return "userdata";
  45. case DataType.Thread:
  46. return "thread";
  47. case DataType.Tuple:
  48. case DataType.TailCallRequest:
  49. default:
  50. throw new ScriptRuntimeException(null, "Unexpected LuaType {0}", type);
  51. }
  52. }
  53. }
  54. }