ranger-compiler 2.1.70 → 3.0.4

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 +114 -0
  2. package/README.md +956 -133
  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/{compiler/bin/output.js → dist/rgrc.js} +15377 -7936
  46. package/dist/stdops.rgr +168 -0
  47. package/package.json +196 -39
  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/bin/output.js +0 -23819
  150. package/compiler/ColorConsole.clj +0 -22
  151. package/compiler/ContextOperators.clj +0 -75
  152. package/compiler/FlowEnterVarDef.clj +0 -223
  153. package/compiler/InputFileSystem.clj +0 -276
  154. package/compiler/RangerDocs.clj +0 -7
  155. package/compiler/TFactory.clj +0 -146
  156. package/compiler/TFiles.clj +0 -23
  157. package/compiler/TFlow.clj +0 -39
  158. package/compiler/TNodeFactory.clj +0 -84
  159. package/compiler/TTypes.clj +0 -188
  160. package/compiler/VirtualCompiler.clj +0 -807
  161. package/compiler/bin/ng_Compiler.js +0 -23779
  162. package/compiler/commonmark_plugin.clj +0 -359
  163. package/compiler/feat2.bat +0 -2
  164. package/compiler/feats.bat +0 -9
  165. package/compiler/feature_tests.clj +0 -192
  166. package/compiler/index.js +0 -2
  167. package/compiler/issue_57.clj +0 -25
  168. package/compiler/makefile_plugin.clj +0 -135
  169. package/compiler/markdown_plugin.clj +0 -386
  170. package/compiler/maven_plugin.clj +0 -162
  171. package/compiler/ng_AndroidPageWriter.clj +0 -299
  172. package/compiler/ng_CodeNode.clj +0 -756
  173. package/compiler/ng_CodeNodeCompilerExtensions.clj +0 -839
  174. package/compiler/ng_Compiler.clj +0 -49
  175. package/compiler/ng_CompilerGeneric.clj +0 -260
  176. package/compiler/ng_CompilerOrig.clj +0 -854
  177. package/compiler/ng_DictNode.clj +0 -346
  178. package/compiler/ng_DictNode2.clj +0 -316
  179. package/compiler/ng_Execute.clj +0 -138
  180. package/compiler/ng_Execute1.clj +0 -129
  181. package/compiler/ng_FlowWork.clj +0 -3951
  182. package/compiler/ng_LiveCompiler.clj +0 -1109
  183. package/compiler/ng_RagnerJavaScriptClassWriter.clj +0 -402
  184. package/compiler/ng_RangerActiveOperators.clj +0 -86
  185. package/compiler/ng_RangerAppClassDesc.clj +0 -400
  186. package/compiler/ng_RangerAppEnums.clj +0 -86
  187. package/compiler/ng_RangerAppFunctionDesc.clj +0 -127
  188. package/compiler/ng_RangerAppMessages.clj +0 -15
  189. package/compiler/ng_RangerAppOperatorDesc.clj +0 -20
  190. package/compiler/ng_RangerAppParamDesc.clj +0 -388
  191. package/compiler/ng_RangerAppWriterContext.clj +0 -1793
  192. package/compiler/ng_RangerArgMatch.clj +0 -638
  193. package/compiler/ng_RangerCSharpClassWriter.clj +0 -484
  194. package/compiler/ng_RangerCppClassWriter.clj +0 -1023
  195. package/compiler/ng_RangerDocGenerator.clj +0 -305
  196. package/compiler/ng_RangerFlowParser.clj +0 -4992
  197. package/compiler/ng_RangerFlowParserOrig.clj +0 -4002
  198. package/compiler/ng_RangerGenericClassWriter.clj +0 -573
  199. package/compiler/ng_RangerGolangClassWriter.clj +0 -1766
  200. package/compiler/ng_RangerImmutableExtension.clj +0 -77
  201. package/compiler/ng_RangerJava7ClassWriter.clj +0 -961
  202. package/compiler/ng_RangerJavaScriptClassWriter.clj +0 -1040
  203. package/compiler/ng_RangerKotlinClassWriter.clj +0 -372
  204. package/compiler/ng_RangerLanguageWriters.clj +0 -14
  205. package/compiler/ng_RangerLispParser.clj +0 -873
  206. package/compiler/ng_RangerPHPClassWriter.clj +0 -643
  207. package/compiler/ng_RangerPlugin.clj +0 -41
  208. package/compiler/ng_RangerRangerClassWriter.clj +0 -357
  209. package/compiler/ng_RangerRustClassWriter.clj +0 -420
  210. package/compiler/ng_RangerScalaClassWriter.clj +0 -818
  211. package/compiler/ng_RangerSerializeClass.clj +0 -502
  212. package/compiler/ng_RangerServiceBuilder.clj +0 -63
  213. package/compiler/ng_RangerSwift3ClassWriter.clj +0 -809
  214. package/compiler/ng_RangerSwiftClassWriter.clj +0 -0
  215. package/compiler/ng_RangerTypeClass.clj +0 -45
  216. package/compiler/ng_SourceParser.clj +0 -241
  217. package/compiler/ng_SourceParser2.clj +0 -214
  218. package/compiler/ng_WebPageWriter.clj +0 -39
  219. package/compiler/ng_jsonParser.clj +0 -340
  220. package/compiler/ng_p_test.clj +0 -1711
  221. package/compiler/ng_parser.clj +0 -911
  222. package/compiler/ng_parser2.clj +0 -735
  223. package/compiler/ng_parser2_backup.clj +0 -1679
  224. package/compiler/ng_parser_backup.clj +0 -886
  225. package/compiler/ng_parser_ok.clj +0 -1718
  226. package/compiler/ng_parser_ok2.clj +0 -1717
  227. package/compiler/ng_parser_std_match.clj +0 -687
  228. package/compiler/ng_parser_std_match2.clj +0 -1012
  229. package/compiler/ng_parser_v2.clj +0 -1251
  230. package/compiler/ng_ui.clj +0 -403
  231. package/compiler/ng_ui_test.clj +0 -18
  232. package/compiler/ng_writer.clj +0 -338
  233. package/compiler/ng_xmlParser.clj +0 -472
  234. package/compiler/ng_xmlParser2.clj +0 -317
  235. package/compiler/ng_xmlParser3.clj +0 -251
  236. package/compiler/opdoc.bat +0 -4
  237. package/compiler/operators.md +0 -290
  238. package/compiler/p.bat +0 -4
  239. package/compiler/package.json +0 -10
  240. package/compiler/pcmd.bat +0 -4
  241. package/compiler/pcmd2.bat +0 -3
  242. package/compiler/plaintext_plugin.clj +0 -69
  243. package/compiler/plugin.bat +0 -19
  244. package/compiler/plugin2.bat +0 -4
  245. package/compiler/plugin_app.bat +0 -3
  246. package/compiler/plugin_apps.clj +0 -27
  247. package/compiler/plugins.bat +0 -10
  248. package/compiler/reveal_plugin.clj +0 -409
  249. package/compiler/simplePlugin.clj +0 -780
  250. package/compiler/t.bat +0 -3
  251. package/compiler/test_any.clj +0 -43
  252. package/compiler/test_call.clj +0 -141
  253. package/compiler/test_chain.clj +0 -79
  254. package/compiler/test_json.clj +0 -10
  255. package/compiler/test_lambda.clj +0 -153
  256. package/compiler/test_pcmd.clj +0 -32
  257. package/compiler/test_pcmd2.clj +0 -29
  258. package/compiler/test_plugin.clj +0 -237
  259. package/compiler/test_readfile.clj +0 -13
  260. package/compiler/test_reveal.clj +0 -19
  261. package/compiler/test_slides.clj +0 -312
  262. package/compiler/test_types.clj +0 -143
  263. package/compiler/test_types2.clj +0 -49
  264. package/compiler/test_types3.clj +0 -53
  265. package/compiler/test_var.clj +0 -40
  266. package/compiler/tonpm.bat +0 -14
  267. package/compiler/tonpm2.bat +0 -12
  268. package/compiler/ui_plugin.clj +0 -507
  269. package/compiler/ui_plugin2.clj +0 -427
  270. package/compiler/update-git.bat +0 -3
  271. package/compiler/vcomp.bat +0 -4
  272. package/compiler/viewbuilder_Android.clj +0 -176
  273. package/compiler/viewbuilder_Web.clj +0 -105
  274. package/dist/bin/api.js +0 -32422
  275. package/dist/bin/compiler.d.ts +0 -1638
  276. package/dist/bin/compiler.js +0 -32444
  277. package/examples/3D/bin/test_3d.js +0 -329
  278. package/examples/3D/test_3d.clj +0 -385
  279. package/examples/EVGColor/EVGColor.clj +0 -310
  280. package/examples/EVGColor/EVGColorContext.clj +0 -176
  281. package/examples/EVGColor/bin/EVGColor.js +0 -286
  282. package/examples/EVGColor/bin/minimized.js +0 -286
  283. package/examples/SVGPath/SVGPath.clj +0 -625
  284. package/examples/SVGPath/Vec2.clj +0 -103
  285. package/examples/SVGPath/bin/SVGPath.cpp +0 -887
  286. package/examples/SVGPath/bin/SVGPath.js +0 -682
  287. package/examples/SVGPath/bin/SVGPath.ts +0 -711
  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,1012 +0,0 @@
