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