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,1379 +0,0 @@
1
- import java.util.Optional;
2
- import java.util.*;
3
-
4
- class RangerGolangClassWriter extends RangerGenericClassWriter {
5
- public String thisName = "this";
6
- public boolean write_raw_type = false;
7
- public boolean did_write_nullable = false;
8
-
9
- public void WriteScalarValue( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
10
- switch (node.value_type ) {
11
- case 2 :
12
- wr.out(node.getParsedString(), false);
13
- break;
14
- case 4 :
15
- final String s = this.EncodeString(node, ctx, wr);
16
- wr.out(("\"" + s) + "\"", false);
17
- break;
18
- case 3 :
19
- wr.out("" + node.int_value, false);
20
- break;
21
- case 5 :
22
- if ( node.boolean_value ) {
23
- wr.out("true", false);
24
- } else {
25
- wr.out("false", false);
26
- }
27
- break;
28
- }
29
- }
30
-
31
- public String getObjectTypeString( String type_string , RangerAppWriterContext ctx ) {
32
- if ( type_string.equals("this") ) {
33
- return thisName;
34
- }
35
- if ( ctx.isDefinedClass(type_string) ) {
36
- final RangerAppClassDesc cc = ctx.findClass(type_string);
37
- if ( cc.doesInherit() ) {
38
- return "IFACE_" + ctx.transformTypeName(type_string);
39
- }
40
- }
41
- switch (type_string ) {
42
- case "int" :
43
- return "int64";
44
- case "string" :
45
- return "string";
46
- case "boolean" :
47
- return "bool";
48
- case "double" :
49
- return "float64";
50
- case "char" :
51
- return "byte";
52
- case "charbuffer" :
53
- return "[]byte";
54
- }
55
- return ctx.transformTypeName(type_string);
56
- }
57
-
58
- public String getTypeString2( String type_string , RangerAppWriterContext ctx ) {
59
- if ( type_string.equals("this") ) {
60
- return thisName;
61
- }
62
- switch (type_string ) {
63
- case "int" :
64
- return "int64";
65
- case "string" :
66
- return "string";
67
- case "boolean" :
68
- return "bool";
69
- case "double" :
70
- return "float64";
71
- case "char" :
72
- return "byte";
73
- case "charbuffer" :
74
- return "[]byte";
75
- }
76
- return ctx.transformTypeName(type_string);
77
- }
78
-
79
- public void writeRawTypeDef( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
80
- write_raw_type = true;
81
- this.writeTypeDef(node, ctx, wr);
82
- write_raw_type = false;
83
- }
84
-
85
- public void writeTypeDef( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
86
- this.writeTypeDef2(node, ctx, wr);
87
- }
88
-
89
- public void writeArrayTypeDef( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
90
- int v_type = node.value_type;
91
- String a_name = node.array_type;
92
- if ( ((v_type == 8) || (v_type == 9)) || (v_type == 0) ) {
93
- v_type = node.typeNameAsType(ctx);
94
- }
95
- if ( node.eval_type != 0 ) {
96
- v_type = node.eval_type;
97
- if ( (node.eval_array_type.length()) > 0 ) {
98
- a_name = node.eval_array_type;
99
- }
100
- }
101
- switch (v_type ) {
102
- case 7 :
103
- if ( ctx.isDefinedClass(a_name) ) {
104
- final RangerAppClassDesc cc = ctx.findClass(a_name);
105
- if ( cc.doesInherit() ) {
106
- wr.out("IFACE_" + this.getTypeString2(a_name, ctx), false);
107
- return;
108
- }
109
- }
110
- if ( ctx.isPrimitiveType(a_name) == false ) {
111
- wr.out("*", false);
112
- }
113
- wr.out(this.getObjectTypeString(a_name, ctx) + "", false);
114
- break;
115
- case 6 :
116
- if ( ctx.isDefinedClass(a_name) ) {
117
- final RangerAppClassDesc cc_1 = ctx.findClass(a_name);
118
- if ( cc_1.doesInherit() ) {
119
- wr.out("IFACE_" + this.getTypeString2(a_name, ctx), false);
120
- return;
121
- }
122
- }
123
- if ( (write_raw_type == false) && (ctx.isPrimitiveType(a_name) == false) ) {
124
- wr.out("*", false);
125
- }
126
- wr.out(this.getObjectTypeString(a_name, ctx) + "", false);
127
- break;
128
- default:
129
- break;
130
- }
131
- }
132
-
133
- public void writeTypeDef2( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
134
- int v_type = node.value_type;
135
- String t_name = node.type_name;
136
- String a_name = node.array_type;
137
- String k_name = node.key_type;
138
- if ( ((v_type == 8) || (v_type == 9)) || (v_type == 0) ) {
139
- v_type = node.typeNameAsType(ctx);
140
- }
141
- if ( node.eval_type != 0 ) {
142
- v_type = node.eval_type;
143
- if ( (node.eval_type_name.length()) > 0 ) {
144
- t_name = node.eval_type_name;
145
- }
146
- if ( (node.eval_array_type.length()) > 0 ) {
147
- a_name = node.eval_array_type;
148
- }
149
- if ( (node.eval_key_type.length()) > 0 ) {
150
- k_name = node.eval_key_type;
151
- }
152
- }
153
- switch (v_type ) {
154
- case 15 :
155
- final CodeNode rv = node.expression_value.get().children.get(0);
156
- final CodeNode sec = node.expression_value.get().children.get(1);
157
- /** unused: final CodeNode fc = sec.getFirst() **/ ;
158
- wr.out("func(", false);
159
- for ( int i = 0; i < sec.children.size(); i++) {
160
- CodeNode arg = sec.children.get(i);
161
- if ( i > 0 ) {
162
- wr.out(", ", false);
163
- }
164
- this.writeTypeDef2(arg, ctx, wr);
165
- }
166
- wr.out(") ", false);
167
- this.writeTypeDef2(rv, ctx, wr);
168
- break;
169
- case 11 :
170
- wr.out("int64", false);
171
- break;
172
- case 3 :
173
- wr.out("int64", false);
174
- break;
175
- case 2 :
176
- wr.out("float64", false);
177
- break;
178
- case 4 :
179
- wr.out("string", false);
180
- break;
181
- case 5 :
182
- wr.out("bool", false);
183
- break;
184
- case 12 :
185
- wr.out("byte", false);
186
- break;
187
- case 13 :
188
- wr.out("[]byte", false);
189
- break;
190
- case 7 :
191
- if ( write_raw_type ) {
192
- wr.out(this.getObjectTypeString(a_name, ctx) + "", false);
193
- } else {
194
- wr.out(("map[" + this.getObjectTypeString(k_name, ctx)) + "]", false);
195
- if ( ctx.isDefinedClass(a_name) ) {
196
- final RangerAppClassDesc cc = ctx.findClass(a_name);
197
- if ( cc.doesInherit() ) {
198
- wr.out("IFACE_" + this.getTypeString2(a_name, ctx), false);
199
- return;
200
- }
201
- }
202
- if ( (write_raw_type == false) && (ctx.isPrimitiveType(a_name) == false) ) {
203
- wr.out("*", false);
204
- }
205
- wr.out(this.getObjectTypeString(a_name, ctx) + "", false);
206
- }
207
- break;
208
- case 6 :
209
- if ( false == write_raw_type ) {
210
- wr.out("[]", false);
211
- }
212
- if ( ctx.isDefinedClass(a_name) ) {
213
- final RangerAppClassDesc cc_1 = ctx.findClass(a_name);
214
- if ( cc_1.doesInherit() ) {
215
- wr.out("IFACE_" + this.getTypeString2(a_name, ctx), false);
216
- return;
217
- }
218
- }
219
- if ( (write_raw_type == false) && (ctx.isPrimitiveType(a_name) == false) ) {
220
- wr.out("*", false);
221
- }
222
- wr.out(this.getObjectTypeString(a_name, ctx) + "", false);
223
- break;
224
- default:
225
- if ( node.type_name.equals("void") ) {
226
- wr.out("()", false);
227
- return;
228
- }
229
- boolean b_iface = false;
230
- if ( ctx.isDefinedClass(t_name) ) {
231
- final RangerAppClassDesc cc_2 = ctx.findClass(t_name);
232
- b_iface = cc_2.is_interface;
233
- }
234
- if ( ctx.isDefinedClass(t_name) ) {
235
- final RangerAppClassDesc cc_3 = ctx.findClass(t_name);
236
- if ( cc_3.doesInherit() ) {
237
- wr.out("IFACE_" + this.getTypeString2(t_name, ctx), false);
238
- return;
239
- }
240
- }
241
- if ( ((write_raw_type == false) && (node.isPrimitiveType() == false)) && (b_iface == false) ) {
242
- wr.out("*", false);
243
- }
244
- wr.out(this.getTypeString2(t_name, ctx), false);
245
- break;
246
- }
247
- }
248
-
249
- public void WriteVRef( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
250
- if ( node.vref.equals("this") ) {
251
- wr.out(thisName, false);
252
- return;
253
- }
254
- if ( node.eval_type == 11 ) {
255
- if ( (node.ns.size()) > 1 ) {
256
- final String rootObjName = node.ns.get(0);
257
- final String enumName = node.ns.get(1);
258
- final Optional<RangerAppEnum> e = ctx.getEnum(rootObjName);
259
- if ( e.isPresent() ) {
260
- wr.out("" + ((Optional.ofNullable(e.get().values.get(enumName))).get()), false);
261
- return;
262
- }
263
- }
264
- }
265
- boolean next_is_gs = false;
266
- /** unused: final boolean last_was_setter = false **/ ;
267
- boolean needs_par = false;
268
- final int ns_last = (node.ns.size()) - 1;
269
- if ( (node.nsp.size()) > 0 ) {
270
- boolean had_static = false;
271
- for ( int i = 0; i < node.nsp.size(); i++) {
272
- RangerAppParamDesc p = node.nsp.get(i);
273
- if ( next_is_gs ) {
274
- if ( p.isProperty() ) {
275
- wr.out(".Get_", false);
276
- needs_par = true;
277
- } else {
278
- needs_par = false;
279
- }
280
- next_is_gs = false;
281
- }
282
- if ( needs_par == false ) {
283
- if ( i > 0 ) {
284
- if ( had_static ) {
285
- wr.out("_static_", false);
286
- } else {
287
- wr.out(".", false);
288
- }
289
- }
290
- }
291
- if ( (p.nameNode.isPresent()) && ctx.isDefinedClass(p.nameNode.get().type_name) ) {
292
- final RangerAppClassDesc c = ctx.findClass(p.nameNode.get().type_name);
293
- if ( c.doesInherit() ) {
294
- next_is_gs = true;
295
- }
296
- }
297
- if ( i == 0 ) {
298
- final String part = node.ns.get(0);
299
- if ( part.equals("this") ) {
300
- wr.out(thisName, false);
301
- continue;
302
- }
303
- if ( (!part.equals(thisName)) && ctx.isMemberVariable(part) ) {
304
- final Optional<RangerAppClassDesc> cc = ctx.getCurrentClass();
305
- final RangerAppClassDesc currC = cc.get();
306
- final Optional<RangerAppParamDesc> up = currC.findVariable(part);
307
- if ( up.isPresent() ) {
308
- /** unused: final RangerAppParamDesc p3 = up.get() **/ ;
309
- wr.out(thisName + ".", false);
310
- }
311
- }
312
- }
313
- if ( (p.compiledName.length()) > 0 ) {
314
- wr.out(this.adjustType(p.compiledName), false);
315
- } else {
316
- if ( (p.name.length()) > 0 ) {
317
- wr.out(this.adjustType(p.name), false);
318
- } else {
319
- wr.out(this.adjustType((node.ns.get(i))), false);
320
- }
321
- }
322
- if ( needs_par ) {
323
- wr.out("()", false);
324
- needs_par = false;
325
- }
326
- if ( ((p.nameNode.isPresent()) && p.nameNode.get().hasFlag("optional")) && (i != ns_last) ) {
327
- wr.out(".value.(", false);
328
- this.writeTypeDef(p.nameNode.get(), ctx, wr);
329
- wr.out(")", false);
330
- }
331
- if ( p.isClass() ) {
332
- had_static = true;
333
- }
334
- }
335
- return;
336
- }
337
- if ( node.hasParamDesc ) {
338
- final String part_1 = node.ns.get(0);
339
- if ( (!part_1.equals(thisName)) && ctx.isMemberVariable(part_1) ) {
340
- final Optional<RangerAppClassDesc> cc_1 = ctx.getCurrentClass();
341
- final RangerAppClassDesc currC_1 = cc_1.get();
342
- final Optional<RangerAppParamDesc> up_1 = currC_1.findVariable(part_1);
343
- if ( up_1.isPresent() ) {
344
- /** unused: final RangerAppParamDesc p3_1 = up_1.get() **/ ;
345
- wr.out(thisName + ".", false);
346
- }
347
- }
348
- final Optional<RangerAppParamDesc> p_1 = node.paramDesc;
349
- wr.out(p_1.get().compiledName, false);
350
- return;
351
- }
352
- boolean b_was_static = false;
353
- for ( int i_1 = 0; i_1 < node.ns.size(); i_1++) {
354
- String part_2 = node.ns.get(i_1);
355
- if ( i_1 > 0 ) {
356
- if ( (i_1 == 1) && b_was_static ) {
357
- wr.out("_static_", false);
358
- } else {
359
- wr.out(".", false);
360
- }
361
- }
362
- if ( i_1 == 0 ) {
363
- if ( part_2.equals("this") ) {
364
- wr.out(thisName, false);
365
- continue;
366
- }
367
- if ( ctx.hasClass(part_2) ) {
368
- b_was_static = true;
369
- }
370
- if ( (!part_2.equals("this")) && ctx.isMemberVariable(part_2) ) {
371
- final Optional<RangerAppClassDesc> cc_2 = ctx.getCurrentClass();
372
- final RangerAppClassDesc currC_2 = cc_2.get();
373
- final Optional<RangerAppParamDesc> up_2 = currC_2.findVariable(part_2);
374
- if ( up_2.isPresent() ) {
375
- /** unused: final RangerAppParamDesc p3_2 = up_2.get() **/ ;
376
- wr.out(thisName + ".", false);
377
- }
378
- }
379
- }
380
- wr.out(this.adjustType(part_2), false);
381
- }
382
- }
383
-
384
- public void WriteSetterVRef( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
385
- if ( node.vref.equals("this") ) {
386
- wr.out(thisName, false);
387
- return;
388
- }
389
- if ( node.eval_type == 11 ) {
390
- final String rootObjName = node.ns.get(0);
391
- final String enumName = node.ns.get(1);
392
- final Optional<RangerAppEnum> e = ctx.getEnum(rootObjName);
393
- if ( e.isPresent() ) {
394
- wr.out("" + ((Optional.ofNullable(e.get().values.get(enumName))).get()), false);
395
- return;
396
- }
397
- }
398
- boolean next_is_gs = false;
399
- /** unused: final boolean last_was_setter = false **/ ;
400
- boolean needs_par = false;
401
- final int ns_len = (node.ns.size()) - 1;
402
- if ( (node.nsp.size()) > 0 ) {
403
- boolean had_static = false;
404
- for ( int i = 0; i < node.nsp.size(); i++) {
405
- RangerAppParamDesc p = node.nsp.get(i);
406
- if ( next_is_gs ) {
407
- if ( p.isProperty() ) {
408
- wr.out(".Get_", false);
409
- needs_par = true;
410
- } else {
411
- needs_par = false;
412
- }
413
- next_is_gs = false;
414
- }
415
- if ( needs_par == false ) {
416
- if ( i > 0 ) {
417
- if ( had_static ) {
418
- wr.out("_static_", false);
419
- } else {
420
- wr.out(".", false);
421
- }
422
- }
423
- }
424
- if ( ctx.isDefinedClass(p.nameNode.get().type_name) ) {
425
- final RangerAppClassDesc c = ctx.findClass(p.nameNode.get().type_name);
426
- if ( c.doesInherit() ) {
427
- next_is_gs = true;
428
- }
429
- }
430
- if ( i == 0 ) {
431
- final String part = node.ns.get(0);
432
- if ( part.equals("this") ) {
433
- wr.out(thisName, false);
434
- continue;
435
- }
436
- if ( (!part.equals(thisName)) && ctx.isMemberVariable(part) ) {
437
- final Optional<RangerAppClassDesc> cc = ctx.getCurrentClass();
438
- final RangerAppClassDesc currC = cc.get();
439
- final Optional<RangerAppParamDesc> up = currC.findVariable(part);
440
- if ( up.isPresent() ) {
441
- /** unused: final RangerAppParamDesc p3 = up.get() **/ ;
442
- wr.out(thisName + ".", false);
443
- }
444
- }
445
- }
446
- if ( (p.compiledName.length()) > 0 ) {
447
- wr.out(this.adjustType(p.compiledName), false);
448
- } else {
449
- if ( (p.name.length()) > 0 ) {
450
- wr.out(this.adjustType(p.name), false);
451
- } else {
452
- wr.out(this.adjustType((node.ns.get(i))), false);
453
- }
454
- }
455
- if ( needs_par ) {
456
- wr.out("()", false);
457
- needs_par = false;
458
- }
459
- if ( i < ns_len ) {
460
- if ( p.nameNode.get().hasFlag("optional") ) {
461
- wr.out(".value.(", false);
462
- this.writeTypeDef(p.nameNode.get(), ctx, wr);
463
- wr.out(")", false);
464
- }
465
- }
466
- if ( p.isClass() ) {
467
- had_static = true;
468
- }
469
- }
470
- return;
471
- }
472
- if ( node.hasParamDesc ) {
473
- final String part_1 = node.ns.get(0);
474
- if ( (!part_1.equals(thisName)) && ctx.isMemberVariable(part_1) ) {
475
- final Optional<RangerAppClassDesc> cc_1 = ctx.getCurrentClass();
476
- final RangerAppClassDesc currC_1 = cc_1.get();
477
- final Optional<RangerAppParamDesc> up_1 = currC_1.findVariable(part_1);
478
- if ( up_1.isPresent() ) {
479
- /** unused: final RangerAppParamDesc p3_1 = up_1.get() **/ ;
480
- wr.out(thisName + ".", false);
481
- }
482
- }
483
- final Optional<RangerAppParamDesc> p_1 = node.paramDesc;
484
- wr.out(p_1.get().compiledName, false);
485
- return;
486
- }
487
- boolean b_was_static = false;
488
- for ( int i_1 = 0; i_1 < node.ns.size(); i_1++) {
489
- String part_2 = node.ns.get(i_1);
490
- if ( i_1 > 0 ) {
491
- if ( (i_1 == 1) && b_was_static ) {
492
- wr.out("_static_", false);
493
- } else {
494
- wr.out(".", false);
495
- }
496
- }
497
- if ( i_1 == 0 ) {
498
- if ( part_2.equals("this") ) {
499
- wr.out(thisName, false);
500
- continue;
501
- }
502
- if ( ctx.hasClass(part_2) ) {
503
- b_was_static = true;
504
- }
505
- if ( (!part_2.equals("this")) && ctx.isMemberVariable(part_2) ) {
506
- final Optional<RangerAppClassDesc> cc_2 = ctx.getCurrentClass();
507
- final RangerAppClassDesc currC_2 = cc_2.get();
508
- final Optional<RangerAppParamDesc> up_2 = currC_2.findVariable(part_2);
509
- if ( up_2.isPresent() ) {
510
- /** unused: final RangerAppParamDesc p3_2 = up_2.get() **/ ;
511
- wr.out(thisName + ".", false);
512
- }
513
- }
514
- }
515
- wr.out(this.adjustType(part_2), false);
516
- }
517
- }
518
-
519
- public void goExtractAssign( CodeNode value , RangerAppParamDesc p , RangerAppWriterContext ctx , CodeWriter wr ) {
520
- final CodeNode arr_node = value.children.get(1);
521
- wr.newline();
522
- wr.out("", true);
523
- wr.out("// array_extract operator ", true);
524
- wr.out("var ", false);
525
- final RangerAppParamDesc pArr = new RangerAppParamDesc();
526
- pArr.name = "_arrTemp";
527
- pArr.node = Optional.of(arr_node);
528
- pArr.nameNode = Optional.of(arr_node);
529
- pArr.is_optional = false;
530
- ctx.defineVariable(p.name, pArr);
531
- wr.out(pArr.compiledName, false);
532
- wr.out(" ", false);
533
- this.writeTypeDef(arr_node, ctx, wr);
534
- wr.newline();
535
- wr.out(((p.compiledName + " , ") + pArr.compiledName) + " = ", false);
536
- ctx.setInExpr();
537
- this.WalkNode(value, ctx, wr);
538
- ctx.unsetInExpr();
539
- wr.out(";", true);
540
- final CodeNode left = arr_node;
541
- final int a_len = (left.ns.size()) - 1;
542
- /** unused: final String last_part = left.ns.get(a_len) **/ ;
543
- boolean next_is_gs = false;
544
- boolean last_was_setter = false;
545
- boolean needs_par = false;
546
- boolean b_was_static = false;
547
- for ( int i = 0; i < left.ns.size(); i++) {
548
- String part = left.ns.get(i);
549
- if ( next_is_gs ) {
550
- if ( i == a_len ) {
551
- wr.out(".Set_", false);
552
- last_was_setter = true;
553
- } else {
554
- wr.out(".Get_", false);
555
- needs_par = true;
556
- next_is_gs = false;
557
- last_was_setter = false;
558
- }
559
- }
560
- if ( (last_was_setter == false) && (needs_par == false) ) {
561
- if ( i > 0 ) {
562
- if ( (i == 1) && b_was_static ) {
563
- wr.out("_static_", false);
564
- } else {
565
- wr.out(".", false);
566
- }
567
- }
568
- }
569
- if ( i == 0 ) {
570
- if ( part.equals("this") ) {
571
- wr.out(thisName, false);
572
- continue;
573
- }
574
- if ( ctx.hasClass(part) ) {
575
- b_was_static = true;
576
- }
577
- final RangerAppParamDesc partDef = ctx.getVariableDef(part);
578
- if ( partDef.nameNode.isPresent() ) {
579
- if ( ctx.isDefinedClass(partDef.nameNode.get().type_name) ) {
580
- final RangerAppClassDesc c = ctx.findClass(partDef.nameNode.get().type_name);
581
- if ( c.doesInherit() ) {
582
- next_is_gs = true;
583
- }
584
- }
585
- }
586
- if ( (!part.equals("this")) && ctx.isMemberVariable(part) ) {
587
- final Optional<RangerAppClassDesc> cc = ctx.getCurrentClass();
588
- final RangerAppClassDesc currC = cc.get();
589
- final Optional<RangerAppParamDesc> up = currC.findVariable(part);
590
- if ( up.isPresent() ) {
591
- /** unused: final RangerAppParamDesc p3 = up.get() **/ ;
592
- wr.out(thisName + ".", false);
593
- }
594
- }
595
- }
596
- if ( (left.nsp.size()) > 0 ) {
597
- final RangerAppParamDesc p_1 = left.nsp.get(i);
598
- wr.out(this.adjustType(p_1.compiledName), false);
599
- } else {
600
- if ( left.hasParamDesc ) {
601
- wr.out(left.paramDesc.get().compiledName, false);
602
- } else {
603
- wr.out(this.adjustType(part), false);
604
- }
605
- }
606
- if ( needs_par ) {
607
- wr.out("()", false);
608
- needs_par = false;
609
- }
610
- if ( (left.nsp.size()) >= (i + 1) ) {
611
- final RangerAppParamDesc pp = left.nsp.get(i);
612
- if ( pp.nameNode.get().hasFlag("optional") ) {
613
- wr.out(".value.(", false);
614
- this.writeTypeDef(pp.nameNode.get(), ctx, wr);
615
- wr.out(")", false);
616
- }
617
- }
618
- }
619
- if ( last_was_setter ) {
620
- wr.out("(", false);
621
- wr.out(pArr.compiledName, false);
622
- wr.out("); ", true);
623
- } else {
624
- wr.out(" = ", false);
625
- wr.out(pArr.compiledName, false);
626
- wr.out("; ", true);
627
- }
628
- wr.out("", true);
629
- }
630
-
631
- public void writeStructField( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
632
- if ( node.hasParamDesc ) {
633
- final CodeNode nn = node.children.get(1);
634
- final Optional<RangerAppParamDesc> p = nn.paramDesc;
635
- wr.out(p.get().compiledName + " ", false);
636
- if ( p.get().nameNode.get().hasFlag("optional") ) {
637
- wr.out("*GoNullable", false);
638
- } else {
639
- this.writeTypeDef(p.get().nameNode.get(), ctx, wr);
640
- }
641
- if ( p.get().ref_cnt == 0 ) {
642
- wr.out(" /** unused **/ ", false);
643
- }
644
- wr.out("", true);
645
- if ( p.get().nameNode.get().hasFlag("optional") ) {
646
- }
647
- }
648
- }
649
-
650
- public void writeVarDef( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
651
- if ( node.hasParamDesc ) {
652
- final CodeNode nn = node.children.get(1);
653
- final Optional<RangerAppParamDesc> p = nn.paramDesc;
654
- boolean b_not_used = false;
655
- if ( (p.get().ref_cnt == 0) && (p.get().is_class_variable == false) ) {
656
- wr.out(("/** unused: " + p.get().compiledName) + "*/", true);
657
- b_not_used = true;
658
- return;
659
- }
660
- final boolean map_or_hash = (nn.value_type == 6) || (nn.value_type == 7);
661
- if ( nn.hasFlag("optional") ) {
662
- wr.out(("var " + p.get().compiledName) + " *GoNullable = new(GoNullable); ", true);
663
- if ( (node.children.size()) > 2 ) {
664
- final CodeNode value = node.children.get(2);
665
- if ( value.hasParamDesc ) {
666
- final Optional<CodeNode> pnn = value.paramDesc.get().nameNode;
667
- if ( pnn.get().hasFlag("optional") ) {
668
- wr.out(p.get().compiledName + ".value = ", false);
669
- ctx.setInExpr();
670
- final CodeNode value_1 = node.getThird();
671
- this.WalkNode(value_1, ctx, wr);
672
- ctx.unsetInExpr();
673
- wr.out(".value;", true);
674
- wr.out(p.get().compiledName + ".has_value = ", false);
675
- ctx.setInExpr();
676
- final CodeNode value_2 = node.getThird();
677
- this.WalkNode(value_2, ctx, wr);
678
- ctx.unsetInExpr();
679
- wr.out(".has_value;", true);
680
- return;
681
- } else {
682
- wr.out(p.get().compiledName + ".value = ", false);
683
- ctx.setInExpr();
684
- final CodeNode value_3 = node.getThird();
685
- this.WalkNode(value_3, ctx, wr);
686
- ctx.unsetInExpr();
687
- wr.out(";", true);
688
- wr.out(p.get().compiledName + ".has_value = true;", true);
689
- return;
690
- }
691
- } else {
692
- wr.out(p.get().compiledName + " = ", false);
693
- ctx.setInExpr();
694
- final CodeNode value_4 = node.getThird();
695
- this.WalkNode(value_4, ctx, wr);
696
- ctx.unsetInExpr();
697
- wr.out(";", true);
698
- return;
699
- }
700
- }
701
- return;
702
- } else {
703
- if ( ((p.get().set_cnt > 0) || p.get().is_class_variable) || map_or_hash ) {
704
- wr.out(("var " + p.get().compiledName) + " ", false);
705
- } else {
706
- wr.out(("var " + p.get().compiledName) + " ", false);
707
- }
708
- }
709
- this.writeTypeDef2(p.get().nameNode.get(), ctx, wr);
710
- if ( (node.children.size()) > 2 ) {
711
- final CodeNode value_5 = node.getThird();
712
- if ( value_5.expression && ((value_5.children.size()) > 1) ) {
713
- final CodeNode fc = value_5.children.get(0);
714
- if ( fc.vref.equals("array_extract") ) {
715
- this.goExtractAssign(value_5, p.get(), ctx, wr);
716
- return;
717
- }
718
- }
719
- wr.out(" = ", false);
720
- ctx.setInExpr();
721
- this.WalkNode(value_5, ctx, wr);
722
- ctx.unsetInExpr();
723
- } else {
724
- if ( nn.value_type == 6 ) {
725
- wr.out(" = make(", false);
726
- this.writeTypeDef(p.get().nameNode.get(), ctx, wr);
727
- wr.out(", 0)", false);
728
- }
729
- if ( nn.value_type == 7 ) {
730
- wr.out(" = make(", false);
731
- this.writeTypeDef(p.get().nameNode.get(), ctx, wr);
732
- wr.out(")", false);
733
- }
734
- }
735
- wr.out(";", false);
736
- if ( (p.get().ref_cnt == 0) && (p.get().is_class_variable == true) ) {
737
- wr.out(" /** note: unused */", false);
738
- }
739
- if ( (p.get().ref_cnt == 0) && (p.get().is_class_variable == false) ) {
740
- wr.out(" **/ ", true);
741
- } else {
742
- wr.newline();
743
- }
744
- if ( b_not_used == false ) {
745
- if ( nn.hasFlag("optional") ) {
746
- wr.addImport("errors");
747
- }
748
- }
749
- }
750
- }
751
-
752
- public void writeArgsDef( RangerAppFunctionDesc fnDesc , RangerAppWriterContext ctx , CodeWriter wr ) {
753
- for ( int i = 0; i < fnDesc.params.size(); i++) {
754
- RangerAppParamDesc arg = fnDesc.params.get(i);
755
- if ( i > 0 ) {
756
- wr.out(", ", false);
757
- }
758
- wr.out(arg.name + " ", false);
759
- if ( arg.nameNode.get().hasFlag("optional") ) {
760
- wr.out("*GoNullable", false);
761
- } else {
762
- this.writeTypeDef(arg.nameNode.get(), ctx, wr);
763
- }
764
- }
765
- }
766
-
767
- public void writeNewCall( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
768
- if ( node.hasNewOper ) {
769
- final Optional<RangerAppClassDesc> cl = node.clDesc;
770
- /** unused: final CodeNode fc = node.getSecond() **/ ;
771
- wr.out(("CreateNew_" + node.clDesc.get().name) + "(", false);
772
- final Optional<RangerAppFunctionDesc> constr = cl.get().constructor_fn;
773
- final CodeNode givenArgs = node.getThird();
774
- if ( constr.isPresent() ) {
775
- for ( int i = 0; i < constr.get().params.size(); i++) {
776
- RangerAppParamDesc arg = constr.get().params.get(i);
777
- final CodeNode n = givenArgs.children.get(i);
778
- if ( i > 0 ) {
779
- wr.out(", ", false);
780
- }
781
- if ( true || (arg.nameNode.isPresent()) ) {
782
- this.WalkNode(n, ctx, wr);
783
- }
784
- }
785
- }
786
- wr.out(")", false);
787
- }
788
- }
789
-
790
- public void CreateLambdaCall( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
791
- final CodeNode fName = node.children.get(0);
792
- final CodeNode args = node.children.get(1);
793
- this.WriteVRef(fName, ctx, wr);
794
- wr.out("(", false);
795
- for ( int i = 0; i < args.children.size(); i++) {
796
- CodeNode arg = args.children.get(i);
797
- if ( i > 0 ) {
798
- wr.out(", ", false);
799
- }
800
- if ( arg.value_type != 0 ) {
801
- this.WalkNode(arg, ctx, wr);
802
- }
803
- }
804
- wr.out(")", false);
805
- if ( ctx.expressionLevel() == 0 ) {
806
- wr.out(";", true);
807
- }
808
- }
809
-
810
- public void CreateLambda( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
811
- final RangerAppWriterContext lambdaCtx = node.lambda_ctx.get();
812
- final CodeNode fnNode = node.children.get(0);
813
- final CodeNode args = node.children.get(1);
814
- final CodeNode body = node.children.get(2);
815
- wr.out("func (", false);
816
- for ( int i = 0; i < args.children.size(); i++) {
817
- CodeNode arg = args.children.get(i);
818
- if ( i > 0 ) {
819
- wr.out(", ", false);
820
- }
821
- this.WalkNode(arg, lambdaCtx, wr);
822
- wr.out(" ", false);
823
- if ( arg.hasFlag("optional") ) {
824
- wr.out("*GoNullable", false);
825
- } else {
826
- this.writeTypeDef(arg, lambdaCtx, wr);
827
- }
828
- }
829
- wr.out(") ", false);
830
- if ( fnNode.hasFlag("optional") ) {
831
- wr.out("*GoNullable", false);
832
- } else {
833
- this.writeTypeDef(fnNode, lambdaCtx, wr);
834
- }
835
- wr.out(" {", true);
836
- wr.indent(1);
837
- lambdaCtx.restartExpressionLevel();
838
- for ( int i_1 = 0; i_1 < body.children.size(); i_1++) {
839
- CodeNode item = body.children.get(i_1);
840
- this.WalkNode(item, lambdaCtx, wr);
841
- }
842
- wr.newline();
843
- wr.indent(-1);
844
- wr.out("}", false);
845
- }
846
-
847
- public void CustomOperator( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
848
- final CodeNode fc = node.getFirst();
849
- final String cmd = fc.vref;
850
- if ( ((cmd.equals("=")) || (cmd.equals("push"))) || (cmd.equals("removeLast")) ) {
851
- final CodeNode left = node.getSecond();
852
- CodeNode right = left;
853
- if ( (cmd.equals("=")) || (cmd.equals("push")) ) {
854
- right = node.getThird();
855
- }
856
- wr.newline();
857
- boolean b_was_static = false;
858
- if ( left.hasParamDesc ) {
859
- final int a_len = (left.ns.size()) - 1;
860
- /** unused: final String last_part = left.ns.get(a_len) **/ ;
861
- boolean next_is_gs = false;
862
- boolean last_was_setter = false;
863
- boolean needs_par = false;
864
- for ( int i = 0; i < left.ns.size(); i++) {
865
- String part = left.ns.get(i);
866
- if ( next_is_gs ) {
867
- if ( i == a_len ) {
868
- wr.out(".Set_", false);
869
- last_was_setter = true;
870
- } else {
871
- wr.out(".Get_", false);
872
- needs_par = true;
873
- next_is_gs = false;
874
- last_was_setter = false;
875
- }
876
- }
877
- if ( (last_was_setter == false) && (needs_par == false) ) {
878
- if ( i > 0 ) {
879
- if ( (i == 1) && b_was_static ) {
880
- wr.out("_static_", false);
881
- } else {
882
- wr.out(".", false);
883
- }
884
- }
885
- }
886
- if ( i == 0 ) {
887
- if ( part.equals("this") ) {
888
- wr.out(thisName, false);
889
- continue;
890
- }
891
- if ( ctx.hasClass(part) ) {
892
- b_was_static = true;
893
- }
894
- if ( (!part.equals("this")) && ctx.isMemberVariable(part) ) {
895
- final Optional<RangerAppClassDesc> cc = ctx.getCurrentClass();
896
- final RangerAppClassDesc currC = cc.get();
897
- final Optional<RangerAppParamDesc> up = currC.findVariable(part);
898
- if ( up.isPresent() ) {
899
- /** unused: final RangerAppParamDesc p3 = up.get() **/ ;
900
- wr.out(thisName + ".", false);
901
- }
902
- }
903
- }
904
- RangerAppParamDesc partDef = ctx.getVariableDef(part);
905
- if ( (left.nsp.size()) > i ) {
906
- partDef = left.nsp.get(i);
907
- }
908
- if ( partDef.nameNode.isPresent() ) {
909
- if ( ctx.isDefinedClass(partDef.nameNode.get().type_name) ) {
910
- final RangerAppClassDesc c = ctx.findClass(partDef.nameNode.get().type_name);
911
- if ( c.doesInherit() ) {
912
- next_is_gs = true;
913
- }
914
- }
915
- }
916
- if ( (left.nsp.size()) > 0 ) {
917
- final RangerAppParamDesc p = left.nsp.get(i);
918
- wr.out(this.adjustType(p.compiledName), false);
919
- } else {
920
- if ( left.hasParamDesc ) {
921
- wr.out(left.paramDesc.get().compiledName, false);
922
- } else {
923
- wr.out(this.adjustType(part), false);
924
- }
925
- }
926
- if ( needs_par ) {
927
- wr.out("()", false);
928
- needs_par = false;
929
- }
930
- if ( (left.nsp.size()) >= (i + 1) ) {
931
- final RangerAppParamDesc pp = left.nsp.get(i);
932
- if ( pp.nameNode.get().hasFlag("optional") ) {
933
- wr.out(".value.(", false);
934
- this.writeTypeDef(pp.nameNode.get(), ctx, wr);
935
- wr.out(")", false);
936
- }
937
- }
938
- }
939
- if ( cmd.equals("removeLast") ) {
940
- if ( last_was_setter ) {
941
- wr.out("(", false);
942
- ctx.setInExpr();
943
- this.WalkNode(left, ctx, wr);
944
- wr.out("[:len(", false);
945
- this.WalkNode(left, ctx, wr);
946
- wr.out(")-1]", false);
947
- ctx.unsetInExpr();
948
- wr.out("); ", true);
949
- } else {
950
- wr.out(" = ", false);
951
- ctx.setInExpr();
952
- this.WalkNode(left, ctx, wr);
953
- wr.out("[:len(", false);
954
- this.WalkNode(left, ctx, wr);
955
- wr.out(")-1]", false);
956
- ctx.unsetInExpr();
957
- wr.out("; ", true);
958
- }
959
- return;
960
- }
961
- if ( cmd.equals("push") ) {
962
- if ( last_was_setter ) {
963
- wr.out("(", false);
964
- ctx.setInExpr();
965
- wr.out("append(", false);
966
- this.WalkNode(left, ctx, wr);
967
- wr.out(",", false);
968
- this.WalkNode(right, ctx, wr);
969
- ctx.unsetInExpr();
970
- wr.out(")); ", true);
971
- } else {
972
- wr.out(" = ", false);
973
- wr.out("append(", false);
974
- ctx.setInExpr();
975
- this.WalkNode(left, ctx, wr);
976
- wr.out(",", false);
977
- this.WalkNode(right, ctx, wr);
978
- ctx.unsetInExpr();
979
- wr.out("); ", true);
980
- }
981
- return;
982
- }
983
- if ( last_was_setter ) {
984
- wr.out("(", false);
985
- ctx.setInExpr();
986
- this.WalkNode(right, ctx, wr);
987
- ctx.unsetInExpr();
988
- wr.out("); ", true);
989
- } else {
990
- wr.out(" = ", false);
991
- ctx.setInExpr();
992
- this.WalkNode(right, ctx, wr);
993
- ctx.unsetInExpr();
994
- wr.out("; ", true);
995
- }
996
- return;
997
- }
998
- this.WriteSetterVRef(left, ctx, wr);
999
- wr.out(" = ", false);
1000
- ctx.setInExpr();
1001
- this.WalkNode(right, ctx, wr);
1002
- ctx.unsetInExpr();
1003
- wr.out("; /* custom */", true);
1004
- }
1005
- }
1006
-
1007
- public void writeInterface( RangerAppClassDesc cl , RangerAppWriterContext ctx , CodeWriter wr ) {
1008
- wr.out(("type " + cl.name) + " interface { ", true);
1009
- wr.indent(1);
1010
- for ( int i = 0; i < cl.defined_variants.size(); i++) {
1011
- String fnVar = cl.defined_variants.get(i);
1012
- final Optional<RangerAppMethodVariants> mVs = Optional.ofNullable(cl.method_variants.get(fnVar));
1013
- for ( int i_1 = 0; i_1 < mVs.get().variants.size(); i_1++) {
1014
- RangerAppFunctionDesc variant = mVs.get().variants.get(i_1);
1015
- wr.out(variant.compiledName + "(", false);
1016
- this.writeArgsDef(variant, ctx, wr);
1017
- wr.out(") ", false);
1018
- if ( variant.nameNode.get().hasFlag("optional") ) {
1019
- wr.out("*GoNullable", false);
1020
- } else {
1021
- this.writeTypeDef(variant.nameNode.get(), ctx, wr);
1022
- }
1023
- wr.out("", true);
1024
- }
1025
- }
1026
- wr.indent(-1);
1027
- wr.out("}", true);
1028
- }
1029
-
1030
- public void writeClass( CodeNode node , RangerAppWriterContext ctx , CodeWriter orig_wr ) {
1031
- final Optional<RangerAppClassDesc> cl = node.clDesc;
1032
- if ( !cl.isPresent() ) {
1033
- return;
1034
- }
1035
- final CodeWriter wr = orig_wr;
1036
- if ( did_write_nullable == false ) {
1037
- wr.raw("\r\ntype GoNullable struct { \r\n value interface{}\r\n has_value bool\r\n}\r\n", true);
1038
- wr.createTag("utilities");
1039
- did_write_nullable = true;
1040
- }
1041
- HashMap<String,Boolean> declaredVariable = new HashMap<String,Boolean>();
1042
- wr.out(("type " + cl.get().name) + " struct { ", true);
1043
- wr.indent(1);
1044
- for ( int i = 0; i < cl.get().variables.size(); i++) {
1045
- RangerAppParamDesc pvar = cl.get().variables.get(i);
1046
- this.writeStructField(pvar.node.get(), ctx, wr);
1047
- declaredVariable.put(pvar.name, true);
1048
- }
1049
- if ( (cl.get().extends_classes.size()) > 0 ) {
1050
- for ( int i_1 = 0; i_1 < cl.get().extends_classes.size(); i_1++) {
1051
- String pName = cl.get().extends_classes.get(i_1);
1052
- final RangerAppClassDesc pC = ctx.findClass(pName);
1053
- wr.out("// inherited from parent class " + pName, true);
1054
- for ( int i_2 = 0; i_2 < pC.variables.size(); i_2++) {
1055
- RangerAppParamDesc pvar_1 = pC.variables.get(i_2);
1056
- if ( declaredVariable.containsKey(pvar_1.name) ) {
1057
- continue;
1058
- }
1059
- this.writeStructField(pvar_1.node.get(), ctx, wr);
1060
- }
1061
- }
1062
- }
1063
- wr.indent(-1);
1064
- wr.out("}", true);
1065
- wr.out(("type IFACE_" + cl.get().name) + " interface { ", true);
1066
- wr.indent(1);
1067
- for ( int i_3 = 0; i_3 < cl.get().variables.size(); i_3++) {
1068
- RangerAppParamDesc p = cl.get().variables.get(i_3);
1069
- wr.out("Get_", false);
1070
- wr.out(p.compiledName + "() ", false);
1071
- if ( p.nameNode.get().hasFlag("optional") ) {
1072
- wr.out("*GoNullable", false);
1073
- } else {
1074
- this.writeTypeDef(p.nameNode.get(), ctx, wr);
1075
- }
1076
- wr.out("", true);
1077
- wr.out("Set_", false);
1078
- wr.out(p.compiledName + "(value ", false);
1079
- if ( p.nameNode.get().hasFlag("optional") ) {
1080
- wr.out("*GoNullable", false);
1081
- } else {
1082
- this.writeTypeDef(p.nameNode.get(), ctx, wr);
1083
- }
1084
- wr.out(") ", true);
1085
- }
1086
- for ( int i_4 = 0; i_4 < cl.get().defined_variants.size(); i_4++) {
1087
- String fnVar = cl.get().defined_variants.get(i_4);
1088
- final Optional<RangerAppMethodVariants> mVs = Optional.ofNullable(cl.get().method_variants.get(fnVar));
1089
- for ( int i_5 = 0; i_5 < mVs.get().variants.size(); i_5++) {
1090
- RangerAppFunctionDesc variant = mVs.get().variants.get(i_5);
1091
- wr.out(variant.compiledName + "(", false);
1092
- this.writeArgsDef(variant, ctx, wr);
1093
- wr.out(") ", false);
1094
- if ( variant.nameNode.get().hasFlag("optional") ) {
1095
- wr.out("*GoNullable", false);
1096
- } else {
1097
- this.writeTypeDef(variant.nameNode.get(), ctx, wr);
1098
- }
1099
- wr.out("", true);
1100
- }
1101
- }
1102
- wr.indent(-1);
1103
- wr.out("}", true);
1104
- thisName = "me";
1105
- wr.out("", true);
1106
- wr.out(("func CreateNew_" + cl.get().name) + "(", false);
1107
- if ( cl.get().has_constructor ) {
1108
- final Optional<RangerAppFunctionDesc> constr = cl.get().constructor_fn;
1109
- for ( int i_6 = 0; i_6 < constr.get().params.size(); i_6++) {
1110
- RangerAppParamDesc arg = constr.get().params.get(i_6);
1111
- if ( i_6 > 0 ) {
1112
- wr.out(", ", false);
1113
- }
1114
- wr.out(arg.name + " ", false);
1115
- this.writeTypeDef(arg.nameNode.get(), ctx, wr);
1116
- }
1117
- }
1118
- wr.out((") *" + cl.get().name) + " {", true);
1119
- wr.indent(1);
1120
- wr.newline();
1121
- wr.out(("me := new(" + cl.get().name) + ")", true);
1122
- for ( int i_7 = 0; i_7 < cl.get().variables.size(); i_7++) {
1123
- RangerAppParamDesc pvar_2 = cl.get().variables.get(i_7);
1124
- final CodeNode nn = pvar_2.node.get();
1125
- if ( (nn.children.size()) > 2 ) {
1126
- final CodeNode valueNode = nn.children.get(2);
1127
- wr.out(("me." + pvar_2.compiledName) + " = ", false);
1128
- this.WalkNode(valueNode, ctx, wr);
1129
- wr.out("", true);
1130
- } else {
1131
- final Optional<CodeNode> pNameN = pvar_2.nameNode;
1132
- if ( pNameN.get().value_type == 6 ) {
1133
- wr.out(("me." + pvar_2.compiledName) + " = ", false);
1134
- wr.out("make(", false);
1135
- this.writeTypeDef(pvar_2.nameNode.get(), ctx, wr);
1136
- wr.out(",0)", true);
1137
- }
1138
- if ( pNameN.get().value_type == 7 ) {
1139
- wr.out(("me." + pvar_2.compiledName) + " = ", false);
1140
- wr.out("make(", false);
1141
- this.writeTypeDef(pvar_2.nameNode.get(), ctx, wr);
1142
- wr.out(")", true);
1143
- }
1144
- }
1145
- }
1146
- for ( int i_8 = 0; i_8 < cl.get().variables.size(); i_8++) {
1147
- RangerAppParamDesc pvar_3 = cl.get().variables.get(i_8);
1148
- if ( pvar_3.nameNode.get().hasFlag("optional") ) {
1149
- wr.out(("me." + pvar_3.compiledName) + " = new(GoNullable);", true);
1150
- }
1151
- }
1152
- if ( (cl.get().extends_classes.size()) > 0 ) {
1153
- for ( int i_9 = 0; i_9 < cl.get().extends_classes.size(); i_9++) {
1154
- String pName_1 = cl.get().extends_classes.get(i_9);
1155
- final RangerAppClassDesc pC_1 = ctx.findClass(pName_1);
1156
- for ( int i_10 = 0; i_10 < pC_1.variables.size(); i_10++) {
1157
- RangerAppParamDesc pvar_4 = pC_1.variables.get(i_10);
1158
- final CodeNode nn_1 = pvar_4.node.get();
1159
- if ( (nn_1.children.size()) > 2 ) {
1160
- final CodeNode valueNode_1 = nn_1.children.get(2);
1161
- wr.out(("me." + pvar_4.compiledName) + " = ", false);
1162
- this.WalkNode(valueNode_1, ctx, wr);
1163
- wr.out("", true);
1164
- } else {
1165
- final CodeNode pNameN_1 = pvar_4.nameNode.get();
1166
- if ( pNameN_1.value_type == 6 ) {
1167
- wr.out(("me." + pvar_4.compiledName) + " = ", false);
1168
- wr.out("make(", false);
1169
- this.writeTypeDef(pvar_4.nameNode.get(), ctx, wr);
1170
- wr.out(",0)", true);
1171
- }
1172
- if ( pNameN_1.value_type == 7 ) {
1173
- wr.out(("me." + pvar_4.compiledName) + " = ", false);
1174
- wr.out("make(", false);
1175
- this.writeTypeDef(pvar_4.nameNode.get(), ctx, wr);
1176
- wr.out(")", true);
1177
- }
1178
- }
1179
- }
1180
- for ( int i_11 = 0; i_11 < pC_1.variables.size(); i_11++) {
1181
- RangerAppParamDesc pvar_5 = pC_1.variables.get(i_11);
1182
- if ( pvar_5.nameNode.get().hasFlag("optional") ) {
1183
- wr.out(("me." + pvar_5.compiledName) + " = new(GoNullable);", true);
1184
- }
1185
- }
1186
- if ( pC_1.has_constructor ) {
1187
- final Optional<RangerAppFunctionDesc> constr_1 = pC_1.constructor_fn;
1188
- final RangerAppWriterContext subCtx = constr_1.get().fnCtx.get();
1189
- subCtx.is_function = true;
1190
- this.WalkNode(constr_1.get().fnBody.get(), subCtx, wr);
1191
- }
1192
- }
1193
- }
1194
- if ( cl.get().has_constructor ) {
1195
- final Optional<RangerAppFunctionDesc> constr_2 = cl.get().constructor_fn;
1196
- final RangerAppWriterContext subCtx_1 = constr_2.get().fnCtx.get();
1197
- subCtx_1.is_function = true;
1198
- this.WalkNode(constr_2.get().fnBody.get(), subCtx_1, wr);
1199
- }
1200
- wr.out("return me;", true);
1201
- wr.indent(-1);
1202
- wr.out("}", true);
1203
- thisName = "this";
1204
- for ( int i_12 = 0; i_12 < cl.get().static_methods.size(); i_12++) {
1205
- RangerAppFunctionDesc variant_1 = cl.get().static_methods.get(i_12);
1206
- if ( variant_1.nameNode.get().hasFlag("main") ) {
1207
- continue;
1208
- }
1209
- wr.newline();
1210
- wr.out(((("func " + cl.get().name) + "_static_") + variant_1.compiledName) + "(", false);
1211
- this.writeArgsDef(variant_1, ctx, wr);
1212
- wr.out(") ", false);
1213
- this.writeTypeDef(variant_1.nameNode.get(), ctx, wr);
1214
- wr.out(" {", true);
1215
- wr.indent(1);
1216
- wr.newline();
1217
- final RangerAppWriterContext subCtx_2 = variant_1.fnCtx.get();
1218
- subCtx_2.is_function = true;
1219
- this.WalkNode(variant_1.fnBody.get(), subCtx_2, wr);
1220
- wr.newline();
1221
- wr.indent(-1);
1222
- wr.out("}", true);
1223
- }
1224
- HashMap<String,Boolean> declaredFn = new HashMap<String,Boolean>();
1225
- for ( int i_13 = 0; i_13 < cl.get().defined_variants.size(); i_13++) {
1226
- String fnVar_1 = cl.get().defined_variants.get(i_13);
1227
- final Optional<RangerAppMethodVariants> mVs_1 = Optional.ofNullable(cl.get().method_variants.get(fnVar_1));
1228
- for ( int i_14 = 0; i_14 < mVs_1.get().variants.size(); i_14++) {
1229
- RangerAppFunctionDesc variant_2 = mVs_1.get().variants.get(i_14);
1230
- declaredFn.put(variant_2.name, true);
1231
- wr.out(((("func (this *" + cl.get().name) + ") ") + variant_2.compiledName) + " (", false);
1232
- this.writeArgsDef(variant_2, ctx, wr);
1233
- wr.out(") ", false);
1234
- if ( variant_2.nameNode.get().hasFlag("optional") ) {
1235
- wr.out("*GoNullable", false);
1236
- } else {
1237
- this.writeTypeDef(variant_2.nameNode.get(), ctx, wr);
1238
- }
1239
- wr.out(" {", true);
1240
- wr.indent(1);
1241
- wr.newline();
1242
- final RangerAppWriterContext subCtx_3 = variant_2.fnCtx.get();
1243
- subCtx_3.is_function = true;
1244
- this.WalkNode(variant_2.fnBody.get(), subCtx_3, wr);
1245
- wr.newline();
1246
- wr.indent(-1);
1247
- wr.out("}", true);
1248
- }
1249
- }
1250
- if ( (cl.get().extends_classes.size()) > 0 ) {
1251
- for ( int i_15 = 0; i_15 < cl.get().extends_classes.size(); i_15++) {
1252
- String pName_2 = cl.get().extends_classes.get(i_15);
1253
- final RangerAppClassDesc pC_2 = ctx.findClass(pName_2);
1254
- wr.out("// inherited methods from parent class " + pName_2, true);
1255
- for ( int i_16 = 0; i_16 < pC_2.defined_variants.size(); i_16++) {
1256
- String fnVar_2 = pC_2.defined_variants.get(i_16);
1257
- final Optional<RangerAppMethodVariants> mVs_2 = Optional.ofNullable(pC_2.method_variants.get(fnVar_2));
1258
- for ( int i_17 = 0; i_17 < mVs_2.get().variants.size(); i_17++) {
1259
- RangerAppFunctionDesc variant_3 = mVs_2.get().variants.get(i_17);
1260
- if ( declaredFn.containsKey(variant_3.name) ) {
1261
- continue;
1262
- }
1263
- wr.out(((("func (this *" + cl.get().name) + ") ") + variant_3.compiledName) + " (", false);
1264
- this.writeArgsDef(variant_3, ctx, wr);
1265
- wr.out(") ", false);
1266
- if ( variant_3.nameNode.get().hasFlag("optional") ) {
1267
- wr.out("*GoNullable", false);
1268
- } else {
1269
- this.writeTypeDef(variant_3.nameNode.get(), ctx, wr);
1270
- }
1271
- wr.out(" {", true);
1272
- wr.indent(1);
1273
- wr.newline();
1274
- final RangerAppWriterContext subCtx_4 = variant_3.fnCtx.get();
1275
- subCtx_4.is_function = true;
1276
- this.WalkNode(variant_3.fnBody.get(), subCtx_4, wr);
1277
- wr.newline();
1278
- wr.indent(-1);
1279
- wr.out("}", true);
1280
- }
1281
- }
1282
- }
1283
- }
1284
- HashMap<String,Boolean> declaredGetter = new HashMap<String,Boolean>();
1285
- for ( int i_18 = 0; i_18 < cl.get().variables.size(); i_18++) {
1286
- RangerAppParamDesc p_1 = cl.get().variables.get(i_18);
1287
- declaredGetter.put(p_1.name, true);
1288
- wr.newline();
1289
- wr.out("// getter for variable " + p_1.name, true);
1290
- wr.out(("func (this *" + cl.get().name) + ") ", false);
1291
- wr.out("Get_", false);
1292
- wr.out(p_1.compiledName + "() ", false);
1293
- if ( p_1.nameNode.get().hasFlag("optional") ) {
1294
- wr.out("*GoNullable", false);
1295
- } else {
1296
- this.writeTypeDef(p_1.nameNode.get(), ctx, wr);
1297
- }
1298
- wr.out(" {", true);
1299
- wr.indent(1);
1300
- wr.out("return this." + p_1.compiledName, true);
1301
- wr.indent(-1);
1302
- wr.out("}", true);
1303
- wr.newline();
1304
- wr.out("// setter for variable " + p_1.name, true);
1305
- wr.out(("func (this *" + cl.get().name) + ") ", false);
1306
- wr.out("Set_", false);
1307
- wr.out(p_1.compiledName + "( value ", false);
1308
- if ( p_1.nameNode.get().hasFlag("optional") ) {
1309
- wr.out("*GoNullable", false);
1310
- } else {
1311
- this.writeTypeDef(p_1.nameNode.get(), ctx, wr);
1312
- }
1313
- wr.out(") ", false);
1314
- wr.out(" {", true);
1315
- wr.indent(1);
1316
- wr.out(("this." + p_1.compiledName) + " = value ", true);
1317
- wr.indent(-1);
1318
- wr.out("}", true);
1319
- }
1320
- if ( (cl.get().extends_classes.size()) > 0 ) {
1321
- for ( int i_19 = 0; i_19 < cl.get().extends_classes.size(); i_19++) {
1322
- String pName_3 = cl.get().extends_classes.get(i_19);
1323
- final RangerAppClassDesc pC_3 = ctx.findClass(pName_3);
1324
- wr.out("// inherited getters and setters from the parent class " + pName_3, true);
1325
- for ( int i_20 = 0; i_20 < pC_3.variables.size(); i_20++) {
1326
- RangerAppParamDesc p_2 = pC_3.variables.get(i_20);
1327
- if ( declaredGetter.containsKey(p_2.name) ) {
1328
- continue;
1329
- }
1330
- wr.newline();
1331
- wr.out("// getter for variable " + p_2.name, true);
1332
- wr.out(("func (this *" + cl.get().name) + ") ", false);
1333
- wr.out("Get_", false);
1334
- wr.out(p_2.compiledName + "() ", false);
1335
- if ( p_2.nameNode.get().hasFlag("optional") ) {
1336
- wr.out("*GoNullable", false);
1337
- } else {
1338
- this.writeTypeDef(p_2.nameNode.get(), ctx, wr);
1339
- }
1340
- wr.out(" {", true);
1341
- wr.indent(1);
1342
- wr.out("return this." + p_2.compiledName, true);
1343
- wr.indent(-1);
1344
- wr.out("}", true);
1345
- wr.newline();
1346
- wr.out("// getter for variable " + p_2.name, true);
1347
- wr.out(("func (this *" + cl.get().name) + ") ", false);
1348
- wr.out("Set_", false);
1349
- wr.out(p_2.compiledName + "( value ", false);
1350
- if ( p_2.nameNode.get().hasFlag("optional") ) {
1351
- wr.out("*GoNullable", false);
1352
- } else {
1353
- this.writeTypeDef(p_2.nameNode.get(), ctx, wr);
1354
- }
1355
- wr.out(") ", false);
1356
- wr.out(" {", true);
1357
- wr.indent(1);
1358
- wr.out(("this." + p_2.compiledName) + " = value ", true);
1359
- wr.indent(-1);
1360
- wr.out("}", true);
1361
- }
1362
- }
1363
- }
1364
- for ( int i_21 = 0; i_21 < cl.get().static_methods.size(); i_21++) {
1365
- RangerAppFunctionDesc variant_4 = cl.get().static_methods.get(i_21);
1366
- if ( variant_4.nameNode.get().hasFlag("main") && (variant_4.nameNode.get().code.get().filename.equals(ctx.getRootFile())) ) {
1367
- wr.out("func main() {", true);
1368
- wr.indent(1);
1369
- wr.newline();
1370
- final RangerAppWriterContext subCtx_5 = variant_4.fnCtx.get();
1371
- subCtx_5.is_function = true;
1372
- this.WalkNode(variant_4.fnBody.get(), subCtx_5, wr);
1373
- wr.newline();
1374
- wr.indent(-1);
1375
- wr.out("}", true);
1376
- }
1377
- }
1378
- }
1379
- }