hash.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. package js
  2. // generated by hasher -file hash.go -type Hash; DO NOT EDIT, except for adding more constants to the list and rerun go generate
  3. // uses github.com/tdewolff/hasher
  4. //go:generate hasher -type=Hash -file=hash.go
  5. // Hash defines perfect hashes for a predefined list of strings
  6. type Hash uint32
  7. // Unique hash definitions to be used instead of strings
  8. const (
  9. Break Hash = 0x5 // break
  10. Case Hash = 0x3404 // case
  11. Catch Hash = 0xba05 // catch
  12. Class Hash = 0x505 // class
  13. Const Hash = 0x2c05 // const
  14. Continue Hash = 0x3e08 // continue
  15. Debugger Hash = 0x8408 // debugger
  16. Default Hash = 0xab07 // default
  17. Delete Hash = 0xcd06 // delete
  18. Do Hash = 0x4c02 // do
  19. Else Hash = 0x3704 // else
  20. Enum Hash = 0x3a04 // enum
  21. Export Hash = 0x1806 // export
  22. Extends Hash = 0x4507 // extends
  23. False Hash = 0x5a05 // false
  24. Finally Hash = 0x7a07 // finally
  25. For Hash = 0xc403 // for
  26. Function Hash = 0x4e08 // function
  27. If Hash = 0x5902 // if
  28. Implements Hash = 0x5f0a // implements
  29. Import Hash = 0x6906 // import
  30. In Hash = 0x4202 // in
  31. Instanceof Hash = 0x710a // instanceof
  32. Interface Hash = 0x8c09 // interface
  33. Let Hash = 0xcf03 // let
  34. New Hash = 0x1203 // new
  35. Null Hash = 0x5504 // null
  36. Package Hash = 0x9507 // package
  37. Private Hash = 0x9c07 // private
  38. Protected Hash = 0xa309 // protected
  39. Public Hash = 0xb506 // public
  40. Return Hash = 0xd06 // return
  41. Static Hash = 0x2f06 // static
  42. Super Hash = 0x905 // super
  43. Switch Hash = 0x2606 // switch
  44. This Hash = 0x2304 // this
  45. Throw Hash = 0x1d05 // throw
  46. True Hash = 0xb104 // true
  47. Try Hash = 0x6e03 // try
  48. Typeof Hash = 0xbf06 // typeof
  49. Var Hash = 0xc703 // var
  50. Void Hash = 0xca04 // void
  51. While Hash = 0x1405 // while
  52. With Hash = 0x2104 // with
  53. Yield Hash = 0x8005 // yield
  54. )
  55. // String returns the hash' name.
  56. func (i Hash) String() string {
  57. start := uint32(i >> 8)
  58. n := uint32(i & 0xff)
  59. if start+n > uint32(len(_Hash_text)) {
  60. return ""
  61. }
  62. return _Hash_text[start : start+n]
  63. }
  64. // ToHash returns the hash whose name is s. It returns zero if there is no
  65. // such hash. It is case sensitive.
  66. func ToHash(s []byte) Hash {
  67. if len(s) == 0 || len(s) > _Hash_maxLen {
  68. return 0
  69. }
  70. h := uint32(_Hash_hash0)
  71. for i := 0; i < len(s); i++ {
  72. h ^= uint32(s[i])
  73. h *= 16777619
  74. }
  75. if i := _Hash_table[h&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) {
  76. t := _Hash_text[i>>8 : i>>8+i&0xff]
  77. for i := 0; i < len(s); i++ {
  78. if t[i] != s[i] {
  79. goto NEXT
  80. }
  81. }
  82. return i
  83. }
  84. NEXT:
  85. if i := _Hash_table[(h>>16)&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) {
  86. t := _Hash_text[i>>8 : i>>8+i&0xff]
  87. for i := 0; i < len(s); i++ {
  88. if t[i] != s[i] {
  89. return 0
  90. }
  91. }
  92. return i
  93. }
  94. return 0
  95. }
  96. const _Hash_hash0 = 0x9acb0442
  97. const _Hash_maxLen = 10
  98. const _Hash_text = "breakclassupereturnewhilexporthrowithiswitchconstaticaselsen" +
  99. "umcontinuextendsdofunctionullifalseimplementsimportryinstanc" +
  100. "eofinallyieldebuggerinterfacepackageprivateprotectedefaultru" +
  101. "epublicatchtypeoforvarvoidelete"
  102. var _Hash_table = [1 << 6]Hash{
  103. 0x0: 0x2f06, // static
  104. 0x1: 0x9c07, // private
  105. 0x3: 0xb104, // true
  106. 0x6: 0x5a05, // false
  107. 0x7: 0x4c02, // do
  108. 0x9: 0x2c05, // const
  109. 0xa: 0x2606, // switch
  110. 0xb: 0x6e03, // try
  111. 0xc: 0x1203, // new
  112. 0xd: 0x4202, // in
  113. 0xf: 0x8005, // yield
  114. 0x10: 0x5f0a, // implements
  115. 0x11: 0xc403, // for
  116. 0x12: 0x505, // class
  117. 0x13: 0x3a04, // enum
  118. 0x16: 0xc703, // var
  119. 0x17: 0x5902, // if
  120. 0x19: 0xcf03, // let
  121. 0x1a: 0x9507, // package
  122. 0x1b: 0xca04, // void
  123. 0x1c: 0xcd06, // delete
  124. 0x1f: 0x5504, // null
  125. 0x20: 0x1806, // export
  126. 0x21: 0xd06, // return
  127. 0x23: 0x4507, // extends
  128. 0x25: 0x2304, // this
  129. 0x26: 0x905, // super
  130. 0x27: 0x1405, // while
  131. 0x29: 0x5, // break
  132. 0x2b: 0x3e08, // continue
  133. 0x2e: 0x3404, // case
  134. 0x2f: 0xab07, // default
  135. 0x31: 0x8408, // debugger
  136. 0x32: 0x1d05, // throw
  137. 0x33: 0xbf06, // typeof
  138. 0x34: 0x2104, // with
  139. 0x35: 0xba05, // catch
  140. 0x36: 0x4e08, // function
  141. 0x37: 0x710a, // instanceof
  142. 0x38: 0xa309, // protected
  143. 0x39: 0x8c09, // interface
  144. 0x3b: 0xb506, // public
  145. 0x3c: 0x3704, // else
  146. 0x3d: 0x7a07, // finally
  147. 0x3f: 0x6906, // import
  148. }