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,772 +0,0 @@
|
|
|
1
|
-
import java.util.Optional;
|
|
2
|
-
import java.util.*;
|
|
3
|
-
import java.io.*;
|
|
4
|
-
|
|
5
|
-
class LiveCompiler {
|
|
6
|
-
public Optional<RangerGenericClassWriter> langWriter = Optional.empty();
|
|
7
|
-
public HashMap<String,Boolean> hasCreatedPolyfill = new HashMap<String,Boolean>() /** note: unused */;
|
|
8
|
-
public Optional<CodeNode> lastProcessedNode = Optional.empty();
|
|
9
|
-
public int repeat_index = 0;
|
|
10
|
-
|
|
11
|
-
public void initWriter( RangerAppWriterContext ctx ) {
|
|
12
|
-
if ( langWriter.isPresent() ) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
final RangerAppWriterContext root = ctx.getRoot();
|
|
16
|
-
switch (root.targetLangName ) {
|
|
17
|
-
case "go" :
|
|
18
|
-
langWriter = Optional.of(new RangerGolangClassWriter());
|
|
19
|
-
break;
|
|
20
|
-
case "scala" :
|
|
21
|
-
langWriter = Optional.of(new RangerScalaClassWriter());
|
|
22
|
-
break;
|
|
23
|
-
case "java7" :
|
|
24
|
-
langWriter = Optional.of(new RangerJava7ClassWriter());
|
|
25
|
-
break;
|
|
26
|
-
case "swift3" :
|
|
27
|
-
langWriter = Optional.of(new RangerSwift3ClassWriter());
|
|
28
|
-
break;
|
|
29
|
-
case "kotlin" :
|
|
30
|
-
langWriter = Optional.of(new RangerKotlinClassWriter());
|
|
31
|
-
break;
|
|
32
|
-
case "php" :
|
|
33
|
-
langWriter = Optional.of(new RangerPHPClassWriter());
|
|
34
|
-
break;
|
|
35
|
-
case "cpp" :
|
|
36
|
-
langWriter = Optional.of(new RangerCppClassWriter());
|
|
37
|
-
break;
|
|
38
|
-
case "csharp" :
|
|
39
|
-
langWriter = Optional.of(new RangerCSharpClassWriter());
|
|
40
|
-
break;
|
|
41
|
-
case "es6" :
|
|
42
|
-
langWriter = Optional.of(new RangerJavaScriptClassWriter());
|
|
43
|
-
break;
|
|
44
|
-
case "ranger" :
|
|
45
|
-
langWriter = Optional.of(new RangerRangerClassWriter());
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
if ( langWriter.isPresent() ) {
|
|
49
|
-
langWriter.get().compiler = Optional.of(this);
|
|
50
|
-
} else {
|
|
51
|
-
langWriter = Optional.of(new RangerGenericClassWriter());
|
|
52
|
-
langWriter.get().compiler = Optional.of(this);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public String EncodeString( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
57
|
-
/** unused: final String encoded_str = "" **/ ;
|
|
58
|
-
final int str_length = node.string_value.length();
|
|
59
|
-
String encoded_str_2 = "";
|
|
60
|
-
int ii = 0;
|
|
61
|
-
while (ii < str_length) {
|
|
62
|
-
final int ch = (int)node.string_value.charAt(ii);
|
|
63
|
-
final int cc = ch;
|
|
64
|
-
switch (cc ) {
|
|
65
|
-
case 8 :
|
|
66
|
-
encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(98))));
|
|
67
|
-
break;
|
|
68
|
-
case 9 :
|
|
69
|
-
encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(116))));
|
|
70
|
-
break;
|
|
71
|
-
case 10 :
|
|
72
|
-
encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(110))));
|
|
73
|
-
break;
|
|
74
|
-
case 12 :
|
|
75
|
-
encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(102))));
|
|
76
|
-
break;
|
|
77
|
-
case 13 :
|
|
78
|
-
encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(114))));
|
|
79
|
-
break;
|
|
80
|
-
case 34 :
|
|
81
|
-
encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(34))));
|
|
82
|
-
break;
|
|
83
|
-
case 92 :
|
|
84
|
-
encoded_str_2 = (encoded_str_2 + ((new String( Character.toChars(92))))) + ((new String( Character.toChars(92))));
|
|
85
|
-
break;
|
|
86
|
-
default:
|
|
87
|
-
encoded_str_2 = encoded_str_2 + ((new String( Character.toChars(ch))));
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
ii = ii + 1;
|
|
91
|
-
}
|
|
92
|
-
return encoded_str_2;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public void WriteScalarValue( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
96
|
-
langWriter.get().WriteScalarValue(node, ctx, wr);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
public String adjustType( String tn ) {
|
|
100
|
-
if ( tn.equals("this") ) {
|
|
101
|
-
return "self";
|
|
102
|
-
}
|
|
103
|
-
return tn;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public void WriteVRef( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
107
|
-
langWriter.get().WriteVRef(node, ctx, wr);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
public void writeTypeDef( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
111
|
-
langWriter.get().writeTypeDef(node, ctx, wr);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public void CreateLambdaCall( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
115
|
-
langWriter.get().CreateLambdaCall(node, ctx, wr);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public void CreateLambda( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
119
|
-
langWriter.get().CreateLambda(node, ctx, wr);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public String getTypeString( String str , RangerAppWriterContext ctx ) {
|
|
123
|
-
return "";
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
public void findOpCode( CodeNode op , CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
127
|
-
final CodeNode fnName = op.children.get(1);
|
|
128
|
-
final CodeNode args = op.children.get(2);
|
|
129
|
-
if ( (op.children.size()) > 3 ) {
|
|
130
|
-
final CodeNode details = op.children.get(3);
|
|
131
|
-
for ( int i = 0; i < details.children.size(); i++) {
|
|
132
|
-
CodeNode det = details.children.get(i);
|
|
133
|
-
if ( (det.children.size()) > 0 ) {
|
|
134
|
-
final CodeNode fc = det.children.get(0);
|
|
135
|
-
if ( fc.vref.equals("code") ) {
|
|
136
|
-
final RangerArgMatch match = new RangerArgMatch();
|
|
137
|
-
final boolean all_matched = match.matchArguments(args, node, ctx, 1);
|
|
138
|
-
if ( all_matched == false ) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
final CodeNode origCode = det.children.get(1);
|
|
142
|
-
final CodeNode theCode = origCode.rebuildWithType(match, true);
|
|
143
|
-
final RangerAppWriterContext appCtx = ctx.getRoot();
|
|
144
|
-
final String stdFnName = appCtx.createSignature(fnName.vref, (fnName.vref + theCode.getCode()));
|
|
145
|
-
final RangerAppClassDesc stdClass = ctx.findClass("RangerStaticMethods");
|
|
146
|
-
final RangerAppWriterContext runCtx = appCtx.fork();
|
|
147
|
-
boolean b_failed = false;
|
|
148
|
-
if ( false == (stdClass.defined_static_methods.containsKey(stdFnName)) ) {
|
|
149
|
-
runCtx.setInMethod();
|
|
150
|
-
final RangerAppFunctionDesc m = new RangerAppFunctionDesc();
|
|
151
|
-
m.name = stdFnName;
|
|
152
|
-
m.node = Optional.of(op);
|
|
153
|
-
m.is_static = true;
|
|
154
|
-
m.nameNode = Optional.of(fnName);
|
|
155
|
-
m.fnBody = Optional.of(theCode);
|
|
156
|
-
for ( int ii = 0; ii < args.children.size(); ii++) {
|
|
157
|
-
CodeNode arg = args.children.get(ii);
|
|
158
|
-
final RangerAppParamDesc p = new RangerAppParamDesc();
|
|
159
|
-
p.name = arg.vref;
|
|
160
|
-
p.value_type = arg.value_type;
|
|
161
|
-
p.node = Optional.of(arg);
|
|
162
|
-
p.nameNode = Optional.of(arg);
|
|
163
|
-
p.refType = 1;
|
|
164
|
-
p.varType = 4;
|
|
165
|
-
m.params.add(p);
|
|
166
|
-
arg.hasParamDesc = true;
|
|
167
|
-
arg.paramDesc = Optional.of(p);
|
|
168
|
-
arg.eval_type = arg.value_type;
|
|
169
|
-
arg.eval_type_name = arg.type_name;
|
|
170
|
-
runCtx.defineVariable(p.name, p);
|
|
171
|
-
}
|
|
172
|
-
stdClass.addStaticMethod(m);
|
|
173
|
-
final int err_cnt = ctx.compilerErrors.size();
|
|
174
|
-
final RangerFlowParser flowParser = new RangerFlowParser();
|
|
175
|
-
final CodeWriter TmpWr = new CodeWriter();
|
|
176
|
-
flowParser.WalkNode(theCode, runCtx, TmpWr);
|
|
177
|
-
runCtx.unsetInMethod();
|
|
178
|
-
final int err_delta = (ctx.compilerErrors.size()) - err_cnt;
|
|
179
|
-
if ( err_delta > 0 ) {
|
|
180
|
-
b_failed = true;
|
|
181
|
-
System.out.println(String.valueOf( "Had following compiler errors:" ) );
|
|
182
|
-
for ( int i_1 = 0; i_1 < ctx.compilerErrors.size(); i_1++) {
|
|
183
|
-
RangerCompilerMessage e = ctx.compilerErrors.get(i_1);
|
|
184
|
-
if ( i_1 < err_cnt ) {
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
final int line_index = e.node.get().getLine();
|
|
188
|
-
System.out.println(String.valueOf( (e.node.get().getFilename() + " Line: ") + line_index ) );
|
|
189
|
-
System.out.println(String.valueOf( e.description ) );
|
|
190
|
-
System.out.println(String.valueOf( e.node.get().getLineString(line_index) ) );
|
|
191
|
-
}
|
|
192
|
-
} else {
|
|
193
|
-
System.out.println(String.valueOf( "no errors found" ) );
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if ( b_failed ) {
|
|
197
|
-
wr.out("/* custom operator compilation failed */ ", false);
|
|
198
|
-
} else {
|
|
199
|
-
wr.out(("RangerStaticMethods." + stdFnName) + "(", false);
|
|
200
|
-
for ( int i_2 = 0; i_2 < node.children.size(); i_2++) {
|
|
201
|
-
CodeNode cc = node.children.get(i_2);
|
|
202
|
-
if ( i_2 == 0 ) {
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
if ( i_2 > 1 ) {
|
|
206
|
-
wr.out(", ", false);
|
|
207
|
-
}
|
|
208
|
-
this.WalkNode(cc, ctx, wr);
|
|
209
|
-
}
|
|
210
|
-
wr.out(")", false);
|
|
211
|
-
}
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
public Optional<CodeNode> findOpTemplate( CodeNode op , CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
220
|
-
/** unused: final CodeNode fnName = op.children.get(1) **/ ;
|
|
221
|
-
/** unused: final RangerAppWriterContext root = ctx.getRoot() **/ ;
|
|
222
|
-
final String langName = ctx.getTargetLang();
|
|
223
|
-
if ( (op.children.size()) > 3 ) {
|
|
224
|
-
final CodeNode details = op.children.get(3);
|
|
225
|
-
for ( int i = 0; i < details.children.size(); i++) {
|
|
226
|
-
CodeNode det = details.children.get(i);
|
|
227
|
-
if ( (det.children.size()) > 0 ) {
|
|
228
|
-
final CodeNode fc = det.children.get(0);
|
|
229
|
-
if ( fc.vref.equals("templates") ) {
|
|
230
|
-
final CodeNode tplList = det.children.get(1);
|
|
231
|
-
for ( int i_1 = 0; i_1 < tplList.children.size(); i_1++) {
|
|
232
|
-
CodeNode tpl = tplList.children.get(i_1);
|
|
233
|
-
final CodeNode tplName = tpl.getFirst();
|
|
234
|
-
Optional<CodeNode> tplImpl = Optional.empty();
|
|
235
|
-
tplImpl = Optional.of(tpl.getSecond());
|
|
236
|
-
if ( (!tplName.vref.equals("*")) && (!tplName.vref.equals(langName)) ) {
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
if ( tplName.hasFlag("mutable") ) {
|
|
240
|
-
if ( false == node.hasFlag("mutable") ) {
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return Optional.ofNullable((tplImpl.isPresent() ? (CodeNode)tplImpl.get() : null ) );
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
final Optional<CodeNode> non = Optional.empty();
|
|
251
|
-
return Optional.ofNullable((non.isPresent() ? (CodeNode)non.get() : null ) );
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
public boolean localCall( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
255
|
-
if ( node.hasFnCall ) {
|
|
256
|
-
if ( langWriter.isPresent() ) {
|
|
257
|
-
langWriter.get().writeFnCall(node, ctx, wr);
|
|
258
|
-
return true;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
if ( node.hasNewOper ) {
|
|
262
|
-
langWriter.get().writeNewCall(node, ctx, wr);
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
if ( node.hasVarDef ) {
|
|
266
|
-
if ( node.disabled_node ) {
|
|
267
|
-
langWriter.get().disabledVarDef(node, ctx, wr);
|
|
268
|
-
} else {
|
|
269
|
-
langWriter.get().writeVarDef(node, ctx, wr);
|
|
270
|
-
}
|
|
271
|
-
return true;
|
|
272
|
-
}
|
|
273
|
-
if ( node.hasClassDescription ) {
|
|
274
|
-
langWriter.get().writeClass(node, ctx, wr);
|
|
275
|
-
return true;
|
|
276
|
-
}
|
|
277
|
-
return false;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
public void WalkNode( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
281
|
-
this.initWriter(ctx);
|
|
282
|
-
if ( node.isPrimitive() ) {
|
|
283
|
-
this.WriteScalarValue(node, ctx, wr);
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
this.lastProcessedNode = Optional.of(node);
|
|
287
|
-
if ( node.value_type == 9 ) {
|
|
288
|
-
this.WriteVRef(node, ctx, wr);
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
if ( node.value_type == 16 ) {
|
|
292
|
-
this.WriteVRef(node, ctx, wr);
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
if ( (node.children.size()) > 0 ) {
|
|
296
|
-
if ( node.has_operator ) {
|
|
297
|
-
final CodeNode op = ctx.findOperator(node);
|
|
298
|
-
/** unused: final CodeNode fc = op.getFirst() **/ ;
|
|
299
|
-
final Optional<CodeNode> tplImpl = this.findOpTemplate(op, node, ctx, wr);
|
|
300
|
-
RangerAppWriterContext evalCtx = ctx;
|
|
301
|
-
if ( node.evalCtx.isPresent() ) {
|
|
302
|
-
evalCtx = node.evalCtx.get();
|
|
303
|
-
}
|
|
304
|
-
if ( tplImpl.isPresent() ) {
|
|
305
|
-
final CodeNode opName = op.getSecond();
|
|
306
|
-
if ( opName.hasFlag("returns") ) {
|
|
307
|
-
langWriter.get().release_local_vars(node, evalCtx, wr);
|
|
308
|
-
}
|
|
309
|
-
this.walkCommandList(tplImpl.get(), node, evalCtx, wr);
|
|
310
|
-
} else {
|
|
311
|
-
this.findOpCode(op, node, evalCtx, wr);
|
|
312
|
-
}
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
if ( node.has_lambda ) {
|
|
316
|
-
this.CreateLambda(node, ctx, wr);
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
if ( node.has_lambda_call ) {
|
|
320
|
-
this.CreateLambdaCall(node, ctx, wr);
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
if ( (node.children.size()) > 1 ) {
|
|
324
|
-
if ( this.localCall(node, ctx, wr) ) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
/** unused: final CodeNode fc_1 = node.getFirst() **/ ;
|
|
329
|
-
}
|
|
330
|
-
if ( node.expression ) {
|
|
331
|
-
for ( int i = 0; i < node.children.size(); i++) {
|
|
332
|
-
CodeNode item = node.children.get(i);
|
|
333
|
-
if ( (node.didReturnAtIndex >= 0) && (node.didReturnAtIndex < i) ) {
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
this.WalkNode(item, ctx, wr);
|
|
337
|
-
}
|
|
338
|
-
} else {
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
public void walkCommandList( CodeNode cmd , CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
343
|
-
if ( ctx.expressionLevel() == 0 ) {
|
|
344
|
-
wr.newline();
|
|
345
|
-
}
|
|
346
|
-
if ( ctx.expressionLevel() > 1 ) {
|
|
347
|
-
wr.out("(", false);
|
|
348
|
-
}
|
|
349
|
-
for ( int i = 0; i < cmd.children.size(); i++) {
|
|
350
|
-
CodeNode c = cmd.children.get(i);
|
|
351
|
-
this.walkCommand(c, node, ctx, wr);
|
|
352
|
-
}
|
|
353
|
-
if ( ctx.expressionLevel() > 1 ) {
|
|
354
|
-
wr.out(")", false);
|
|
355
|
-
}
|
|
356
|
-
if ( ctx.expressionLevel() == 0 ) {
|
|
357
|
-
wr.newline();
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
public void walkCommand( CodeNode cmd , CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
362
|
-
if ( cmd.expression ) {
|
|
363
|
-
if ( (cmd.children.size()) < 2 ) {
|
|
364
|
-
ctx.addError(node, "Invalid command");
|
|
365
|
-
ctx.addError(cmd, "Invalid command");
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
final CodeNode cmdE = cmd.getFirst();
|
|
369
|
-
final CodeNode cmdArg = cmd.getSecond();
|
|
370
|
-
switch (cmdE.vref ) {
|
|
371
|
-
case "str" :
|
|
372
|
-
final int idx = cmdArg.int_value;
|
|
373
|
-
if ( (node.children.size()) > idx ) {
|
|
374
|
-
final CodeNode arg = node.children.get(idx);
|
|
375
|
-
wr.out(arg.string_value, false);
|
|
376
|
-
}
|
|
377
|
-
break;
|
|
378
|
-
case "block" :
|
|
379
|
-
final int idx_1 = cmdArg.int_value;
|
|
380
|
-
if ( (node.children.size()) > idx_1 ) {
|
|
381
|
-
final CodeNode arg_1 = node.children.get(idx_1);
|
|
382
|
-
this.WalkNode(arg_1, ctx, wr);
|
|
383
|
-
}
|
|
384
|
-
break;
|
|
385
|
-
case "varname" :
|
|
386
|
-
if ( ctx.isVarDefined(cmdArg.vref) ) {
|
|
387
|
-
final RangerAppParamDesc p = ctx.getVariableDef(cmdArg.vref);
|
|
388
|
-
wr.out(p.compiledName, false);
|
|
389
|
-
}
|
|
390
|
-
break;
|
|
391
|
-
case "defvar" :
|
|
392
|
-
final RangerAppParamDesc p_1 = new RangerAppParamDesc();
|
|
393
|
-
p_1.name = cmdArg.vref;
|
|
394
|
-
p_1.value_type = cmdArg.value_type;
|
|
395
|
-
p_1.node = Optional.of(cmdArg);
|
|
396
|
-
p_1.nameNode = Optional.of(cmdArg);
|
|
397
|
-
p_1.is_optional = false;
|
|
398
|
-
ctx.defineVariable(p_1.name, p_1);
|
|
399
|
-
break;
|
|
400
|
-
case "cc" :
|
|
401
|
-
final int idx_2 = cmdArg.int_value;
|
|
402
|
-
if ( (node.children.size()) > idx_2 ) {
|
|
403
|
-
final CodeNode arg_2 = node.children.get(idx_2);
|
|
404
|
-
final byte cc = ((arg_2.string_value.getBytes())[0]);
|
|
405
|
-
wr.out("" + (cc), false);
|
|
406
|
-
}
|
|
407
|
-
break;
|
|
408
|
-
case "java_case" :
|
|
409
|
-
final int idx_3 = cmdArg.int_value;
|
|
410
|
-
if ( (node.children.size()) > idx_3 ) {
|
|
411
|
-
final CodeNode arg_3 = node.children.get(idx_3);
|
|
412
|
-
this.WalkNode(arg_3, ctx, wr);
|
|
413
|
-
if ( arg_3.didReturnAtIndex < 0 ) {
|
|
414
|
-
wr.newline();
|
|
415
|
-
wr.out("break;", true);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
break;
|
|
419
|
-
case "e" :
|
|
420
|
-
final int idx_4 = cmdArg.int_value;
|
|
421
|
-
if ( (node.children.size()) > idx_4 ) {
|
|
422
|
-
final CodeNode arg_4 = node.children.get(idx_4);
|
|
423
|
-
ctx.setInExpr();
|
|
424
|
-
this.WalkNode(arg_4, ctx, wr);
|
|
425
|
-
ctx.unsetInExpr();
|
|
426
|
-
}
|
|
427
|
-
break;
|
|
428
|
-
case "goset" :
|
|
429
|
-
final int idx_5 = cmdArg.int_value;
|
|
430
|
-
if ( (node.children.size()) > idx_5 ) {
|
|
431
|
-
final CodeNode arg_5 = node.children.get(idx_5);
|
|
432
|
-
ctx.setInExpr();
|
|
433
|
-
langWriter.get().WriteSetterVRef(arg_5, ctx, wr);
|
|
434
|
-
ctx.unsetInExpr();
|
|
435
|
-
}
|
|
436
|
-
break;
|
|
437
|
-
case "pe" :
|
|
438
|
-
final int idx_6 = cmdArg.int_value;
|
|
439
|
-
if ( (node.children.size()) > idx_6 ) {
|
|
440
|
-
final CodeNode arg_6 = node.children.get(idx_6);
|
|
441
|
-
this.WalkNode(arg_6, ctx, wr);
|
|
442
|
-
}
|
|
443
|
-
break;
|
|
444
|
-
case "ptr" :
|
|
445
|
-
final int idx_7 = cmdArg.int_value;
|
|
446
|
-
if ( (node.children.size()) > idx_7 ) {
|
|
447
|
-
final CodeNode arg_7 = node.children.get(idx_7);
|
|
448
|
-
if ( arg_7.hasParamDesc ) {
|
|
449
|
-
if ( arg_7.paramDesc.get().nameNode.get().isAPrimitiveType() == false ) {
|
|
450
|
-
wr.out("*", false);
|
|
451
|
-
}
|
|
452
|
-
} else {
|
|
453
|
-
if ( arg_7.isAPrimitiveType() == false ) {
|
|
454
|
-
wr.out("*", false);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
break;
|
|
459
|
-
case "ptrsrc" :
|
|
460
|
-
final int idx_8 = cmdArg.int_value;
|
|
461
|
-
if ( (node.children.size()) > idx_8 ) {
|
|
462
|
-
final CodeNode arg_8 = node.children.get(idx_8);
|
|
463
|
-
if ( (arg_8.isPrimitiveType() == false) && (arg_8.isPrimitive() == false) ) {
|
|
464
|
-
wr.out("&", false);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
break;
|
|
468
|
-
case "nameof" :
|
|
469
|
-
final int idx_9 = cmdArg.int_value;
|
|
470
|
-
if ( (node.children.size()) > idx_9 ) {
|
|
471
|
-
final CodeNode arg_9 = node.children.get(idx_9);
|
|
472
|
-
wr.out(arg_9.vref, false);
|
|
473
|
-
}
|
|
474
|
-
break;
|
|
475
|
-
case "list" :
|
|
476
|
-
final int idx_10 = cmdArg.int_value;
|
|
477
|
-
if ( (node.children.size()) > idx_10 ) {
|
|
478
|
-
final CodeNode arg_10 = node.children.get(idx_10);
|
|
479
|
-
for ( int i = 0; i < arg_10.children.size(); i++) {
|
|
480
|
-
CodeNode ch = arg_10.children.get(i);
|
|
481
|
-
if ( i > 0 ) {
|
|
482
|
-
wr.out(" ", false);
|
|
483
|
-
}
|
|
484
|
-
ctx.setInExpr();
|
|
485
|
-
this.WalkNode(ch, ctx, wr);
|
|
486
|
-
ctx.unsetInExpr();
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
break;
|
|
490
|
-
case "repeat_from" :
|
|
491
|
-
final int idx_11 = cmdArg.int_value;
|
|
492
|
-
repeat_index = idx_11;
|
|
493
|
-
if ( (node.children.size()) >= idx_11 ) {
|
|
494
|
-
final CodeNode cmdToRepeat = cmd.getThird();
|
|
495
|
-
int i_1 = idx_11;
|
|
496
|
-
while (i_1 < (node.children.size())) {
|
|
497
|
-
if ( i_1 >= idx_11 ) {
|
|
498
|
-
for ( int ii = 0; ii < cmdToRepeat.children.size(); ii++) {
|
|
499
|
-
CodeNode cc_1 = cmdToRepeat.children.get(ii);
|
|
500
|
-
if ( (cc_1.children.size()) > 0 ) {
|
|
501
|
-
final CodeNode fc = cc_1.getFirst();
|
|
502
|
-
if ( fc.vref.equals("e") ) {
|
|
503
|
-
final CodeNode dc = cc_1.getSecond();
|
|
504
|
-
dc.int_value = i_1;
|
|
505
|
-
}
|
|
506
|
-
if ( fc.vref.equals("block") ) {
|
|
507
|
-
final CodeNode dc_1 = cc_1.getSecond();
|
|
508
|
-
dc_1.int_value = i_1;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
this.walkCommandList(cmdToRepeat, node, ctx, wr);
|
|
513
|
-
if ( (i_1 + 1) < (node.children.size()) ) {
|
|
514
|
-
wr.out(",", false);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
i_1 = i_1 + 1;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
break;
|
|
521
|
-
case "comma" :
|
|
522
|
-
final int idx_12 = cmdArg.int_value;
|
|
523
|
-
if ( (node.children.size()) > idx_12 ) {
|
|
524
|
-
final CodeNode arg_11 = node.children.get(idx_12);
|
|
525
|
-
for ( int i_2 = 0; i_2 < arg_11.children.size(); i_2++) {
|
|
526
|
-
CodeNode ch_1 = arg_11.children.get(i_2);
|
|
527
|
-
if ( i_2 > 0 ) {
|
|
528
|
-
wr.out(",", false);
|
|
529
|
-
}
|
|
530
|
-
ctx.setInExpr();
|
|
531
|
-
this.WalkNode(ch_1, ctx, wr);
|
|
532
|
-
ctx.unsetInExpr();
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
break;
|
|
536
|
-
case "swift_rc" :
|
|
537
|
-
final int idx_13 = cmdArg.int_value;
|
|
538
|
-
if ( (node.children.size()) > idx_13 ) {
|
|
539
|
-
final CodeNode arg_12 = node.children.get(idx_13);
|
|
540
|
-
if ( arg_12.hasParamDesc ) {
|
|
541
|
-
if ( arg_12.paramDesc.get().ref_cnt == 0 ) {
|
|
542
|
-
wr.out("_", false);
|
|
543
|
-
} else {
|
|
544
|
-
final RangerAppParamDesc p_2 = ctx.getVariableDef(arg_12.vref);
|
|
545
|
-
wr.out(p_2.compiledName, false);
|
|
546
|
-
}
|
|
547
|
-
} else {
|
|
548
|
-
wr.out(arg_12.vref, false);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
break;
|
|
552
|
-
case "r_ktype" :
|
|
553
|
-
final int idx_14 = cmdArg.int_value;
|
|
554
|
-
if ( (node.children.size()) > idx_14 ) {
|
|
555
|
-
final CodeNode arg_13 = node.children.get(idx_14);
|
|
556
|
-
if ( arg_13.hasParamDesc ) {
|
|
557
|
-
final String ss = langWriter.get().getObjectTypeString(arg_13.paramDesc.get().nameNode.get().key_type, ctx);
|
|
558
|
-
wr.out(ss, false);
|
|
559
|
-
} else {
|
|
560
|
-
final String ss_1 = langWriter.get().getObjectTypeString(arg_13.key_type, ctx);
|
|
561
|
-
wr.out(ss_1, false);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
break;
|
|
565
|
-
case "r_atype" :
|
|
566
|
-
final int idx_15 = cmdArg.int_value;
|
|
567
|
-
if ( (node.children.size()) > idx_15 ) {
|
|
568
|
-
final CodeNode arg_14 = node.children.get(idx_15);
|
|
569
|
-
if ( arg_14.hasParamDesc ) {
|
|
570
|
-
final String ss_2 = langWriter.get().getObjectTypeString(arg_14.paramDesc.get().nameNode.get().array_type, ctx);
|
|
571
|
-
wr.out(ss_2, false);
|
|
572
|
-
} else {
|
|
573
|
-
final String ss_3 = langWriter.get().getObjectTypeString(arg_14.array_type, ctx);
|
|
574
|
-
wr.out(ss_3, false);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
break;
|
|
578
|
-
case "custom" :
|
|
579
|
-
langWriter.get().CustomOperator(node, ctx, wr);
|
|
580
|
-
break;
|
|
581
|
-
case "arraytype" :
|
|
582
|
-
final int idx_16 = cmdArg.int_value;
|
|
583
|
-
if ( (node.children.size()) > idx_16 ) {
|
|
584
|
-
final CodeNode arg_15 = node.children.get(idx_16);
|
|
585
|
-
if ( arg_15.hasParamDesc ) {
|
|
586
|
-
langWriter.get().writeArrayTypeDef(arg_15.paramDesc.get().nameNode.get(), ctx, wr);
|
|
587
|
-
} else {
|
|
588
|
-
langWriter.get().writeArrayTypeDef(arg_15, ctx, wr);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
break;
|
|
592
|
-
case "rawtype" :
|
|
593
|
-
final int idx_17 = cmdArg.int_value;
|
|
594
|
-
if ( (node.children.size()) > idx_17 ) {
|
|
595
|
-
final CodeNode arg_16 = node.children.get(idx_17);
|
|
596
|
-
if ( arg_16.hasParamDesc ) {
|
|
597
|
-
langWriter.get().writeRawTypeDef(arg_16.paramDesc.get().nameNode.get(), ctx, wr);
|
|
598
|
-
} else {
|
|
599
|
-
langWriter.get().writeRawTypeDef(arg_16, ctx, wr);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
break;
|
|
603
|
-
case "macro" :
|
|
604
|
-
final CodeWriter p_write = wr.getTag("utilities");
|
|
605
|
-
final CodeWriter newWriter = new CodeWriter();
|
|
606
|
-
final RangerAppWriterContext testCtx = ctx.fork();
|
|
607
|
-
testCtx.restartExpressionLevel();
|
|
608
|
-
this.walkCommandList(cmdArg, node, testCtx, newWriter);
|
|
609
|
-
final String p_str = newWriter.getCode();
|
|
610
|
-
/** unused: final RangerAppWriterContext root = ctx.getRoot() **/ ;
|
|
611
|
-
if ( (p_write.compiledTags.containsKey(p_str)) == false ) {
|
|
612
|
-
p_write.compiledTags.put(p_str, true);
|
|
613
|
-
final RangerAppWriterContext mCtx = ctx.fork();
|
|
614
|
-
mCtx.restartExpressionLevel();
|
|
615
|
-
this.walkCommandList(cmdArg, node, mCtx, p_write);
|
|
616
|
-
}
|
|
617
|
-
break;
|
|
618
|
-
case "create_polyfill" :
|
|
619
|
-
final CodeWriter p_write_1 = wr.getTag("utilities");
|
|
620
|
-
final String p_str_1 = cmdArg.string_value;
|
|
621
|
-
if ( (p_write_1.compiledTags.containsKey(p_str_1)) == false ) {
|
|
622
|
-
p_write_1.raw(p_str_1, true);
|
|
623
|
-
p_write_1.compiledTags.put(p_str_1, true);
|
|
624
|
-
}
|
|
625
|
-
break;
|
|
626
|
-
case "typeof" :
|
|
627
|
-
final int idx_18 = cmdArg.int_value;
|
|
628
|
-
if ( (node.children.size()) >= idx_18 ) {
|
|
629
|
-
final CodeNode arg_17 = node.children.get(idx_18);
|
|
630
|
-
if ( arg_17.hasParamDesc ) {
|
|
631
|
-
this.writeTypeDef(arg_17.paramDesc.get().nameNode.get(), ctx, wr);
|
|
632
|
-
} else {
|
|
633
|
-
this.writeTypeDef(arg_17, ctx, wr);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
break;
|
|
637
|
-
case "imp" :
|
|
638
|
-
langWriter.get().import_lib(cmdArg.string_value, ctx, wr);
|
|
639
|
-
break;
|
|
640
|
-
case "atype" :
|
|
641
|
-
final int idx_19 = cmdArg.int_value;
|
|
642
|
-
if ( (node.children.size()) >= idx_19 ) {
|
|
643
|
-
final CodeNode arg_18 = node.children.get(idx_19);
|
|
644
|
-
final Optional<RangerAppParamDesc> p_3 = this.findParamDesc(arg_18, ctx, wr);
|
|
645
|
-
final CodeNode nameNode = p_3.get().nameNode.get();
|
|
646
|
-
final String tn = nameNode.array_type;
|
|
647
|
-
wr.out(this.getTypeString(tn, ctx), false);
|
|
648
|
-
}
|
|
649
|
-
break;
|
|
650
|
-
}
|
|
651
|
-
} else {
|
|
652
|
-
if ( cmd.value_type == 9 ) {
|
|
653
|
-
switch (cmd.vref ) {
|
|
654
|
-
case "nl" :
|
|
655
|
-
wr.newline();
|
|
656
|
-
break;
|
|
657
|
-
case "space" :
|
|
658
|
-
wr.out(" ", false);
|
|
659
|
-
break;
|
|
660
|
-
case "I" :
|
|
661
|
-
wr.indent(1);
|
|
662
|
-
break;
|
|
663
|
-
case "i" :
|
|
664
|
-
wr.indent(-1);
|
|
665
|
-
break;
|
|
666
|
-
case "op" :
|
|
667
|
-
final CodeNode fc_1 = node.getFirst();
|
|
668
|
-
wr.out(fc_1.vref, false);
|
|
669
|
-
break;
|
|
670
|
-
}
|
|
671
|
-
} else {
|
|
672
|
-
if ( cmd.value_type == 4 ) {
|
|
673
|
-
wr.out(cmd.string_value, false);
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
public void compile( CodeNode node , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
public Optional<RangerAppParamDesc> findParamDesc( CodeNode obj , RangerAppWriterContext ctx , CodeWriter wr ) {
|
|
683
|
-
Optional<RangerAppParamDesc> varDesc = Optional.empty();
|
|
684
|
-
boolean set_nsp = false;
|
|
685
|
-
Optional<RangerAppClassDesc> classDesc = Optional.empty();
|
|
686
|
-
if ( 0 == (obj.nsp.size()) ) {
|
|
687
|
-
set_nsp = true;
|
|
688
|
-
}
|
|
689
|
-
if ( !obj.vref.equals("this") ) {
|
|
690
|
-
if ( (obj.ns.size()) > 1 ) {
|
|
691
|
-
final int cnt = obj.ns.size();
|
|
692
|
-
Optional<RangerAppParamDesc> classRefDesc = Optional.empty();
|
|
693
|
-
for ( int i = 0; i < obj.ns.size(); i++) {
|
|
694
|
-
String strname = obj.ns.get(i);
|
|
695
|
-
if ( i == 0 ) {
|
|
696
|
-
if ( strname.equals("this") ) {
|
|
697
|
-
classDesc = ctx.getCurrentClass();
|
|
698
|
-
if ( set_nsp ) {
|
|
699
|
-
obj.nsp.add(classDesc.get());
|
|
700
|
-
}
|
|
701
|
-
} else {
|
|
702
|
-
if ( ctx.isDefinedClass(strname) ) {
|
|
703
|
-
classDesc = Optional.of(ctx.findClass(strname));
|
|
704
|
-
if ( set_nsp ) {
|
|
705
|
-
obj.nsp.add(classDesc.get());
|
|
706
|
-
}
|
|
707
|
-
continue;
|
|
708
|
-
}
|
|
709
|
-
classRefDesc = Optional.of(ctx.getVariableDef(strname));
|
|
710
|
-
if ( !classRefDesc.isPresent() ) {
|
|
711
|
-
ctx.addError(obj, "Error, no description for called object: " + strname);
|
|
712
|
-
break;
|
|
713
|
-
}
|
|
714
|
-
if ( set_nsp ) {
|
|
715
|
-
obj.nsp.add(classRefDesc.get());
|
|
716
|
-
}
|
|
717
|
-
classRefDesc.get().ref_cnt = 1 + classRefDesc.get().ref_cnt;
|
|
718
|
-
classDesc = Optional.of(ctx.findClass(classRefDesc.get().nameNode.get().type_name));
|
|
719
|
-
}
|
|
720
|
-
} else {
|
|
721
|
-
if ( i < (cnt - 1) ) {
|
|
722
|
-
varDesc = classDesc.get().findVariable(strname);
|
|
723
|
-
if ( !varDesc.isPresent() ) {
|
|
724
|
-
ctx.addError(obj, "Error, no description for refenced obj: " + strname);
|
|
725
|
-
}
|
|
726
|
-
final String subClass = varDesc.get().getTypeName();
|
|
727
|
-
classDesc = Optional.of(ctx.findClass(subClass));
|
|
728
|
-
if ( set_nsp ) {
|
|
729
|
-
obj.nsp.add(varDesc.get());
|
|
730
|
-
}
|
|
731
|
-
continue;
|
|
732
|
-
}
|
|
733
|
-
if ( classDesc.isPresent() ) {
|
|
734
|
-
varDesc = classDesc.get().findVariable(strname);
|
|
735
|
-
if ( !varDesc.isPresent() ) {
|
|
736
|
-
Optional<RangerAppFunctionDesc> classMethod = classDesc.get().findMethod(strname);
|
|
737
|
-
if ( !classMethod.isPresent() ) {
|
|
738
|
-
classMethod = classDesc.get().findStaticMethod(strname);
|
|
739
|
-
if ( !classMethod.isPresent() ) {
|
|
740
|
-
ctx.addError(obj, "variable not found " + strname);
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
if ( classMethod.isPresent() ) {
|
|
744
|
-
if ( set_nsp ) {
|
|
745
|
-
obj.nsp.add(classMethod.get());
|
|
746
|
-
}
|
|
747
|
-
return Optional.ofNullable((classMethod.isPresent() ? (RangerAppParamDesc)classMethod.get() : null ) );
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
if ( set_nsp ) {
|
|
751
|
-
obj.nsp.add(varDesc.get());
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
return Optional.ofNullable((varDesc.isPresent() ? (RangerAppParamDesc)varDesc.get() : null ) );
|
|
757
|
-
}
|
|
758
|
-
varDesc = Optional.of(ctx.getVariableDef(obj.vref));
|
|
759
|
-
if ( varDesc.get().nameNode.isPresent() ) {
|
|
760
|
-
} else {
|
|
761
|
-
System.out.println(String.valueOf( "findParamDesc : description not found for " + obj.vref ) );
|
|
762
|
-
if ( varDesc.isPresent() ) {
|
|
763
|
-
System.out.println(String.valueOf( "Vardesc was found though..." + varDesc.get().name ) );
|
|
764
|
-
}
|
|
765
|
-
ctx.addError(obj, "Error, no description for called object: " + obj.vref);
|
|
766
|
-
}
|
|
767
|
-
return Optional.ofNullable((varDesc.isPresent() ? (RangerAppParamDesc)varDesc.get() : null ) );
|
|
768
|
-
}
|
|
769
|
-
final Optional<RangerAppClassDesc> cc = ctx.getCurrentClass();
|
|
770
|
-
return Optional.ofNullable((cc.isPresent() ? (RangerAppParamDesc)cc.get() : null ) );
|
|
771
|
-
}
|
|
772
|
-
}
|