1
-
2
- extension RangerFlowParser {
3
-
4
- fn findLanguageOper@(optional weak):CodeNode (details:CodeNode ctx:RangerAppWriterContext opDef:CodeNode) {
5
- def langName (ctx.getTargetLang())
6
- def rv:CodeNode
7
- for details.children det:CodeNode i {
8
- if ( (array_length det.children ) > 0) {
9
- def fc:CodeNode (itemAt det.children 0)
10
- if (fc.vref == "templates") {
11
- def tplList:CodeNode (itemAt det.children 1)
12
- for tplList.children tpl:CodeNode i {
13
-
14
- if(tpl.hasExpressionProperty("flags")) {
15
- def flagList (tpl.getExpressionProperty("flags"))
16
- def b_matched false
17
- flagList.children.forEach({
18
- print "FLAG " + item.vref
19
- b_matched = (b_matched || (ctx.hasCompilerFlag(item.vref)))
20
- })
21
- if( b_matched == false ) {
22
- continue
23
- }
24
- }
25
- def tplName:CodeNode (tpl.getFirst())
26
- def is_ts (ctx.hasCompilerFlag('typescript'))
27
- if( is_ts && ( tplName.vref == 'typescript' || tplName.vref == 'ts')) {
28
- rv = tpl
29
- return rv
30
- }
31
- if ((tplName.vref != "*") && (tplName.vref != langName)) {
32
- continue
33
- }
34
- rv = tpl
35
- return rv
36
- }
37
- ; op _:void () { templates {}}
38
- if(langName == 'ranger') {
39
- ; es6 ( '(operator ' (e 1) ' ' ))
40
- def opNameNode (opDef.getFirst())
41
- def opArgs (opDef.getThird())
42
- def rangerTpl (r.expression (r.value ('(' + opNameNode.vref + ' ' ) ) ) )
43
-
44
- def cnt 1
45
- opArgs.children.forEach({
46
- if(item.type_name == 'block') {
47
- push rangerTpl.children (r.expression (r.vref 'block') (r.value cnt ))
48
- } {
49
- push rangerTpl.children (r.expression (r.vref 'e') (r.value cnt ))
50
- }
51
- cnt = cnt + 1
52
- })
53
- push rangerTpl.children (r.value ')')
54
- rv = (r.expression (r.vref 'ranger') rangerTpl )
55
- }
56
- }
57
- }
58
- }
59
- return rv
60
- }
61
-
62
- fn buildMacro:CodeNode ( langOper@(optional):CodeNode args:CodeNode ctx:RangerAppWriterContext ) {
63
-
64
- def subCtx:RangerAppWriterContext (ctx.fork())
65
- def wr:CodeWriter (new CodeWriter ())
66
- def lcc:LiveCompiler (new LiveCompiler())
67
-
68
- lcc.langWriter = (new RangerRangerClassWriter ())
69
- lcc.langWriter.compiler = lcc
70
-
71
- subCtx.targetLangName = "ranger"
72
- subCtx.restartExpressionLevel()
73
-
74
- def macroNode:CodeNode (unwrap langOper)
75
- def cmdList:CodeNode (macroNode.getSecond())
76
- if(ctx.hasCompilerFlag("show-macros")) {
77
- print "Building macro " + macroNode.vref + " : " + (cmdList.getCode())
78
- print "Arguments : " + (args.getCode())
79
- }
80
- ;walkCommandList:void (cmd:CodeNode node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
81
- lcc.walkCommandList( cmdList args subCtx wr )
82
- def lang_str:string (wr.getCode())
83
- def lang_code:SourceCode (new SourceCode ( lang_str ) )
84
- lang_code.filename = "<macro " + macroNode.vref + ">"
85
- def lang_parser:RangerLispParser (new RangerLispParser (lang_code))
86
- lang_parser.parse((ctx.hasCompilerFlag("no-op-transform")))
87
-
88
- def node@(lives):CodeNode (unwrap lang_parser.rootNode)
89
-
90
- if(has args.register_expressions) {
91
- node.register_expressions = (clone args.register_expressions)
92
- }
93
- args.children.forEach({
94
- item.register_expressions.forEach({
95
- def re@(temp) item
96
- push node.register_expressions re
97
- })
98
- })
99
-
100
- return node
101
- }
102
-
103
- fn stdParamMatch:boolean (callArgs@(lives):CodeNode inCtx:RangerAppWriterContext wr:CodeWriter require_all_match:boolean) {
104
- stdCommands = (inCtx.getStdCommands())
105
- def callFnName:CodeNode (callArgs.getFirst())
106
- def cmds:CodeNode stdCommands
107
- def some_matched:boolean false
108
- def found_fn:boolean false
109
- def added_ns ""
110
- def missed_args:[string]
111
- def ctx:RangerAppWriterContext (inCtx.fork())
112
- def lang_name:string (ctx.getTargetLang())
113
- def expects_error:boolean false
114
- def err_cnt:int (inCtx.getErrorCount())
115
- def arg_eval_start 0
116
- if( callArgs.hasBooleanProperty("error")) {
117
- expects_error = true
118
- }
119
-
120
- if( ( (inCtx.expressionLevel()) == 0 ) ) {
121
- ; print " expr level zero for " + (callArgs.getCode())
122
- inCtx.lastBlockOp = callArgs
123
- } {
124
- ; print " expr level " + (inCtx.expressionLevel()) + " -> " + (callArgs.getCode())
125
- }
126
-
127
-
128
- def in_chain false
129
- def call_arg_cnt (size callArgs.children)
130
- def op_list (ctx.getOperators(callFnName.vref))
131
-
132
- ; here the op_list is the available operator list
133
- ; TODO:
134
- ; - you could sort it so that the most relevant operator is checked first
135
- ; - do not evalute keyword values unless necessary
136
-
137
- for op_list ch@(lives):CodeNode main_index {
138
-
139
- def fc:CodeNode (ch.getFirst())
140
- def nameNode:CodeNode (ch.getSecond())
141
- def args:CodeNode (ch.getThird())
142
-
143
- ; variable disables operator usage...
144
- if( inCtx.isVarDefined( fc.vref )) {
145
- return false
146
- }
147
-
148
- ; if loop is done two times, remove the old NS definition
149
- ctx.removeOpNs( added_ns )
150
- ctx.addOpNs( fc.vref )
151
- added_ns = fc.vref
152
-
153
- def line_index:int (callArgs.getLine())
154
- ; def callerArgCnt:int (((array_length callArgs.children) - 1))
155
- def callerArgCnt (call_arg_cnt - 1)
156
- def fnArgCnt:int (array_length args.children)
157
- def has_eval_ctx:boolean false
158
- def is_macro:boolean false
159
- def plugin_name "operator"
160
- def plugin_fn ""
161
- def is_plugin false
162
- def is_pure false
163
- def is_static_fn false
164
- def static_fn_name ""
165
- def static_class_name ""
166
- def static_nameNode@(weak):CodeNode
167
- if (nameNode.hasFlag("newcontext")) {
168
- ctx = (inCtx.fork())
169
- has_eval_ctx = true
170
- }
171
- def throws_exception ( nameNode.hasFlag("throws"))
172
- def is_async ( nameNode.hasFlag("async"))
173
- ; if (nameNode)
174
- def expanding_node:boolean (nameNode.hasFlag("expands"))
175
- if ( (callerArgCnt == fnArgCnt) || expanding_node) {
176
- def details_list:CodeNode (itemAt ch.children 3)
177
- def langOper:CodeNode (this.findLanguageOper( details_list ctx ch ))
178
- if(null? langOper) {
179
- ; ctx.addError( callArgs "Did not find language based operator")
180
- continue
181
- }
182
- is_pure = ( nameNode.hasFlag("pure"))
183
- if( ( langOper.hasBooleanProperty("macro") ) || ( (nameNode.hasFlag("macro"))) ) {
184
- is_macro = true
185
- }
186
- if( langOper.hasStringProperty("plugin") ) {
187
- plugin_name = ( langOper.getStringProperty('plugin') )
188
- is_plugin = true
189
- def pluginFn ( langOper.getStringProperty('fn'))
190
- if( has pluginFn ) {
191
- plugin_fn = pluginFn
192
- print "Function : " + plugin_fn
193
- }
194
- }
195
- def codeDef (langOper.getSecond())
196
- def match:RangerArgMatch (new RangerArgMatch ())
197
- def last_walked:int 0
198
-
199
- def last_was_block false
200
- def walk_later:[WalkLater]
201
- def not_enough_args false
202
- def blocksToWalkLater@(weak):[CodeNode]
203
-
204
- if(ch.hasExpressionProperty("flags")) {
205
- def flagList (ch.getExpressionProperty("flags"))
206
- def b_matched false
207
- flagList.children.forEach({
208
- b_matched = (b_matched || (ctx.hasCompilerFlag(item.vref)))
209
- })
210
- if( b_matched == false ) {
211
- continue
212
- }
213
- }
214
- ctx.setInExpr()
215
- for args.children arg@(lives):CodeNode i {
216
-
217
- if( i < arg_eval_start) {
218
- continue
219
- }
220
- arg_eval_start = i
221
- if( (array_length callArgs.children) <= (i + 1)) {
222
- not_enough_args = true
223
- break
224
- }
225
- def callArg@(lives):CodeNode (itemAt callArgs.children (i + 1))
226
- if (arg.hasFlag("define")) {
227
- def p@(lives):RangerAppParamDesc (new RangerAppParamDesc ())
228
- p.name = callArg.vref
229
- p.value_type = arg.value_type
230
- p.node = callArg
231
- p.nameNode = callArg
232
- p.is_optional = false
233
- p.init_cnt = 1
234
- ctx.defineVariable(p.name p)
235
-
236
- callArg.hasParamDesc = true
237
- callArg.ownParamDesc = p
238
- callArg.paramDesc = p
239
- if ((strlen callArg.type_name) == 0) {
240
- callArg.type_name = arg.type_name
241
- callArg.value_type = arg.value_type
242
- }
243
- callArg.eval_type = arg.value_type
244
- callArg.eval_type_name = arg.type_name
245
- }
246
- if (arg.hasFlag("ignore")) {
247
- continue _
248
- }
249
- if (arg.hasFlag("keyword")) {
250
- ; print "keywords " + callArg.vref + " arg " + arg.vref
251
- if( callArg.vref != arg.vref) {
252
- not_enough_args = true
253
- }
254
- continue _
255
- }
256
- if (arg.hasFlag("noeval")) {
257
- callArg.eval_type = callArg.value_type
258
- callArg.eval_type_name = callArg.type_name
259
- callArg.eval_array_type = callArg.array_type
260
- callArg.eval_key_type = callArg.key_type
261
- continue _
262
- }
263
- last_walked = (i + 1)
264
-
265
- ; anonymous fn or Lambda argument
266
- if( arg.value_type == RangerNodeType.ExpressionType ) {
267
-
268
- def opList (ctx.getOpFns(callArg.vref))
269
- if(has opList) {
270
- def signature (arg.expression_value.copy())
271
- def params (at signature.children 1)
272
- }
273
- if(codeDef.is_block_node == false) {
274
- def later (new WalkLater)
275
- later.arg = arg
276
- later.callArg = callArg
277
- push walk_later later
278
- }
279
- } {
280
- if(arg.type_name == "block" || (arg.hasFlag("block"))) {
281
- if( arg.hasFlag("try_block")) {
282
- def tmpCtx@(lives) (ctx.fork())
283
- tmpCtx.is_try_block = true
284
- callArg.evalCtx = tmpCtx
285
- tmpCtx.newBlock()
286
- this.WalkNode(callArg tmpCtx wr)
287
- } {
288
- def tmpCtx@(lives) (ctx.fork())
289
- tmpCtx.newBlock()
290
- callArg.evalCtx = tmpCtx
291
- this.WalkNode(callArg tmpCtx wr)
292
- }
293
-
294
- last_was_block = true
295
- } {
296
- ctx.setInExpr()
297
- this.WalkNode(callArg ctx wr)
298
- ctx.unsetInExpr()
299
-
300
- ; union conversion...
301
- if( (strlen arg.type_name) > 0 ) {
302
- this.convertToUnion( arg.type_name callArg ctx wr)
303
- }
304
- last_was_block = false
305
- }
306
- if( arg.hasFlag("mutates")) {
307
- if(callArg.hasParamDesc) {
308
- if(callArg.paramDesc && (!null? callArg.paramDesc.propertyClass)) {
309
- if(callArg.paramDesc.propertyClass.nameNode.hasFlag("immutable")) {
310
- def propC (callArg.paramDesc.propertyClass)
311
- def currC (ctx.getCurrentClass())
312
- if( (unwrap currC) != (unwrap propC) ) {
313
- ; --> skip as if error
314
- not_enough_args = true
315
- ; ctx.addError(callArg "Not possible to modify immutable class property")
316
- }
317
- }
318
- }
319
- }
320
- }
321
- }
322
- }
323
- ctx.unsetInExpr()
324
- if not_enough_args {
325
- continue
326
- }
327
- if expanding_node {
328
- for callArgs.children caCh:CodeNode i2 {
329
- ; do not walk immediately the blocks
330
- if(caCh.is_block_node) {
331
- def tmpCtx@(lives) ctx
332
- caCh.evalCtx = tmpCtx
333
- push blocksToWalkLater caCh
334
- continue
335
- }
336
- if(i2 > last_walked) {
337
- if last_was_block {
338
- def sCtx (ctx.forkWithOps( (itemAt ch.children 3) ))
339
- this.WalkNode(caCh sCtx wr)
340
- } {
341
- ctx.setInExpr()
342
- this.WalkNode(caCh ctx wr)
343
- ctx.unsetInExpr()
344
- }
345
- }
346
- }
347
- }
348
-
349
- def all_matched:boolean (match.matchArguments(args callArgs ctx 1))
350
-
351
- if all_matched {
352
-
353
- def expr_level (ctx.expressionLevel())
354
- def is_last false
355
-
356
- if(!null? callArgs.parent) {
357
- is_last = ( (size callArgs.parent.children) == ( 1 + ( indexOf callArgs.parent.children callArgs ) ) )
358
- }
359
-
360
- if( (fc.vref == 'if') && (ctx.hasCompilerFlag('voidexpr')) && ( expr_level > 0 || is_last) ) {
361
-
362
- print "IF expr leve == " +( ctx.expressionLevel() )
363
-
364
- print (callArgs.getCode())
365
-
366
- ; simple eval test, works only for strings...
367
- def thenBlock (at callArgs.children 2)
368
- def lastRow (last thenBlock.children)
369
-
370
- print "Last row == " + (lastRow.getCode())
371
-
372
- def BlockOP (ctx.getLastBlockOp())
373
- def regName (ctx.createNewRegName())
374
- def regExpr (r.expression (r.vref 'def') (r.vref regName lastRow.eval_type_name) )
375
-
376
- callArgs.eval_type = lastRow.eval_type
377
- callArgs.eval_type_name = lastRow.eval_type_name
378
-
379
- def fnC (ctx.findFunctionCtx())
380
-
381
- this.WalkNode( regExpr fnC wr )
382
- def realRegName ( (at regExpr.children 1) .paramDesc.compiledName )
383
-
384
- def then_regs false
385
- if( has lastRow.register_name ) {
386
- def newLastRow (r.expression (r.vref '=') (r.vref regName) (r.vref lastRow.register_name) ))
387
- this.WalkNode( newLastRow ctx wr )
388
- push thenBlock.children newLastRow
389
- then_regs = true
390
- } {
391
- def vCopy (lastRow.cleanCopy())
392
- lastRow.expression = true
393
- lastRow.vref = ""
394
- lastRow.value_type = RangerNodeType.NoType
395
- lastRow.flow_done = false
396
- lastRow.getChildrenFrom( (r.expression (r.vref '=') (r.vref regName) vCopy ))
397
- this.WalkNode( lastRow ctx wr )
398
- }
399
-
400
- if( (size callArgs.children ) == 4) {
401
- def elseBlock (at callArgs.children 3)
402
- def lastRow (last elseBlock.children)
403
- if( has lastRow.register_name ) {
404
- def newLastRow (r.expression (r.vref '=') (r.vref regName) (r.vref lastRow.register_name) ))
405
- this.WalkNode( newLastRow ctx wr )
406
- push elseBlock.children newLastRow
407
- then_regs = true
408
- } {
409
- def vCopy (lastRow.cleanCopy())
410
- lastRow.expression = true
411
- lastRow.vref = ""
412
- lastRow.value_type = RangerNodeType.NoType
413
- lastRow.flow_done = false
414
- lastRow.getChildrenFrom( (r.expression (r.vref '=') (r.vref regName) vCopy ))
415
- print " lastRow value --> " + (vCopy.getCode())
416
- this.WalkNode( lastRow ctx wr )
417
- }
418
- }
419
- def tmp@(temp) (callArgs.clone())
420
- BlockOP.register_expressions.push( regExpr )
421
- BlockOP.register_expressions.push( tmp )
422
- ; callArgs.register_name = realRegName
423
- callArgs.register_name = regName
424
- callArgs.reg_compiled_name = realRegName
425
-
426
- tmp.has_operator = true
427
- tmp.op_index = main_index
428
- tmp.operator_node = ch
429
-
430
-
431
- return true
432
- }
433
-
434
- ; (fc.vref != 'if') && (fc.vref != 'if!')
435
- if( (fc.vref != 'for') && (ctx.hasCompilerFlag('new')) ) {
436
- def opDef (langOper.getSecond())
437
- def opCnts:[int:int]
438
- def regNames:[int:string]
439
- def firstRef@(weak):[int:CodeNode]
440
- ; possible multiple evaluations for an item...
441
- forEach args.children {
442
- def opArg item
443
- if( (opArg.hasFlag('loopcondition')) ) {
444
-
445
- def loopBlock:CodeNode
446
- forEach args.children {
447
- if(item.hasFlag('loopblock')) {
448
- def tmp@(temp) (at callArgs.children (index + 1))
449
- loopBlock = tmp
450
- }
451
- }
452
- if(null? loopBlock) {
453
- ctx.addError( args "Invalid operator: Loop condition without block ")
454
- return
455
- }
456
-
457
- def opName (index + 1)
458
- def item (callArgs.children.at( (index + 1) ))
459
- ; print "LOOP condition found " + (item.getCode())
460
- def regName ""
461
- def realArg (at callArgs.children (opName))
462
-
463
- if( has realArg.register_name ) {
464
- regName = realArg.register_name
465
- } {
466
- regName = (ctx.createNewRegName())
467
- }
468
- def argCopy (realArg.copy())
469
- def regExpr (r.expression (r.vref 'def') (r.vref regName) argCopy)
470
- ; should be function ctx ?
471
- ; def fnC (ctx.findFunctionCtx())
472
-
473
- ; print "while last op was " + (lastOp.getCode())
474
-
475
- ctx.lastBlockOp = callArgs
476
- this.WalkNode( regExpr ctx wr )
477
-
478
- def realRegName ( (at regExpr.children 1) .paramDesc.compiledName )
479
-
480
- def regArg (at regExpr.children 1)
481
- regArg.paramDesc.set_cnt = 1
482
- regArg.paramDesc.ref_cnt = 1
483
-
484
- def BlockOP (ctx.getLastBlockOp())
485
- BlockOP.register_expressions.push( regExpr )
486
-
487
- realArg.register_name = regName
488
- realArg.reg_compiled_name = realRegName
489
- forEach callArgs.children {
490
- if(item.is_block_node) {
491
- def argCopy (realArg.copy())
492
- argCopy.register_name = ""
493
- argCopy.forTree({
494
- item.register_name = ""
495
- })
496
- def eval_expr@(lives) (r.expression (r.vref '=') (r.vref regName) argCopy)
497
-
498
- def lastOp@(lives) (at loopBlock.children ( (size loopBlock.children) - 1) )
499
- ctx.lastBlockOp = eval_expr
500
-
501
- this.WalkNode( eval_expr ctx wr )
502
- push item.children eval_expr
503
- ; print "pushed " + (eval_expr.getCode())
504
- }
505
- }
506
- }
507
- }
508
-
509
- opDef.children.forEach({
510
- if(item.isFirstVref('e')) {
511
- if( (item.hasFlag('ignore')) || (item.hasFlag('noeval')) ) {
512
- return
513
- }
514
- def opName ((item.getSecond()).int_value)
515
- def opArg (at args.children (opName - 1))
516
- if( (has opCnts opName ) ) {
517
- ; print (langOper.getCode())
518
- ; print "several uses of e " + opName + " => " + (callArgs.getCode())
519
- ; print " ^ " + (opDef.getCode())
520
- ; find function level context
521
-
522
- def regName ""
523
- def realArg (at callArgs.children (opName))
524
- def just_vref (fn:boolean (a:CodeNode) {
525
- return false
526
- })
527
-
528
- just_vref = (fn:boolean (a:CodeNode) {
529
- if( has a.vref ) {
530
- return true
531
- }
532
- if( TTypes.isPrimitive( a.value_type ) ) {
533
- return true
534
- }
535
- if( (size a.children ) == 1 ) {
536
- return ( just_vref( (at a.children 0)) )
537
- }
538
- return false
539
- })
540
- if(just_vref(realArg)) {
541
- return
542
- }
543
-
544
- if( has regNames opName ) {
545
- if( has realArg.register_name ) {
546
- regName = realArg.register_name
547
- } {
548
- regName = (unwrap (get regNames opName))
549
- }
550
- realArg.register_name = regName
551
- } {
552
- if( has realArg.register_name ) {
553
- regName = realArg.register_name
554
- } {
555
- regName = (ctx.createNewRegName())
556
- ; print "creating def for " + regName
557
- set regNames opName regName
558
- ; define the register...
559
- def argCopy (realArg.copy())
560
- def regExpr (r.expression (r.vref 'def') (r.vref regName) argCopy)
561
- ; should be function ctx ?
562
- ; def fnC (ctx.findFunctionCtx())
563
- this.WalkNode( regExpr ctx wr )
564
- def regArg (at regExpr.children 1)
565
- def realRegName ( (at regExpr.children 1) .paramDesc.compiledName )
566
- regArg.paramDesc.set_cnt = 1
567
- regArg.paramDesc.ref_cnt = 1
568
-
569
- def BlockOP (ctx.getLastBlockOp())
570
- BlockOP.register_expressions.push( regExpr )
571
-
572
- ; realArg.register_expressions.push( regExpr )
573
- realArg.register_name = regName
574
- realArg.reg_compiled_name = realRegName
575
-
576
- ; print "last block was" + (BlockOP.getCode())
577
- }
578
- }
579
-
580
- } {
581
- set opCnts opName 1
582
- set firstRef opName item
583
- }
584
- }
585
- })
586
-
587
- }
588
-
589
- }
590
-
591
- if all_matched {
592
-
593
- if is_async {
594
- def activeFn (ctx.getCurrentMethod())
595
- if( (!null? activeFn.nameNode) ) {
596
- activeFn.nameNode.setFlag('async')
597
- }
598
- while( !null? activeFn.insideFn) {
599
- activeFn = (unwrap activeFn.insideFn)
600
- if( (!null? activeFn.nameNode) ) {
601
- activeFn.nameNode.setFlag('async')
602
- }
603
- }
604
- }
605
- if throws_exception {
606
- if( false == (ctx.isTryBlock())) {
607
- def activeFn (ctx.getCurrentMethod())
608
- if( (!null? activeFn.nameNode) && ( activeFn.nameNode.hasFlag("throws")) ) {
609
- ; if marked as throws it's ok
610
- } {
611
- ctx.addError(callArgs ('The operator ' + fc.vref + " potentially throws an exception, try { } block is required"))
612
- }
613
- }
614
- }
615
- for blocksToWalkLater b:CodeNode i {
616
- def localFork (b.evalCtx.fork())
617
- this.WalkNode(b localFork wr)
618
- }
619
-
620
- for walk_later later:WalkLater i {
621
- def ca (unwrap later.callArg)
622
- def aa (unwrap later.arg)
623
-
624
-
625
- def newNode:CodeNode (new CodeNode ( (unwrap ca.code) ca.sp ca.ep))
626
-
627
- ; avoid re-transforming already transformed functions
628
-
629
- ; transform only blocks
630
- if( ca.is_block_node && ((ca.isFirstVref("fn")) == false ) && ((ca.isFirstVref("fun")) == false )) {
631
-
632
- ; print "transforming " + (ca.getCode())
633
- ; def match:RangerArgMatch (new RangerArgMatch ())
634
- def fnDef:CodeNode (unwrap aa.expression_value)
635
- def copyOf:CodeNode (fnDef.rebuildWithType( match false ))
636
- def ffc:CodeNode (itemAt copyOf.children 0)
637
- ffc.vref = "fun"
638
- def itemCopy:CodeNode (ca.rebuildWithType (match false))
639
- push copyOf.children itemCopy
640
- def cnt:int ( array_length ca.children )
641
- while( cnt > 0) {
642
- removeLast ca.children
643
- cnt = cnt - 1
644
- }
645
- for copyOf.children ch@(lives):CodeNode i {
646
- push ca.children ch
647
- }
648
- }
649
- ; -->
650
- ; def sCtx (ctx.forkWithOps( (itemAt ch.children 3) ))
651
- def sCtx (ctx.fork())
652
- sCtx.newBlock()
653
- this.WalkNode(ca sCtx wr)
654
- ; last_was_block = true
655
-
656
- }
657
- }
658
- def staticMethod:RangerAppFunctionDesc
659
-
660
- if(codeDef.is_block_node && (all_matched)) {
661
-
662
- def pure_transform (ctx.hasCompilerFlag("pure"))
663
- ; -- could do a pure function transformation here ---
664
- if ( is_pure && pure_transform ) {
665
- def argDefs (CodeNode.blockFromList(
666
- (args.children.map({
667
- def callArg (itemAt callArgs.children (index + 1))
668
- def arg item
669
- def vName (item.copy())
670
- def caCopy (callArg.copy())
671
- def prms (this.transformParams2( ([] _:CodeNode (callArg) ) ([] _:CodeNode (arg) ) (ctx) ))
672
- def firstp (itemAt prms 0)
673
- def ad (r.op "def" vName firstp )
674
- return ad
675
- }))
676
- ))
677
- def bodyStart (r.block
678
- argDefs
679
- codeDef
680
- )
681
- def newCtx (ctx.fork())
682
- def bodyCopy (bodyStart.rebuildWithType(match true))
683
- callArgs.flow_done = false
684
- callArgs.getChildrenFrom( bodyCopy )
685
- this.WalkNode ( callArgs newCtx wr)
686
- return true
687
- }
688
- ; -- could do a pure function transformation here ---
689
-
690
- def nSig ""
691
- if( (array_length args.children) > 0) {
692
- def arg0 (args.getFirst())
693
- nSig = ( (this.getNameSignature(arg0)) )
694
- } {
695
- nSig = ( (this.getVoidNameSignature()) )
696
- }
697
- ;print "---- static method ----"
698
- ;print "arg0 " + (arg0.getCode())
699
- def new_cl ( ctx.createOpStaticClass( nSig ) )
700
- this.WalkNode( (unwrap new_cl.classNode ) ctx wr)
701
- def bodyCopy (codeDef.rebuildWithType(match true))
702
- def argsCopy (args.rebuildWithType(match true))
703
- def nameCopy (nameNode.rebuildWithType(match true))
704
-
705
- def sigN (ctx.transformOpNameWord( fc.vref ))
706
- def argsSig ( sigN + (this.getArgsSignature(argsCopy)) )
707
-
708
- if( false == (new_cl.hasStaticMethod(argsSig))) {
709
-
710
- def sMethod@(lives) ( ctx.createStaticMethod( argsSig new_cl nameCopy argsCopy bodyCopy this wr) )
711
- staticMethod = sMethod
712
- def currM (ctx.getCurrentMethod())
713
- currM.addCallTo( sMethod )
714
-
715
- static_nameNode = nameCopy
716
- def fCtx (unwrap sMethod.fnCtx)
717
- fCtx.currentMethod = sMethod
718
- fCtx.is_function = true
719
- def m:RangerAppFunctionDesc sMethod
720
-
721
- fCtx.in_static_method = true
722
- if (nameCopy.hasFlag("weak")) {
723
- m.changeStrength(0 1 nameNode)
724
- } {
725
- m.changeStrength(1 1 nameNode)
726
- }
727
- fCtx.setInMethod()
728
- for m.params v@(lives):RangerAppParamDesc i {
729
- fCtx.defineVariable(v.name v)
730
- v.nameNode.eval_type = (v.nameNode.typeNameAsType(fCtx))
731
- v.nameNode.eval_type_name = v.nameNode.type_name
732
- }
733
- this.WalkNodeChildren( bodyCopy fCtx wr)
734
- fCtx.unsetInMethod()
735
- fCtx.in_static_method = false
736
- fCtx.function_level_context = true
737
- ;if (fnBody.didReturnAtIndex == -1) {
738
- ; if (cn.type_name != "void") {
739
- ; ctx.addError(node "Function does not return any values!")
740
- ; }
741
- ;}
742
- for fCtx.localVarNames n:string i {
743
- def p:RangerAppParamDesc (get fCtx.localVariables n)
744
- if (p.set_cnt > 0) {
745
- if(p.is_immutable) {
746
- ctx.addError( callArgs "Immutable variable was assigned")
747
- }
748
- def defNode:CodeNode p.node
749
- defNode.setFlag("mutable")
750
- def nNode:CodeNode p.nameNode
751
- nNode.setFlag("mutable")
752
- }
753
- }
754
- } {
755
- def sMethod ( new_cl.findStaticMethod( argsSig ) )
756
- static_nameNode = sMethod.nameNode
757
- def currM (ctx.getCurrentMethod())
758
- currM.addCallTo((unwrap sMethod ) )
759
- staticMethod = sMethod
760
- }
761
- is_static_fn = true
762
- static_fn_name = argsSig
763
- static_class_name = new_cl.name
764
- }
765
- if all_matched {
766
-
767
- if is_static_fn {
768
-
769
- def firstArg (callArgs.getFirst())
770
- firstArg.vref = static_class_name + "." + static_fn_name
771
- firstArg.flow_done = false
772
- firstArg.value_type = RangerNodeType.VRef
773
- clear firstArg.ns
774
- push firstArg.ns static_class_name
775
- push firstArg.ns static_fn_name
776
-
777
- def newArgs:CodeNode (new CodeNode ( (unwrap callArgs.code) callArgs.sp callArgs.ep) )
778
- ; note: noeval flag is used here to mark a parameter which is matched but not evaluated
779
- ; if(arg.hasFlag("noeval"))
780
- for callArgs.children ca:CodeNode i {
781
- if ca.is_part_of_chain {
782
- continue
783
- }
784
- if( i > 0) {
785
- def arg (itemAt args.children (i - 1))
786
- if( arg.hasFlag("noeval")) {
787
- continue
788
- }
789
- push newArgs.children ca
790
- }
791
- }
792
- def arg_len:int (array_length callArgs.children)
793
- while (arg_len > 1 ) {
794
- removeLast callArgs.children
795
- arg_len = arg_len - 1
796
- }
797
- push callArgs.children newArgs
798
-
799
- callArgs.flow_done = false
800
- this.WalkNode ( callArgs ctx wr)
801
-
802
-
803
- def currMM@(lives) (ctx.getCurrentMethod())
804
-
805
- for newArgs.children ca:CodeNode i {
806
- if(ca.eval_type == RangerNodeType.ExpressionType) {
807
- ; print "--> EXPRESSION"
808
- if(!null? ca.lambdaFnDesc) {
809
- ; print "--> and has lambdaFnDesc"
810
- if(!null? staticMethod) {
811
- ; is it possible to call using async operator?
812
- staticMethod.addCallTo( (unwrap ca.lambdaFnDesc ) )
813
- if( ca.lambdaFnDesc.nameNode.hasFlag('async')) {
814
- ; print "ASYNC with lambdaFnDesc"
815
- staticMethod.nameNode.setFlag('async')
816
- }
817
- }
818
- }
819
- }
820
- ca.forTree({
821
- if( (!null? item.fnDesc) ) {
822
- if(!null? staticMethod) {
823
- ; print "--> CA tree had also call"
824
- staticMethod.addCallTo( (unwrap item.fnDesc ) )
825
- }
826
- }
827
- })
828
- }
829
-
830
- match.setRvBasedOn((unwrap static_nameNode) callArgs)
831
- ctx.removeOpNs( added_ns )
832
- return true
833
- }
834
- if is_plugin {
835
- try {
836
- def fileName ( (current_directory) + "/" + plugin_name)
837
- print "trying to load plugin: " + fileName
838
- def plugin (load_compiler_plugin fileName )
839
- call_plugin plugin plugin_fn callArgs ctx wr
840
- callArgs.flow_done = false
841
- this.WalkNode( callArgs ctx wr)
842
- match.setRvBasedOn(nameNode callArgs)
843
- ctx.removeOpNs( added_ns )
844
- print "plugin ready..."
845
- } {
846
- ctx.addError( callArgs ('Plugin operator failed ' + (error_msg)) )
847
- }
848
- return true
849
- }
850
-
851
- if is_macro {
852
- def macroNode:CodeNode ( this.buildMacro( langOper callArgs ctx ) )
853
- def arg_len:int (array_length callArgs.children)
854
- while (arg_len > 0 ) {
855
- removeLast callArgs.children
856
- arg_len = arg_len - 1
857
- }
858
- push callArgs.children macroNode
859
- macroNode.parent = callArgs
860
- this.WalkNode( macroNode ctx wr)
861
- match.setRvBasedOn(nameNode callArgs)
862
- ; print "--- macro was walked -- "
863
- ctx.removeOpNs( added_ns )
864
- return true
865
- }
866
-
867
- if (nameNode.hasFlag("moves")) {
868
- def moves_opt@(optional):CodeNode (nameNode.getFlag("moves"))
869
- def moves:CodeNode (unwrap moves_opt)
870
- def ann:CodeNode moves.vref_annotation
871
- def from:CodeNode (ann.getFirst())
872
- def toItem:CodeNode (ann.getSecond())
873
- def cA:CodeNode (itemAt callArgs.children from.int_value)
874
- def cA2:CodeNode (itemAt callArgs.children toItem.int_value)
875
- if cA.hasParamDesc {
876
- def pp:RangerAppParamDesc cA.paramDesc
877
- def pp2:RangerAppParamDesc cA2.paramDesc
878
- pp.moveRefTo(callArgs (unwrap pp2) ctx)
879
- }
880
- }
881
- if (nameNode.hasFlag("returns")) {
882
- ; print "==> returns flag for " + (callArgs.getLineAsString())
883
- def activeFn:RangerAppFunctionDesc (ctx.getCurrentMethod())
884
- if ( (activeFn.nameNode.type_name != "void") || (activeFn.nameNode.value_type == RangerNodeType.ExpressionType)) {
885
-
886
- if ( (array_length callArgs.children) < 2 ) {
887
- ctx.addError(callArgs " missing return value !!!")
888
- } {
889
- def returnedValue:CodeNode (itemAt callArgs.children 1)
890
- def validated_returnvalue false
891
- if(activeFn.nameNode.value_type == RangerNodeType.ExpressionType) {
892
- validated_returnvalue = true
893
- ; lambda format of the called function
894
- def fnExpr (activeFn.nameNode.expression_value)
895
- if(null? fnExpr) {
896
- ctx.addError( (unwrap activeFn.nameNode) "returned anonymous function should have a method signature")
897
- } {
898
- if( (returnedValue.value_type != RangerNodeType.ExpressionType ) &&
899
- (returnedValue.eval_type != RangerNodeType.ExpressionType) ) {
900
- ctx.addError(returnedValue "Function should return anonymous function!")
901
- } {
902
-
903
- if( returnedValue.hasParamDesc && (!null? returnedValue.paramDesc.nameNode)) {
904
- def rExpr returnedValue.paramDesc.nameNode.expression_value
905
- this.matchLambdaArgs( (unwrap fnExpr) (unwrap rExpr) ctx wr )
906
- } {
907
- def rExpr returnedValue.expression_value
908
- this.matchLambdaArgs( (unwrap fnExpr) (unwrap rExpr) ctx wr )
909
- }
910
- }
911
- }
912
- }
913
-
914
- if( validated_returnvalue == false ) {
915
- if ((match.doesMatch( (unwrap activeFn.nameNode) returnedValue ctx)) == false) {
916
- if(activeFn.nameNode.ifNoTypeSetToEvalTypeOf( returnedValue)) {
917
- ; sets the type
918
- } {
919
- ctx.addError(returnedValue "invalid return value type!!! " + (returnedValue.getCode()))
920
- ctx.addError(returnedValue "^ code: " + (returnedValue.getCode()))
921
- ctx.addError( (unwrap activeFn.nameNode) "^ regarding to")
922
- if( returnedValue.eval_type == RangerNodeType.Method) {
923
- ctx.addError( (unwrap activeFn.nameNode) "^ which was a method")
924
- }
925
- ctx.addError( (unwrap activeFn.nameNode) ( '^ value type = ' + returnedValue.eval_type) )
926
- }
927
- }
928
- }
929
- def argNode:CodeNode (unwrap activeFn.nameNode)
930
- if( returnedValue.hasFlag("optional")) {
931
- if ( false == (argNode.hasFlag("optional")) ) {
932
- ctx.addError(callArgs ( 'function return value optionality does not match, expected non-optional return value, optional given at ' + (argNode.getCode())) )
933
- }
934
- }
935
-
936
- if( argNode.hasFlag("optional")) {
937
- if ( false == (returnedValue.hasFlag("optional")) ) {
938
- ctx.addError(callArgs ( 'function return value optionality does not match, expected optional return value ' + (argNode.getCode())) )
939
- }
940
- }
941
-
942
- def pp:RangerAppParamDesc returnedValue.paramDesc
943
- if (!null? pp) {
944
- pp.moveRefTo(callArgs activeFn ctx)
945
- }
946
-
947
-
948
- }
949
- }
950
- if (null? callArgs.parent) {
951
- ctx.addError(callArgs "did not have parent")
952
- print ('no parent => ' + (callArgs.getCode()))
953
- }
954
- callArgs.parent.didReturnAtIndex = (indexOf callArgs.parent.children callArgs)
955
- }
956
- if ((nameNode.hasFlag("returns")) == false) {
957
- match.setRvBasedOn(nameNode callArgs)
958
- callArgs.evalTypeClass = (TFactory.new_def_signature( nameNode ctx wr ))
959
- }
960
- if has_eval_ctx {
961
- def tmpCtx@(lives) ctx
962
- callArgs.evalCtx = tmpCtx
963
- }
964
- def nodeP:CodeNode callArgs.parent
965
- if (!null? nodeP) {
966
- } {
967
- }
968
- def sig:string (nameNode.buildTypeSignatureUsingMatch(match))
969
- ; def ts:RangerTypeClass (callArgs.createTypeSignatureForName(sig ctx))
970
- ; callArgs.typeClass = ts
971
- some_matched = true
972
- callArgs.has_operator = true
973
- callArgs.op_index = main_index
974
- callArgs.operator_node = ch
975
- for args.children arg:CodeNode arg_index {
976
- if arg.has_vref_annotation {
977
- def anns:CodeNode arg.vref_annotation
978
- for anns.children ann:CodeNode i {
979
- if (ann.vref == "mutates") {
980
- def theArg:CodeNode (itemAt callArgs.children (arg_index + 1))
981
- if theArg.hasParamDesc {
982
- theArg.paramDesc.set_cnt = (theArg.paramDesc.set_cnt + 1)
983
- }
984
- }
985
- }
986
- }
987
- }
988
- ; print "some_matched for op operator_node -> " + (ch.getLineAsString())
989
- break _
990
- }
991
- }
992
-
993
- }
994
- if ( require_all_match == true && some_matched == false) {
995
- ctx.addError(callArgs ('Could not match argument types for ' + callFnName.vref))
996
- }
997
- if(expects_error) {
998
- def cnt_now:int (ctx.getErrorCount())
999
- if (cnt_now == err_cnt) {
1000
- ctx.addParserError( callArgs "LANGUAGE_PARSER_ERROR: expected generated error, err counts : " + err_cnt + " : " +cnt_now)
1001
- }
1002
- } {
1003
- def cnt_now:int (ctx.getErrorCount())
1004
- if (cnt_now > err_cnt) {
1005
- ctx.addParserError( callArgs "LANGUAGE_PARSER_ERROR: did not expect generated error, err counts : " + err_cnt + " : " +cnt_now)
1006
- }
1007
- }
1008
- ctx.removeOpNs( added_ns )
1009
- return some_matched
1010
- }
1011
-
1012
- }