ranger-compiler 2.1.69 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/README.md +991 -96
  3. package/{compiler/Lang.clj → dist/Lang.rgr} +2345 -75
  4. package/dist/README.md +116 -0
  5. package/dist/{bin/api.d.ts → api.d.ts} +430 -154
  6. package/dist/api.js +34345 -0
  7. package/{lib/Ajax.clj → dist/lib/Ajax.rgr} +1 -1
  8. package/{lib/CmdParams.clj → dist/lib/CmdParams.rgr} +72 -72
  9. package/{lib/Crypto.clj → dist/lib/Crypto.rgr} +1 -1
  10. package/{lib/DOMLib.clj → dist/lib/DOMLib.rgr} +2 -2
  11. package/{lib/Engine3D.clj → dist/lib/Engine3D.rgr} +1 -1
  12. package/{lib/ImmutableVector.clj → dist/lib/ImmutableVector.rgr} +364 -364
  13. package/{lib/IndexedDB.clj → dist/lib/IndexedDB.rgr} +1 -1
  14. package/{lib/JSON.clj → dist/lib/JSON.rgr} +105 -2
  15. package/{lib/JinxProcess.clj → dist/lib/JinxProcess.rgr} +3 -3
  16. package/{lib/Storage.clj → dist/lib/Storage.rgr} +1 -1
  17. package/{lib/Timers.clj → dist/lib/Timers.rgr} +176 -170
  18. package/{lib/ViewLib.clj → dist/lib/ViewLib.rgr} +1 -1
  19. package/dist/lib/lib/ACEEditor.rgr +5 -0
  20. package/dist/lib/lib/Ajax.rgr +196 -0
  21. package/dist/lib/lib/CmdParams.rgr +72 -0
  22. package/dist/lib/lib/Crypto.rgr +90 -0
  23. package/dist/lib/lib/DOMLib.rgr +307 -0
  24. package/{examples/3D/Engine3D.clj → dist/lib/lib/Engine3D.rgr} +870 -857
  25. package/dist/lib/lib/ImmutableVector.rgr +364 -0
  26. package/dist/lib/lib/IndexedDB.rgr +32 -0
  27. package/{compiler/JSON.clj → dist/lib/lib/JSON.rgr} +106 -3
  28. package/dist/lib/lib/JinxProcess.rgr +838 -0
  29. package/dist/lib/lib/SQL.rgr +44 -0
  30. package/dist/lib/lib/ServiceLib.rgr +9 -0
  31. package/dist/lib/lib/Storage.rgr +89 -0
  32. package/dist/lib/lib/Time.rgr +75 -0
  33. package/dist/lib/lib/Timers.rgr +176 -0
  34. package/dist/lib/lib/TypedArrays.rgr +14 -0
  35. package/dist/lib/lib/ViewLib.rgr +851 -0
  36. package/dist/lib/lib/WebLib.rgr +47 -0
  37. package/dist/lib/lib/WebServerLib.rgr +137 -0
  38. package/{lib/ranger-dir.clj → dist/lib/lib/ranger-dir.rgr} +1 -1
  39. package/{compiler/stdlib.clj → dist/lib/lib/stdlib.rgr} +42 -19
  40. package/{lib/stdops.clj → dist/lib/lib/stdops.rgr} +1 -1
  41. package/dist/lib/ranger-dir.rgr +175 -0
  42. package/{lib/stdlib.clj → dist/lib/stdlib.rgr} +2 -2
  43. package/dist/lib/stdops.rgr +168 -0
  44. package/dist/package.json +47 -0
  45. package/{bin/output.js → dist/rgrc.js} +15377 -7935
  46. package/dist/stdops.rgr +168 -0
  47. package/package.json +196 -38
  48. package/adventofcode/day1/bin/LambdaSignature1.java +0 -3
  49. package/adventofcode/day1/bin/LambdaSignature2.java +0 -3
  50. package/adventofcode/day1/bin/LambdaSignature3.java +0 -3
  51. package/adventofcode/day1/bin/day1.cpp +0 -124
  52. package/adventofcode/day1/bin/day1.go +0 -75
  53. package/adventofcode/day1/bin/day1.js +0 -45
  54. package/adventofcode/day1/bin/day1.php +0 -46
  55. package/adventofcode/day1/bin/day1.scala +0 -48
  56. package/adventofcode/day1/bin/day1.swift +0 -48
  57. package/adventofcode/day1/bin/day1_part2.cpp +0 -180
  58. package/adventofcode/day1/bin/day1_part2.go +0 -123
  59. package/adventofcode/day1/bin/day1_part2.js +0 -76
  60. package/adventofcode/day1/bin/day1_part2.php +0 -88
  61. package/adventofcode/day1/bin/day1_part2.scala +0 -81
  62. package/adventofcode/day1/bin/day1_part2.swift +0 -91
  63. package/adventofcode/day1/bin/day_one.java +0 -38
  64. package/adventofcode/day1/bin/day_one_part_two.java +0 -57
  65. package/adventofcode/day1/bin/operatorsOf.java +0 -37
  66. package/adventofcode/day1/bin/operatorsOf_5.java +0 -10
  67. package/adventofcode/day1/bin/operatorsOfboolean_5.java +0 -10
  68. package/adventofcode/day1/bin/variant.hpp +0 -2416
  69. package/adventofcode/day1/compile.bat +0 -7
  70. package/adventofcode/day1/compile2.bat +0 -7
  71. package/adventofcode/day1/day1.clj +0 -19
  72. package/adventofcode/day1/day1_part2.clj +0 -43
  73. package/adventofcode/day1/input1.txt +0 -1
  74. package/adventofcode/day2/bin/LambdaSignature1.class +0 -0
  75. package/adventofcode/day2/bin/LambdaSignature1.java +0 -3
  76. package/adventofcode/day2/bin/LambdaSignature2.class +0 -0
  77. package/adventofcode/day2/bin/LambdaSignature2.java +0 -3
  78. package/adventofcode/day2/bin/day2.cpp +0 -133
  79. package/adventofcode/day2/bin/day2.go +0 -85
  80. package/adventofcode/day2/bin/day2.js +0 -45
  81. package/adventofcode/day2/bin/day2.php +0 -59
  82. package/adventofcode/day2/bin/day2.scala +0 -54
  83. package/adventofcode/day2/bin/day2.swift +0 -62
  84. package/adventofcode/day2/bin/day2_part2.cpp +0 -150
  85. package/adventofcode/day2/bin/day2_part2.go +0 -101
  86. package/adventofcode/day2/bin/day2_part2.js +0 -54
  87. package/adventofcode/day2/bin/day2_part2.php +0 -80
  88. package/adventofcode/day2/bin/day2_part2.scala +0 -68
  89. package/adventofcode/day2/bin/day2_part2.swift +0 -82
  90. package/adventofcode/day2/bin/day_two.java +0 -61
  91. package/adventofcode/day2/bin/day_two_part_two$1$1$1.class +0 -0
  92. package/adventofcode/day2/bin/day_two_part_two$1$1.class +0 -0
  93. package/adventofcode/day2/bin/day_two_part_two$1.class +0 -0
  94. package/adventofcode/day2/bin/day_two_part_two.class +0 -0
  95. package/adventofcode/day2/bin/day_two_part_two.java +0 -80
  96. package/adventofcode/day2/bin/operatorsOf.class +0 -0
  97. package/adventofcode/day2/bin/operatorsOf.java +0 -18
  98. package/adventofcode/day2/bin/variant.hpp +0 -2416
  99. package/adventofcode/day2/compile.bat +0 -7
  100. package/adventofcode/day2/compile2.bat +0 -7
  101. package/adventofcode/day2/day2.clj +0 -60
  102. package/adventofcode/day2/day2_part2.clj +0 -69
  103. package/adventofcode/day2/input1.txt +0 -1
  104. package/adventofcode/day3/bin/Grid.java +0 -92
  105. package/adventofcode/day3/bin/GridRow.java +0 -5
  106. package/adventofcode/day3/bin/LambdaSignature1.java +0 -3
  107. package/adventofcode/day3/bin/LambdaSignature2.java +0 -3
  108. package/adventofcode/day3/bin/LambdaSignature3.java +0 -3
  109. package/adventofcode/day3/bin/day3.cpp +0 -64
  110. package/adventofcode/day3/bin/day3.go +0 -55
  111. package/adventofcode/day3/bin/day3.js +0 -42
  112. package/adventofcode/day3/bin/day3.php +0 -41
  113. package/adventofcode/day3/bin/day3.scala +0 -52
  114. package/adventofcode/day3/bin/day3.swift +0 -43
  115. package/adventofcode/day3/bin/day3_part2.cpp +0 -216
  116. package/adventofcode/day3/bin/day3_part2.go +0 -188
  117. package/adventofcode/day3/bin/day3_part2.js +0 -123
  118. package/adventofcode/day3/bin/day3_part2.php +0 -135
  119. package/adventofcode/day3/bin/day3_part2.swift +0 -131
  120. package/adventofcode/day3/bin/day_three_part_two.java +0 -43
  121. package/adventofcode/day3/bin/day_two.java +0 -42
  122. package/adventofcode/day3/bin/operatorsOf.java +0 -14
  123. package/adventofcode/day3/bin/variant.hpp +0 -2416
  124. package/adventofcode/day3/compile.bat +0 -7
  125. package/adventofcode/day3/compile2.bat +0 -7
  126. package/adventofcode/day3/day3.clj +0 -42
  127. package/adventofcode/day3/day3_part2.clj +0 -112
  128. package/adventofcode/day4/bin/LambdaSignature1.java +0 -3
  129. package/adventofcode/day4/bin/day4.cpp +0 -118
  130. package/adventofcode/day4/bin/day4.go +0 -75
  131. package/adventofcode/day4/bin/day4.js +0 -40
  132. package/adventofcode/day4/bin/day4.php +0 -52
  133. package/adventofcode/day4/bin/day4.scala +0 -47
  134. package/adventofcode/day4/bin/day4.swift +0 -56
  135. package/adventofcode/day4/bin/day4_part2.go +0 -129
  136. package/adventofcode/day4/bin/day4_part2.js +0 -72
  137. package/adventofcode/day4/bin/day_four.java +0 -41
  138. package/adventofcode/day4/bin/inputData.java +0 -7
  139. package/adventofcode/day4/bin/operatorsOf.java +0 -11
  140. package/adventofcode/day4/bin/variant.hpp +0 -2416
  141. package/adventofcode/day4/compile.bat +0 -7
  142. package/adventofcode/day4/compile2.bat +0 -7
  143. package/adventofcode/day4/day4.clj +0 -32
  144. package/adventofcode/day4/day4_part2.clj +0 -44
  145. package/adventofcode/day4/input.clj +0 -519
  146. package/adventofcode/day4/input.txt +0 -512
  147. package/bin/api.ts +0 -24471
  148. package/bin/compiler.ts +0 -24482
  149. package/compiler/ColorConsole.clj +0 -22
  150. package/compiler/ContextOperators.clj +0 -75
  151. package/compiler/FlowEnterVarDef.clj +0 -223
  152. package/compiler/InputFileSystem.clj +0 -276
  153. package/compiler/RangerDocs.clj +0 -7
  154. package/compiler/TFactory.clj +0 -146
  155. package/compiler/TFiles.clj +0 -23
  156. package/compiler/TFlow.clj +0 -39
  157. package/compiler/TNodeFactory.clj +0 -84
  158. package/compiler/TTypes.clj +0 -188
  159. package/compiler/VirtualCompiler.clj +0 -800
  160. package/compiler/bin/ng_Compiler.js +0 -23779
  161. package/compiler/commonmark_plugin.clj +0 -359
  162. package/compiler/feat2.bat +0 -2
  163. package/compiler/feats.bat +0 -9
  164. package/compiler/feature_tests.clj +0 -192
  165. package/compiler/index.js +0 -2
  166. package/compiler/issue_57.clj +0 -25
  167. package/compiler/makefile_plugin.clj +0 -135
  168. package/compiler/markdown_plugin.clj +0 -386
  169. package/compiler/maven_plugin.clj +0 -162
  170. package/compiler/ng_AndroidPageWriter.clj +0 -299
  171. package/compiler/ng_CodeNode.clj +0 -756
  172. package/compiler/ng_CodeNodeCompilerExtensions.clj +0 -839
  173. package/compiler/ng_Compiler.clj +0 -49
  174. package/compiler/ng_CompilerGeneric.clj +0 -260
  175. package/compiler/ng_CompilerOrig.clj +0 -854
  176. package/compiler/ng_DictNode.clj +0 -346
  177. package/compiler/ng_DictNode2.clj +0 -316
  178. package/compiler/ng_Execute.clj +0 -138
  179. package/compiler/ng_Execute1.clj +0 -129
  180. package/compiler/ng_FlowWork.clj +0 -3951
  181. package/compiler/ng_LiveCompiler.clj +0 -1109
  182. package/compiler/ng_RagnerJavaScriptClassWriter.clj +0 -402
  183. package/compiler/ng_RangerActiveOperators.clj +0 -86
  184. package/compiler/ng_RangerAppClassDesc.clj +0 -400
  185. package/compiler/ng_RangerAppEnums.clj +0 -86
  186. package/compiler/ng_RangerAppFunctionDesc.clj +0 -127
  187. package/compiler/ng_RangerAppMessages.clj +0 -15
  188. package/compiler/ng_RangerAppOperatorDesc.clj +0 -20
  189. package/compiler/ng_RangerAppParamDesc.clj +0 -388
  190. package/compiler/ng_RangerAppWriterContext.clj +0 -1793
  191. package/compiler/ng_RangerArgMatch.clj +0 -638
  192. package/compiler/ng_RangerCSharpClassWriter.clj +0 -484
  193. package/compiler/ng_RangerCppClassWriter.clj +0 -1023
  194. package/compiler/ng_RangerDocGenerator.clj +0 -305
  195. package/compiler/ng_RangerFlowParser.clj +0 -4992
  196. package/compiler/ng_RangerFlowParserOrig.clj +0 -4002
  197. package/compiler/ng_RangerGenericClassWriter.clj +0 -573
  198. package/compiler/ng_RangerGolangClassWriter.clj +0 -1766
  199. package/compiler/ng_RangerImmutableExtension.clj +0 -77
  200. package/compiler/ng_RangerJava7ClassWriter.clj +0 -961
  201. package/compiler/ng_RangerJavaScriptClassWriter.clj +0 -1042
  202. package/compiler/ng_RangerKotlinClassWriter.clj +0 -372
  203. package/compiler/ng_RangerLanguageWriters.clj +0 -14
  204. package/compiler/ng_RangerLispParser.clj +0 -873
  205. package/compiler/ng_RangerPHPClassWriter.clj +0 -643
  206. package/compiler/ng_RangerPlugin.clj +0 -41
  207. package/compiler/ng_RangerRangerClassWriter.clj +0 -357
  208. package/compiler/ng_RangerRustClassWriter.clj +0 -420
  209. package/compiler/ng_RangerScalaClassWriter.clj +0 -818
  210. package/compiler/ng_RangerSerializeClass.clj +0 -502
  211. package/compiler/ng_RangerServiceBuilder.clj +0 -63
  212. package/compiler/ng_RangerSwift3ClassWriter.clj +0 -809
  213. package/compiler/ng_RangerSwiftClassWriter.clj +0 -0
  214. package/compiler/ng_RangerTypeClass.clj +0 -45
  215. package/compiler/ng_SourceParser.clj +0 -241
  216. package/compiler/ng_SourceParser2.clj +0 -214
  217. package/compiler/ng_WebPageWriter.clj +0 -39
  218. package/compiler/ng_jsonParser.clj +0 -340
  219. package/compiler/ng_p_test.clj +0 -1711
  220. package/compiler/ng_parser.clj +0 -911
  221. package/compiler/ng_parser2.clj +0 -735
  222. package/compiler/ng_parser2_backup.clj +0 -1679
  223. package/compiler/ng_parser_backup.clj +0 -886
  224. package/compiler/ng_parser_ok.clj +0 -1718
  225. package/compiler/ng_parser_ok2.clj +0 -1717
  226. package/compiler/ng_parser_std_match.clj +0 -687
  227. package/compiler/ng_parser_std_match2.clj +0 -1012
  228. package/compiler/ng_parser_v2.clj +0 -1251
  229. package/compiler/ng_ui.clj +0 -403
  230. package/compiler/ng_ui_test.clj +0 -18
  231. package/compiler/ng_writer.clj +0 -338
  232. package/compiler/ng_xmlParser.clj +0 -472
  233. package/compiler/ng_xmlParser2.clj +0 -317
  234. package/compiler/ng_xmlParser3.clj +0 -251
  235. package/compiler/opdoc.bat +0 -4
  236. package/compiler/operators.md +0 -290
  237. package/compiler/p.bat +0 -4
  238. package/compiler/package.json +0 -10
  239. package/compiler/pcmd.bat +0 -4
  240. package/compiler/pcmd2.bat +0 -3
  241. package/compiler/plaintext_plugin.clj +0 -69
  242. package/compiler/plugin.bat +0 -19
  243. package/compiler/plugin2.bat +0 -4
  244. package/compiler/plugin_app.bat +0 -3
  245. package/compiler/plugin_apps.clj +0 -27
  246. package/compiler/plugins.bat +0 -10
  247. package/compiler/reveal_plugin.clj +0 -409
  248. package/compiler/simplePlugin.clj +0 -780
  249. package/compiler/t.bat +0 -3
  250. package/compiler/test_any.clj +0 -43
  251. package/compiler/test_call.clj +0 -141
  252. package/compiler/test_chain.clj +0 -79
  253. package/compiler/test_json.clj +0 -10
  254. package/compiler/test_lambda.clj +0 -153
  255. package/compiler/test_pcmd.clj +0 -32
  256. package/compiler/test_pcmd2.clj +0 -29
  257. package/compiler/test_plugin.clj +0 -237
  258. package/compiler/test_readfile.clj +0 -13
  259. package/compiler/test_reveal.clj +0 -19
  260. package/compiler/test_slides.clj +0 -312
  261. package/compiler/test_types.clj +0 -143
  262. package/compiler/test_types2.clj +0 -49
  263. package/compiler/test_types3.clj +0 -53
  264. package/compiler/test_var.clj +0 -40
  265. package/compiler/tonpm.bat +0 -14
  266. package/compiler/tonpm2.bat +0 -12
  267. package/compiler/ui_plugin.clj +0 -507
  268. package/compiler/ui_plugin2.clj +0 -427
  269. package/compiler/update-git.bat +0 -3
  270. package/compiler/vcomp.bat +0 -4
  271. package/compiler/viewbuilder_Android.clj +0 -176
  272. package/compiler/viewbuilder_Web.clj +0 -105
  273. package/dist/bin/api.js +0 -32422
  274. package/dist/bin/api.js.map +0 -1
  275. package/dist/bin/compiler.d.ts +0 -1638
  276. package/dist/bin/compiler.js +0 -32444
  277. package/dist/bin/compiler.js.map +0 -1
  278. package/examples/3D/bin/test_3d.js +0 -329
  279. package/examples/3D/test_3d.clj +0 -385
  280. package/examples/EVGColor/EVGColor.clj +0 -310
  281. package/examples/EVGColor/EVGColorContext.clj +0 -176
  282. package/examples/EVGColor/bin/EVGColor.js +0 -286
  283. package/examples/EVGColor/bin/minimized.js +0 -286
  284. package/examples/SVGPath/SVGPath.clj +0 -625
  285. package/examples/SVGPath/Vec2.clj +0 -103
  286. package/examples/SVGPath/bin/SVGPath.cpp +0 -887
  287. package/examples/SVGPath/bin/SVGPath.js +0 -682
  288. package/examples/SVGPath/bin/minimized.js +0 -578
  289. package/examples/SVGPath/bin/variant.hpp +0 -2416
  290. package/examples/minification/Vec2.clj +0 -103
  291. package/examples/minification/bin/minified.js +0 -44
  292. package/examples/minification/bin/test.js +0 -117
  293. package/examples/minification/test.clj +0 -13
  294. package/fiddle/VirtualCompiler.js +0 -23495
  295. package/fiddle/browser_editor.js +0 -13240
  296. package/fiddle/compileEnv.js +0 -1
  297. package/fiddle/compileEnv.json +0 -1
  298. package/fiddle/lang_data.js +0 -1
  299. package/index.html +0 -18
  300. package/native/httpd/HttpTester.clj +0 -33
  301. package/native/httpd/RangerWebService.clj +0 -81
  302. package/operators.md +0 -290
  303. package/tsconfig.json +0 -29
  304. package/versions/cpp/compiler.cpp +0 -15032
  305. package/versions/es6/compiler.js +0 -12860
  306. package/versions/go/compiler.go +0 -21338
  307. package/versions/java/AfterCodeNode.java +0 -4
  308. package/versions/java/ClassJoinPoint.java +0 -6
  309. package/versions/java/CodeFile.java +0 -42
  310. package/versions/java/CodeFileSystem.java +0 -72
  311. package/versions/java/CodeNode.java +0 -807
  312. package/versions/java/CodeSlice.java +0 -13
  313. package/versions/java/CodeWriter.java +0 -185
  314. package/versions/java/ColorConsole.java +0 -8
  315. package/versions/java/CompilerInterface.java +0 -213
  316. package/versions/java/DictNode.java +0 -353
  317. package/versions/java/LiveCompiler.java +0 -772
  318. package/versions/java/NodeEvalState.java +0 -24
  319. package/versions/java/OpFindResult.java +0 -6
  320. package/versions/java/RangerAppArrayValue.java +0 -7
  321. package/versions/java/RangerAppClassDesc.java +0 -217
  322. package/versions/java/RangerAppEnum.java +0 -14
  323. package/versions/java/RangerAppFunctionDesc.java +0 -20
  324. package/versions/java/RangerAppHashValue.java +0 -11
  325. package/versions/java/RangerAppInterfaceImpl.java +0 -6
  326. package/versions/java/RangerAppMethodVariants.java +0 -6
  327. package/versions/java/RangerAppParamDesc.java +0 -321
  328. package/versions/java/RangerAppTodo.java +0 -6
  329. package/versions/java/RangerAppValue.java +0 -10
  330. package/versions/java/RangerAppWriterContext.java +0 -800
  331. package/versions/java/RangerArgMatch.java +0 -317
  332. package/versions/java/RangerBackReference.java +0 -7
  333. package/versions/java/RangerCSharpClassWriter.java +0 -287
  334. package/versions/java/RangerCompilerMessage.java +0 -9
  335. package/versions/java/RangerCppClassWriter.java +0 -725
  336. package/versions/java/RangerFlowParser.java +0 -2142
  337. package/versions/java/RangerGenericClassWriter.java +0 -367
  338. package/versions/java/RangerGolangClassWriter.java +0 -1379
  339. package/versions/java/RangerJava7ClassWriter.java +0 -652
  340. package/versions/java/RangerJavaScriptClassWriter.java +0 -305
  341. package/versions/java/RangerKotlinClassWriter.java +0 -380
  342. package/versions/java/RangerLispParser.java +0 -845
  343. package/versions/java/RangerNodeValue.java +0 -9
  344. package/versions/java/RangerPHPClassWriter.java +0 -527
  345. package/versions/java/RangerParamEventHandler.java +0 -6
  346. package/versions/java/RangerParamEventList.java +0 -5
  347. package/versions/java/RangerParamEventMap.java +0 -27
  348. package/versions/java/RangerRangerClassWriter.java +0 -268
  349. package/versions/java/RangerRefForce.java +0 -7
  350. package/versions/java/RangerScalaClassWriter.java +0 -365
  351. package/versions/java/RangerSerializeClass.java +0 -148
  352. package/versions/java/RangerSwift3ClassWriter.java +0 -548
  353. package/versions/java/RangerTypeClass.java +0 -17
  354. package/versions/java/SourceCode.java +0 -65
  355. package/versions/php/compiler.php +0 -13830
  356. package/versions/swift3/compiler.swift +0 -12542
  357. /package/{lib/ACEEditor.clj → dist/lib/ACEEditor.rgr} +0 -0
  358. /package/{lib/SQL.clj → dist/lib/SQL.rgr} +0 -0
  359. /package/{lib/ServiceLib.clj → dist/lib/ServiceLib.rgr} +0 -0
  360. /package/{lib/Time.clj → dist/lib/Time.rgr} +0 -0
  361. /package/{lib/TypedArrays.clj → dist/lib/TypedArrays.rgr} +0 -0
  362. /package/{lib/WebLib.clj → dist/lib/WebLib.rgr} +0 -0
  363. /package/{lib/WebServerLib.clj → dist/lib/WebServerLib.rgr} +0 -0
