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.
- package/CHANGELOG.md +114 -0
- package/README.md +956 -133
- package/{compiler/Lang.clj → dist/Lang.rgr} +2345 -75
- package/dist/README.md +116 -0
- package/dist/{bin/api.d.ts → api.d.ts} +430 -154
- package/dist/api.js +34345 -0
- package/{lib/Ajax.clj → dist/lib/Ajax.rgr} +1 -1
- package/{lib/CmdParams.clj → dist/lib/CmdParams.rgr} +72 -72
- package/{lib/Crypto.clj → dist/lib/Crypto.rgr} +1 -1
- package/{lib/DOMLib.clj → dist/lib/DOMLib.rgr} +2 -2
- package/{lib/Engine3D.clj → dist/lib/Engine3D.rgr} +1 -1
- package/{lib/ImmutableVector.clj → dist/lib/ImmutableVector.rgr} +364 -364
- package/{lib/IndexedDB.clj → dist/lib/IndexedDB.rgr} +1 -1
- package/{lib/JSON.clj → dist/lib/JSON.rgr} +105 -2
- package/{lib/JinxProcess.clj → dist/lib/JinxProcess.rgr} +3 -3
- package/{lib/Storage.clj → dist/lib/Storage.rgr} +1 -1
- package/{lib/Timers.clj → dist/lib/Timers.rgr} +176 -170
- package/{lib/ViewLib.clj → dist/lib/ViewLib.rgr} +1 -1
- package/dist/lib/lib/ACEEditor.rgr +5 -0
- package/dist/lib/lib/Ajax.rgr +196 -0
- package/dist/lib/lib/CmdParams.rgr +72 -0
- package/dist/lib/lib/Crypto.rgr +90 -0
- package/dist/lib/lib/DOMLib.rgr +307 -0
- package/{examples/3D/Engine3D.clj → dist/lib/lib/Engine3D.rgr} +870 -857
- package/dist/lib/lib/ImmutableVector.rgr +364 -0
- package/dist/lib/lib/IndexedDB.rgr +32 -0
- package/{compiler/JSON.clj → dist/lib/lib/JSON.rgr} +106 -3
- package/dist/lib/lib/JinxProcess.rgr +838 -0
- package/dist/lib/lib/SQL.rgr +44 -0
- package/dist/lib/lib/ServiceLib.rgr +9 -0
- package/dist/lib/lib/Storage.rgr +89 -0
- package/dist/lib/lib/Time.rgr +75 -0
- package/dist/lib/lib/Timers.rgr +176 -0
- package/dist/lib/lib/TypedArrays.rgr +14 -0
- package/dist/lib/lib/ViewLib.rgr +851 -0
- package/dist/lib/lib/WebLib.rgr +47 -0
- package/dist/lib/lib/WebServerLib.rgr +137 -0
- package/{lib/ranger-dir.clj → dist/lib/lib/ranger-dir.rgr} +1 -1
- package/{compiler/stdlib.clj → dist/lib/lib/stdlib.rgr} +42 -19
- package/{lib/stdops.clj → dist/lib/lib/stdops.rgr} +1 -1
- package/dist/lib/ranger-dir.rgr +175 -0
- package/{lib/stdlib.clj → dist/lib/stdlib.rgr} +2 -2
- package/dist/lib/stdops.rgr +168 -0
- package/dist/package.json +47 -0
- package/{compiler/bin/output.js → dist/rgrc.js} +15377 -7936
- package/dist/stdops.rgr +168 -0
- package/package.json +196 -39
- package/adventofcode/day1/bin/LambdaSignature1.java +0 -3
- package/adventofcode/day1/bin/LambdaSignature2.java +0 -3
- package/adventofcode/day1/bin/LambdaSignature3.java +0 -3
- package/adventofcode/day1/bin/day1.cpp +0 -124
- package/adventofcode/day1/bin/day1.go +0 -75
- package/adventofcode/day1/bin/day1.js +0 -45
- package/adventofcode/day1/bin/day1.php +0 -46
- package/adventofcode/day1/bin/day1.scala +0 -48
- package/adventofcode/day1/bin/day1.swift +0 -48
- package/adventofcode/day1/bin/day1_part2.cpp +0 -180
- package/adventofcode/day1/bin/day1_part2.go +0 -123
- package/adventofcode/day1/bin/day1_part2.js +0 -76
- package/adventofcode/day1/bin/day1_part2.php +0 -88
- package/adventofcode/day1/bin/day1_part2.scala +0 -81
- package/adventofcode/day1/bin/day1_part2.swift +0 -91
- package/adventofcode/day1/bin/day_one.java +0 -38
- package/adventofcode/day1/bin/day_one_part_two.java +0 -57
- package/adventofcode/day1/bin/operatorsOf.java +0 -37
- package/adventofcode/day1/bin/operatorsOf_5.java +0 -10
- package/adventofcode/day1/bin/operatorsOfboolean_5.java +0 -10
- package/adventofcode/day1/bin/variant.hpp +0 -2416
- package/adventofcode/day1/compile.bat +0 -7
- package/adventofcode/day1/compile2.bat +0 -7
- package/adventofcode/day1/day1.clj +0 -19
- package/adventofcode/day1/day1_part2.clj +0 -43
- package/adventofcode/day1/input1.txt +0 -1
- package/adventofcode/day2/bin/LambdaSignature1.class +0 -0
- package/adventofcode/day2/bin/LambdaSignature1.java +0 -3
- package/adventofcode/day2/bin/LambdaSignature2.class +0 -0
- package/adventofcode/day2/bin/LambdaSignature2.java +0 -3
- package/adventofcode/day2/bin/day2.cpp +0 -133
- package/adventofcode/day2/bin/day2.go +0 -85
- package/adventofcode/day2/bin/day2.js +0 -45
- package/adventofcode/day2/bin/day2.php +0 -59
- package/adventofcode/day2/bin/day2.scala +0 -54
- package/adventofcode/day2/bin/day2.swift +0 -62
- package/adventofcode/day2/bin/day2_part2.cpp +0 -150
- package/adventofcode/day2/bin/day2_part2.go +0 -101
- package/adventofcode/day2/bin/day2_part2.js +0 -54
- package/adventofcode/day2/bin/day2_part2.php +0 -80
- package/adventofcode/day2/bin/day2_part2.scala +0 -68
- package/adventofcode/day2/bin/day2_part2.swift +0 -82
- package/adventofcode/day2/bin/day_two.java +0 -61
- package/adventofcode/day2/bin/day_two_part_two$1$1$1.class +0 -0
- package/adventofcode/day2/bin/day_two_part_two$1$1.class +0 -0
- package/adventofcode/day2/bin/day_two_part_two$1.class +0 -0
- package/adventofcode/day2/bin/day_two_part_two.class +0 -0
- package/adventofcode/day2/bin/day_two_part_two.java +0 -80
- package/adventofcode/day2/bin/operatorsOf.class +0 -0
- package/adventofcode/day2/bin/operatorsOf.java +0 -18
- package/adventofcode/day2/bin/variant.hpp +0 -2416
- package/adventofcode/day2/compile.bat +0 -7
- package/adventofcode/day2/compile2.bat +0 -7
- package/adventofcode/day2/day2.clj +0 -60
- package/adventofcode/day2/day2_part2.clj +0 -69
- package/adventofcode/day2/input1.txt +0 -1
- package/adventofcode/day3/bin/Grid.java +0 -92
- package/adventofcode/day3/bin/GridRow.java +0 -5
- package/adventofcode/day3/bin/LambdaSignature1.java +0 -3
- package/adventofcode/day3/bin/LambdaSignature2.java +0 -3
- package/adventofcode/day3/bin/LambdaSignature3.java +0 -3
- package/adventofcode/day3/bin/day3.cpp +0 -64
- package/adventofcode/day3/bin/day3.go +0 -55
- package/adventofcode/day3/bin/day3.js +0 -42
- package/adventofcode/day3/bin/day3.php +0 -41
- package/adventofcode/day3/bin/day3.scala +0 -52
- package/adventofcode/day3/bin/day3.swift +0 -43
- package/adventofcode/day3/bin/day3_part2.cpp +0 -216
- package/adventofcode/day3/bin/day3_part2.go +0 -188
- package/adventofcode/day3/bin/day3_part2.js +0 -123
- package/adventofcode/day3/bin/day3_part2.php +0 -135
- package/adventofcode/day3/bin/day3_part2.swift +0 -131
- package/adventofcode/day3/bin/day_three_part_two.java +0 -43
- package/adventofcode/day3/bin/day_two.java +0 -42
- package/adventofcode/day3/bin/operatorsOf.java +0 -14
- package/adventofcode/day3/bin/variant.hpp +0 -2416
- package/adventofcode/day3/compile.bat +0 -7
- package/adventofcode/day3/compile2.bat +0 -7
- package/adventofcode/day3/day3.clj +0 -42
- package/adventofcode/day3/day3_part2.clj +0 -112
- package/adventofcode/day4/bin/LambdaSignature1.java +0 -3
- package/adventofcode/day4/bin/day4.cpp +0 -118
- package/adventofcode/day4/bin/day4.go +0 -75
- package/adventofcode/day4/bin/day4.js +0 -40
- package/adventofcode/day4/bin/day4.php +0 -52
- package/adventofcode/day4/bin/day4.scala +0 -47
- package/adventofcode/day4/bin/day4.swift +0 -56
- package/adventofcode/day4/bin/day4_part2.go +0 -129
- package/adventofcode/day4/bin/day4_part2.js +0 -72
- package/adventofcode/day4/bin/day_four.java +0 -41
- package/adventofcode/day4/bin/inputData.java +0 -7
- package/adventofcode/day4/bin/operatorsOf.java +0 -11
- package/adventofcode/day4/bin/variant.hpp +0 -2416
- package/adventofcode/day4/compile.bat +0 -7
- package/adventofcode/day4/compile2.bat +0 -7
- package/adventofcode/day4/day4.clj +0 -32
- package/adventofcode/day4/day4_part2.clj +0 -44
- package/adventofcode/day4/input.clj +0 -519
- package/adventofcode/day4/input.txt +0 -512
- package/bin/api.ts +0 -24471
- package/bin/compiler.ts +0 -24482
- package/bin/output.js +0 -23819
- package/compiler/ColorConsole.clj +0 -22
- package/compiler/ContextOperators.clj +0 -75
- package/compiler/FlowEnterVarDef.clj +0 -223
- package/compiler/InputFileSystem.clj +0 -276
- package/compiler/RangerDocs.clj +0 -7
- package/compiler/TFactory.clj +0 -146
- package/compiler/TFiles.clj +0 -23
- package/compiler/TFlow.clj +0 -39
- package/compiler/TNodeFactory.clj +0 -84
- package/compiler/TTypes.clj +0 -188
- package/compiler/VirtualCompiler.clj +0 -807
- package/compiler/bin/ng_Compiler.js +0 -23779
- package/compiler/commonmark_plugin.clj +0 -359
- package/compiler/feat2.bat +0 -2
- package/compiler/feats.bat +0 -9
- package/compiler/feature_tests.clj +0 -192
- package/compiler/index.js +0 -2
- package/compiler/issue_57.clj +0 -25
- package/compiler/makefile_plugin.clj +0 -135
- package/compiler/markdown_plugin.clj +0 -386
- package/compiler/maven_plugin.clj +0 -162
- package/compiler/ng_AndroidPageWriter.clj +0 -299
- package/compiler/ng_CodeNode.clj +0 -756
- package/compiler/ng_CodeNodeCompilerExtensions.clj +0 -839
- package/compiler/ng_Compiler.clj +0 -49
- package/compiler/ng_CompilerGeneric.clj +0 -260
- package/compiler/ng_CompilerOrig.clj +0 -854
- package/compiler/ng_DictNode.clj +0 -346
- package/compiler/ng_DictNode2.clj +0 -316
- package/compiler/ng_Execute.clj +0 -138
- package/compiler/ng_Execute1.clj +0 -129
- package/compiler/ng_FlowWork.clj +0 -3951
- package/compiler/ng_LiveCompiler.clj +0 -1109
- package/compiler/ng_RagnerJavaScriptClassWriter.clj +0 -402
- package/compiler/ng_RangerActiveOperators.clj +0 -86
- package/compiler/ng_RangerAppClassDesc.clj +0 -400
- package/compiler/ng_RangerAppEnums.clj +0 -86
- package/compiler/ng_RangerAppFunctionDesc.clj +0 -127
- package/compiler/ng_RangerAppMessages.clj +0 -15
- package/compiler/ng_RangerAppOperatorDesc.clj +0 -20
- package/compiler/ng_RangerAppParamDesc.clj +0 -388
- package/compiler/ng_RangerAppWriterContext.clj +0 -1793
- package/compiler/ng_RangerArgMatch.clj +0 -638
- package/compiler/ng_RangerCSharpClassWriter.clj +0 -484
- package/compiler/ng_RangerCppClassWriter.clj +0 -1023
- package/compiler/ng_RangerDocGenerator.clj +0 -305
- package/compiler/ng_RangerFlowParser.clj +0 -4992
- package/compiler/ng_RangerFlowParserOrig.clj +0 -4002
- package/compiler/ng_RangerGenericClassWriter.clj +0 -573
- package/compiler/ng_RangerGolangClassWriter.clj +0 -1766
- package/compiler/ng_RangerImmutableExtension.clj +0 -77
- package/compiler/ng_RangerJava7ClassWriter.clj +0 -961
- package/compiler/ng_RangerJavaScriptClassWriter.clj +0 -1040
- package/compiler/ng_RangerKotlinClassWriter.clj +0 -372
- package/compiler/ng_RangerLanguageWriters.clj +0 -14
- package/compiler/ng_RangerLispParser.clj +0 -873
- package/compiler/ng_RangerPHPClassWriter.clj +0 -643
- package/compiler/ng_RangerPlugin.clj +0 -41
- package/compiler/ng_RangerRangerClassWriter.clj +0 -357
- package/compiler/ng_RangerRustClassWriter.clj +0 -420
- package/compiler/ng_RangerScalaClassWriter.clj +0 -818
- package/compiler/ng_RangerSerializeClass.clj +0 -502
- package/compiler/ng_RangerServiceBuilder.clj +0 -63
- package/compiler/ng_RangerSwift3ClassWriter.clj +0 -809
- package/compiler/ng_RangerSwiftClassWriter.clj +0 -0
- package/compiler/ng_RangerTypeClass.clj +0 -45
- package/compiler/ng_SourceParser.clj +0 -241
- package/compiler/ng_SourceParser2.clj +0 -214
- package/compiler/ng_WebPageWriter.clj +0 -39
- package/compiler/ng_jsonParser.clj +0 -340
- package/compiler/ng_p_test.clj +0 -1711
- package/compiler/ng_parser.clj +0 -911
- package/compiler/ng_parser2.clj +0 -735
- package/compiler/ng_parser2_backup.clj +0 -1679
- package/compiler/ng_parser_backup.clj +0 -886
- package/compiler/ng_parser_ok.clj +0 -1718
- package/compiler/ng_parser_ok2.clj +0 -1717
- package/compiler/ng_parser_std_match.clj +0 -687
- package/compiler/ng_parser_std_match2.clj +0 -1012
- package/compiler/ng_parser_v2.clj +0 -1251
- package/compiler/ng_ui.clj +0 -403
- package/compiler/ng_ui_test.clj +0 -18
- package/compiler/ng_writer.clj +0 -338
- package/compiler/ng_xmlParser.clj +0 -472
- package/compiler/ng_xmlParser2.clj +0 -317
- package/compiler/ng_xmlParser3.clj +0 -251
- package/compiler/opdoc.bat +0 -4
- package/compiler/operators.md +0 -290
- package/compiler/p.bat +0 -4
- package/compiler/package.json +0 -10
- package/compiler/pcmd.bat +0 -4
- package/compiler/pcmd2.bat +0 -3
- package/compiler/plaintext_plugin.clj +0 -69
- package/compiler/plugin.bat +0 -19
- package/compiler/plugin2.bat +0 -4
- package/compiler/plugin_app.bat +0 -3
- package/compiler/plugin_apps.clj +0 -27
- package/compiler/plugins.bat +0 -10
- package/compiler/reveal_plugin.clj +0 -409
- package/compiler/simplePlugin.clj +0 -780
- package/compiler/t.bat +0 -3
- package/compiler/test_any.clj +0 -43
- package/compiler/test_call.clj +0 -141
- package/compiler/test_chain.clj +0 -79
- package/compiler/test_json.clj +0 -10
- package/compiler/test_lambda.clj +0 -153
- package/compiler/test_pcmd.clj +0 -32
- package/compiler/test_pcmd2.clj +0 -29
- package/compiler/test_plugin.clj +0 -237
- package/compiler/test_readfile.clj +0 -13
- package/compiler/test_reveal.clj +0 -19
- package/compiler/test_slides.clj +0 -312
- package/compiler/test_types.clj +0 -143
- package/compiler/test_types2.clj +0 -49
- package/compiler/test_types3.clj +0 -53
- package/compiler/test_var.clj +0 -40
- package/compiler/tonpm.bat +0 -14
- package/compiler/tonpm2.bat +0 -12
- package/compiler/ui_plugin.clj +0 -507
- package/compiler/ui_plugin2.clj +0 -427
- package/compiler/update-git.bat +0 -3
- package/compiler/vcomp.bat +0 -4
- package/compiler/viewbuilder_Android.clj +0 -176
- package/compiler/viewbuilder_Web.clj +0 -105
- package/dist/bin/api.js +0 -32422
- package/dist/bin/compiler.d.ts +0 -1638
- package/dist/bin/compiler.js +0 -32444
- package/examples/3D/bin/test_3d.js +0 -329
- package/examples/3D/test_3d.clj +0 -385
- package/examples/EVGColor/EVGColor.clj +0 -310
- package/examples/EVGColor/EVGColorContext.clj +0 -176
- package/examples/EVGColor/bin/EVGColor.js +0 -286
- package/examples/EVGColor/bin/minimized.js +0 -286
- package/examples/SVGPath/SVGPath.clj +0 -625
- package/examples/SVGPath/Vec2.clj +0 -103
- package/examples/SVGPath/bin/SVGPath.cpp +0 -887
- package/examples/SVGPath/bin/SVGPath.js +0 -682
- package/examples/SVGPath/bin/SVGPath.ts +0 -711
- package/examples/SVGPath/bin/minimized.js +0 -578
- package/examples/SVGPath/bin/variant.hpp +0 -2416
- package/examples/minification/Vec2.clj +0 -103
- package/examples/minification/bin/minified.js +0 -44
- package/examples/minification/bin/test.js +0 -117
- package/examples/minification/test.clj +0 -13
- package/fiddle/VirtualCompiler.js +0 -23495
- package/fiddle/browser_editor.js +0 -13240
- package/fiddle/compileEnv.js +0 -1
- package/fiddle/compileEnv.json +0 -1
- package/fiddle/lang_data.js +0 -1
- package/index.html +0 -18
- package/native/httpd/HttpTester.clj +0 -33
- package/native/httpd/RangerWebService.clj +0 -81
- package/operators.md +0 -290
- package/tsconfig.json +0 -29
- package/versions/cpp/compiler.cpp +0 -15032
- package/versions/es6/compiler.js +0 -12860
- package/versions/go/compiler.go +0 -21338
- package/versions/java/AfterCodeNode.java +0 -4
- package/versions/java/ClassJoinPoint.java +0 -6
- package/versions/java/CodeFile.java +0 -42
- package/versions/java/CodeFileSystem.java +0 -72
- package/versions/java/CodeNode.java +0 -807
- package/versions/java/CodeSlice.java +0 -13
- package/versions/java/CodeWriter.java +0 -185
- package/versions/java/ColorConsole.java +0 -8
- package/versions/java/CompilerInterface.java +0 -213
- package/versions/java/DictNode.java +0 -353
- package/versions/java/LiveCompiler.java +0 -772
- package/versions/java/NodeEvalState.java +0 -24
- package/versions/java/OpFindResult.java +0 -6
- package/versions/java/RangerAppArrayValue.java +0 -7
- package/versions/java/RangerAppClassDesc.java +0 -217
- package/versions/java/RangerAppEnum.java +0 -14
- package/versions/java/RangerAppFunctionDesc.java +0 -20
- package/versions/java/RangerAppHashValue.java +0 -11
- package/versions/java/RangerAppInterfaceImpl.java +0 -6
- package/versions/java/RangerAppMethodVariants.java +0 -6
- package/versions/java/RangerAppParamDesc.java +0 -321
- package/versions/java/RangerAppTodo.java +0 -6
- package/versions/java/RangerAppValue.java +0 -10
- package/versions/java/RangerAppWriterContext.java +0 -800
- package/versions/java/RangerArgMatch.java +0 -317
- package/versions/java/RangerBackReference.java +0 -7
- package/versions/java/RangerCSharpClassWriter.java +0 -287
- package/versions/java/RangerCompilerMessage.java +0 -9
- package/versions/java/RangerCppClassWriter.java +0 -725
- package/versions/java/RangerFlowParser.java +0 -2142
- package/versions/java/RangerGenericClassWriter.java +0 -367
- package/versions/java/RangerGolangClassWriter.java +0 -1379
- package/versions/java/RangerJava7ClassWriter.java +0 -652
- package/versions/java/RangerJavaScriptClassWriter.java +0 -305
- package/versions/java/RangerKotlinClassWriter.java +0 -380
- package/versions/java/RangerLispParser.java +0 -845
- package/versions/java/RangerNodeValue.java +0 -9
- package/versions/java/RangerPHPClassWriter.java +0 -527
- package/versions/java/RangerParamEventHandler.java +0 -6
- package/versions/java/RangerParamEventList.java +0 -5
- package/versions/java/RangerParamEventMap.java +0 -27
- package/versions/java/RangerRangerClassWriter.java +0 -268
- package/versions/java/RangerRefForce.java +0 -7
- package/versions/java/RangerScalaClassWriter.java +0 -365
- package/versions/java/RangerSerializeClass.java +0 -148
- package/versions/java/RangerSwift3ClassWriter.java +0 -548
- package/versions/java/RangerTypeClass.java +0 -17
- package/versions/java/SourceCode.java +0 -65
- package/versions/php/compiler.php +0 -13830
- package/versions/swift3/compiler.swift +0 -12542
- /package/{lib/ACEEditor.clj → dist/lib/ACEEditor.rgr} +0 -0
- /package/{lib/SQL.clj → dist/lib/SQL.rgr} +0 -0
- /package/{lib/ServiceLib.clj → dist/lib/ServiceLib.rgr} +0 -0
- /package/{lib/Time.clj → dist/lib/Time.rgr} +0 -0
- /package/{lib/TypedArrays.clj → dist/lib/TypedArrays.rgr} +0 -0
- /package/{lib/WebLib.clj → dist/lib/WebLib.rgr} +0 -0
- /package/{lib/WebServerLib.clj → dist/lib/WebServerLib.rgr} +0 -0
|
@@ -1,1766 +0,0 @@
|
|
|
1
|
-
class RangerGolangClassWriter {
|
|
2
|
-
Extends (RangerGenericClassWriter)
|
|
3
|
-
def compiler:LiveCompiler
|
|
4
|
-
def thisName:string "this"
|
|
5
|
-
def write_raw_type:boolean false
|
|
6
|
-
def did_write_nullable:boolean false
|
|
7
|
-
|
|
8
|
-
fn WriteScalarValue:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
9
|
-
switch node.value_type {
|
|
10
|
-
case RangerNodeType.Double {
|
|
11
|
-
wr.out((node.getParsedString()) false)
|
|
12
|
-
}
|
|
13
|
-
case RangerNodeType.String {
|
|
14
|
-
def s:string (this.EncodeString(node ctx wr))
|
|
15
|
-
wr.out((("\"" + s) + "\"") false)
|
|
16
|
-
}
|
|
17
|
-
case RangerNodeType.Integer {
|
|
18
|
-
wr.out(("int64(" + node.int_value+")") false)
|
|
19
|
-
}
|
|
20
|
-
case RangerNodeType.Boolean {
|
|
21
|
-
if node.boolean_value {
|
|
22
|
-
wr.out("true" false)
|
|
23
|
-
} {
|
|
24
|
-
wr.out("false" false)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
fn getObjectTypeString:string (type_string:string ctx:RangerAppWriterContext) {
|
|
30
|
-
if (type_string == "this") {
|
|
31
|
-
return thisName
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if(ctx.isDefinedClass(type_string)) {
|
|
35
|
-
def cc:RangerAppClassDesc (ctx.findClass(type_string))
|
|
36
|
-
|
|
37
|
-
if(cc.is_union) {
|
|
38
|
-
return "interface{}"
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if(cc.doesInherit()) {
|
|
42
|
-
return "IFACE_" + (ctx.transformTypeName(type_string))
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
switch type_string {
|
|
47
|
-
case "int" {
|
|
48
|
-
return "int64"
|
|
49
|
-
}
|
|
50
|
-
case "string" {
|
|
51
|
-
return "string"
|
|
52
|
-
}
|
|
53
|
-
case "boolean" {
|
|
54
|
-
return "bool"
|
|
55
|
-
}
|
|
56
|
-
case "double" {
|
|
57
|
-
return "float64"
|
|
58
|
-
}
|
|
59
|
-
case "char" {
|
|
60
|
-
return "byte"
|
|
61
|
-
}
|
|
62
|
-
case "charbuffer" {
|
|
63
|
-
return "[]byte"
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return (ctx.transformTypeName(type_string))
|
|
67
|
-
}
|
|
68
|
-
fn getTypeString2:string (type_string:string ctx:RangerAppWriterContext) {
|
|
69
|
-
if (type_string == "this") {
|
|
70
|
-
return thisName
|
|
71
|
-
}
|
|
72
|
-
switch type_string {
|
|
73
|
-
case "int" {
|
|
74
|
-
return "int64"
|
|
75
|
-
}
|
|
76
|
-
case "string" {
|
|
77
|
-
return "string"
|
|
78
|
-
}
|
|
79
|
-
case "boolean" {
|
|
80
|
-
return "bool"
|
|
81
|
-
}
|
|
82
|
-
case "double" {
|
|
83
|
-
return "float64"
|
|
84
|
-
}
|
|
85
|
-
case "char" {
|
|
86
|
-
return "byte"
|
|
87
|
-
}
|
|
88
|
-
case "charbuffer" {
|
|
89
|
-
return "[]byte"
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if(ctx.isDefinedClass(type_string)) {
|
|
94
|
-
def cc:RangerAppClassDesc (ctx.findClass(type_string))
|
|
95
|
-
if(cc.is_union) {
|
|
96
|
-
return "interface{}"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return (ctx.transformTypeName(type_string))
|
|
100
|
-
}
|
|
101
|
-
fn writeRawTypeDef:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
102
|
-
write_raw_type = true
|
|
103
|
-
this.writeTypeDef(node ctx wr)
|
|
104
|
-
write_raw_type = false
|
|
105
|
-
}
|
|
106
|
-
fn writeTypeDef:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
107
|
-
this.writeTypeDef2(node ctx wr)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
fn writeArrayTypeDef:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
111
|
-
|
|
112
|
-
def v_type:RangerNodeType node.value_type
|
|
113
|
-
def a_name:string node.array_type
|
|
114
|
-
|
|
115
|
-
if ((v_type == RangerNodeType.Object) || (v_type == RangerNodeType.VRef) || (v_type == RangerNodeType.NoType)) {
|
|
116
|
-
v_type = (node.typeNameAsType(ctx))
|
|
117
|
-
}
|
|
118
|
-
if (node.eval_type != RangerNodeType.NoType) {
|
|
119
|
-
v_type = node.eval_type
|
|
120
|
-
if ( (strlen node.eval_array_type) > 0 ) {
|
|
121
|
-
a_name = node.eval_array_type
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
switch v_type {
|
|
126
|
-
|
|
127
|
-
case RangerNodeType.Hash {
|
|
128
|
-
if(ctx.isDefinedClass(a_name)) {
|
|
129
|
-
def cc:RangerAppClassDesc (ctx.findClass(a_name))
|
|
130
|
-
if(cc.is_union) {
|
|
131
|
-
wr.out("interface{}" , false)
|
|
132
|
-
return
|
|
133
|
-
}
|
|
134
|
-
if(cc.doesInherit()) {
|
|
135
|
-
wr.out("IFACE_" + (this.getTypeString2(a_name ctx)) , false)
|
|
136
|
-
return
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if ( (ctx.isPrimitiveType(a_name)) == false) {
|
|
140
|
-
wr.out("*" false)
|
|
141
|
-
}
|
|
142
|
-
wr.out(((this.getObjectTypeString(a_name ctx)) + "") , false)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
case RangerNodeType.Array {
|
|
146
|
-
|
|
147
|
-
if(ctx.isDefinedClass(a_name)) {
|
|
148
|
-
def cc:RangerAppClassDesc (ctx.findClass(a_name))
|
|
149
|
-
if(cc.is_union) {
|
|
150
|
-
wr.out("interface{}" , false)
|
|
151
|
-
return
|
|
152
|
-
}
|
|
153
|
-
if(cc.doesInherit()) {
|
|
154
|
-
wr.out("IFACE_" + (this.getTypeString2(a_name ctx)) , false)
|
|
155
|
-
return
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if ((write_raw_type == false) && ((ctx.isPrimitiveType(a_name)) == false)) {
|
|
159
|
-
wr.out("*" false)
|
|
160
|
-
}
|
|
161
|
-
wr.out(((this.getObjectTypeString(a_name ctx)) + "") false)
|
|
162
|
-
}
|
|
163
|
-
default {
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
fn writeTypeDef2:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
171
|
-
|
|
172
|
-
def v_type:RangerNodeType node.value_type
|
|
173
|
-
def t_name:string node.type_name
|
|
174
|
-
def a_name:string node.array_type
|
|
175
|
-
def k_name:string node.key_type
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if ((v_type == RangerNodeType.Object) || (v_type == RangerNodeType.VRef) || (v_type == RangerNodeType.NoType)) {
|
|
179
|
-
v_type = (node.typeNameAsType(ctx))
|
|
180
|
-
}
|
|
181
|
-
if (node.eval_type != RangerNodeType.NoType) {
|
|
182
|
-
v_type = node.eval_type
|
|
183
|
-
if ( (strlen node.eval_type_name) > 0 ) {
|
|
184
|
-
t_name = node.eval_type_name
|
|
185
|
-
}
|
|
186
|
-
if ( (strlen node.eval_array_type) > 0 ) {
|
|
187
|
-
a_name = node.eval_array_type
|
|
188
|
-
}
|
|
189
|
-
if ( (strlen node.eval_key_type) > 0 ) {
|
|
190
|
-
k_name = node.eval_key_type
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
switch v_type {
|
|
195
|
-
case RangerNodeType.ExpressionType {
|
|
196
|
-
def rv:CodeNode (itemAt node.expression_value.children 0)
|
|
197
|
-
def sec:CodeNode (itemAt node.expression_value.children 1)
|
|
198
|
-
def fc:CodeNode (sec.getFirst())
|
|
199
|
-
wr.out("func(" false)
|
|
200
|
-
|
|
201
|
-
for sec.children arg:CodeNode i {
|
|
202
|
-
if( i > 0 ) {
|
|
203
|
-
wr.out(", " false)
|
|
204
|
-
}
|
|
205
|
-
this.writeTypeDef2( arg ctx wr)
|
|
206
|
-
}
|
|
207
|
-
wr.out( ") " false)
|
|
208
|
-
this.writeTypeDef2( rv ctx wr)
|
|
209
|
-
}
|
|
210
|
-
case RangerNodeType.Enum {
|
|
211
|
-
wr.out("int64" false)
|
|
212
|
-
}
|
|
213
|
-
case RangerNodeType.Integer {
|
|
214
|
-
wr.out("int64" false)
|
|
215
|
-
}
|
|
216
|
-
case RangerNodeType.Double {
|
|
217
|
-
wr.out("float64" false)
|
|
218
|
-
}
|
|
219
|
-
case RangerNodeType.String {
|
|
220
|
-
wr.out("string" false)
|
|
221
|
-
}
|
|
222
|
-
case RangerNodeType.Boolean {
|
|
223
|
-
wr.out("bool" false)
|
|
224
|
-
}
|
|
225
|
-
case RangerNodeType.Char {
|
|
226
|
-
wr.out("byte" false)
|
|
227
|
-
}
|
|
228
|
-
case RangerNodeType.CharBuffer {
|
|
229
|
-
wr.out("[]byte" false)
|
|
230
|
-
}
|
|
231
|
-
case RangerNodeType.Hash {
|
|
232
|
-
if write_raw_type {
|
|
233
|
-
wr.out( ( (this.getObjectTypeString(a_name ctx) ) + "") , false)
|
|
234
|
-
} {
|
|
235
|
-
wr.out((("map[" + (this.getObjectTypeString(k_name ctx))) + "]") , false)
|
|
236
|
-
|
|
237
|
-
if(ctx.isDefinedClass(a_name)) {
|
|
238
|
-
def cc:RangerAppClassDesc (ctx.findClass(a_name))
|
|
239
|
-
if(cc.is_union) {
|
|
240
|
-
wr.out("interface{}" , false)
|
|
241
|
-
return
|
|
242
|
-
}
|
|
243
|
-
if(cc.doesInherit()) {
|
|
244
|
-
wr.out("IFACE_" + (this.getTypeString2(a_name ctx)) , false)
|
|
245
|
-
return
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if ((write_raw_type == false) && ((ctx.isPrimitiveType(a_name)) == false)) {
|
|
250
|
-
wr.out("*" false)
|
|
251
|
-
}
|
|
252
|
-
wr.out(((this.getObjectTypeString(a_name ctx)) + "") , false)
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
case RangerNodeType.Array {
|
|
256
|
-
if (false == write_raw_type) {
|
|
257
|
-
wr.out("[]" false)
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if(ctx.isDefinedClass(a_name)) {
|
|
261
|
-
def cc:RangerAppClassDesc (ctx.findClass(a_name))
|
|
262
|
-
if(cc.is_union) {
|
|
263
|
-
wr.out("interface{}" , false)
|
|
264
|
-
return
|
|
265
|
-
}
|
|
266
|
-
if(cc.doesInherit()) {
|
|
267
|
-
wr.out("IFACE_" + (this.getTypeString2(a_name ctx)) , false)
|
|
268
|
-
return
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if ((write_raw_type == false) && ((ctx.isPrimitiveType(a_name)) == false)) {
|
|
273
|
-
wr.out("*" false)
|
|
274
|
-
}
|
|
275
|
-
wr.out(((this.getObjectTypeString(a_name ctx)) + "") false)
|
|
276
|
-
}
|
|
277
|
-
default {
|
|
278
|
-
if( (node.type_name == "void") || (! (has node.type_name)) ) {
|
|
279
|
-
(wr.out("()" false))
|
|
280
|
-
return
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
def b_iface false
|
|
284
|
-
if(ctx.isDefinedClass(t_name)) {
|
|
285
|
-
def cc:RangerAppClassDesc (ctx.findClass(t_name))
|
|
286
|
-
b_iface = cc.is_interface
|
|
287
|
-
if(cc.is_system) {
|
|
288
|
-
def sysName (get cc.systemNames "go")
|
|
289
|
-
if(!null? sysName) {
|
|
290
|
-
wr.out( (unwrap sysName) false)
|
|
291
|
-
} {
|
|
292
|
-
ctx.addError(node ( "No system class " + t_name + "defined for Go "))
|
|
293
|
-
}
|
|
294
|
-
return
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
if(ctx.isDefinedClass(t_name)) {
|
|
299
|
-
def cc:RangerAppClassDesc (ctx.findClass(t_name))
|
|
300
|
-
|
|
301
|
-
if(cc.is_union) {
|
|
302
|
-
wr.out("interface{}" false)
|
|
303
|
-
return
|
|
304
|
-
}
|
|
305
|
-
if(cc.doesInherit()) {
|
|
306
|
-
wr.out("IFACE_" + (this.getTypeString2(t_name ctx)) , false)
|
|
307
|
-
return
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if ((write_raw_type == false) && ((node.isPrimitiveType()) == false) && (b_iface == false)) {
|
|
312
|
-
(wr.out("*" false))
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
wr.out((this.getTypeString2(t_name ctx)) false))
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
fn WriteVRef:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
321
|
-
if (node.vref == "this") {
|
|
322
|
-
wr.out(thisName false)
|
|
323
|
-
return
|
|
324
|
-
}
|
|
325
|
-
if (node.eval_type == RangerNodeType.Enum) {
|
|
326
|
-
if( (array_length node.ns) > 1) {
|
|
327
|
-
def rootObjName:string (itemAt node.ns 0)
|
|
328
|
-
def enumName:string (itemAt node.ns 1)
|
|
329
|
-
def e@(optional):RangerAppEnum (ctx.getEnum(rootObjName))
|
|
330
|
-
if (!null? e) {
|
|
331
|
-
wr.out(("" + (unwrap (get e.values enumName) ) ) false)
|
|
332
|
-
return
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
def next_is_gs:boolean false
|
|
338
|
-
def last_was_setter:boolean false
|
|
339
|
-
def needs_par:boolean false
|
|
340
|
-
def ns_last:int ( (array_length node.ns) - 1)
|
|
341
|
-
|
|
342
|
-
if ((array_length node.nsp) > 0) {
|
|
343
|
-
def had_static:boolean false
|
|
344
|
-
|
|
345
|
-
for node.nsp p:RangerAppParamDesc i {
|
|
346
|
-
|
|
347
|
-
if next_is_gs {
|
|
348
|
-
|
|
349
|
-
if(p.isProperty()) {
|
|
350
|
-
wr.out(".Get_" false)
|
|
351
|
-
needs_par = true
|
|
352
|
-
} {
|
|
353
|
-
needs_par = false
|
|
354
|
-
}
|
|
355
|
-
next_is_gs = false
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (needs_par == false) {
|
|
359
|
-
if (i > 0) {
|
|
360
|
-
if had_static {
|
|
361
|
-
wr.out("_static_" false)
|
|
362
|
-
} {
|
|
363
|
-
wr.out("." false)
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
if( (!null? p.nameNode) && (ctx.isDefinedClass(p.nameNode.type_name))) {
|
|
369
|
-
def c:RangerAppClassDesc (ctx.findClass(p.nameNode.type_name))
|
|
370
|
-
if(c.doesInherit()) {
|
|
371
|
-
next_is_gs = true
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
if (i == 0) {
|
|
375
|
-
def part:string (itemAt node.ns 0)
|
|
376
|
-
|
|
377
|
-
if(part == "this") {
|
|
378
|
-
wr.out(thisName false)
|
|
379
|
-
continue
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
383
|
-
if ((part != thisName) && (!null? cc) && (false == (ctx.isInStatic())) ) {
|
|
384
|
-
def currC:RangerAppClassDesc (unwrap cc)
|
|
385
|
-
def up@(optional):RangerAppParamDesc (currC.findVariable(part))
|
|
386
|
-
def lvDef (ctx.getVariableDef(part))
|
|
387
|
-
if ( (!null? up) && (lvDef.is_class_variable) ) {
|
|
388
|
-
def p3:RangerAppParamDesc (unwrap up)
|
|
389
|
-
wr.out((thisName + ".") false)
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
if ((strlen p.compiledName) > 0) {
|
|
394
|
-
wr.out((this.adjustType(p.compiledName)) false)
|
|
395
|
-
} {
|
|
396
|
-
if ((strlen p.name) > 0) {
|
|
397
|
-
wr.out((this.adjustType(p.name)) false)
|
|
398
|
-
} {
|
|
399
|
-
wr.out((this.adjustType( (itemAt node.ns i))) false)
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
if needs_par {
|
|
404
|
-
wr.out("()" false)
|
|
405
|
-
needs_par = false
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if ( (!null? p.nameNode) && (p.nameNode.hasFlag("optional")) && ( i != ns_last)) {
|
|
409
|
-
wr.out(".value.(" false)
|
|
410
|
-
this.writeTypeDef( (unwrap p.nameNode ) ctx wr)
|
|
411
|
-
wr.out(")" false)
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
if (p.isClass()) {
|
|
415
|
-
had_static = true
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
return
|
|
420
|
-
}
|
|
421
|
-
if node.hasParamDesc {
|
|
422
|
-
def part:string (itemAt node.ns 0)
|
|
423
|
-
def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
424
|
-
|
|
425
|
-
if ((part != thisName) && (!null? cc) && (false == (ctx.isInStatic()))) {
|
|
426
|
-
; def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
427
|
-
def currC:RangerAppClassDesc (unwrap cc)
|
|
428
|
-
def up@(optional):RangerAppParamDesc (currC.findVariable(part))
|
|
429
|
-
def lvDef (ctx.getVariableDef(part))
|
|
430
|
-
if ( (!null? up) && (lvDef.is_class_variable) ) {
|
|
431
|
-
def p3:RangerAppParamDesc (unwrap up)
|
|
432
|
-
wr.out((thisName + ".") false)
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
def p:RangerAppParamDesc node.paramDesc
|
|
436
|
-
wr.out(p.compiledName false)
|
|
437
|
-
return
|
|
438
|
-
}
|
|
439
|
-
def b_was_static:boolean false
|
|
440
|
-
for node.ns part:string i {
|
|
441
|
-
if (i > 0) {
|
|
442
|
-
if ((i == 1) && b_was_static) {
|
|
443
|
-
wr.out("_static_" false)
|
|
444
|
-
} {
|
|
445
|
-
wr.out("." false)
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
if (i == 0) {
|
|
449
|
-
|
|
450
|
-
if(part == "this") {
|
|
451
|
-
wr.out(thisName false)
|
|
452
|
-
continue
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
if (ctx.hasClass(part)) {
|
|
456
|
-
b_was_static = true
|
|
457
|
-
}
|
|
458
|
-
def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
459
|
-
if ((part != "this") && (!null? cc) && (false == (ctx.isInStatic()))) {
|
|
460
|
-
def currC:RangerAppClassDesc (unwrap cc)
|
|
461
|
-
def up@(optional):RangerAppParamDesc (currC.findVariable(part))
|
|
462
|
-
def lvDef (ctx.getVariableDef(part))
|
|
463
|
-
if ( (!null? up) && (lvDef.is_class_variable) ) {
|
|
464
|
-
|
|
465
|
-
def p3:RangerAppParamDesc (unwrap up)
|
|
466
|
-
wr.out((thisName + ".") false)
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
wr.out((this.adjustType(part)) false)
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
fn WriteSetterVRef:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
476
|
-
if (node.vref == "this") {
|
|
477
|
-
wr.out(thisName false)
|
|
478
|
-
return
|
|
479
|
-
}
|
|
480
|
-
if (node.eval_type == RangerNodeType.Enum) {
|
|
481
|
-
def rootObjName:string (itemAt node.ns 0)
|
|
482
|
-
def enumName:string (itemAt node.ns 1)
|
|
483
|
-
def e@(optional):RangerAppEnum (ctx.getEnum(rootObjName))
|
|
484
|
-
if (!null? e) {
|
|
485
|
-
wr.out(("" + (unwrap (get e.values enumName) ) ) false)
|
|
486
|
-
return
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
def next_is_gs:boolean false
|
|
491
|
-
def last_was_setter:boolean false
|
|
492
|
-
def needs_par:boolean false
|
|
493
|
-
|
|
494
|
-
def ns_len:int ((array_length node.ns) - 1)
|
|
495
|
-
|
|
496
|
-
if ((array_length node.nsp) > 0) {
|
|
497
|
-
def had_static:boolean false
|
|
498
|
-
|
|
499
|
-
for node.nsp p:RangerAppParamDesc i {
|
|
500
|
-
|
|
501
|
-
if next_is_gs {
|
|
502
|
-
if(p.isProperty()) {
|
|
503
|
-
wr.out(".Get_" false)
|
|
504
|
-
needs_par = true
|
|
505
|
-
} {
|
|
506
|
-
needs_par = false
|
|
507
|
-
}
|
|
508
|
-
next_is_gs = false
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
if (needs_par == false) {
|
|
512
|
-
if (i > 0) {
|
|
513
|
-
if had_static {
|
|
514
|
-
wr.out("_static_" false)
|
|
515
|
-
} {
|
|
516
|
-
wr.out("." false)
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
if(ctx.isDefinedClass(p.nameNode.type_name)) {
|
|
522
|
-
def c:RangerAppClassDesc (ctx.findClass(p.nameNode.type_name))
|
|
523
|
-
if(c.doesInherit()) {
|
|
524
|
-
next_is_gs = true
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
if (i == 0) {
|
|
528
|
-
def part:string (itemAt node.ns 0)
|
|
529
|
-
|
|
530
|
-
if(part == "this") {
|
|
531
|
-
wr.out(thisName false)
|
|
532
|
-
continue
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
536
|
-
|
|
537
|
-
if ((part != thisName) && (!null? cc) && (false == (ctx.isInStatic()))) {
|
|
538
|
-
def currC:RangerAppClassDesc (unwrap cc)
|
|
539
|
-
def up@(optional):RangerAppParamDesc (currC.findVariable(part))
|
|
540
|
-
def lvDef (ctx.getVariableDef(part))
|
|
541
|
-
if ( (!null? up) && (lvDef.is_class_variable) ) {
|
|
542
|
-
def p3:RangerAppParamDesc (unwrap up)
|
|
543
|
-
wr.out((thisName + ".") false)
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
if ((strlen p.compiledName) > 0) {
|
|
548
|
-
wr.out((this.adjustType(p.compiledName)) false)
|
|
549
|
-
} {
|
|
550
|
-
if ((strlen p.name) > 0) {
|
|
551
|
-
wr.out((this.adjustType(p.name)) false)
|
|
552
|
-
} {
|
|
553
|
-
wr.out((this.adjustType( (itemAt node.ns i))) false)
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
if needs_par {
|
|
558
|
-
wr.out("()" false)
|
|
559
|
-
needs_par = false
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
; i == 0
|
|
563
|
-
if (i < (ns_len )) {
|
|
564
|
-
if (p.nameNode.hasFlag("optional")) {
|
|
565
|
-
wr.out(".value.(" false)
|
|
566
|
-
this.writeTypeDef( ( unwrap p.nameNode )ctx wr)
|
|
567
|
-
wr.out(")" false)
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
if (p.isClass()) {
|
|
571
|
-
had_static = true
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
return
|
|
576
|
-
}
|
|
577
|
-
if node.hasParamDesc {
|
|
578
|
-
def part:string (itemAt node.ns 0)
|
|
579
|
-
def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
580
|
-
if ((part != thisName) && (!null? cc) && (false == (ctx.isInStatic()))) {
|
|
581
|
-
; def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
582
|
-
def currC:RangerAppClassDesc (unwrap cc)
|
|
583
|
-
def up@(optional):RangerAppParamDesc (currC.findVariable(part))
|
|
584
|
-
def lvDef (ctx.getVariableDef(part))
|
|
585
|
-
if ( (!null? up) && (lvDef.is_class_variable) ) {
|
|
586
|
-
def p3:RangerAppParamDesc (unwrap up)
|
|
587
|
-
wr.out((thisName + ".") false)
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
def p:RangerAppParamDesc node.paramDesc
|
|
591
|
-
wr.out(p.compiledName false)
|
|
592
|
-
return
|
|
593
|
-
}
|
|
594
|
-
def b_was_static:boolean false
|
|
595
|
-
for node.ns part:string i {
|
|
596
|
-
if (i > 0) {
|
|
597
|
-
if ((i == 1) && b_was_static) {
|
|
598
|
-
wr.out("_static_" false)
|
|
599
|
-
} {
|
|
600
|
-
wr.out("." false)
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
if (i == 0) {
|
|
604
|
-
|
|
605
|
-
if(part == "this") {
|
|
606
|
-
wr.out(thisName false)
|
|
607
|
-
continue
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
if (ctx.hasClass(part)) {
|
|
611
|
-
b_was_static = true
|
|
612
|
-
}
|
|
613
|
-
def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
614
|
-
if ((part != "this") && (!null? cc) && (false == (ctx.isInStatic()))) {
|
|
615
|
-
; def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
616
|
-
def currC:RangerAppClassDesc (unwrap cc)
|
|
617
|
-
def up@(optional):RangerAppParamDesc (currC.findVariable(part))
|
|
618
|
-
def lvDef (ctx.getVariableDef(part))
|
|
619
|
-
if ( (!null? up) && (lvDef.is_class_variable) ) {
|
|
620
|
-
def p3:RangerAppParamDesc (unwrap up)
|
|
621
|
-
wr.out((thisName + ".") false)
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
wr.out((this.adjustType(part)) false)
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
fn goExtractAssign:void ( value:CodeNode p:RangerAppParamDesc ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
631
|
-
|
|
632
|
-
def arr_node@(lives):CodeNode (itemAt value.children 1)
|
|
633
|
-
|
|
634
|
-
wr.newline()
|
|
635
|
-
wr.out("" true)
|
|
636
|
-
wr.out("// array_extract operator " true)
|
|
637
|
-
wr.out("var " false)
|
|
638
|
-
|
|
639
|
-
def pArr@(lives):RangerAppParamDesc (new RangerAppParamDesc ())
|
|
640
|
-
pArr.name = "_arrTemp"
|
|
641
|
-
pArr.node = arr_node
|
|
642
|
-
pArr.nameNode = arr_node
|
|
643
|
-
pArr.is_optional = false
|
|
644
|
-
ctx.defineVariable(p.name pArr)
|
|
645
|
-
|
|
646
|
-
wr.out(pArr.compiledName false)
|
|
647
|
-
wr.out(" " false)
|
|
648
|
-
this.writeTypeDef(arr_node ctx wr)
|
|
649
|
-
wr.newline()
|
|
650
|
-
|
|
651
|
-
wr.out((p.compiledName + " , " + pArr.compiledName + " = ") false)
|
|
652
|
-
|
|
653
|
-
ctx.setInExpr()
|
|
654
|
-
this.WalkNode(value ctx wr)
|
|
655
|
-
ctx.unsetInExpr()
|
|
656
|
-
wr.out(";" true)
|
|
657
|
-
|
|
658
|
-
def left:CodeNode arr_node
|
|
659
|
-
|
|
660
|
-
def a_len:int ( (array_length left.ns) - 1)
|
|
661
|
-
def last_part:string (itemAt left.ns a_len)
|
|
662
|
-
|
|
663
|
-
def next_is_gs:boolean false
|
|
664
|
-
def last_was_setter:boolean false
|
|
665
|
-
def needs_par:boolean false
|
|
666
|
-
def b_was_static:boolean false
|
|
667
|
-
|
|
668
|
-
for left.ns part:string i {
|
|
669
|
-
|
|
670
|
-
if next_is_gs {
|
|
671
|
-
if( i == a_len) {
|
|
672
|
-
wr.out(".Set_" false)
|
|
673
|
-
last_was_setter = true
|
|
674
|
-
} {
|
|
675
|
-
wr.out(".Get_" false)
|
|
676
|
-
needs_par = true
|
|
677
|
-
next_is_gs = false
|
|
678
|
-
last_was_setter = false
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
if( last_was_setter == false && needs_par == false) {
|
|
683
|
-
if (i > 0) {
|
|
684
|
-
if ((i == 1) && b_was_static) {
|
|
685
|
-
wr.out("_static_" false)
|
|
686
|
-
} {
|
|
687
|
-
wr.out("." false)
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
if (i == 0) {
|
|
693
|
-
|
|
694
|
-
if(part == "this") {
|
|
695
|
-
wr.out(thisName false)
|
|
696
|
-
continue
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
if (ctx.hasClass(part)) {
|
|
700
|
-
b_was_static = true
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
def partDef:RangerAppParamDesc (ctx.getVariableDef(part))
|
|
704
|
-
if(!null? partDef.nameNode) {
|
|
705
|
-
if(ctx.isDefinedClass(partDef.nameNode.type_name)) {
|
|
706
|
-
def c:RangerAppClassDesc (ctx.findClass(partDef.nameNode.type_name))
|
|
707
|
-
if(c.doesInherit()) {
|
|
708
|
-
next_is_gs = true
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
715
|
-
;ctx.isMemberVariable(part)
|
|
716
|
-
if ((part != "this") && (!null? cc) && (false == (ctx.isInStatic())) ) {
|
|
717
|
-
def currC:RangerAppClassDesc (unwrap cc)
|
|
718
|
-
def up@(optional):RangerAppParamDesc (currC.findVariable(part))
|
|
719
|
-
def lvDef (ctx.getVariableDef(part))
|
|
720
|
-
if ( (!null? up) && (lvDef.is_class_variable) ) {
|
|
721
|
-
def p3:RangerAppParamDesc (unwrap up)
|
|
722
|
-
wr.out((thisName + ".") false)
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
if( (array_length left.nsp ) > 0) {
|
|
728
|
-
def p:RangerAppParamDesc (itemAt left.nsp i)
|
|
729
|
-
wr.out((this.adjustType(p.compiledName)) false)
|
|
730
|
-
} {
|
|
731
|
-
if(left.hasParamDesc) {
|
|
732
|
-
wr.out(left.paramDesc.compiledName false)
|
|
733
|
-
} {
|
|
734
|
-
wr.out((this.adjustType(part)) false)
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
if needs_par {
|
|
739
|
-
wr.out("()" false)
|
|
740
|
-
needs_par = false
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
if( (array_length left.nsp ) >= (i+1)) {
|
|
744
|
-
def pp:RangerAppParamDesc (itemAt left.nsp i)
|
|
745
|
-
if(pp.nameNode.hasFlag("optional")) {
|
|
746
|
-
wr.out(".value.(" false)
|
|
747
|
-
this.writeTypeDef( (unwrap pp.nameNode) ctx wr)
|
|
748
|
-
wr.out(")" false)
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
}
|
|
753
|
-
if last_was_setter {
|
|
754
|
-
wr.out( "(" false)
|
|
755
|
-
wr.out( pArr.compiledName false)
|
|
756
|
-
wr.out("); " true)
|
|
757
|
-
} {
|
|
758
|
-
wr.out(" = " false)
|
|
759
|
-
wr.out( pArr.compiledName false)
|
|
760
|
-
wr.out("; " true)
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
wr.out("" true)
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
fn writeStructField:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
771
|
-
if node.hasParamDesc {
|
|
772
|
-
def nn:CodeNode (itemAt node.children 1)
|
|
773
|
-
def p:RangerAppParamDesc nn.paramDesc
|
|
774
|
-
wr.out((p.compiledName + " ") false)
|
|
775
|
-
if (p.nameNode.hasFlag("optional")) {
|
|
776
|
-
wr.out("*GoNullable" false)
|
|
777
|
-
} {
|
|
778
|
-
this.writeTypeDef(( unwrap p.nameNode )ctx wr)
|
|
779
|
-
}
|
|
780
|
-
if (p.ref_cnt == 0) {
|
|
781
|
-
wr.out(" /** unused **/ " false)
|
|
782
|
-
}
|
|
783
|
-
wr.out( (' `json:"' + p.name + '"` ') false)
|
|
784
|
-
wr.out("" true)
|
|
785
|
-
if (p.nameNode.hasFlag("optional")) {
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
fn writeVarDef:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
790
|
-
if node.hasParamDesc {
|
|
791
|
-
def nn:CodeNode (itemAt node.children 1)
|
|
792
|
-
def p:RangerAppParamDesc nn.paramDesc
|
|
793
|
-
def b_not_used:boolean false
|
|
794
|
-
if ((p.ref_cnt == 0) && (p.is_class_variable == false)) {
|
|
795
|
-
|
|
796
|
-
; testing if variable definition can be omitted is here...
|
|
797
|
-
def b_can_skip true
|
|
798
|
-
if ((array_length node.children) > 2) {
|
|
799
|
-
def value:CodeNode (node.getThird())
|
|
800
|
-
if(value.has_call || value.has_lambda_call) {
|
|
801
|
-
b_can_skip = false
|
|
802
|
-
}
|
|
803
|
-
value.forTree({
|
|
804
|
-
; can you detect operators with side effects ?
|
|
805
|
-
if(item.has_call || item.has_lambda_call) {
|
|
806
|
-
b_can_skip = false
|
|
807
|
-
}
|
|
808
|
-
})
|
|
809
|
-
if( b_can_skip == false ) {
|
|
810
|
-
wr.out(" _ = " false)
|
|
811
|
-
ctx.setInExpr()
|
|
812
|
-
this.WalkNode(value ctx wr)
|
|
813
|
-
ctx.unsetInExpr()
|
|
814
|
-
wr.out('' true)
|
|
815
|
-
return
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
if b_can_skip {
|
|
819
|
-
wr.out((("/** unused: " + p.compiledName) + "*/") true)
|
|
820
|
-
b_not_used = true
|
|
821
|
-
return
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
def map_or_hash:boolean ((nn.value_type == RangerNodeType.Array) || (nn.value_type == RangerNodeType.Hash))
|
|
825
|
-
if (nn.hasFlag("optional")) {
|
|
826
|
-
wr.out((("var " + p.compiledName) + " *GoNullable = new(GoNullable); ") true)
|
|
827
|
-
if ((array_length node.children) > 2) {
|
|
828
|
-
def value:CodeNode (itemAt node.children 2)
|
|
829
|
-
if value.hasParamDesc {
|
|
830
|
-
def pnn:CodeNode value.paramDesc.nameNode
|
|
831
|
-
if (pnn.hasFlag("optional")) {
|
|
832
|
-
wr.out((p.compiledName + ".value = ") false)
|
|
833
|
-
ctx.setInExpr()
|
|
834
|
-
def value:CodeNode (node.getThird())
|
|
835
|
-
this.WalkNode(value ctx wr)
|
|
836
|
-
ctx.unsetInExpr()
|
|
837
|
-
wr.out(".value;" true)
|
|
838
|
-
wr.out((p.compiledName + ".has_value = ") false)
|
|
839
|
-
ctx.setInExpr()
|
|
840
|
-
def value:CodeNode (node.getThird())
|
|
841
|
-
this.WalkNode(value ctx wr)
|
|
842
|
-
ctx.unsetInExpr()
|
|
843
|
-
wr.out(".has_value;" true)
|
|
844
|
-
return
|
|
845
|
-
} {
|
|
846
|
-
wr.out((p.compiledName + ".value = ") false)
|
|
847
|
-
ctx.setInExpr()
|
|
848
|
-
def value:CodeNode (node.getThird())
|
|
849
|
-
this.WalkNode(value ctx wr)
|
|
850
|
-
ctx.unsetInExpr()
|
|
851
|
-
wr.out(";" true)
|
|
852
|
-
wr.out((p.compiledName + ".has_value = true;") true)
|
|
853
|
-
return
|
|
854
|
-
}
|
|
855
|
-
} {
|
|
856
|
-
wr.out((p.compiledName + " = ") false)
|
|
857
|
-
ctx.setInExpr()
|
|
858
|
-
def value:CodeNode (node.getThird())
|
|
859
|
-
this.WalkNode(value ctx wr)
|
|
860
|
-
ctx.unsetInExpr()
|
|
861
|
-
wr.out(";" true)
|
|
862
|
-
return
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
return
|
|
866
|
-
} {
|
|
867
|
-
if (((p.set_cnt > 0) || p.is_class_variable) || map_or_hash) {
|
|
868
|
-
wr.out((("var " + p.compiledName) + " ") false)
|
|
869
|
-
} {
|
|
870
|
-
wr.out((("var " + p.compiledName) + " ") false)
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
def ti_ok (ctx.canUseTypeInference( (unwrap p.nameNode) ))
|
|
875
|
-
if( (false == ti_ok ) || ( (false == (p.nameNode.hasFlag("optional"))) && ( (array_length node.children) == 2) ) ) {
|
|
876
|
-
this.writeTypeDef2(( unwrap p.nameNode )ctx wr)
|
|
877
|
-
}
|
|
878
|
-
if ((array_length node.children) > 2) {
|
|
879
|
-
def value:CodeNode (node.getThird())
|
|
880
|
-
if (value.expression && ((array_length value.children) > 1)) {
|
|
881
|
-
def fc:CodeNode (itemAt value.children 0)
|
|
882
|
-
if (fc.vref == "array_extract") {
|
|
883
|
-
; special case to create assigment for array_extract in golang
|
|
884
|
-
|
|
885
|
-
this.goExtractAssign( value (unwrap p) ctx wr )
|
|
886
|
-
return
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
wr.out("= " false)
|
|
890
|
-
ctx.setInExpr()
|
|
891
|
-
if( p.nameNode.eval_type_name == "char") {
|
|
892
|
-
wr.out("byte(" false)
|
|
893
|
-
}
|
|
894
|
-
this.WalkNode(value ctx wr)
|
|
895
|
-
if( p.nameNode.eval_type_name == "char") {
|
|
896
|
-
wr.out(")" false)
|
|
897
|
-
}
|
|
898
|
-
ctx.unsetInExpr()
|
|
899
|
-
} {
|
|
900
|
-
if (nn.value_type == RangerNodeType.Array) {
|
|
901
|
-
wr.out(" = make(" false)
|
|
902
|
-
this.writeTypeDef(( unwrap p.nameNode ) ctx wr)
|
|
903
|
-
wr.out(", 0)" false)
|
|
904
|
-
}
|
|
905
|
-
if (nn.value_type == RangerNodeType.Hash) {
|
|
906
|
-
wr.out(" = make(" false)
|
|
907
|
-
this.writeTypeDef(( unwrap p.nameNode ) ctx wr)
|
|
908
|
-
wr.out(")" false)
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
wr.out(";" false)
|
|
912
|
-
if ((p.ref_cnt == 0) && (p.is_class_variable == true)) {
|
|
913
|
-
wr.out(" /** note: unused */" false)
|
|
914
|
-
}
|
|
915
|
-
if ((p.ref_cnt == 0) && (p.is_class_variable == false)) {
|
|
916
|
-
|
|
917
|
-
} {
|
|
918
|
-
wr.newline()
|
|
919
|
-
}
|
|
920
|
-
if (b_not_used == false) {
|
|
921
|
-
if (nn.hasFlag("optional")) {
|
|
922
|
-
wr.addImport("errors")
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
fn writeArgsDef:void (fnDesc:RangerAppFunctionDesc ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
928
|
-
for fnDesc.params arg:RangerAppParamDesc i {
|
|
929
|
-
if (i > 0) {
|
|
930
|
-
wr.out(", " false)
|
|
931
|
-
}
|
|
932
|
-
wr.out((arg.compiledName + " ") false)
|
|
933
|
-
|
|
934
|
-
if (arg.nameNode.hasFlag("optional")) {
|
|
935
|
-
wr.out("*GoNullable" false)
|
|
936
|
-
} {
|
|
937
|
-
this.writeTypeDef( (unwrap arg.nameNode) ctx wr)
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
fn writeNewCall:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
944
|
-
if node.hasNewOper {
|
|
945
|
-
def cl:RangerAppClassDesc node.clDesc
|
|
946
|
-
def fc:CodeNode (node.getSecond())
|
|
947
|
-
wr.out((("CreateNew_" + node.clDesc.name) + "(") false)
|
|
948
|
-
def constr:RangerAppFunctionDesc cl.constructor_fn
|
|
949
|
-
def givenArgs:CodeNode (node.getThird())
|
|
950
|
-
if (!null? constr) {
|
|
951
|
-
for constr.params arg:RangerAppParamDesc i {
|
|
952
|
-
def n:CodeNode (itemAt givenArgs.children i)
|
|
953
|
-
if (i > 0) {
|
|
954
|
-
wr.out(", " false)
|
|
955
|
-
}
|
|
956
|
-
if( true || (!null? arg.nameNode)) {
|
|
957
|
-
this.WalkNode(n ctx wr)
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
wr.out(")" false)
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
fn writeArrayLiteral( node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
966
|
-
this.writeTypeDef(node ctx wr)
|
|
967
|
-
wr.out(" {" false)
|
|
968
|
-
node.children.forEach({
|
|
969
|
-
if( index > 0 ) {
|
|
970
|
-
wr.out(", " false)
|
|
971
|
-
}
|
|
972
|
-
this.WalkNode( item ctx wr )
|
|
973
|
-
})
|
|
974
|
-
wr.out("}" false)
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
fn CreateLambdaCall:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
978
|
-
def fName:CodeNode (itemAt node.children 0)
|
|
979
|
-
def givenArgs:CodeNode (itemAt node.children 1)
|
|
980
|
-
|
|
981
|
-
def args:CodeNode
|
|
982
|
-
if( (!null? fName.expression_value) ) {
|
|
983
|
-
args = ( itemAt fName.expression_value.children 1)
|
|
984
|
-
} {
|
|
985
|
-
def param (ctx.getVariableDef(fName.vref))
|
|
986
|
-
args = ( itemAt param.nameNode.expression_value.children 1)
|
|
987
|
-
}
|
|
988
|
-
ctx.setInExpr()
|
|
989
|
-
this.WalkNode(fName ctx wr)
|
|
990
|
-
wr.out("(" false)
|
|
991
|
-
def subCtx (ctx.fork())
|
|
992
|
-
for args.children arg:CodeNode i {
|
|
993
|
-
def n:CodeNode (itemAt givenArgs.children i)
|
|
994
|
-
if (i > 0) {
|
|
995
|
-
wr.out(", " false)
|
|
996
|
-
}
|
|
997
|
-
if(arg.value_type != RangerNodeType.NoType) {
|
|
998
|
-
this.WalkNode(n subCtx wr)
|
|
999
|
-
} {
|
|
1000
|
-
this.WalkNode(n subCtx wr)
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
ctx.unsetInExpr()
|
|
1004
|
-
wr.out(")" false)
|
|
1005
|
-
if ((ctx.expressionLevel()) == 0) {
|
|
1006
|
-
wr.out(";" true)
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
fn CreateLambda:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
1010
|
-
def lambdaCtx (unwrap node.lambda_ctx)
|
|
1011
|
-
def fnNode:CodeNode (itemAt node.children 0)
|
|
1012
|
-
def args:CodeNode (itemAt node.children 1)
|
|
1013
|
-
def body:CodeNode (itemAt node.children 2)
|
|
1014
|
-
; def nameNode:CodeNode (itemAt fnNode.expression_value.children 0)
|
|
1015
|
-
wr.out("func (" false)
|
|
1016
|
-
for args.children arg:CodeNode i {
|
|
1017
|
-
if (i > 0) {
|
|
1018
|
-
wr.out(", " false)
|
|
1019
|
-
}
|
|
1020
|
-
wr.out(arg.vref false)
|
|
1021
|
-
; this.WalkNode(arg lambdaCtx wr)
|
|
1022
|
-
wr.out(" " false)
|
|
1023
|
-
if (arg.hasFlag("optional")) {
|
|
1024
|
-
wr.out("*GoNullable" false)
|
|
1025
|
-
} {
|
|
1026
|
-
this.writeTypeDef( arg lambdaCtx wr)
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
wr.out(") " false)
|
|
1030
|
-
|
|
1031
|
-
if (fnNode.hasFlag("optional")) {
|
|
1032
|
-
wr.out("*GoNullable" false)
|
|
1033
|
-
} {
|
|
1034
|
-
this.writeTypeDef(fnNode lambdaCtx wr)
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
wr.out(" {" true)
|
|
1038
|
-
wr.indent(1)
|
|
1039
|
-
lambdaCtx.restartExpressionLevel()
|
|
1040
|
-
for body.children item:CodeNode i {
|
|
1041
|
-
this.WalkNode(item lambdaCtx wr)
|
|
1042
|
-
}
|
|
1043
|
-
wr.newline()
|
|
1044
|
-
wr.indent(-1)
|
|
1045
|
-
wr.out("}" false)
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
; current:
|
|
1050
|
-
; a.Get_friendList() = append(a.Get_friendList(),b);
|
|
1051
|
-
; goal:
|
|
1052
|
-
; a.Set_FriendList( append(a.Get_friendList(),b) )
|
|
1053
|
-
; push arr item
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
fn CustomOperator:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
1057
|
-
|
|
1058
|
-
def fc:CodeNode (node.getFirst())
|
|
1059
|
-
def cmd:string fc.vref
|
|
1060
|
-
|
|
1061
|
-
if(cmd == "return" ) {
|
|
1062
|
-
if( (array_length node.children ) > 1 ) {
|
|
1063
|
-
def rValue (node.getSecond())
|
|
1064
|
-
if( (ctx.isCatchBlock()) || (ctx.isTryBlock()) ) {
|
|
1065
|
-
wr.out("__ex_returned = true" true)
|
|
1066
|
-
wr.out("__exReturn = " false)
|
|
1067
|
-
ctx.setInExpr()
|
|
1068
|
-
this.WalkNode( rValue ctx wr )
|
|
1069
|
-
ctx.unsetInExpr()
|
|
1070
|
-
wr.newline()
|
|
1071
|
-
if( ctx.isTryBlock() ) {
|
|
1072
|
-
wr.out("return __ex_returned, __exReturn" true)
|
|
1073
|
-
}
|
|
1074
|
-
} {
|
|
1075
|
-
wr.out("return " false)
|
|
1076
|
-
ctx.setInExpr()
|
|
1077
|
-
this.WalkNode( rValue ctx wr )
|
|
1078
|
-
ctx.unsetInExpr()
|
|
1079
|
-
wr.newline()
|
|
1080
|
-
}
|
|
1081
|
-
} {
|
|
1082
|
-
if(ctx.isCatchBlock()) {
|
|
1083
|
-
wr.out("__ex_returned = true" true)
|
|
1084
|
-
}
|
|
1085
|
-
if(ctx.isTryBlock()) {
|
|
1086
|
-
wr.out("return false, nil" true)
|
|
1087
|
-
}
|
|
1088
|
-
wr.out("return" true)
|
|
1089
|
-
}
|
|
1090
|
-
return
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
; create custom try... catch... operator
|
|
1094
|
-
if(cmd == "try" ) {
|
|
1095
|
-
|
|
1096
|
-
def tryBlock (node.getSecond())
|
|
1097
|
-
def catchBlock (node.getThird())
|
|
1098
|
-
|
|
1099
|
-
def currFn (ctx.getCurrentMethod())
|
|
1100
|
-
; def ex1 (create_var ctx "did_throw" "boolean")
|
|
1101
|
-
def ex2 (create_var ctx "did_return" "boolean")
|
|
1102
|
-
def ex3 (create_var ctx "ex_result" (unwrap currFn.nameNode) )
|
|
1103
|
-
|
|
1104
|
-
if( currFn.nameNode.type_name == "void") {
|
|
1105
|
-
wr.out( ex2.compiledName + ", _ := (func () ( __ex_returned bool, __exReturn interface{}) {" , true)
|
|
1106
|
-
; wr.out( "(func () ( __ex_returned bool, __exReturn interface{}) {" , true)
|
|
1107
|
-
} {
|
|
1108
|
-
wr.out( ex2.compiledName + ", " + ex3.compiledName + " := (func () ( __ex_returned bool, __exReturn interface{}) {" , true)
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
wr.indent(1)
|
|
1112
|
-
wr.out("defer func() {" true)
|
|
1113
|
-
wr.indent(1)
|
|
1114
|
-
wr.out("if r:= recover(); r != nil {" true)
|
|
1115
|
-
wr.indent(1)
|
|
1116
|
-
|
|
1117
|
-
def subCtx (ctx.fork())
|
|
1118
|
-
subCtx.is_catch_block = true
|
|
1119
|
-
; -- here the return should be converted
|
|
1120
|
-
this.WalkNode( catchBlock subCtx wr)
|
|
1121
|
-
wr.indent(-1)
|
|
1122
|
-
wr.out("}" true)
|
|
1123
|
-
wr.indent(-1)
|
|
1124
|
-
wr.out("}()" true)
|
|
1125
|
-
; the try block here...
|
|
1126
|
-
def subCtx (ctx.fork())
|
|
1127
|
-
subCtx.is_try_block = true
|
|
1128
|
-
this.WalkNode( tryBlock subCtx wr)
|
|
1129
|
-
; wr.out("if")
|
|
1130
|
-
wr.out("return __ex_returned, __exReturn" true)
|
|
1131
|
-
wr.indent(-1)
|
|
1132
|
-
wr.out("})()" true)
|
|
1133
|
-
|
|
1134
|
-
if( currFn.nameNode.type_name != "void") {
|
|
1135
|
-
wr.out("if " + ex2.compiledName + " {" , true)
|
|
1136
|
-
wr.indent(1)
|
|
1137
|
-
wr.out("return " + ex3.compiledName , false)
|
|
1138
|
-
wr.out(".(" false)
|
|
1139
|
-
this.writeTypeDef((unwrap currFn.nameNode) ctx wr)
|
|
1140
|
-
wr.out(")" true)
|
|
1141
|
-
|
|
1142
|
-
wr.indent(-1)
|
|
1143
|
-
wr.out("}" true)
|
|
1144
|
-
} {
|
|
1145
|
-
wr.out("if " + ex2.compiledName + " {" , true)
|
|
1146
|
-
wr.indent(1)
|
|
1147
|
-
wr.out("return ", true)
|
|
1148
|
-
wr.indent(-1)
|
|
1149
|
-
wr.out("}" true)
|
|
1150
|
-
}
|
|
1151
|
-
return
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
if(cmd == "=" || cmd == "push" || cmd == "removeLast") {
|
|
1155
|
-
|
|
1156
|
-
def left:CodeNode (node.getSecond())
|
|
1157
|
-
def right:CodeNode left
|
|
1158
|
-
|
|
1159
|
-
if(cmd == "=" || cmd == "push") {
|
|
1160
|
-
right = (node.getThird())
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
wr.newline()
|
|
1164
|
-
|
|
1165
|
-
def b_was_static:boolean false
|
|
1166
|
-
|
|
1167
|
-
if(left.hasParamDesc) {
|
|
1168
|
-
|
|
1169
|
-
def a_len:int ( (array_length left.ns) - 1)
|
|
1170
|
-
def last_part:string (itemAt left.ns a_len)
|
|
1171
|
-
|
|
1172
|
-
def next_is_gs:boolean false
|
|
1173
|
-
def last_was_setter:boolean false
|
|
1174
|
-
def needs_par:boolean false
|
|
1175
|
-
|
|
1176
|
-
for left.ns part:string i {
|
|
1177
|
-
if next_is_gs {
|
|
1178
|
-
if( i == a_len) {
|
|
1179
|
-
wr.out(".Set_" false)
|
|
1180
|
-
last_was_setter = true
|
|
1181
|
-
} {
|
|
1182
|
-
wr.out(".Get_" false)
|
|
1183
|
-
needs_par = true
|
|
1184
|
-
next_is_gs = false
|
|
1185
|
-
last_was_setter = false
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
if( last_was_setter == false && needs_par == false) {
|
|
1189
|
-
if (i > 0) {
|
|
1190
|
-
if ((i == 1) && b_was_static) {
|
|
1191
|
-
wr.out("_static_" false)
|
|
1192
|
-
} {
|
|
1193
|
-
wr.out("." false)
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
if (i == 0) {
|
|
1198
|
-
if(part == "this") {
|
|
1199
|
-
wr.out(thisName false)
|
|
1200
|
-
continue
|
|
1201
|
-
}
|
|
1202
|
-
if (ctx.hasClass(part)) {
|
|
1203
|
-
b_was_static = true
|
|
1204
|
-
}
|
|
1205
|
-
def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
1206
|
-
if ((part != "this") && (!null? cc) && (false == (ctx.isInStatic())) ) {
|
|
1207
|
-
; def cc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
1208
|
-
def currC:RangerAppClassDesc (unwrap cc)
|
|
1209
|
-
def up@(optional):RangerAppParamDesc (currC.findVariable(part))
|
|
1210
|
-
def lvDef (ctx.getVariableDef(part))
|
|
1211
|
-
if ( (!null? up) && (lvDef.is_class_variable) ) {
|
|
1212
|
-
def p3:RangerAppParamDesc (unwrap up)
|
|
1213
|
-
wr.out((thisName + ".") false)
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
def partDef:RangerAppParamDesc (ctx.getVariableDef(part))
|
|
1219
|
-
if( (array_length left.nsp) > i ) {
|
|
1220
|
-
partDef = (itemAt left.nsp i)
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
if(!null? partDef.nameNode) {
|
|
1224
|
-
if(ctx.isDefinedClass(partDef.nameNode.type_name)) {
|
|
1225
|
-
def c:RangerAppClassDesc (ctx.findClass(partDef.nameNode.type_name))
|
|
1226
|
-
if(c.doesInherit()) {
|
|
1227
|
-
next_is_gs = true
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
if( (array_length left.nsp ) > 0) {
|
|
1233
|
-
def p:RangerAppParamDesc (itemAt left.nsp i)
|
|
1234
|
-
wr.out((this.adjustType(p.compiledName)) false)
|
|
1235
|
-
} {
|
|
1236
|
-
if(left.hasParamDesc) {
|
|
1237
|
-
wr.out(left.paramDesc.compiledName false)
|
|
1238
|
-
} {
|
|
1239
|
-
wr.out((this.adjustType(part)) false)
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
if needs_par {
|
|
1244
|
-
wr.out("()" false)
|
|
1245
|
-
needs_par = false
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
if( (array_length left.nsp ) >= (i+1)) {
|
|
1249
|
-
def pp:RangerAppParamDesc (itemAt left.nsp i)
|
|
1250
|
-
if(pp.nameNode.hasFlag("optional")) {
|
|
1251
|
-
if( (array_length left.nsp ) > (i+1)) {
|
|
1252
|
-
wr.out(".value.(" false)
|
|
1253
|
-
this.writeTypeDef((unwrap pp.nameNode) ctx wr)
|
|
1254
|
-
wr.out(")" false)
|
|
1255
|
-
} {
|
|
1256
|
-
wr.out(".value" false)
|
|
1257
|
-
if( (right.hasFlag("optional")) == false) {
|
|
1258
|
-
wr.out(" /* right is not optional, should set the has_value -> true */" false)
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
; go ( (e 1) "= " (e 1) "[:len(" (e 1)") - 1]")
|
|
1267
|
-
if( cmd == "removeLast") {
|
|
1268
|
-
if last_was_setter {
|
|
1269
|
-
wr.out("(" false)
|
|
1270
|
-
ctx.setInExpr()
|
|
1271
|
-
this.WalkNode(left ctx wr)
|
|
1272
|
-
wr.out("[:len(" false)
|
|
1273
|
-
this.WalkNode(left ctx wr)
|
|
1274
|
-
wr.out(")-1]" false)
|
|
1275
|
-
ctx.unsetInExpr()
|
|
1276
|
-
wr.out("); " true)
|
|
1277
|
-
} {
|
|
1278
|
-
wr.out(" = " false)
|
|
1279
|
-
ctx.setInExpr()
|
|
1280
|
-
this.WalkNode(left ctx wr)
|
|
1281
|
-
wr.out("[:len(" false)
|
|
1282
|
-
this.WalkNode(left ctx wr)
|
|
1283
|
-
wr.out(")-1]" false)
|
|
1284
|
-
ctx.unsetInExpr()
|
|
1285
|
-
wr.out("; " true)
|
|
1286
|
-
}
|
|
1287
|
-
return
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
if( cmd == "push") {
|
|
1292
|
-
if last_was_setter {
|
|
1293
|
-
wr.out("(" false)
|
|
1294
|
-
ctx.setInExpr()
|
|
1295
|
-
wr.out("append(" false)
|
|
1296
|
-
this.WalkNode(left ctx wr)
|
|
1297
|
-
wr.out("," false)
|
|
1298
|
-
this.WalkNode(right ctx wr)
|
|
1299
|
-
ctx.unsetInExpr()
|
|
1300
|
-
wr.out(")); " true)
|
|
1301
|
-
} {
|
|
1302
|
-
wr.out(" = " false)
|
|
1303
|
-
wr.out("append(" false)
|
|
1304
|
-
ctx.setInExpr()
|
|
1305
|
-
this.WalkNode(left ctx wr)
|
|
1306
|
-
wr.out("," false)
|
|
1307
|
-
this.WalkNode(right ctx wr)
|
|
1308
|
-
ctx.unsetInExpr()
|
|
1309
|
-
wr.out("); " true)
|
|
1310
|
-
}
|
|
1311
|
-
return
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
if last_was_setter {
|
|
1315
|
-
wr.out("(" false)
|
|
1316
|
-
ctx.setInExpr()
|
|
1317
|
-
this.WalkNode(right ctx wr)
|
|
1318
|
-
ctx.unsetInExpr()
|
|
1319
|
-
wr.out("); " true)
|
|
1320
|
-
} {
|
|
1321
|
-
wr.out(" = " false)
|
|
1322
|
-
ctx.setInExpr()
|
|
1323
|
-
this.WalkNode(right ctx wr)
|
|
1324
|
-
ctx.unsetInExpr()
|
|
1325
|
-
wr.out("; " true)
|
|
1326
|
-
}
|
|
1327
|
-
return
|
|
1328
|
-
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
this.WriteSetterVRef(left ctx wr)
|
|
1332
|
-
wr.out(" = " false)
|
|
1333
|
-
ctx.setInExpr()
|
|
1334
|
-
this.WalkNode(right ctx wr)
|
|
1335
|
-
ctx.unsetInExpr()
|
|
1336
|
-
wr.out("; /* custom */" true)
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
fn writeInterface:void (cl:RangerAppClassDesc ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
1341
|
-
|
|
1342
|
-
wr.out((("type " + cl.name) + " interface { ") true)
|
|
1343
|
-
wr.indent(1)
|
|
1344
|
-
for cl.defined_variants fnVar:string i {
|
|
1345
|
-
def mVs:RangerAppMethodVariants (get cl.method_variants fnVar)
|
|
1346
|
-
for mVs.variants variant:RangerAppFunctionDesc i {
|
|
1347
|
-
wr.out( variant.compiledName + "(" , false)
|
|
1348
|
-
this.writeArgsDef(variant ctx wr)
|
|
1349
|
-
wr.out(") " false)
|
|
1350
|
-
if (variant.nameNode.hasFlag("optional")) {
|
|
1351
|
-
wr.out("*GoNullable" false)
|
|
1352
|
-
} {
|
|
1353
|
-
this.writeTypeDef(( unwrap variant.nameNode ) ctx wr)
|
|
1354
|
-
}
|
|
1355
|
-
wr.out("" true)
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
wr.indent(-1)
|
|
1359
|
-
wr.out("}" true)
|
|
1360
|
-
}
|
|
1361
|
-
fn writeClass:void (node:CodeNode ctx:RangerAppWriterContext orig_wr:CodeWriter) {
|
|
1362
|
-
def cl:RangerAppClassDesc node.clDesc
|
|
1363
|
-
if (null? cl) {
|
|
1364
|
-
return
|
|
1365
|
-
}
|
|
1366
|
-
def wr:CodeWriter orig_wr
|
|
1367
|
-
if (did_write_nullable == false) {
|
|
1368
|
-
wr.raw("\r\ntype GoNullable struct { \r\n value interface{}\r\n has_value bool\r\n}\r\n" true)
|
|
1369
|
-
wr.createTag("utilities")
|
|
1370
|
-
did_write_nullable = true
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
def declaredVariable:[string:boolean]
|
|
1374
|
-
def declaredFunction:[string:boolean]
|
|
1375
|
-
def declaredIfFunction:[string:boolean]
|
|
1376
|
-
|
|
1377
|
-
wr.out((("type " + cl.name) + " struct { ") true)
|
|
1378
|
-
wr.indent(1)
|
|
1379
|
-
|
|
1380
|
-
for cl.variables pvar:RangerAppParamDesc i {
|
|
1381
|
-
this.writeStructField(( unwrap pvar.node ) ctx wr)
|
|
1382
|
-
set declaredVariable pvar.name true
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
if ( ( array_length cl.extends_classes ) > 0 ) {
|
|
1386
|
-
for cl.extends_classes pName:string i {
|
|
1387
|
-
def pC:RangerAppClassDesc (ctx.findClass(pName))
|
|
1388
|
-
wr.out("// inherited from parent class " + pName , true)
|
|
1389
|
-
for pC.variables pvar:RangerAppParamDesc i {
|
|
1390
|
-
if(has declaredVariable pvar.name) {
|
|
1391
|
-
continue
|
|
1392
|
-
}
|
|
1393
|
-
this.writeStructField(( unwrap pvar.node ) ctx wr)
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
wr.indent(-1)
|
|
1400
|
-
wr.out("}" true)
|
|
1401
|
-
|
|
1402
|
-
if( (cl.doesInherit()) || (has cl.extends_classes) ) {
|
|
1403
|
-
wr.out((("type IFACE_" + cl.name) + " interface { ") true)
|
|
1404
|
-
wr.indent(1)
|
|
1405
|
-
for cl.variables p:RangerAppParamDesc i {
|
|
1406
|
-
wr.out("Get_" false)
|
|
1407
|
-
wr.out((p.compiledName + "() ") false)
|
|
1408
|
-
if (p.nameNode.hasFlag("optional")) {
|
|
1409
|
-
wr.out("*GoNullable" false)
|
|
1410
|
-
} {
|
|
1411
|
-
this.writeTypeDef(( unwrap p.nameNode )ctx wr)
|
|
1412
|
-
}
|
|
1413
|
-
wr.out("" true)
|
|
1414
|
-
wr.out("Set_" false)
|
|
1415
|
-
wr.out(p.compiledName + "(value " , false )
|
|
1416
|
-
if (p.nameNode.hasFlag("optional")) {
|
|
1417
|
-
wr.out("*GoNullable" false)
|
|
1418
|
-
} {
|
|
1419
|
-
this.writeTypeDef(( unwrap p.nameNode )ctx wr)
|
|
1420
|
-
}
|
|
1421
|
-
wr.out(") " true)
|
|
1422
|
-
}
|
|
1423
|
-
for cl.defined_variants fnVar:string i {
|
|
1424
|
-
def mVs:RangerAppMethodVariants (get cl.method_variants fnVar)
|
|
1425
|
-
for mVs.variants variant:RangerAppFunctionDesc i {
|
|
1426
|
-
if(has declaredIfFunction variant.name) {
|
|
1427
|
-
continue
|
|
1428
|
-
}
|
|
1429
|
-
set declaredIfFunction variant.name true
|
|
1430
|
-
wr.out( variant.compiledName + "(" , false)
|
|
1431
|
-
this.writeArgsDef(variant ctx wr)
|
|
1432
|
-
wr.out(") " false)
|
|
1433
|
-
if (variant.nameNode.hasFlag("optional")) {
|
|
1434
|
-
wr.out("*GoNullable" false)
|
|
1435
|
-
} {
|
|
1436
|
-
this.writeTypeDef(( unwrap variant.nameNode ) ctx wr)
|
|
1437
|
-
}
|
|
1438
|
-
wr.out("" true)
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
wr.indent(-1)
|
|
1442
|
-
wr.out("}" true)
|
|
1443
|
-
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
thisName = "me"
|
|
1449
|
-
wr.out("" true)
|
|
1450
|
-
wr.out((("func CreateNew_" + cl.name) + "(") false)
|
|
1451
|
-
if cl.has_constructor {
|
|
1452
|
-
def constr:RangerAppFunctionDesc cl.constructor_fn
|
|
1453
|
-
for constr.params arg:RangerAppParamDesc i {
|
|
1454
|
-
if (i > 0) {
|
|
1455
|
-
wr.out(", " false)
|
|
1456
|
-
}
|
|
1457
|
-
wr.out((arg.name + " ") false)
|
|
1458
|
-
this.writeTypeDef((unwrap arg.nameNode) ctx wr)
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
wr.out(((") *" + cl.name) + " {") true)
|
|
1462
|
-
wr.indent(1)
|
|
1463
|
-
wr.newline()
|
|
1464
|
-
wr.out((("me := new(" + cl.name) + ")") true)
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
; write inherited vriables
|
|
1468
|
-
if ( ( array_length cl.extends_classes ) > 0 ) {
|
|
1469
|
-
for cl.extends_classes pName:string i {
|
|
1470
|
-
def pC:RangerAppClassDesc (ctx.findClass(pName))
|
|
1471
|
-
|
|
1472
|
-
for pC.variables pvar:RangerAppParamDesc i {
|
|
1473
|
-
def nn:CodeNode ( unwrap pvar.node )
|
|
1474
|
-
if ((array_length nn.children) > 2) {
|
|
1475
|
-
def valueNode:CodeNode (itemAt nn.children 2)
|
|
1476
|
-
wr.out((("me." + pvar.compiledName) + " = ") false)
|
|
1477
|
-
this.WalkNode(valueNode ctx wr)
|
|
1478
|
-
wr.out("" true)
|
|
1479
|
-
} {
|
|
1480
|
-
def pNameN:CodeNode (unwrap pvar.nameNode)
|
|
1481
|
-
if (pNameN.value_type == RangerNodeType.Array) {
|
|
1482
|
-
wr.out((("me." + pvar.compiledName) + " = ") false)
|
|
1483
|
-
wr.out("make(" false)
|
|
1484
|
-
this.writeTypeDef( (unwrap pvar.nameNode) ctx wr)
|
|
1485
|
-
wr.out(",0)" true)
|
|
1486
|
-
}
|
|
1487
|
-
if (pNameN.value_type == RangerNodeType.Hash) {
|
|
1488
|
-
wr.out((("me." + pvar.compiledName) + " = ") false)
|
|
1489
|
-
wr.out("make(" false)
|
|
1490
|
-
this.writeTypeDef((unwrap pvar.nameNode) ctx wr)
|
|
1491
|
-
wr.out(")" true)
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
for pC.variables pvar:RangerAppParamDesc i {
|
|
1496
|
-
if (pvar.nameNode.hasFlag("optional")) {
|
|
1497
|
-
wr.out((("me." + pvar.compiledName) + " = new(GoNullable);") true)
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
if pC.has_constructor {
|
|
1501
|
-
def constr:RangerAppFunctionDesc pC.constructor_fn
|
|
1502
|
-
def subCtx:RangerAppWriterContext ( unwrap constr.fnCtx )
|
|
1503
|
-
subCtx.is_function = true
|
|
1504
|
-
this.WalkNode(( unwrap constr.fnBody ) subCtx wr)
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
for cl.variables pvar:RangerAppParamDesc i {
|
|
1511
|
-
def nn:CodeNode ( unwrap pvar.node )
|
|
1512
|
-
if ((array_length nn.children) > 2) {
|
|
1513
|
-
def valueNode:CodeNode (itemAt nn.children 2)
|
|
1514
|
-
wr.out((("me." + pvar.compiledName) + " = ") false)
|
|
1515
|
-
this.WalkNode(valueNode ctx wr)
|
|
1516
|
-
wr.out("" true)
|
|
1517
|
-
} {
|
|
1518
|
-
def pNameN:CodeNode pvar.nameNode
|
|
1519
|
-
if (pNameN.value_type == RangerNodeType.Array) {
|
|
1520
|
-
wr.out((("me." + pvar.compiledName) + " = ") false)
|
|
1521
|
-
wr.out("make(" false)
|
|
1522
|
-
this.writeTypeDef((unwrap pvar.nameNode) ctx wr)
|
|
1523
|
-
wr.out(",0)" true)
|
|
1524
|
-
}
|
|
1525
|
-
if (pNameN.value_type == RangerNodeType.Hash) {
|
|
1526
|
-
wr.out((("me." + pvar.compiledName) + " = ") false)
|
|
1527
|
-
wr.out("make(" false)
|
|
1528
|
-
this.writeTypeDef((unwrap pvar.nameNode) ctx wr)
|
|
1529
|
-
wr.out(")" true)
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
for cl.variables pvar:RangerAppParamDesc i {
|
|
1534
|
-
if (pvar.nameNode.hasFlag("optional")) {
|
|
1535
|
-
wr.out((("me." + pvar.compiledName) + " = new(GoNullable);") true)
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
if cl.has_constructor {
|
|
1540
|
-
def constr:RangerAppFunctionDesc cl.constructor_fn
|
|
1541
|
-
def subCtx:RangerAppWriterContext ( unwrap constr.fnCtx )
|
|
1542
|
-
subCtx.is_function = true
|
|
1543
|
-
this.WalkNode(( unwrap constr.fnBody ) subCtx wr)
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
wr.out("return me;" true)
|
|
1547
|
-
wr.indent(-1)
|
|
1548
|
-
wr.out("}" true)
|
|
1549
|
-
thisName = "this"
|
|
1550
|
-
for cl.static_methods variant:RangerAppFunctionDesc i {
|
|
1551
|
-
if (variant.nameNode.hasFlag("main")) {
|
|
1552
|
-
continue _
|
|
1553
|
-
}
|
|
1554
|
-
wr.newline()
|
|
1555
|
-
wr.out((((("func " + cl.name) + "_static_") + variant.compiledName) + "(") false)
|
|
1556
|
-
this.writeArgsDef(variant ctx wr)
|
|
1557
|
-
wr.out(") " false)
|
|
1558
|
-
|
|
1559
|
-
def vnn (unwrap variant.nameNode)
|
|
1560
|
-
if (vnn.hasFlag("optional")) {
|
|
1561
|
-
wr.out("*GoNullable" false)
|
|
1562
|
-
} {
|
|
1563
|
-
this.writeTypeDef(vnn ctx wr)
|
|
1564
|
-
}
|
|
1565
|
-
; this.writeTypeDef(( unwrap variant.nameNode ) ctx wr)
|
|
1566
|
-
wr.out(" {" true)
|
|
1567
|
-
wr.indent(1)
|
|
1568
|
-
wr.newline()
|
|
1569
|
-
def subCtx:RangerAppWriterContext (unwrap variant.fnCtx)
|
|
1570
|
-
subCtx.is_function = true
|
|
1571
|
-
subCtx.in_static_method = true
|
|
1572
|
-
this.WalkNode(( unwrap variant.fnBody ) subCtx wr)
|
|
1573
|
-
subCtx.in_static_method = false
|
|
1574
|
-
wr.newline()
|
|
1575
|
-
wr.indent(-1)
|
|
1576
|
-
wr.out("}" true)
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
def declaredFn:[string:boolean]
|
|
1581
|
-
|
|
1582
|
-
for cl.defined_variants fnVar:string i {
|
|
1583
|
-
def mVs:RangerAppMethodVariants (get cl.method_variants fnVar)
|
|
1584
|
-
for mVs.variants variant:RangerAppFunctionDesc i {
|
|
1585
|
-
|
|
1586
|
-
if(has declaredFunction variant.name) {
|
|
1587
|
-
continue
|
|
1588
|
-
}
|
|
1589
|
-
set declaredFunction variant.name true
|
|
1590
|
-
set declaredFn variant.name true
|
|
1591
|
-
wr.out((((("func (this *" + cl.name) + ") ") + variant.compiledName) + " (") false)
|
|
1592
|
-
this.writeArgsDef(variant ctx wr)
|
|
1593
|
-
wr.out(") " false)
|
|
1594
|
-
if (variant.nameNode.hasFlag("optional")) {
|
|
1595
|
-
wr.out("*GoNullable" false)
|
|
1596
|
-
} {
|
|
1597
|
-
this.writeTypeDef(( unwrap variant.nameNode ) ctx wr)
|
|
1598
|
-
}
|
|
1599
|
-
wr.out(" {" true)
|
|
1600
|
-
wr.indent(1)
|
|
1601
|
-
wr.newline()
|
|
1602
|
-
def subCtx:RangerAppWriterContext (unwrap variant.fnCtx)
|
|
1603
|
-
subCtx.is_function = true
|
|
1604
|
-
this.WalkNode(( unwrap variant.fnBody ) subCtx wr)
|
|
1605
|
-
wr.newline()
|
|
1606
|
-
wr.indent(-1)
|
|
1607
|
-
wr.out("}" true)
|
|
1608
|
-
}
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
if ( ( array_length cl.extends_classes ) > 0 ) {
|
|
1613
|
-
for cl.extends_classes pName:string i {
|
|
1614
|
-
def pC:RangerAppClassDesc (ctx.findClass(pName))
|
|
1615
|
-
wr.out("// inherited methods from parent class " + pName , true)
|
|
1616
|
-
for pC.defined_variants fnVar:string i {
|
|
1617
|
-
def mVs:RangerAppMethodVariants (get pC.method_variants fnVar)
|
|
1618
|
-
for mVs.variants variant:RangerAppFunctionDesc i {
|
|
1619
|
-
|
|
1620
|
-
if(has declaredFn variant.name) {
|
|
1621
|
-
; print variant.name + "was declared already!"
|
|
1622
|
-
continue
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
; if(has declaredFunction variant.name) {
|
|
1626
|
-
; continue
|
|
1627
|
-
; }
|
|
1628
|
-
; set declaredFunction variant.name true
|
|
1629
|
-
|
|
1630
|
-
wr.out((((("func (this *" + cl.name) + ") ") + variant.compiledName) + " (") false)
|
|
1631
|
-
this.writeArgsDef(variant ctx wr)
|
|
1632
|
-
wr.out(") " false)
|
|
1633
|
-
if (variant.nameNode.hasFlag("optional")) {
|
|
1634
|
-
wr.out("*GoNullable" false)
|
|
1635
|
-
} {
|
|
1636
|
-
this.writeTypeDef(( unwrap variant.nameNode ) ctx wr)
|
|
1637
|
-
}
|
|
1638
|
-
wr.out(" {" true)
|
|
1639
|
-
wr.indent(1)
|
|
1640
|
-
wr.newline()
|
|
1641
|
-
def subCtx:RangerAppWriterContext (unwrap variant.fnCtx)
|
|
1642
|
-
subCtx.is_function = true
|
|
1643
|
-
this.WalkNode(( unwrap variant.fnBody ) subCtx wr)
|
|
1644
|
-
wr.newline()
|
|
1645
|
-
wr.indent(-1)
|
|
1646
|
-
wr.out("}" true)
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
|
-
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
def declaredGetter:[string:boolean]
|
|
1655
|
-
|
|
1656
|
-
if( (cl.doesInherit()) || (has cl.extends_classes) ) {
|
|
1657
|
-
|
|
1658
|
-
for cl.variables p:RangerAppParamDesc i {
|
|
1659
|
-
|
|
1660
|
-
set declaredGetter p.name true
|
|
1661
|
-
|
|
1662
|
-
wr.newline()
|
|
1663
|
-
wr.out("// getter for variable " + p.name , true)
|
|
1664
|
-
wr.out( "func (this *" + cl.name + ") " , false)
|
|
1665
|
-
wr.out("Get_" false)
|
|
1666
|
-
wr.out((p.compiledName + "() ") false)
|
|
1667
|
-
if (p.nameNode.hasFlag("optional")) {
|
|
1668
|
-
wr.out("*GoNullable" false)
|
|
1669
|
-
} {
|
|
1670
|
-
this.writeTypeDef(( unwrap p.nameNode )ctx wr)
|
|
1671
|
-
}
|
|
1672
|
-
wr.out(" {" true)
|
|
1673
|
-
wr.indent(1)
|
|
1674
|
-
wr.out("return this." + p.compiledName , true)
|
|
1675
|
-
wr.indent(-1)
|
|
1676
|
-
wr.out("}" true)
|
|
1677
|
-
|
|
1678
|
-
wr.newline()
|
|
1679
|
-
wr.out("// setter for variable " + p.name , true)
|
|
1680
|
-
wr.out( "func (this *" + cl.name + ") " , false)
|
|
1681
|
-
wr.out("Set_" false)
|
|
1682
|
-
wr.out(p.compiledName + "( value " , false)
|
|
1683
|
-
if (p.nameNode.hasFlag("optional")) {
|
|
1684
|
-
wr.out("*GoNullable" false)
|
|
1685
|
-
} {
|
|
1686
|
-
this.writeTypeDef(( unwrap p.nameNode )ctx wr)
|
|
1687
|
-
}
|
|
1688
|
-
wr.out(") " false)
|
|
1689
|
-
|
|
1690
|
-
wr.out(" {" true)
|
|
1691
|
-
wr.indent(1)
|
|
1692
|
-
wr.out("this." + p.compiledName +" = value " , true)
|
|
1693
|
-
wr.indent(-1)
|
|
1694
|
-
wr.out("}" true)
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
|
-
if ( ( array_length cl.extends_classes ) > 0 ) {
|
|
1698
|
-
for cl.extends_classes pName:string i {
|
|
1699
|
-
def pC:RangerAppClassDesc (ctx.findClass(pName))
|
|
1700
|
-
wr.out("// inherited getters and setters from the parent class " + pName , true)
|
|
1701
|
-
for pC.variables p:RangerAppParamDesc i {
|
|
1702
|
-
|
|
1703
|
-
if( has declaredGetter p.name ) {
|
|
1704
|
-
continue
|
|
1705
|
-
}
|
|
1706
|
-
wr.newline()
|
|
1707
|
-
wr.out("// getter for variable " + p.name , true)
|
|
1708
|
-
wr.out( "func (this *" + cl.name + ") " , false)
|
|
1709
|
-
wr.out("Get_" false)
|
|
1710
|
-
wr.out((p.compiledName + "() ") false)
|
|
1711
|
-
if (p.nameNode.hasFlag("optional")) {
|
|
1712
|
-
wr.out("*GoNullable" false)
|
|
1713
|
-
} {
|
|
1714
|
-
this.writeTypeDef(( unwrap p.nameNode )ctx wr)
|
|
1715
|
-
}
|
|
1716
|
-
wr.out(" {" true)
|
|
1717
|
-
wr.indent(1)
|
|
1718
|
-
wr.out("return this." + p.compiledName , true)
|
|
1719
|
-
wr.indent(-1)
|
|
1720
|
-
wr.out("}" true)
|
|
1721
|
-
|
|
1722
|
-
wr.newline()
|
|
1723
|
-
wr.out("// getter for variable " + p.name , true)
|
|
1724
|
-
wr.out( "func (this *" + cl.name + ") " , false)
|
|
1725
|
-
wr.out("Set_" false)
|
|
1726
|
-
wr.out(p.compiledName + "( value " , false)
|
|
1727
|
-
if (p.nameNode.hasFlag("optional")) {
|
|
1728
|
-
wr.out("*GoNullable" false)
|
|
1729
|
-
} {
|
|
1730
|
-
this.writeTypeDef(( unwrap p.nameNode )ctx wr)
|
|
1731
|
-
}
|
|
1732
|
-
wr.out(") " false)
|
|
1733
|
-
|
|
1734
|
-
wr.out(" {" true)
|
|
1735
|
-
wr.indent(1)
|
|
1736
|
-
wr.out("this." + p.compiledName +" = value " , true)
|
|
1737
|
-
wr.indent(-1)
|
|
1738
|
-
wr.out("}" true)
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1743
|
-
|
|
1744
|
-
for cl.static_methods variant:RangerAppFunctionDesc i {
|
|
1745
|
-
if ( (variant.nameNode.hasFlag("main")) && (variant.nameNode.code.filename == (ctx.getRootFile()))) {
|
|
1746
|
-
wr.out("func main() {" true)
|
|
1747
|
-
wr.indent(1)
|
|
1748
|
-
wr.newline()
|
|
1749
|
-
def subCtx:RangerAppWriterContext (unwrap variant.fnCtx)
|
|
1750
|
-
subCtx.is_function = true
|
|
1751
|
-
subCtx.in_static_method = true
|
|
1752
|
-
this.WalkNode(( unwrap variant.fnBody ) subCtx wr)
|
|
1753
|
-
subCtx.in_static_method = false
|
|
1754
|
-
|
|
1755
|
-
if( ctx.hasCompilerFlag('forever')) {
|
|
1756
|
-
wr.out(`for {}` true)
|
|
1757
|
-
}
|
|
1758
|
-
|
|
1759
|
-
wr.newline()
|
|
1760
|
-
wr.indent(-1)
|
|
1761
|
-
wr.out("}" true)
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
|