BaseDefinitions.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. using NTERA.Engine.Compiler;
  2. namespace NTERA.Engine.Runtime
  3. {
  4. public static class BaseDefinitions
  5. {
  6. public static FunctionVariable[] DefaultGlobalVariables { get; } =
  7. {
  8. new FunctionVariable("LOCAL", ValueType.Real),
  9. new FunctionVariable("ABL", ValueType.Real),
  10. new FunctionVariable("RESULT", ValueType.Real),
  11. new FunctionVariable("SOURCE", ValueType.Real),
  12. new FunctionVariable("ARG", ValueType.Real),
  13. new FunctionVariable("GLOBAL", ValueType.Real),
  14. new FunctionVariable("IS", ValueType.Real),
  15. new FunctionVariable("CUP", ValueType.Real),
  16. new FunctionVariable("CDOWN", ValueType.Real),
  17. new FunctionVariable("UP", ValueType.Real),
  18. new FunctionVariable("DOWN", ValueType.Real),
  19. new FunctionVariable("DOWNBASE", ValueType.Real),
  20. new FunctionVariable("COUNT", ValueType.Real),
  21. new FunctionVariable("TCVAR", ValueType.Real),
  22. new FunctionVariable("CDFLAG", ValueType.Real),
  23. new FunctionVariable("ITEMPRICE", ValueType.Real),
  24. new FunctionVariable("RANDDATA", ValueType.Real),
  25. new FunctionVariable("LINECOUNT", ValueType.Real),
  26. new FunctionVariable("ISTIMEOUT", ValueType.Real),
  27. new FunctionVariable("__INT_MAX__", ValueType.Real),
  28. new FunctionVariable("__INT_MIN__", ValueType.Real),
  29. new FunctionVariable("RAND", ValueType.Real),
  30. new FunctionVariable("CHARANUM", ValueType.Real),
  31. new FunctionVariable("TALENT", ValueType.Real),
  32. new FunctionVariable("FLAG", ValueType.Real),
  33. new FunctionVariable("TFLAG", ValueType.Real),
  34. new FunctionVariable("CFLAG", ValueType.Real),
  35. new FunctionVariable("MASTER", ValueType.Real),
  36. new FunctionVariable("BASE", ValueType.Real),
  37. new FunctionVariable("MAXBASE", ValueType.Real),
  38. new FunctionVariable("PALAM", ValueType.Real),
  39. new FunctionVariable("TEQUIP", ValueType.Real),
  40. new FunctionVariable("EQUIP", ValueType.Real),
  41. new FunctionVariable("DAY", ValueType.Real),
  42. new FunctionVariable("MARK", ValueType.Real),
  43. new FunctionVariable("PALAMLV", ValueType.Real),
  44. new FunctionVariable("TARGET", ValueType.Real),
  45. new FunctionVariable("PLAYER", ValueType.Real),
  46. new FunctionVariable("NOWEX", ValueType.Real),
  47. new FunctionVariable("EX", ValueType.Real),
  48. new FunctionVariable("STAIN", ValueType.Real),
  49. new FunctionVariable("EXP", ValueType.Real),
  50. new FunctionVariable("ASSIPLAY", ValueType.Real),
  51. new FunctionVariable("ASSI", ValueType.Real),
  52. new FunctionVariable("ITEM", ValueType.Real),
  53. new FunctionVariable("EXPLV", ValueType.Real),
  54. new FunctionVariable("TIME", ValueType.Real),
  55. new FunctionVariable("MONEY", ValueType.Real),
  56. new FunctionVariable("SELECTCOM", ValueType.Real),
  57. new FunctionVariable("PREVCOM", ValueType.Real),
  58. new FunctionVariable("NEXTCOM", ValueType.Real),
  59. new FunctionVariable("DITEMTYPE", ValueType.Real),
  60. new FunctionVariable("NO", ValueType.Real),
  61. new FunctionVariable("RELATION", ValueType.Real),
  62. new FunctionVariable("JUEL", ValueType.Real),
  63. new FunctionVariable("GOTJUEL", ValueType.Real),
  64. new FunctionVariable("EJAC", ValueType.Real),
  65. new FunctionVariable("BOUGHT", ValueType.Real),
  66. new FunctionVariable("ITEMSALES", ValueType.Real),
  67. new FunctionVariable("FORWARD", ValueType.Real), //special casing for SORTCHARA
  68. new FunctionVariable("BACK", ValueType.Real), //special casing for SORTCHARA
  69. new FunctionVariable("LEFT", ValueType.Real), //special casing for __FORMAT
  70. new FunctionVariable("RIGHT", ValueType.Real), //special casing for __FORMAT
  71. new FunctionVariable("DEBUG_MODE", ValueType.Real),
  72. new FunctionVariable("NOITEM", ValueType.Real),
  73. new FunctionVariable("A", ValueType.Real),
  74. new FunctionVariable("B", ValueType.Real),
  75. new FunctionVariable("C", ValueType.Real),
  76. new FunctionVariable("D", ValueType.Real),
  77. new FunctionVariable("E", ValueType.Real),
  78. new FunctionVariable("F", ValueType.Real),
  79. new FunctionVariable("G", ValueType.Real),
  80. new FunctionVariable("H", ValueType.Real),
  81. new FunctionVariable("I", ValueType.Real),
  82. new FunctionVariable("J", ValueType.Real),
  83. new FunctionVariable("K", ValueType.Real),
  84. new FunctionVariable("L", ValueType.Real),
  85. new FunctionVariable("M", ValueType.Real),
  86. new FunctionVariable("N", ValueType.Real),
  87. new FunctionVariable("O", ValueType.Real),
  88. new FunctionVariable("P", ValueType.Real),
  89. new FunctionVariable("Q", ValueType.Real),
  90. new FunctionVariable("R", ValueType.Real),
  91. new FunctionVariable("S", ValueType.Real),
  92. new FunctionVariable("T", ValueType.Real),
  93. new FunctionVariable("U", ValueType.Real),
  94. new FunctionVariable("V", ValueType.Real),
  95. new FunctionVariable("W", ValueType.Real),
  96. new FunctionVariable("X", ValueType.Real),
  97. new FunctionVariable("Y", ValueType.Real),
  98. new FunctionVariable("Z", ValueType.Real),
  99. new FunctionVariable("LOCALS", ValueType.String),
  100. new FunctionVariable("ARGS", ValueType.String),
  101. new FunctionVariable("RESULTS", ValueType.String),
  102. new FunctionVariable("CSTR", ValueType.String),
  103. new FunctionVariable("GLOBALS", ValueType.String),
  104. new FunctionVariable("NICKNAME", ValueType.String),
  105. new FunctionVariable("MASTERNAME", ValueType.String),
  106. new FunctionVariable("NAME", ValueType.String),
  107. new FunctionVariable("TRAINNAME", ValueType.String),
  108. new FunctionVariable("BASENAME", ValueType.String),
  109. new FunctionVariable("EQUIPNAME", ValueType.String),
  110. new FunctionVariable("TEQUIPNAME", ValueType.String),
  111. new FunctionVariable("STAINNAME", ValueType.String),
  112. new FunctionVariable("EXNAME", ValueType.String),
  113. new FunctionVariable("SOURCENAME", ValueType.String),
  114. new FunctionVariable("CALLNAME", ValueType.String),
  115. new FunctionVariable("FLAGNAME", ValueType.String),
  116. new FunctionVariable("TFLAGNAME", ValueType.String),
  117. new FunctionVariable("CFLAGNAME", ValueType.String),
  118. new FunctionVariable("TCVARNAME", ValueType.String),
  119. new FunctionVariable("STRNAME", ValueType.String),
  120. new FunctionVariable("TSTRNAME", ValueType.String),
  121. new FunctionVariable("CSTRNAME", ValueType.String),
  122. new FunctionVariable("SAVESTRNAME", ValueType.String),
  123. new FunctionVariable("CDFLAGNAME", ValueType.String),
  124. new FunctionVariable("GLOBALNAME", ValueType.String),
  125. new FunctionVariable("GLOBALSNAME", ValueType.String),
  126. new FunctionVariable("GAMEBASE_AUTHOR", ValueType.String),
  127. new FunctionVariable("GAMEBASE_INFO", ValueType.String),
  128. new FunctionVariable("GAMEBASE_YEAR", ValueType.String),
  129. new FunctionVariable("GAMEBASE_TITLE", ValueType.String),
  130. new FunctionVariable("GAMEBASE_GAMECODE", ValueType.String),
  131. new FunctionVariable("GAMEBASE_VERSION", ValueType.String),
  132. new FunctionVariable("GAMEBASE_ALLOWVERSION", ValueType.String),
  133. new FunctionVariable("GAMEBASE_DEFAULTCHARA", ValueType.String),
  134. new FunctionVariable("GAMEBASE_NOITEM", ValueType.String),
  135. new FunctionVariable("WINDOW_TITLE", ValueType.String),
  136. new FunctionVariable("MONEYLABEL", ValueType.String),
  137. new FunctionVariable("DRAWLINESTR", ValueType.String),
  138. new FunctionVariable("LASTLOAD_VERSION", ValueType.String),
  139. new FunctionVariable("LASTLOAD_NO", ValueType.String),
  140. new FunctionVariable("LASTLOAD_TEXT", ValueType.String),
  141. new FunctionVariable("SAVEDATA_TEXT", ValueType.String),
  142. new FunctionVariable("TSTR", ValueType.String),
  143. new FunctionVariable("STR", ValueType.String),
  144. new FunctionVariable("SAVESTR", ValueType.String),
  145. new FunctionVariable("ABLNAME", ValueType.String),
  146. new FunctionVariable("MARKNAME", ValueType.String),
  147. new FunctionVariable("TALENTNAME", ValueType.String),
  148. new FunctionVariable("ITEMNAME", ValueType.String),
  149. new FunctionVariable("PALAMNAME", ValueType.String),
  150. new FunctionVariable("EXPNAME", ValueType.String)
  151. };
  152. public static FunctionDefinition[] DefaultGlobalFunctions { get; } =
  153. {
  154. new FunctionDefinition("ABS", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  155. new FunctionDefinition("SQRT", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  156. new FunctionDefinition("SIGN", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  157. new FunctionDefinition("CSVCALLNAME", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  158. new FunctionDefinition("TOFULL", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  159. new FunctionDefinition("TOINT", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  160. new FunctionDefinition("RAND", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("b", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  161. new FunctionDefinition("VARSIZE", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("b", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  162. new FunctionDefinition("TOSTR", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("b", new string[0], "") }, new FunctionVariable[0], true, "_GLOBAL"),
  163. new FunctionDefinition("TOUPPER", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  164. new FunctionDefinition("TOLOWER", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  165. new FunctionDefinition("TOHALF", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  166. new FunctionDefinition("TOFULL", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  167. new FunctionDefinition("TOUPPER", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  168. new FunctionDefinition("ISNUMERIC", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  169. new FunctionDefinition("LOG10", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  170. new FunctionDefinition("ESCAPE", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  171. new FunctionDefinition("STRCOUNT", new[] { new FunctionParameter("input", new string[0]), new FunctionParameter("match", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  172. new FunctionDefinition("MIN", new[] { new FunctionParameter("a", new string[0], isArrayParameter: true) }, new FunctionVariable[0], true, "_GLOBAL"),
  173. new FunctionDefinition("MAX", new[] { new FunctionParameter("a", new string[0], isArrayParameter: true) }, new FunctionVariable[0], true, "_GLOBAL"),
  174. new FunctionDefinition("POWER", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("b", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  175. new FunctionDefinition("GETPALAMLV", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("b", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  176. new FunctionDefinition("GETBIT", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("b", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  177. new FunctionDefinition("GETEXPLV", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("b", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  178. new FunctionDefinition("UNICODE", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  179. new FunctionDefinition("MATCH", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("b", new string[0]), new FunctionParameter("c", new string[0], "a"), new FunctionParameter("d", new string[0], "f") }, new FunctionVariable[0], true, "_GLOBAL"),
  180. new FunctionDefinition("INRANGE", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("b", new string[0]), new FunctionParameter("c", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  181. new FunctionDefinition("HE_SHE", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  182. new FunctionDefinition("SUBSTRING", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  183. new FunctionDefinition("STRLENS", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  184. new FunctionDefinition("CSVNAME", new[] { new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  185. new FunctionDefinition("CSVNAME", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  186. new FunctionDefinition("CSVBASE", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  187. new FunctionDefinition("CSVTALENT", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  188. new FunctionDefinition("CSVCFLAG", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  189. new FunctionDefinition("CSVRELATION", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  190. new FunctionDefinition("CSVCSTR", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  191. new FunctionDefinition("CSVEXP", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  192. new FunctionDefinition("CSVABL", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  193. new FunctionDefinition("GETNUM", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  194. new FunctionDefinition("FINDCHARA", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  195. new FunctionDefinition("LIMIT", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  196. new FunctionDefinition("SUMCARRAY", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  197. new FunctionDefinition("MAXCARRAY", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  198. new FunctionDefinition("SUBSTRINGU", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  199. new FunctionDefinition("FINDELEMENT", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0]) }, new FunctionVariable[0], true, "_GLOBAL"),
  200. new FunctionDefinition("GROUPMATCH", new[] { new FunctionParameter("a", new string[0]), new FunctionParameter("a", new string[0], isArrayParameter: true) }, new FunctionVariable[0], true, "_GLOBAL"),
  201. new FunctionDefinition("GETTIME", new FunctionParameter[0], new FunctionVariable[0], true, "_GLOBAL"),
  202. new FunctionDefinition("SAVENOS", new FunctionParameter[0], new FunctionVariable[0], true, "_GLOBAL"),
  203. new FunctionDefinition("GETCOLOR", new FunctionParameter[0], new FunctionVariable[0], true, "_GLOBAL"),
  204. new FunctionDefinition("CURRENTREDRAW", new FunctionParameter[0], new FunctionVariable[0], true, "_GLOBAL"),
  205. new FunctionDefinition("GETFONT", new FunctionParameter[0], new FunctionVariable[0], true, "_GLOBAL"),
  206. new FunctionDefinition("GETMILLISECOND", new FunctionParameter[0], new FunctionVariable[0], true, "_GLOBAL")
  207. };
  208. public static Keyword[] DefaultKeywords { get; } =
  209. {
  210. new Keyword("DRAWLINEFORM", true, true),
  211. new Keyword("PRINTFORML", true, true),
  212. new Keyword("DATAFORM", true, true),
  213. new Keyword("PRINTFORMD", true, true),
  214. new Keyword("PRINTFORMDL", true, true),
  215. new Keyword("PRINTFORMW", true, true),
  216. new Keyword("PRINTFORMDW", true, true),
  217. new Keyword("PRINTFORMC", true, true),
  218. new Keyword("PRINTFORMLC", true, true),
  219. new Keyword("PRINTFORM", true, true),
  220. new Keyword("PRINTPLAINFORM", true, true),
  221. new Keyword("DEBUGPRINTFORM", true, true),
  222. new Keyword("DEBUGPRINTFORML", true, true),
  223. new Keyword("THROW", true, true),
  224. new Keyword("PRINT", true),
  225. new Keyword("PRINTD", true),
  226. new Keyword("PRINTDW", true),
  227. new Keyword("PRINTDL", true),
  228. new Keyword("PRINTW", true),
  229. new Keyword("PRINTV", true),
  230. new Keyword("PRINTL", true),
  231. new Keyword("PRINTLC", true),
  232. new Keyword("PRINTC", true),
  233. new Keyword("ALIGNMENT", true),
  234. new Keyword("CALL", true, true),
  235. new Keyword("CUSTOMDRAWLINE", true),
  236. new Keyword("GOTO", true),
  237. new Keyword("DEBUGPRINTL", true),
  238. new Keyword("REUSELASTLINE", true),
  239. new Keyword("PRINTPLAIN", true),
  240. new Keyword("PRINT_TRAIN_NAME", true),
  241. new Keyword("PRINT_STR", true),
  242. };
  243. }
  244. }