@@ -1,772 +0,0 @@
1
- import java.util.Optional;
2
- import java.util.*;
3
- import java.io.*;
4
-
5
- class LiveCompiler {
6
- public Optional<RangerGenericClassWriter> langWriter = Optional.empty();
7
- public HashMap<String,Boolean> hasCreatedPolyfill = new HashMap<String,Boolean>() /** note: unused */;
8
- public Optional<CodeNode> lastProcessedNode = Optional.empty();
9
- public int repeat_index = 0;
10
-
11
- public void initWriter( RangerAppWriterContext ctx ) {
12
- if ( langWriter.isPresent() ) {
13
- return;
14
- }
15
- final RangerAppWriterContext root = ctx.getRoot();
16
- switch (root.targetLangName ) {
17
- case "go" :
18
- langWriter = Optional.of(new RangerGolangClassWriter());
19
- break;
20
- case "scala" :
21
- langWriter = Optional.of(new RangerScalaClassWriter());
22
- break;
23
- case "java7" :
24
- langWriter = Optional.of(new RangerJava7ClassWriter());
25
- break;
26
- case "swift3" :
27
- langWriter = Optional.of(new RangerSwift3ClassWriter());
28
- break;
29
- case "kotlin" :
30
- langWriter = Optional.of(new RangerKotlinClassWriter());
31
- break;
32
- case "php" :
33
- langWriter = Optional.of(new RangerPHPClassWriter());
34
- break;
35
- case "cpp" :
36
- langWriter = Optional.of(new RangerCppClassWriter());
37
- break;
38
- case "csharp" :
39
- langWriter = Optional.of(new RangerCSharpClassWriter());
40
- break;
41
- case "es6" :
42
- langWriter = Optional.of(new RangerJavaScriptClassWriter());
43
- break;
44
- case "ranger" :
45
- langWriter = Optional.of(new RangerRangerClassWriter());
46
- break;
47
- }
48
- if ( langWriter.isPresent() ) {
49
- langWriter.get().compiler = Optional.of(this);
50
- } else {
51
- langWriter = Optional.of(new RangerGenericClassWriter());
52
- langWriter.get().compiler = Optional.of(this);
53
- }
54
- }
55
-
56
- public String EncodeString( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
57
- /** unused: final String encoded_str = "" **/ ;
58
- final int str_length = node.string_value.length();
59
- String encoded_str_2 = "";
60
- int ii = 0;
61
- while (ii < str_length) {
62
- final int ch = (int)node.string_value.charAt(ii);
63
- final int cc = ch;
64
- switch (cc ) {
65
- case 8 :
66
- encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(98))));
67
- break;
68
- case 9 :
69
- encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(116))));
70
- break;
71
- case 10 :
72
- encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(110))));
73
- break;
74
- case 12 :
75
- encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(102))));
76
- break;
77
- case 13 :
78
- encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(114))));
79
- break;
80
- case 34 :
81
- encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(34))));
82
- break;
83
- case 92 :
84
- encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(92))));
85
- break;
86
- default:
87
- encoded_str_2 = encoded_str_2 + ((new String( Character.toChars(ch))));
88
- break;
89
- }
90
- ii = ii + 1;
91
- }
92
- return encoded_str_2;
93
- }
94
-
95
- public void WriteScalarValue( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
96
- langWriter.get().WriteScalarValue(node, ctx, wr);
97
- }
98
-
99
- public String adjustType( String tn ) {
100
- if ( tn.equals("this") ) {
101
- return "self";
102
- }
103
- return tn;
104
- }
105
-
106
- public void WriteVRef( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
107
- langWriter.get().WriteVRef(node, ctx, wr);
108
- }
109
-
110
- public void writeTypeDef( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
111
- langWriter.get().writeTypeDef(node, ctx, wr);
112
- }
113
-
114
- public void CreateLambdaCall( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
115
- langWriter.get().CreateLambdaCall(node, ctx, wr);
116
- }
117
-
118
- public void CreateLambda( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
119
- langWriter.get().CreateLambda(node, ctx, wr);
120
- }
121
-
122
- public String getTypeString( String str , RangerAppWriterContext ctx ) {
123
- return "";
124
- }
125
-
126
- public void findOpCode( CodeNode op , CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
127
- final CodeNode fnName = op.children.get(1);
128
- final CodeNode args = op.children.get(2);
129
- if ( (op.children.size()) > 3 ) {
130
- final CodeNode details = op.children.get(3);
131
- for ( int i = 0; i < details.children.size(); i++) {
132
- CodeNode det = details.children.get(i);
133
- if ( (det.children.size()) > 0 ) {
134
- final CodeNode fc = det.children.get(0);
135
- if ( fc.vref.equals("code") ) {
136
- final RangerArgMatch match = new RangerArgMatch();
137
- final boolean all_matched = match.matchArguments(args, node, ctx, 1);
138
- if ( all_matched == false ) {
139
- return;
140
- }
141
- final CodeNode origCode = det.children.get(1);
142
- final CodeNode theCode = origCode.rebuildWithType(match, true);
143
- final RangerAppWriterContext appCtx = ctx.getRoot();
144
- final String stdFnName = appCtx.createSignature(fnName.vref, (fnName.vref + theCode.getCode()));
145
- final RangerAppClassDesc stdClass = ctx.findClass("RangerStaticMethods");
146
- final RangerAppWriterContext runCtx = appCtx.fork();
147
- boolean b_failed = false;
148
- if ( false == (stdClass.defined_static_methods.containsKey(stdFnName)) ) {
149
- runCtx.setInMethod();
150
- final RangerAppFunctionDesc m = new RangerAppFunctionDesc();
151
- m.name = stdFnName;
152
- m.node = Optional.of(op);
153
- m.is_static = true;
154
- m.nameNode = Optional.of(fnName);
155
- m.fnBody = Optional.of(theCode);
156
- for ( int ii = 0; ii < args.children.size(); ii++) {
157
- CodeNode arg = args.children.get(ii);
158
- final RangerAppParamDesc p = new RangerAppParamDesc();
159
- p.name = arg.vref;
160
- p.value_type = arg.value_type;
161
- p.node = Optional.of(arg);
162
- p.nameNode = Optional.of(arg);
163
- p.refType = 1;
164
- p.varType = 4;
165
- m.params.add(p);
166
- arg.hasParamDesc = true;
167
- arg.paramDesc = Optional.of(p);
168
- arg.eval_type = arg.value_type;
169
- arg.eval_type_name = arg.type_name;
170
- runCtx.defineVariable(p.name, p);
171
- }
172
- stdClass.addStaticMethod(m);
173
- final int err_cnt = ctx.compilerErrors.size();
174
- final RangerFlowParser flowParser = new RangerFlowParser();
175
- final CodeWriter TmpWr = new CodeWriter();
176
- flowParser.WalkNode(theCode, runCtx, TmpWr);
177
- runCtx.unsetInMethod();
178
- final int err_delta = (ctx.compilerErrors.size()) - err_cnt;
179
- if ( err_delta > 0 ) {
180
- b_failed = true;
181
- System.out.println(String.valueOf( "Had following compiler errors:" ) );
182
- for ( int i_1 = 0; i_1 < ctx.compilerErrors.size(); i_1++) {
183
- RangerCompilerMessage e = ctx.compilerErrors.get(i_1);
184
- if ( i_1 < err_cnt ) {
185
- continue;
186
- }
187
- final int line_index = e.node.get().getLine();
188
- System.out.println(String.valueOf( (e.node.get().getFilename() + " Line: ") + line_index ) );
189
- System.out.println(String.valueOf( e.description ) );
190
- System.out.println(String.valueOf( e.node.get().getLineString(line_index) ) );
191
- }
192
- } else {
193
- System.out.println(String.valueOf( "no errors found" ) );
194
- }
195
- }
196
- if ( b_failed ) {
197
- wr.out("/* custom operator compilation failed */ ", false);
198
- } else {
199
- wr.out(("RangerStaticMethods." + stdFnName) + "(", false);
200
- for ( int i_2 = 0; i_2 < node.children.size(); i_2++) {
201
- CodeNode cc = node.children.get(i_2);
202
- if ( i_2 == 0 ) {
203
- continue;
204
- }
205
- if ( i_2 > 1 ) {
206
- wr.out(", ", false);
207
- }
208
- this.WalkNode(cc, ctx, wr);
209
- }
210
- wr.out(")", false);
211
- }
212
- return;
213
- }
214
- }
215
- }
216
- }
217
- }
218
-
219
- public Optional<CodeNode> findOpTemplate( CodeNode op , CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
220
- /** unused: final CodeNode fnName = op.children.get(1) **/ ;
221
- /** unused: final RangerAppWriterContext root = ctx.getRoot() **/ ;
222
- final String langName = ctx.getTargetLang();
223
- if ( (op.children.size()) > 3 ) {
224
- final CodeNode details = op.children.get(3);
225
- for ( int i = 0; i < details.children.size(); i++) {
226
- CodeNode det = details.children.get(i);
227
- if ( (det.children.size()) > 0 ) {
228
- final CodeNode fc = det.children.get(0);
229
- if ( fc.vref.equals("templates") ) {
230
- final CodeNode tplList = det.children.get(1);
231
- for ( int i_1 = 0; i_1 < tplList.children.size(); i_1++) {
232
- CodeNode tpl = tplList.children.get(i_1);
233
- final CodeNode tplName = tpl.getFirst();
234
- Optional<CodeNode> tplImpl = Optional.empty();
235
- tplImpl = Optional.of(tpl.getSecond());
236
- if ( (!tplName.vref.equals("*")) && (!tplName.vref.equals(langName)) ) {
237
- continue;
238
- }
239
- if ( tplName.hasFlag("mutable") ) {
240
- if ( false == node.hasFlag("mutable") ) {
241
- continue;
242
- }
243
- }
244
- return Optional.ofNullable((tplImpl.isPresent() ? (CodeNode)tplImpl.get() : null ) );
245
- }
246
- }
247
- }
248
- }
249
- }
250
- final Optional<CodeNode> non = Optional.empty();
251
- return Optional.ofNullable((non.isPresent() ? (CodeNode)non.get() : null ) );
252
- }
253
-
254
- public boolean localCall( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
255
- if ( node.hasFnCall ) {
256
- if ( langWriter.isPresent() ) {
257
- langWriter.get().writeFnCall(node, ctx, wr);
258
- return true;
259
- }
260
- }
261
- if ( node.hasNewOper ) {
262
- langWriter.get().writeNewCall(node, ctx, wr);
263
- return true;
264
- }
265
- if ( node.hasVarDef ) {
266
- if ( node.disabled_node ) {
267
- langWriter.get().disabledVarDef(node, ctx, wr);
268
- } else {
269
- langWriter.get().writeVarDef(node, ctx, wr);
270
- }
271
- return true;
272
- }
273
- if ( node.hasClassDescription ) {
274
- langWriter.get().writeClass(node, ctx, wr);
275
- return true;
276
- }
277
- return false;
278
- }
279
-
280
- public void WalkNode( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
281
- this.initWriter(ctx);
282
- if ( node.isPrimitive() ) {
283
- this.WriteScalarValue(node, ctx, wr);
284
- return;
285
- }
286
- this.lastProcessedNode = Optional.of(node);
287
- if ( node.value_type == 9 ) {
288
- this.WriteVRef(node, ctx, wr);
289
- return;
290
- }
291
- if ( node.value_type == 16 ) {
292
- this.WriteVRef(node, ctx, wr);
293
- return;
294
- }
295
- if ( (node.children.size()) > 0 ) {
296
- if ( node.has_operator ) {
297
- final CodeNode op = ctx.findOperator(node);
298
- /** unused: final CodeNode fc = op.getFirst() **/ ;
299
- final Optional<CodeNode> tplImpl = this.findOpTemplate(op, node, ctx, wr);
300
- RangerAppWriterContext evalCtx = ctx;
301
- if ( node.evalCtx.isPresent() ) {
302
- evalCtx = node.evalCtx.get();
303
- }
304
- if ( tplImpl.isPresent() ) {
305
- final CodeNode opName = op.getSecond();
306
- if ( opName.hasFlag("returns") ) {
307
- langWriter.get().release_local_vars(node, evalCtx, wr);
308
- }
309
- this.walkCommandList(tplImpl.get(), node, evalCtx, wr);
310
- } else {
311
- this.findOpCode(op, node, evalCtx, wr);
312
- }
313
- return;
314
- }
315
- if ( node.has_lambda ) {
316
- this.CreateLambda(node, ctx, wr);
317
- return;
318
- }
319
- if ( node.has_lambda_call ) {
320
- this.CreateLambdaCall(node, ctx, wr);
321
- return;
322
- }
323
- if ( (node.children.size()) > 1 ) {
324
- if ( this.localCall(node, ctx, wr) ) {
325
- return;
326
- }
327
- }
328
- /** unused: final CodeNode fc_1 = node.getFirst() **/ ;
329
- }
330
- if ( node.expression ) {
331
- for ( int i = 0; i < node.children.size(); i++) {
332
- CodeNode item = node.children.get(i);
333
- if ( (node.didReturnAtIndex >= 0) && (node.didReturnAtIndex < i) ) {
334
- break;
335
- }
336
- this.WalkNode(item, ctx, wr);
337
- }
338
- } else {
339
- }
340
- }
341
-
342
- public void walkCommandList( CodeNode cmd , CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
343
- if ( ctx.expressionLevel() == 0 ) {
344
- wr.newline();
345
- }
346
- if ( ctx.expressionLevel() > 1 ) {
347
- wr.out("(", false);
348
- }
349
- for ( int i = 0; i < cmd.children.size(); i++) {
350
- CodeNode c = cmd.children.get(i);
351
- this.walkCommand(c, node, ctx, wr);
352
- }
353
- if ( ctx.expressionLevel() > 1 ) {
354
- wr.out(")", false);
355
- }
356
- if ( ctx.expressionLevel() == 0 ) {
357
- wr.newline();
358
- }
359
- }
360
-
361
- public void walkCommand( CodeNode cmd , CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
362
- if ( cmd.expression ) {
363
- if ( (cmd.children.size()) < 2 ) {
364
- ctx.addError(node, "Invalid command");
365
- ctx.addError(cmd, "Invalid command");
366
- return;
367
- }
368
- final CodeNode cmdE = cmd.getFirst();
369
- final CodeNode cmdArg = cmd.getSecond();
370
- switch (cmdE.vref ) {
371
- case "str" :
372
- final int idx = cmdArg.int_value;
373
- if ( (node.children.size()) > idx ) {
374
- final CodeNode arg = node.children.get(idx);
375
- wr.out(arg.string_value, false);
376
- }
377
- break;
378
- case "block" :
379
- final int idx_1 = cmdArg.int_value;
380
- if ( (node.children.size()) > idx_1 ) {
381
- final CodeNode arg_1 = node.children.get(idx_1);
382
- this.WalkNode(arg_1, ctx, wr);
383
- }
384
- break;
385
- case "varname" :
386
- if ( ctx.isVarDefined(cmdArg.vref) ) {
387
- final RangerAppParamDesc p = ctx.getVariableDef(cmdArg.vref);
388
- wr.out(p.compiledName, false);
389
- }
390
- break;
391
- case "defvar" :
392
- final RangerAppParamDesc p_1 = new RangerAppParamDesc();
393
- p_1.name = cmdArg.vref;
394
- p_1.value_type = cmdArg.value_type;
395
- p_1.node = Optional.of(cmdArg);
396
- p_1.nameNode = Optional.of(cmdArg);
397
- p_1.is_optional = false;
398
- ctx.defineVariable(p_1.name, p_1);
399
- break;
400
- case "cc" :
401
- final int idx_2 = cmdArg.int_value;
402
- if ( (node.children.size()) > idx_2 ) {
403
- final CodeNode arg_2 = node.children.get(idx_2);
404
- final byte cc = ((arg_2.string_value.getBytes())[0]);
405
- wr.out("" + (cc), false);
406
- }
407
- break;
408
- case "java_case" :
409
- final int idx_3 = cmdArg.int_value;
410
- if ( (node.children.size()) > idx_3 ) {
411
- final CodeNode arg_3 = node.children.get(idx_3);
412
- this.WalkNode(arg_3, ctx, wr);
413
- if ( arg_3.didReturnAtIndex < 0 ) {
414
- wr.newline();
415
- wr.out("break;", true);
416
- }
417
- }
418
- break;
419
- case "e" :
420
- final int idx_4 = cmdArg.int_value;
421
- if ( (node.children.size()) > idx_4 ) {
422
- final CodeNode arg_4 = node.children.get(idx_4);
423
- ctx.setInExpr();
424
- this.WalkNode(arg_4, ctx, wr);
425
- ctx.unsetInExpr();
426
- }
427
- break;
428
- case "goset" :
429
- final int idx_5 = cmdArg.int_value;
430
- if ( (node.children.size()) > idx_5 ) {
431
- final CodeNode arg_5 = node.children.get(idx_5);
432
- ctx.setInExpr();
433
- langWriter.get().WriteSetterVRef(arg_5, ctx, wr);
434
- ctx.unsetInExpr();
435
- }
436
- break;
437
- case "pe" :
438
- final int idx_6 = cmdArg.int_value;
439
- if ( (node.children.size()) > idx_6 ) {
440
- final CodeNode arg_6 = node.children.get(idx_6);
441
- this.WalkNode(arg_6, ctx, wr);
442
- }
443
- break;
444
- case "ptr" :
445
- final int idx_7 = cmdArg.int_value;
446
- if ( (node.children.size()) > idx_7 ) {
447
- final CodeNode arg_7 = node.children.get(idx_7);
448
- if ( arg_7.hasParamDesc ) {
449
- if ( arg_7.paramDesc.get().nameNode.get().isAPrimitiveType() == false ) {
450
- wr.out("*", false);
451
- }
452
- } else {
453
- if ( arg_7.isAPrimitiveType() == false ) {
454
- wr.out("*", false);
455
- }
456
- }
457
- }
458
- break;
459
- case "ptrsrc" :
460
- final int idx_8 = cmdArg.int_value;
461
- if ( (node.children.size()) > idx_8 ) {
462
- final CodeNode arg_8 = node.children.get(idx_8);
463
- if ( (arg_8.isPrimitiveType() == false) && (arg_8.isPrimitive() == false) ) {
464
- wr.out("&", false);
465
- }
466
- }
467
- break;
468
- case "nameof" :
469
- final int idx_9 = cmdArg.int_value;
470
- if ( (node.children.size()) > idx_9 ) {
471
- final CodeNode arg_9 = node.children.get(idx_9);
472
- wr.out(arg_9.vref, false);
473
- }
474
- break;
475
- case "list" :
476
- final int idx_10 = cmdArg.int_value;
477
- if ( (node.children.size()) > idx_10 ) {
478
- final CodeNode arg_10 = node.children.get(idx_10);
479
- for ( int i = 0; i < arg_10.children.size(); i++) {
480
- CodeNode ch = arg_10.children.get(i);
481
- if ( i > 0 ) {
482
- wr.out(" ", false);
483
- }
484
- ctx.setInExpr();
485
- this.WalkNode(ch, ctx, wr);
486
- ctx.unsetInExpr();
487
- }
488
- }
489
- break;
490
- case "repeat_from" :
491
- final int idx_11 = cmdArg.int_value;
492
- repeat_index = idx_11;
493
- if ( (node.children.size()) >= idx_11 ) {
494
- final CodeNode cmdToRepeat = cmd.getThird();
495
- int i_1 = idx_11;
496
- while (i_1 < (node.children.size())) {
497
- if ( i_1 >= idx_11 ) {
498
- for ( int ii = 0; ii < cmdToRepeat.children.size(); ii++) {
499
- CodeNode cc_1 = cmdToRepeat.children.get(ii);
500
- if ( (cc_1.children.size()) > 0 ) {
501
- final CodeNode fc = cc_1.getFirst();
502
- if ( fc.vref.equals("e") ) {
503
- final CodeNode dc = cc_1.getSecond();
504
- dc.int_value = i_1;
505
- }
506
- if ( fc.vref.equals("block") ) {
507
- final CodeNode dc_1 = cc_1.getSecond();
508
- dc_1.int_value = i_1;
509
- }
510
- }
511
- }
512
- this.walkCommandList(cmdToRepeat, node, ctx, wr);
513
- if ( (i_1 + 1) < (node.children.size()) ) {
514
- wr.out(",", false);
515
- }
516
- }
517
- i_1 = i_1 + 1;
518
- }
519
- }
520
- break;
521
- case "comma" :
522
- final int idx_12 = cmdArg.int_value;
523
- if ( (node.children.size()) > idx_12 ) {
524
- final CodeNode arg_11 = node.children.get(idx_12);
525
- for ( int i_2 = 0; i_2 < arg_11.children.size(); i_2++) {
526
- CodeNode ch_1 = arg_11.children.get(i_2);
527
- if ( i_2 > 0 ) {
528
- wr.out(",", false);
529
- }
530
- ctx.setInExpr();
531
- this.WalkNode(ch_1, ctx, wr);
532
- ctx.unsetInExpr();
533
- }
534
- }
535
- break;
536
- case "swift_rc" :
537
- final int idx_13 = cmdArg.int_value;
538
- if ( (node.children.size()) > idx_13 ) {
539
- final CodeNode arg_12 = node.children.get(idx_13);
540
- if ( arg_12.hasParamDesc ) {
541
- if ( arg_12.paramDesc.get().ref_cnt == 0 ) {
542
- wr.out("_", false);
543
- } else {
544
- final RangerAppParamDesc p_2 = ctx.getVariableDef(arg_12.vref);
545
- wr.out(p_2.compiledName, false);
546
- }
547
- } else {
548
- wr.out(arg_12.vref, false);
549
- }
550
- }
551
- break;
552
- case "r_ktype" :
553
- final int idx_14 = cmdArg.int_value;
554
- if ( (node.children.size()) > idx_14 ) {
555
- final CodeNode arg_13 = node.children.get(idx_14);
556
- if ( arg_13.hasParamDesc ) {
557
- final String ss = langWriter.get().getObjectTypeString(arg_13.paramDesc.get().nameNode.get().key_type, ctx);
558
- wr.out(ss, false);
559
- } else {
560
- final String ss_1 = langWriter.get().getObjectTypeString(arg_13.key_type, ctx);
561
- wr.out(ss_1, false);
562
- }
563
- }
564
- break;
565
- case "r_atype" :
566
- final int idx_15 = cmdArg.int_value;
567
- if ( (node.children.size()) > idx_15 ) {
568
- final CodeNode arg_14 = node.children.get(idx_15);
569
- if ( arg_14.hasParamDesc ) {
570
- final String ss_2 = langWriter.get().getObjectTypeString(arg_14.paramDesc.get().nameNode.get().array_type, ctx);
571
- wr.out(ss_2, false);
572
- } else {
573
- final String ss_3 = langWriter.get().getObjectTypeString(arg_14.array_type, ctx);
574
- wr.out(ss_3, false);
575
- }
576
- }
577
- break;
578
- case "custom" :
579
- langWriter.get().CustomOperator(node, ctx, wr);
580
- break;
581
- case "arraytype" :
582
- final int idx_16 = cmdArg.int_value;
583
- if ( (node.children.size()) > idx_16 ) {
584
- final CodeNode arg_15 = node.children.get(idx_16);
585
- if ( arg_15.hasParamDesc ) {
586
- langWriter.get().writeArrayTypeDef(arg_15.paramDesc.get().nameNode.get(), ctx, wr);
587
- } else {
588
- langWriter.get().writeArrayTypeDef(arg_15, ctx, wr);
589
- }
590
- }
591
- break;
592
- case "rawtype" :
593
- final int idx_17 = cmdArg.int_value;
594
- if ( (node.children.size()) > idx_17 ) {
595
- final CodeNode arg_16 = node.children.get(idx_17);
596
- if ( arg_16.hasParamDesc ) {
597
- langWriter.get().writeRawTypeDef(arg_16.paramDesc.get().nameNode.get(), ctx, wr);
598
- } else {
599
- langWriter.get().writeRawTypeDef(arg_16, ctx, wr);
600
- }
601
- }
602
- break;
603
- case "macro" :
604
- final CodeWriter p_write = wr.getTag("utilities");
605
- final CodeWriter newWriter = new CodeWriter();
606
- final RangerAppWriterContext testCtx = ctx.fork();
607
- testCtx.restartExpressionLevel();
608
- this.walkCommandList(cmdArg, node, testCtx, newWriter);
609
- final String p_str = newWriter.getCode();
610
- /** unused: final RangerAppWriterContext root = ctx.getRoot() **/ ;
611
- if ( (p_write.compiledTags.containsKey(p_str)) == false ) {
612
- p_write.compiledTags.put(p_str, true);
613
- final RangerAppWriterContext mCtx = ctx.fork();
614
- mCtx.restartExpressionLevel();
615
- this.walkCommandList(cmdArg, node, mCtx, p_write);
616
- }
617
- break;
618
- case "create_polyfill" :
619
- final CodeWriter p_write_1 = wr.getTag("utilities");
620
- final String p_str_1 = cmdArg.string_value;
621
- if ( (p_write_1.compiledTags.containsKey(p_str_1)) == false ) {
622
- p_write_1.raw(p_str_1, true);
623
- p_write_1.compiledTags.put(p_str_1, true);
624
- }
625
- break;
626
- case "typeof" :
627
- final int idx_18 = cmdArg.int_value;
628
- if ( (node.children.size()) >= idx_18 ) {
629
- final CodeNode arg_17 = node.children.get(idx_18);
630
- if ( arg_17.hasParamDesc ) {
631
- this.writeTypeDef(arg_17.paramDesc.get().nameNode.get(), ctx, wr);
632
- } else {
633
- this.writeTypeDef(arg_17, ctx, wr);
634
- }
635
- }
636
- break;
637
- case "imp" :
638
- langWriter.get().import_lib(cmdArg.string_value, ctx, wr);
639
- break;
640
- case "atype" :
641
- final int idx_19 = cmdArg.int_value;
642
- if ( (node.children.size()) >= idx_19 ) {
643
- final CodeNode arg_18 = node.children.get(idx_19);
644
- final Optional<RangerAppParamDesc> p_3 = this.findParamDesc(arg_18, ctx, wr);
645
- final CodeNode nameNode = p_3.get().nameNode.get();
646
- final String tn = nameNode.array_type;
647
- wr.out(this.getTypeString(tn, ctx), false);
648
- }
649
- break;
650
- }
651
- } else {
652
- if ( cmd.value_type == 9 ) {
653
- switch (cmd.vref ) {
654
- case "nl" :
655
- wr.newline();
656
- break;
657
- case "space" :
658
- wr.out(" ", false);
659
- break;
660
- case "I" :
661
- wr.indent(1);
662
- break;
663
- case "i" :
664
- wr.indent(-1);
665
- break;
666
- case "op" :
667
- final CodeNode fc_1 = node.getFirst();
668
- wr.out(fc_1.vref, false);
669
- break;
670
- }
671
- } else {
672
- if ( cmd.value_type == 4 ) {
673
- wr.out(cmd.string_value, false);
674
- }
675
- }
676
- }
677
- }
678
-
679
- public void compile( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
680
- }
681
-
682
- public Optional<RangerAppParamDesc> findParamDesc( CodeNode obj , RangerAppWriterContext ctx , CodeWriter wr ) {
683
- Optional<RangerAppParamDesc> varDesc = Optional.empty();
684
- boolean set_nsp = false;
685
- Optional<RangerAppClassDesc> classDesc = Optional.empty();
686
- if ( 0 == (obj.nsp.size()) ) {
687
- set_nsp = true;
688
- }
689
- if ( !obj.vref.equals("this") ) {
690
- if ( (obj.ns.size()) > 1 ) {
691
- final int cnt = obj.ns.size();
692
- Optional<RangerAppParamDesc> classRefDesc = Optional.empty();
693
- for ( int i = 0; i < obj.ns.size(); i++) {
694
- String strname = obj.ns.get(i);
695
- if ( i == 0 ) {
696
- if ( strname.equals("this") ) {
697
- classDesc = ctx.getCurrentClass();
698
- if ( set_nsp ) {
699
- obj.nsp.add(classDesc.get());
700
- }
701
- } else {
702
- if ( ctx.isDefinedClass(strname) ) {
703
- classDesc = Optional.of(ctx.findClass(strname));
704
- if ( set_nsp ) {
705
- obj.nsp.add(classDesc.get());
706
- }
707
- continue;
708
- }
709
- classRefDesc = Optional.of(ctx.getVariableDef(strname));
710
- if ( !classRefDesc.isPresent() ) {
711
- ctx.addError(obj, "Error, no description for called object: " + strname);
712
- break;
713
- }
714
- if ( set_nsp ) {
715
- obj.nsp.add(classRefDesc.get());
716
- }
717
- classRefDesc.get().ref_cnt = 1 + classRefDesc.get().ref_cnt;
718
- classDesc = Optional.of(ctx.findClass(classRefDesc.get().nameNode.get().type_name));
719
- }
720
- } else {
721
- if ( i < (cnt - 1) ) {
722
- varDesc = classDesc.get().findVariable(strname);
723
- if ( !varDesc.isPresent() ) {
724
- ctx.addError(obj, "Error, no description for refenced obj: " + strname);
725
- }
726
- final String subClass = varDesc.get().getTypeName();
727
- classDesc = Optional.of(ctx.findClass(subClass));
728
- if ( set_nsp ) {
729
- obj.nsp.add(varDesc.get());
730
- }
731
- continue;
732
- }
733
- if ( classDesc.isPresent() ) {
734
- varDesc = classDesc.get().findVariable(strname);
735
- if ( !varDesc.isPresent() ) {
736
- Optional<RangerAppFunctionDesc> classMethod = classDesc.get().findMethod(strname);
737
- if ( !classMethod.isPresent() ) {
738
- classMethod = classDesc.get().findStaticMethod(strname);
739
- if ( !classMethod.isPresent() ) {
740
- ctx.addError(obj, "variable not found " + strname);
741
- }
742
- }
743
- if ( classMethod.isPresent() ) {
744
- if ( set_nsp ) {
745
- obj.nsp.add(classMethod.get());
746
- }
747
- return Optional.ofNullable((classMethod.isPresent() ? (RangerAppParamDesc)classMethod.get() : null ) );
748
- }
749
- }
750
- if ( set_nsp ) {
751
- obj.nsp.add(varDesc.get());
752
- }
753
- }
754
- }
755
- }
756
- return Optional.ofNullable((varDesc.isPresent() ? (RangerAppParamDesc)varDesc.get() : null ) );
757
- }
758
- varDesc = Optional.of(ctx.getVariableDef(obj.vref));
759
- if ( varDesc.get().nameNode.isPresent() ) {
760
- } else {
761
- System.out.println(String.valueOf( "findParamDesc : description not found for " + obj.vref ) );
762
- if ( varDesc.isPresent() ) {
763
- System.out.println(String.valueOf( "Vardesc was found though..." + varDesc.get().name ) );
764
- }
765
- ctx.addError(obj, "Error, no description for called object: " + obj.vref);
766
- }
767
- return Optional.ofNullable((varDesc.isPresent() ? (RangerAppParamDesc)varDesc.get() : null ) );
768
- }
769
- final Optional<RangerAppClassDesc> cc = ctx.getCurrentClass();
770
- return Optional.ofNullable((cc.isPresent() ? (RangerAppParamDesc)cc.get() : null ) );
771
- }
772
- }