ranger-compiler 2.1.70 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +114 -0
- package/README.md +956 -133
- package/{compiler/Lang.clj → dist/Lang.rgr} +2345 -75
- package/dist/README.md +116 -0
- package/dist/{bin/api.d.ts → api.d.ts} +430 -154
- package/dist/api.js +34345 -0
- package/{lib/Ajax.clj → dist/lib/Ajax.rgr} +1 -1
- package/{lib/CmdParams.clj → dist/lib/CmdParams.rgr} +72 -72
- package/{lib/Crypto.clj → dist/lib/Crypto.rgr} +1 -1
- package/{lib/DOMLib.clj → dist/lib/DOMLib.rgr} +2 -2
- package/{lib/Engine3D.clj → dist/lib/Engine3D.rgr} +1 -1
- package/{lib/ImmutableVector.clj → dist/lib/ImmutableVector.rgr} +364 -364
- package/{lib/IndexedDB.clj → dist/lib/IndexedDB.rgr} +1 -1
- package/{lib/JSON.clj → dist/lib/JSON.rgr} +105 -2
- package/{lib/JinxProcess.clj → dist/lib/JinxProcess.rgr} +3 -3
- package/{lib/Storage.clj → dist/lib/Storage.rgr} +1 -1
- package/{lib/Timers.clj → dist/lib/Timers.rgr} +176 -170
- package/{lib/ViewLib.clj → dist/lib/ViewLib.rgr} +1 -1
- package/dist/lib/lib/ACEEditor.rgr +5 -0
- package/dist/lib/lib/Ajax.rgr +196 -0
- package/dist/lib/lib/CmdParams.rgr +72 -0
- package/dist/lib/lib/Crypto.rgr +90 -0
- package/dist/lib/lib/DOMLib.rgr +307 -0
- package/{examples/3D/Engine3D.clj → dist/lib/lib/Engine3D.rgr} +870 -857
- package/dist/lib/lib/ImmutableVector.rgr +364 -0
- package/dist/lib/lib/IndexedDB.rgr +32 -0
- package/{compiler/JSON.clj → dist/lib/lib/JSON.rgr} +106 -3
- package/dist/lib/lib/JinxProcess.rgr +838 -0
- package/dist/lib/lib/SQL.rgr +44 -0
- package/dist/lib/lib/ServiceLib.rgr +9 -0
- package/dist/lib/lib/Storage.rgr +89 -0
- package/dist/lib/lib/Time.rgr +75 -0
- package/dist/lib/lib/Timers.rgr +176 -0
- package/dist/lib/lib/TypedArrays.rgr +14 -0
- package/dist/lib/lib/ViewLib.rgr +851 -0
- package/dist/lib/lib/WebLib.rgr +47 -0
- package/dist/lib/lib/WebServerLib.rgr +137 -0
- package/{lib/ranger-dir.clj → dist/lib/lib/ranger-dir.rgr} +1 -1
- package/{compiler/stdlib.clj → dist/lib/lib/stdlib.rgr} +42 -19
- package/{lib/stdops.clj → dist/lib/lib/stdops.rgr} +1 -1
- package/dist/lib/ranger-dir.rgr +175 -0
- package/{lib/stdlib.clj → dist/lib/stdlib.rgr} +2 -2
- package/dist/lib/stdops.rgr +168 -0
- package/dist/package.json +47 -0
- package/{compiler/bin/output.js → dist/rgrc.js} +15377 -7936
- package/dist/stdops.rgr +168 -0
- package/package.json +196 -39
- package/adventofcode/day1/bin/LambdaSignature1.java +0 -3
- package/adventofcode/day1/bin/LambdaSignature2.java +0 -3
- package/adventofcode/day1/bin/LambdaSignature3.java +0 -3
- package/adventofcode/day1/bin/day1.cpp +0 -124
- package/adventofcode/day1/bin/day1.go +0 -75
- package/adventofcode/day1/bin/day1.js +0 -45
- package/adventofcode/day1/bin/day1.php +0 -46
- package/adventofcode/day1/bin/day1.scala +0 -48
- package/adventofcode/day1/bin/day1.swift +0 -48
- package/adventofcode/day1/bin/day1_part2.cpp +0 -180
- package/adventofcode/day1/bin/day1_part2.go +0 -123
- package/adventofcode/day1/bin/day1_part2.js +0 -76
- package/adventofcode/day1/bin/day1_part2.php +0 -88
- package/adventofcode/day1/bin/day1_part2.scala +0 -81
- package/adventofcode/day1/bin/day1_part2.swift +0 -91
- package/adventofcode/day1/bin/day_one.java +0 -38
- package/adventofcode/day1/bin/day_one_part_two.java +0 -57
- package/adventofcode/day1/bin/operatorsOf.java +0 -37
- package/adventofcode/day1/bin/operatorsOf_5.java +0 -10
- package/adventofcode/day1/bin/operatorsOfboolean_5.java +0 -10
- package/adventofcode/day1/bin/variant.hpp +0 -2416
- package/adventofcode/day1/compile.bat +0 -7
- package/adventofcode/day1/compile2.bat +0 -7
- package/adventofcode/day1/day1.clj +0 -19
- package/adventofcode/day1/day1_part2.clj +0 -43
- package/adventofcode/day1/input1.txt +0 -1
- package/adventofcode/day2/bin/LambdaSignature1.class +0 -0
- package/adventofcode/day2/bin/LambdaSignature1.java +0 -3
- package/adventofcode/day2/bin/LambdaSignature2.class +0 -0
- package/adventofcode/day2/bin/LambdaSignature2.java +0 -3
- package/adventofcode/day2/bin/day2.cpp +0 -133
- package/adventofcode/day2/bin/day2.go +0 -85
- package/adventofcode/day2/bin/day2.js +0 -45
- package/adventofcode/day2/bin/day2.php +0 -59
- package/adventofcode/day2/bin/day2.scala +0 -54
- package/adventofcode/day2/bin/day2.swift +0 -62
- package/adventofcode/day2/bin/day2_part2.cpp +0 -150
- package/adventofcode/day2/bin/day2_part2.go +0 -101
- package/adventofcode/day2/bin/day2_part2.js +0 -54
- package/adventofcode/day2/bin/day2_part2.php +0 -80
- package/adventofcode/day2/bin/day2_part2.scala +0 -68
- package/adventofcode/day2/bin/day2_part2.swift +0 -82
- package/adventofcode/day2/bin/day_two.java +0 -61
- package/adventofcode/day2/bin/day_two_part_two$1$1$1.class +0 -0
- package/adventofcode/day2/bin/day_two_part_two$1$1.class +0 -0
- package/adventofcode/day2/bin/day_two_part_two$1.class +0 -0
- package/adventofcode/day2/bin/day_two_part_two.class +0 -0
- package/adventofcode/day2/bin/day_two_part_two.java +0 -80
- package/adventofcode/day2/bin/operatorsOf.class +0 -0
- package/adventofcode/day2/bin/operatorsOf.java +0 -18
- package/adventofcode/day2/bin/variant.hpp +0 -2416
- package/adventofcode/day2/compile.bat +0 -7
- package/adventofcode/day2/compile2.bat +0 -7
- package/adventofcode/day2/day2.clj +0 -60
- package/adventofcode/day2/day2_part2.clj +0 -69
- package/adventofcode/day2/input1.txt +0 -1
- package/adventofcode/day3/bin/Grid.java +0 -92
- package/adventofcode/day3/bin/GridRow.java +0 -5
- package/adventofcode/day3/bin/LambdaSignature1.java +0 -3
- package/adventofcode/day3/bin/LambdaSignature2.java +0 -3
- package/adventofcode/day3/bin/LambdaSignature3.java +0 -3
- package/adventofcode/day3/bin/day3.cpp +0 -64
- package/adventofcode/day3/bin/day3.go +0 -55
- package/adventofcode/day3/bin/day3.js +0 -42
- package/adventofcode/day3/bin/day3.php +0 -41
- package/adventofcode/day3/bin/day3.scala +0 -52
- package/adventofcode/day3/bin/day3.swift +0 -43
- package/adventofcode/day3/bin/day3_part2.cpp +0 -216
- package/adventofcode/day3/bin/day3_part2.go +0 -188
- package/adventofcode/day3/bin/day3_part2.js +0 -123
- package/adventofcode/day3/bin/day3_part2.php +0 -135
- package/adventofcode/day3/bin/day3_part2.swift +0 -131
- package/adventofcode/day3/bin/day_three_part_two.java +0 -43
- package/adventofcode/day3/bin/day_two.java +0 -42
- package/adventofcode/day3/bin/operatorsOf.java +0 -14
- package/adventofcode/day3/bin/variant.hpp +0 -2416
- package/adventofcode/day3/compile.bat +0 -7
- package/adventofcode/day3/compile2.bat +0 -7
- package/adventofcode/day3/day3.clj +0 -42
- package/adventofcode/day3/day3_part2.clj +0 -112
- package/adventofcode/day4/bin/LambdaSignature1.java +0 -3
- package/adventofcode/day4/bin/day4.cpp +0 -118
- package/adventofcode/day4/bin/day4.go +0 -75
- package/adventofcode/day4/bin/day4.js +0 -40
- package/adventofcode/day4/bin/day4.php +0 -52
- package/adventofcode/day4/bin/day4.scala +0 -47
- package/adventofcode/day4/bin/day4.swift +0 -56
- package/adventofcode/day4/bin/day4_part2.go +0 -129
- package/adventofcode/day4/bin/day4_part2.js +0 -72
- package/adventofcode/day4/bin/day_four.java +0 -41
- package/adventofcode/day4/bin/inputData.java +0 -7
- package/adventofcode/day4/bin/operatorsOf.java +0 -11
- package/adventofcode/day4/bin/variant.hpp +0 -2416
- package/adventofcode/day4/compile.bat +0 -7
- package/adventofcode/day4/compile2.bat +0 -7
- package/adventofcode/day4/day4.clj +0 -32
- package/adventofcode/day4/day4_part2.clj +0 -44
- package/adventofcode/day4/input.clj +0 -519
- package/adventofcode/day4/input.txt +0 -512
- package/bin/api.ts +0 -24471
- package/bin/compiler.ts +0 -24482
- package/bin/output.js +0 -23819
- package/compiler/ColorConsole.clj +0 -22
- package/compiler/ContextOperators.clj +0 -75
- package/compiler/FlowEnterVarDef.clj +0 -223
- package/compiler/InputFileSystem.clj +0 -276
- package/compiler/RangerDocs.clj +0 -7
- package/compiler/TFactory.clj +0 -146
- package/compiler/TFiles.clj +0 -23
- package/compiler/TFlow.clj +0 -39
- package/compiler/TNodeFactory.clj +0 -84
- package/compiler/TTypes.clj +0 -188
- package/compiler/VirtualCompiler.clj +0 -807
- package/compiler/bin/ng_Compiler.js +0 -23779
- package/compiler/commonmark_plugin.clj +0 -359
- package/compiler/feat2.bat +0 -2
- package/compiler/feats.bat +0 -9
- package/compiler/feature_tests.clj +0 -192
- package/compiler/index.js +0 -2
- package/compiler/issue_57.clj +0 -25
- package/compiler/makefile_plugin.clj +0 -135
- package/compiler/markdown_plugin.clj +0 -386
- package/compiler/maven_plugin.clj +0 -162
- package/compiler/ng_AndroidPageWriter.clj +0 -299
- package/compiler/ng_CodeNode.clj +0 -756
- package/compiler/ng_CodeNodeCompilerExtensions.clj +0 -839
- package/compiler/ng_Compiler.clj +0 -49
- package/compiler/ng_CompilerGeneric.clj +0 -260
- package/compiler/ng_CompilerOrig.clj +0 -854
- package/compiler/ng_DictNode.clj +0 -346
- package/compiler/ng_DictNode2.clj +0 -316
- package/compiler/ng_Execute.clj +0 -138
- package/compiler/ng_Execute1.clj +0 -129
- package/compiler/ng_FlowWork.clj +0 -3951
- package/compiler/ng_LiveCompiler.clj +0 -1109
- package/compiler/ng_RagnerJavaScriptClassWriter.clj +0 -402
- package/compiler/ng_RangerActiveOperators.clj +0 -86
- package/compiler/ng_RangerAppClassDesc.clj +0 -400
- package/compiler/ng_RangerAppEnums.clj +0 -86
- package/compiler/ng_RangerAppFunctionDesc.clj +0 -127
- package/compiler/ng_RangerAppMessages.clj +0 -15
- package/compiler/ng_RangerAppOperatorDesc.clj +0 -20
- package/compiler/ng_RangerAppParamDesc.clj +0 -388
- package/compiler/ng_RangerAppWriterContext.clj +0 -1793
- package/compiler/ng_RangerArgMatch.clj +0 -638
- package/compiler/ng_RangerCSharpClassWriter.clj +0 -484
- package/compiler/ng_RangerCppClassWriter.clj +0 -1023
- package/compiler/ng_RangerDocGenerator.clj +0 -305
- package/compiler/ng_RangerFlowParser.clj +0 -4992
- package/compiler/ng_RangerFlowParserOrig.clj +0 -4002
- package/compiler/ng_RangerGenericClassWriter.clj +0 -573
- package/compiler/ng_RangerGolangClassWriter.clj +0 -1766
- package/compiler/ng_RangerImmutableExtension.clj +0 -77
- package/compiler/ng_RangerJava7ClassWriter.clj +0 -961
- package/compiler/ng_RangerJavaScriptClassWriter.clj +0 -1040
- package/compiler/ng_RangerKotlinClassWriter.clj +0 -372
- package/compiler/ng_RangerLanguageWriters.clj +0 -14
- package/compiler/ng_RangerLispParser.clj +0 -873
- package/compiler/ng_RangerPHPClassWriter.clj +0 -643
- package/compiler/ng_RangerPlugin.clj +0 -41
- package/compiler/ng_RangerRangerClassWriter.clj +0 -357
- package/compiler/ng_RangerRustClassWriter.clj +0 -420
- package/compiler/ng_RangerScalaClassWriter.clj +0 -818
- package/compiler/ng_RangerSerializeClass.clj +0 -502
- package/compiler/ng_RangerServiceBuilder.clj +0 -63
- package/compiler/ng_RangerSwift3ClassWriter.clj +0 -809
- package/compiler/ng_RangerSwiftClassWriter.clj +0 -0
- package/compiler/ng_RangerTypeClass.clj +0 -45
- package/compiler/ng_SourceParser.clj +0 -241
- package/compiler/ng_SourceParser2.clj +0 -214
- package/compiler/ng_WebPageWriter.clj +0 -39
- package/compiler/ng_jsonParser.clj +0 -340
- package/compiler/ng_p_test.clj +0 -1711
- package/compiler/ng_parser.clj +0 -911
- package/compiler/ng_parser2.clj +0 -735
- package/compiler/ng_parser2_backup.clj +0 -1679
- package/compiler/ng_parser_backup.clj +0 -886
- package/compiler/ng_parser_ok.clj +0 -1718
- package/compiler/ng_parser_ok2.clj +0 -1717
- package/compiler/ng_parser_std_match.clj +0 -687
- package/compiler/ng_parser_std_match2.clj +0 -1012
- package/compiler/ng_parser_v2.clj +0 -1251
- package/compiler/ng_ui.clj +0 -403
- package/compiler/ng_ui_test.clj +0 -18
- package/compiler/ng_writer.clj +0 -338
- package/compiler/ng_xmlParser.clj +0 -472
- package/compiler/ng_xmlParser2.clj +0 -317
- package/compiler/ng_xmlParser3.clj +0 -251
- package/compiler/opdoc.bat +0 -4
- package/compiler/operators.md +0 -290
- package/compiler/p.bat +0 -4
- package/compiler/package.json +0 -10
- package/compiler/pcmd.bat +0 -4
- package/compiler/pcmd2.bat +0 -3
- package/compiler/plaintext_plugin.clj +0 -69
- package/compiler/plugin.bat +0 -19
- package/compiler/plugin2.bat +0 -4
- package/compiler/plugin_app.bat +0 -3
- package/compiler/plugin_apps.clj +0 -27
- package/compiler/plugins.bat +0 -10
- package/compiler/reveal_plugin.clj +0 -409
- package/compiler/simplePlugin.clj +0 -780
- package/compiler/t.bat +0 -3
- package/compiler/test_any.clj +0 -43
- package/compiler/test_call.clj +0 -141
- package/compiler/test_chain.clj +0 -79
- package/compiler/test_json.clj +0 -10
- package/compiler/test_lambda.clj +0 -153
- package/compiler/test_pcmd.clj +0 -32
- package/compiler/test_pcmd2.clj +0 -29
- package/compiler/test_plugin.clj +0 -237
- package/compiler/test_readfile.clj +0 -13
- package/compiler/test_reveal.clj +0 -19
- package/compiler/test_slides.clj +0 -312
- package/compiler/test_types.clj +0 -143
- package/compiler/test_types2.clj +0 -49
- package/compiler/test_types3.clj +0 -53
- package/compiler/test_var.clj +0 -40
- package/compiler/tonpm.bat +0 -14
- package/compiler/tonpm2.bat +0 -12
- package/compiler/ui_plugin.clj +0 -507
- package/compiler/ui_plugin2.clj +0 -427
- package/compiler/update-git.bat +0 -3
- package/compiler/vcomp.bat +0 -4
- package/compiler/viewbuilder_Android.clj +0 -176
- package/compiler/viewbuilder_Web.clj +0 -105
- package/dist/bin/api.js +0 -32422
- package/dist/bin/compiler.d.ts +0 -1638
- package/dist/bin/compiler.js +0 -32444
- package/examples/3D/bin/test_3d.js +0 -329
- package/examples/3D/test_3d.clj +0 -385
- package/examples/EVGColor/EVGColor.clj +0 -310
- package/examples/EVGColor/EVGColorContext.clj +0 -176
- package/examples/EVGColor/bin/EVGColor.js +0 -286
- package/examples/EVGColor/bin/minimized.js +0 -286
- package/examples/SVGPath/SVGPath.clj +0 -625
- package/examples/SVGPath/Vec2.clj +0 -103
- package/examples/SVGPath/bin/SVGPath.cpp +0 -887
- package/examples/SVGPath/bin/SVGPath.js +0 -682
- package/examples/SVGPath/bin/SVGPath.ts +0 -711
- package/examples/SVGPath/bin/minimized.js +0 -578
- package/examples/SVGPath/bin/variant.hpp +0 -2416
- package/examples/minification/Vec2.clj +0 -103
- package/examples/minification/bin/minified.js +0 -44
- package/examples/minification/bin/test.js +0 -117
- package/examples/minification/test.clj +0 -13
- package/fiddle/VirtualCompiler.js +0 -23495
- package/fiddle/browser_editor.js +0 -13240
- package/fiddle/compileEnv.js +0 -1
- package/fiddle/compileEnv.json +0 -1
- package/fiddle/lang_data.js +0 -1
- package/index.html +0 -18
- package/native/httpd/HttpTester.clj +0 -33
- package/native/httpd/RangerWebService.clj +0 -81
- package/operators.md +0 -290
- package/tsconfig.json +0 -29
- package/versions/cpp/compiler.cpp +0 -15032
- package/versions/es6/compiler.js +0 -12860
- package/versions/go/compiler.go +0 -21338
- package/versions/java/AfterCodeNode.java +0 -4
- package/versions/java/ClassJoinPoint.java +0 -6
- package/versions/java/CodeFile.java +0 -42
- package/versions/java/CodeFileSystem.java +0 -72
- package/versions/java/CodeNode.java +0 -807
- package/versions/java/CodeSlice.java +0 -13
- package/versions/java/CodeWriter.java +0 -185
- package/versions/java/ColorConsole.java +0 -8
- package/versions/java/CompilerInterface.java +0 -213
- package/versions/java/DictNode.java +0 -353
- package/versions/java/LiveCompiler.java +0 -772
- package/versions/java/NodeEvalState.java +0 -24
- package/versions/java/OpFindResult.java +0 -6
- package/versions/java/RangerAppArrayValue.java +0 -7
- package/versions/java/RangerAppClassDesc.java +0 -217
- package/versions/java/RangerAppEnum.java +0 -14
- package/versions/java/RangerAppFunctionDesc.java +0 -20
- package/versions/java/RangerAppHashValue.java +0 -11
- package/versions/java/RangerAppInterfaceImpl.java +0 -6
- package/versions/java/RangerAppMethodVariants.java +0 -6
- package/versions/java/RangerAppParamDesc.java +0 -321
- package/versions/java/RangerAppTodo.java +0 -6
- package/versions/java/RangerAppValue.java +0 -10
- package/versions/java/RangerAppWriterContext.java +0 -800
- package/versions/java/RangerArgMatch.java +0 -317
- package/versions/java/RangerBackReference.java +0 -7
- package/versions/java/RangerCSharpClassWriter.java +0 -287
- package/versions/java/RangerCompilerMessage.java +0 -9
- package/versions/java/RangerCppClassWriter.java +0 -725
- package/versions/java/RangerFlowParser.java +0 -2142
- package/versions/java/RangerGenericClassWriter.java +0 -367
- package/versions/java/RangerGolangClassWriter.java +0 -1379
- package/versions/java/RangerJava7ClassWriter.java +0 -652
- package/versions/java/RangerJavaScriptClassWriter.java +0 -305
- package/versions/java/RangerKotlinClassWriter.java +0 -380
- package/versions/java/RangerLispParser.java +0 -845
- package/versions/java/RangerNodeValue.java +0 -9
- package/versions/java/RangerPHPClassWriter.java +0 -527
- package/versions/java/RangerParamEventHandler.java +0 -6
- package/versions/java/RangerParamEventList.java +0 -5
- package/versions/java/RangerParamEventMap.java +0 -27
- package/versions/java/RangerRangerClassWriter.java +0 -268
- package/versions/java/RangerRefForce.java +0 -7
- package/versions/java/RangerScalaClassWriter.java +0 -365
- package/versions/java/RangerSerializeClass.java +0 -148
- package/versions/java/RangerSwift3ClassWriter.java +0 -548
- package/versions/java/RangerTypeClass.java +0 -17
- package/versions/java/SourceCode.java +0 -65
- package/versions/php/compiler.php +0 -13830
- package/versions/swift3/compiler.swift +0 -12542
- /package/{lib/ACEEditor.clj → dist/lib/ACEEditor.rgr} +0 -0
- /package/{lib/SQL.clj → dist/lib/SQL.rgr} +0 -0
- /package/{lib/ServiceLib.clj → dist/lib/ServiceLib.rgr} +0 -0
- /package/{lib/Time.clj → dist/lib/Time.rgr} +0 -0
- /package/{lib/TypedArrays.clj → dist/lib/TypedArrays.rgr} +0 -0
- /package/{lib/WebLib.clj → dist/lib/WebLib.rgr} +0 -0
- /package/{lib/WebServerLib.clj → dist/lib/WebServerLib.rgr} +0 -0
|
@@ -1,1040 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Import "ng_WebPageWriter.clj"
|
|
3
|
-
|
|
4
|
-
class RangerJavaScriptClassWriter {
|
|
5
|
-
|
|
6
|
-
Extends (RangerGenericClassWriter)
|
|
7
|
-
def compiler:LiveCompiler
|
|
8
|
-
def thisName:string "this"
|
|
9
|
-
def wrote_header:boolean false
|
|
10
|
-
|
|
11
|
-
def target_flow false
|
|
12
|
-
def target_typescript false
|
|
13
|
-
|
|
14
|
-
fn lineEnding:string () {
|
|
15
|
-
return ";"
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
fn adjustType:string (tn:string) {
|
|
19
|
-
if (tn == "this") {
|
|
20
|
-
return "this"
|
|
21
|
-
}
|
|
22
|
-
return tn
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
fn CreateTsUnions (parser:RangerFlowParser ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
26
|
-
def root (ctx.getRoot())
|
|
27
|
-
root.definedClasses.forEach({
|
|
28
|
-
; index == name
|
|
29
|
-
; item == class description
|
|
30
|
-
if(item.is_union) {
|
|
31
|
-
; TODO: implement system class unions too...
|
|
32
|
-
wr.out( ( "type union_" + index + " = " ) false)
|
|
33
|
-
wr.indent(1)
|
|
34
|
-
def cnt 0
|
|
35
|
-
item.is_union_of.forEach({
|
|
36
|
-
if (ctx.isDefinedClass(item)) {
|
|
37
|
-
def cl (ctx.findClass(item))
|
|
38
|
-
if( false == (cl.isNormalClass() ) ) {
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
if( cnt > 0 ) {
|
|
42
|
-
wr.out("|" false)
|
|
43
|
-
}
|
|
44
|
-
wr.out( (this.getObjectTypeString( item ctx ) ) false )
|
|
45
|
-
cnt = cnt + 1
|
|
46
|
-
} {
|
|
47
|
-
if( cnt > 0 ) {
|
|
48
|
-
wr.out("|" false)
|
|
49
|
-
}
|
|
50
|
-
wr.out( (this.getObjectTypeString( item ctx ) ) false )
|
|
51
|
-
cnt = cnt + 1
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
wr.indent(-1)
|
|
55
|
-
wr.out(";" true)
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
fn writeFnCall:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
61
|
-
if node.hasFnCall {
|
|
62
|
-
def fc:CodeNode (node.getFirst())
|
|
63
|
-
|
|
64
|
-
if( (!null? node.fnDesc) && (!null? node.fnDesc.nameNode) ) {
|
|
65
|
-
def fnName:CodeNode node.fnDesc.nameNode
|
|
66
|
-
if( fnName.hasFlag('async') ) {
|
|
67
|
-
wr.out('await ' false)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
this.WriteVRef(fc ctx wr)
|
|
72
|
-
wr.out("(" false)
|
|
73
|
-
def givenArgs:CodeNode (node.getSecond())
|
|
74
|
-
ctx.setInExpr();
|
|
75
|
-
def cnt 0
|
|
76
|
-
for node.fnDesc.params arg:RangerAppParamDesc i {
|
|
77
|
-
if( arg.nameNode.hasFlag('keyword')) {
|
|
78
|
-
continue
|
|
79
|
-
}
|
|
80
|
-
if (cnt > 0) {
|
|
81
|
-
wr.out(', ' false)
|
|
82
|
-
}
|
|
83
|
-
cnt = cnt + 1
|
|
84
|
-
if( (array_length givenArgs.children) <= i) {
|
|
85
|
-
def defVal@(optional):CodeNode (arg.nameNode.getFlag("default"))
|
|
86
|
-
if (!null? defVal) {
|
|
87
|
-
def fc:CodeNode (defVal.vref_annotation.getFirst())
|
|
88
|
-
this.WalkNode(fc ctx wr)
|
|
89
|
-
} {
|
|
90
|
-
ctx.addError(node "Default argument was missing")
|
|
91
|
-
}
|
|
92
|
-
continue
|
|
93
|
-
}
|
|
94
|
-
def n:CodeNode (itemAt givenArgs.children i)
|
|
95
|
-
this.WalkNode(n ctx wr)
|
|
96
|
-
}
|
|
97
|
-
ctx.unsetInExpr()
|
|
98
|
-
wr.out(")" false)
|
|
99
|
-
|
|
100
|
-
if(has node.methodChain) {
|
|
101
|
-
; wr.newline()
|
|
102
|
-
; wr.indent(1)
|
|
103
|
-
for node.methodChain cc:CallChain i {
|
|
104
|
-
wr.out("." + cc.methodName , false)
|
|
105
|
-
wr.out("(" false)
|
|
106
|
-
ctx.setInExpr()
|
|
107
|
-
for cc.args.children arg:CodeNode i {
|
|
108
|
-
if (i > 0) {
|
|
109
|
-
wr.out(", " false)
|
|
110
|
-
}
|
|
111
|
-
this.WalkNode( arg ctx wr)
|
|
112
|
-
}
|
|
113
|
-
ctx.unsetInExpr()
|
|
114
|
-
wr.out(")" false)
|
|
115
|
-
}
|
|
116
|
-
; wr.indent(-1)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if ((ctx.expressionLevel()) == 0) {
|
|
120
|
-
wr.out(";" true)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
fn CreateCallExpression(node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
126
|
-
if node.has_call {
|
|
127
|
-
def obj:CodeNode (node.getSecond())
|
|
128
|
-
def method:CodeNode (node.getThird())
|
|
129
|
-
def args:CodeNode (itemAt node.children 3)
|
|
130
|
-
|
|
131
|
-
if( (!null? node.fnDesc) && (!null? node.fnDesc.nameNode) ) {
|
|
132
|
-
def fnName:CodeNode node.fnDesc.nameNode
|
|
133
|
-
if( fnName.hasFlag('async') ) {
|
|
134
|
-
wr.out('await ' false)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
wr.out("(" false)
|
|
139
|
-
ctx.setInExpr()
|
|
140
|
-
this.WalkNode( obj ctx wr)
|
|
141
|
-
ctx.unsetInExpr()
|
|
142
|
-
wr.out(")." false)
|
|
143
|
-
wr.out(method.vref false)
|
|
144
|
-
; this.WriteVRef(fc ctx wr)
|
|
145
|
-
wr.out("(" false)
|
|
146
|
-
ctx.setInExpr()
|
|
147
|
-
for args.children arg:CodeNode i {
|
|
148
|
-
if (i > 0) {
|
|
149
|
-
wr.out(", " false)
|
|
150
|
-
}
|
|
151
|
-
; TODO: optionality check here ?
|
|
152
|
-
this.WalkNode(arg ctx wr)
|
|
153
|
-
}
|
|
154
|
-
ctx.unsetInExpr()
|
|
155
|
-
wr.out(")" false)
|
|
156
|
-
if ((ctx.expressionLevel()) == 0) {
|
|
157
|
-
wr.out(";" true)
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
; typescript type
|
|
163
|
-
fn getObjectTypeString:string (type_string:string ctx:RangerAppWriterContext) {
|
|
164
|
-
switch type_string {
|
|
165
|
-
case "int" {
|
|
166
|
-
return "number"
|
|
167
|
-
}
|
|
168
|
-
case "string" {
|
|
169
|
-
return "string"
|
|
170
|
-
}
|
|
171
|
-
case "charbuffer" {
|
|
172
|
-
return "string"
|
|
173
|
-
}
|
|
174
|
-
case "char" {
|
|
175
|
-
return "number"
|
|
176
|
-
}
|
|
177
|
-
case "boolean" {
|
|
178
|
-
return "boolean"
|
|
179
|
-
}
|
|
180
|
-
case "double" {
|
|
181
|
-
return "number"
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if(ctx.isDefinedClass(type_string)) {
|
|
185
|
-
def cc (ctx.findClass(type_string))
|
|
186
|
-
if(cc.is_system) {
|
|
187
|
-
def current_sys (ctx)
|
|
188
|
-
def sName (unwrap (get cc.systemNames "es6"))
|
|
189
|
-
return sName
|
|
190
|
-
}
|
|
191
|
-
; define the unions
|
|
192
|
-
if(cc.is_union) {
|
|
193
|
-
return ("union_" + cc.name)
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return type_string
|
|
197
|
-
}
|
|
198
|
-
fn getTypeString:string (type_string:string) {
|
|
199
|
-
switch type_string {
|
|
200
|
-
case "int" {
|
|
201
|
-
return "number"
|
|
202
|
-
}
|
|
203
|
-
case "string" {
|
|
204
|
-
return "string"
|
|
205
|
-
}
|
|
206
|
-
case "charbuffer" {
|
|
207
|
-
return "string"
|
|
208
|
-
}
|
|
209
|
-
case "char" {
|
|
210
|
-
return "number"
|
|
211
|
-
}
|
|
212
|
-
case "boolean" {
|
|
213
|
-
return "boolean"
|
|
214
|
-
}
|
|
215
|
-
case "double" {
|
|
216
|
-
return "number"
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return type_string
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
fn writeTypeDef:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
223
|
-
def v_type:RangerNodeType node.value_type
|
|
224
|
-
def t_name:string node.type_name
|
|
225
|
-
def a_name:string node.array_type
|
|
226
|
-
def k_name:string node.key_type
|
|
227
|
-
if ((v_type == RangerNodeType.Object) || (v_type == RangerNodeType.VRef) || (v_type == RangerNodeType.NoType)) {
|
|
228
|
-
v_type = (node.typeNameAsType(ctx))
|
|
229
|
-
}
|
|
230
|
-
if (node.eval_type != RangerNodeType.NoType) {
|
|
231
|
-
v_type = node.eval_type
|
|
232
|
-
if ( (strlen node.eval_type_name) > 0 ) {
|
|
233
|
-
t_name = node.eval_type_name
|
|
234
|
-
}
|
|
235
|
-
if ( (strlen node.eval_array_type) > 0 ) {
|
|
236
|
-
a_name = node.eval_array_type
|
|
237
|
-
}
|
|
238
|
-
if ( (strlen node.eval_key_type) > 0 ) {
|
|
239
|
-
k_name = node.eval_key_type
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
; std::function<int (int, int)>
|
|
243
|
-
switch v_type {
|
|
244
|
-
case RangerNodeType.ExpressionType {
|
|
245
|
-
|
|
246
|
-
; (n: number) => any
|
|
247
|
-
def rv:CodeNode (itemAt node.expression_value.children 0)
|
|
248
|
-
def sec:CodeNode (itemAt node.expression_value.children 1)
|
|
249
|
-
def fc:CodeNode (sec.getFirst())
|
|
250
|
-
|
|
251
|
-
wr.out("(" false)
|
|
252
|
-
for sec.children arg:CodeNode i {
|
|
253
|
-
if( i > 0 ) {
|
|
254
|
-
wr.out(", " false)
|
|
255
|
-
}
|
|
256
|
-
this.WalkNode( arg ctx wr )
|
|
257
|
-
wr.out(":" false)
|
|
258
|
-
this.writeTypeDef( arg ctx wr)
|
|
259
|
-
}
|
|
260
|
-
wr.out(") => " false )
|
|
261
|
-
|
|
262
|
-
if( target_typescript ) {
|
|
263
|
-
if(node.hasFlag('async')) {
|
|
264
|
-
wr.out('Promise<' false)
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
this.writeTypeDef( rv ctx wr)
|
|
268
|
-
|
|
269
|
-
if( target_typescript ) {
|
|
270
|
-
if(node.hasFlag('async')) {
|
|
271
|
-
wr.out('>' false)
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
case RangerNodeType.Enum {
|
|
277
|
-
wr.out("number" false)
|
|
278
|
-
}
|
|
279
|
-
case RangerNodeType.Integer {
|
|
280
|
-
wr.out("number" false)
|
|
281
|
-
}
|
|
282
|
-
case RangerNodeType.Char {
|
|
283
|
-
wr.out("number" false)
|
|
284
|
-
}
|
|
285
|
-
case RangerNodeType.CharBuffer {
|
|
286
|
-
wr.out("string" false)
|
|
287
|
-
}
|
|
288
|
-
case RangerNodeType.Double {
|
|
289
|
-
wr.out("number" false)
|
|
290
|
-
}
|
|
291
|
-
case RangerNodeType.String {
|
|
292
|
-
wr.out("string" false)
|
|
293
|
-
}
|
|
294
|
-
case RangerNodeType.Boolean {
|
|
295
|
-
wr.out("boolean" false)
|
|
296
|
-
}
|
|
297
|
-
case RangerNodeType.Hash {
|
|
298
|
-
wr.out((((("{[key:" + (this.getObjectTypeString(k_name ctx))) + "]:") + (this.getObjectTypeString(a_name ctx)))) + "}" , false)
|
|
299
|
-
}
|
|
300
|
-
case RangerNodeType.Array {
|
|
301
|
-
wr.out((("Array<" + (this.getObjectTypeString(a_name ctx))) + ">") false)
|
|
302
|
-
}
|
|
303
|
-
default {
|
|
304
|
-
if (node.type_name == "void") {
|
|
305
|
-
wr.out("void" false)
|
|
306
|
-
return
|
|
307
|
-
}
|
|
308
|
-
if(ctx.isDefinedClass(t_name)) {
|
|
309
|
-
def cc (ctx.findClass(t_name))
|
|
310
|
-
|
|
311
|
-
if(cc.is_system) {
|
|
312
|
-
def current_sys (ctx)
|
|
313
|
-
def sName (unwrap (get cc.systemNames "es6"))
|
|
314
|
-
wr.out(sName false)
|
|
315
|
-
return
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if(cc.is_union) {
|
|
319
|
-
wr.out("union_" false)
|
|
320
|
-
wr.out(t_name false)
|
|
321
|
-
return
|
|
322
|
-
}
|
|
323
|
-
def cc:RangerAppClassDesc (ctx.findClass(t_name))
|
|
324
|
-
wr.out(cc.name false)
|
|
325
|
-
return
|
|
326
|
-
}
|
|
327
|
-
wr.out((this.getTypeString(t_name)) false))
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
fn WriteVRef:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
334
|
-
if (node.eval_type == RangerNodeType.Enum) {
|
|
335
|
-
if( (array_length node.ns) > 1) {
|
|
336
|
-
def rootObjName:string (itemAt node.ns 0)
|
|
337
|
-
def enumName:string (itemAt node.ns 1)
|
|
338
|
-
def e@(optional):RangerAppEnum (ctx.getEnum(rootObjName))
|
|
339
|
-
if (!null? e) {
|
|
340
|
-
wr.out(("" + (unwrap (get e.values enumName))) false)
|
|
341
|
-
return
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
if ((array_length node.nsp) > 0) {
|
|
346
|
-
for node.nsp p:RangerAppParamDesc i {
|
|
347
|
-
if (i > 0) {
|
|
348
|
-
wr.out("." false)
|
|
349
|
-
}
|
|
350
|
-
if (i == 0) {
|
|
351
|
-
; if (p.nameNode.hasFlag("optional")) {
|
|
352
|
-
; }
|
|
353
|
-
def part:string (itemAt node.ns 0)
|
|
354
|
-
if ((part != "this") && (ctx.isMemberVariable(part))) {
|
|
355
|
-
def uc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
356
|
-
def currC:RangerAppClassDesc (unwrap uc)
|
|
357
|
-
def up@(optional):RangerAppParamDesc (currC.findVariable(part))
|
|
358
|
-
if (!null? up) {
|
|
359
|
-
wr.out( "this." false)
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
if(part == "this") {
|
|
363
|
-
wr.out("this" false)
|
|
364
|
-
continue
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
if ((strlen p.compiledName) > 0) {
|
|
368
|
-
wr.out((this.adjustType(p.compiledName)) false)
|
|
369
|
-
} {
|
|
370
|
-
if ((strlen p.name) > 0) {
|
|
371
|
-
wr.out((this.adjustType(p.name)) false)
|
|
372
|
-
} {
|
|
373
|
-
wr.out((this.adjustType( (itemAt node.ns i))) false)
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
return
|
|
378
|
-
}
|
|
379
|
-
if node.hasParamDesc {
|
|
380
|
-
def part:string (itemAt node.ns 0)
|
|
381
|
-
if ((part != "this") && (ctx.isMemberVariable(part))) {
|
|
382
|
-
def uc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
383
|
-
def currC:RangerAppClassDesc (unwrap uc)
|
|
384
|
-
def up@(optional):RangerAppParamDesc (currC.findVariable(part))
|
|
385
|
-
if (!null? up) {
|
|
386
|
-
wr.out("this." false)
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
def p:RangerAppParamDesc node.paramDesc
|
|
390
|
-
wr.out(p.compiledName false)
|
|
391
|
-
return
|
|
392
|
-
}
|
|
393
|
-
def b_was_static:boolean false
|
|
394
|
-
for node.ns part:string i {
|
|
395
|
-
if (i > 0) {
|
|
396
|
-
if ((i == 1) && b_was_static) {
|
|
397
|
-
wr.out("." false)
|
|
398
|
-
} {
|
|
399
|
-
wr.out("." false)
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
if (i == 0) {
|
|
403
|
-
if (ctx.hasClass(part)) {
|
|
404
|
-
b_was_static = true
|
|
405
|
-
} {
|
|
406
|
-
wr.out("" false)
|
|
407
|
-
}
|
|
408
|
-
if ((part != "this") && (ctx.isMemberVariable(part))) {
|
|
409
|
-
def uc@(optional):RangerAppClassDesc (ctx.getCurrentClass())
|
|
410
|
-
def currC:RangerAppClassDesc (unwrap uc)
|
|
411
|
-
def up@(optional):RangerAppParamDesc (currC.findVariable(part))
|
|
412
|
-
if (!null? up) {
|
|
413
|
-
wr.out("this." false)
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
wr.out((this.adjustType(part)) false)
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
fn writeVarInitDef:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
421
|
-
if node.hasParamDesc {
|
|
422
|
-
def nn:CodeNode (itemAt node.children 1)
|
|
423
|
-
def p:RangerAppParamDesc nn.paramDesc
|
|
424
|
-
def remove_unused:boolean (ctx.hasCompilerFlag("remove-unused-class-vars"))
|
|
425
|
-
|
|
426
|
-
if ((p.ref_cnt == 0) && (remove_unused || (p.is_class_variable == false))) {
|
|
427
|
-
return
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
def was_set false
|
|
431
|
-
|
|
432
|
-
if ((array_length node.children) > 2) {
|
|
433
|
-
wr.out(("this." + p.compiledName + " = ") , false)
|
|
434
|
-
ctx.setInExpr()
|
|
435
|
-
def value:CodeNode (node.getThird())
|
|
436
|
-
this.WalkNode(value ctx wr)
|
|
437
|
-
ctx.unsetInExpr()
|
|
438
|
-
was_set = true
|
|
439
|
-
} {
|
|
440
|
-
if (nn.value_type == RangerNodeType.Array) {
|
|
441
|
-
wr.out(("this." + p.compiledName ) , false)
|
|
442
|
-
if(nn.hasFlag("immutable")) {
|
|
443
|
-
wr.out(" = require('immutable').List()" false)
|
|
444
|
-
} {
|
|
445
|
-
wr.out(" = []" false)
|
|
446
|
-
}
|
|
447
|
-
was_set = true
|
|
448
|
-
}
|
|
449
|
-
if (nn.value_type == RangerNodeType.Hash) {
|
|
450
|
-
wr.out(("this." + p.compiledName ) , false)
|
|
451
|
-
; wr.out(" = {}" false)
|
|
452
|
-
if(nn.hasFlag("immutable")) {
|
|
453
|
-
wr.out(" = require('immutable').Map()" false)
|
|
454
|
-
} {
|
|
455
|
-
wr.out(" = {}" false)
|
|
456
|
-
}
|
|
457
|
-
was_set = true
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
if was_set {
|
|
461
|
-
wr.out(";" false)
|
|
462
|
-
if ((p.ref_cnt == 0) && (p.is_class_variable == true)) {
|
|
463
|
-
wr.out(" /** note: unused */" false)
|
|
464
|
-
}
|
|
465
|
-
wr.newline()
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
fn writeVarDef:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
470
|
-
if node.hasParamDesc {
|
|
471
|
-
def nn:CodeNode (itemAt node.children 1)
|
|
472
|
-
def p:RangerAppParamDesc nn.paramDesc
|
|
473
|
-
def opt_js:boolean (ctx.hasCompilerFlag("optimize-js"))
|
|
474
|
-
if ((p.ref_cnt == 0) && (p.is_class_variable == false)) {
|
|
475
|
-
wr.out("/** unused: " false)
|
|
476
|
-
}
|
|
477
|
-
def has_value false
|
|
478
|
-
if ((array_length node.children) > 2) {
|
|
479
|
-
has_value = true
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
if ((p.set_cnt > 0) || p.is_class_variable || (has_value == false)) {
|
|
483
|
-
wr.out(("let " + p.compiledName) false)
|
|
484
|
-
} {
|
|
485
|
-
wr.out(("const " + p.compiledName) false)
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
if target_typescript {
|
|
489
|
-
wr.out(" : " false)
|
|
490
|
-
this.writeTypeDef((unwrap p.nameNode) ctx wr)
|
|
491
|
-
wr.out(" " false)
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
if ((array_length node.children) > 2) {
|
|
495
|
-
wr.out(" = " false)
|
|
496
|
-
ctx.setInExpr()
|
|
497
|
-
def value:CodeNode (node.getThird())
|
|
498
|
-
this.WalkNode(value ctx wr)
|
|
499
|
-
ctx.unsetInExpr()
|
|
500
|
-
} {
|
|
501
|
-
; the compiler could call the operators here with possibly some parameters ?
|
|
502
|
-
if (nn.value_type == RangerNodeType.Array) {
|
|
503
|
-
if(nn.hasFlag("immutable")) {
|
|
504
|
-
wr.out(" = require('immutable').List()" false)
|
|
505
|
-
} {
|
|
506
|
-
wr.out(" = []" false)
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
if (nn.value_type == RangerNodeType.Hash) {
|
|
510
|
-
if(nn.hasFlag("immutable")) {
|
|
511
|
-
wr.out(" = require('immutable').Map()" false)
|
|
512
|
-
} {
|
|
513
|
-
wr.out(" = {}" false)
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
if ((p.ref_cnt == 0) && (p.is_class_variable == true)) {
|
|
518
|
-
wr.out(" /** note: unused */" false)
|
|
519
|
-
}
|
|
520
|
-
if ((p.ref_cnt == 0) && (p.is_class_variable == false)) {
|
|
521
|
-
wr.out(" **/ " true)
|
|
522
|
-
} {
|
|
523
|
-
wr.out(";" false)
|
|
524
|
-
wr.newline()
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
fn writeClassVarDef:void (p:RangerAppParamDesc ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
529
|
-
if target_typescript {
|
|
530
|
-
wr.out( p.compiledName false)
|
|
531
|
-
wr.out(": " false)
|
|
532
|
-
this.writeTypeDef( (unwrap p.nameNode) ctx wr)
|
|
533
|
-
wr.out(";" true)
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
fn CreateLambdaCall:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
538
|
-
def fName:CodeNode (itemAt node.children 0)
|
|
539
|
-
def args:CodeNode (itemAt node.children 1)
|
|
540
|
-
ctx.setInExpr()
|
|
541
|
-
|
|
542
|
-
def currM ( ctx.getCurrentMethod( ))
|
|
543
|
-
|
|
544
|
-
if( (!null? currM.nameNode) && (currM.nameNode.hasFlag('async'))) {
|
|
545
|
-
wr.out('await ' false)
|
|
546
|
-
}
|
|
547
|
-
this.WalkNode( fName ctx wr)
|
|
548
|
-
; this.WriteVRef(fName ctx wr)
|
|
549
|
-
wr.out("(" false)
|
|
550
|
-
for args.children arg:CodeNode i {
|
|
551
|
-
if (i > 0) {
|
|
552
|
-
wr.out(", " false)
|
|
553
|
-
}
|
|
554
|
-
this.WalkNode( arg ctx wr)
|
|
555
|
-
}
|
|
556
|
-
wr.out(")" false)
|
|
557
|
-
ctx.unsetInExpr()
|
|
558
|
-
if ((ctx.expressionLevel()) == 0) {
|
|
559
|
-
wr.out(";" true)
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
fn CreateLambda:void (node:CodeNode ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
564
|
-
def lambdaCtx (unwrap node.lambda_ctx)
|
|
565
|
-
def fName:CodeNode (itemAt node.children 0)
|
|
566
|
-
def args:CodeNode (itemAt node.children 1)
|
|
567
|
-
def body:CodeNode (itemAt node.children 2)
|
|
568
|
-
|
|
569
|
-
if ((ctx.expressionLevel()) > 0) {
|
|
570
|
-
wr.out('(' false)
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
if( fName.hasFlag('async') ) {
|
|
574
|
-
wr.out('async ' false)
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
wr.out("(" false)
|
|
578
|
-
for args.children arg:CodeNode i {
|
|
579
|
-
if (i > 0) {
|
|
580
|
-
wr.out(', ' false)
|
|
581
|
-
}
|
|
582
|
-
if(arg.flow_done == false) {
|
|
583
|
-
this.compiler.parser.WalkNode( arg lambdaCtx wr)
|
|
584
|
-
}
|
|
585
|
-
this.WalkNode(arg lambdaCtx wr)
|
|
586
|
-
if target_typescript {
|
|
587
|
-
wr.out(' : ' false)
|
|
588
|
-
this.writeTypeDef( arg ctx wr)
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
wr.out(')' false)
|
|
592
|
-
if(target_typescript) {
|
|
593
|
-
wr.out(":" false)
|
|
594
|
-
if( fName.hasFlag('async') ) {
|
|
595
|
-
wr.out(' Promise<' false)
|
|
596
|
-
}
|
|
597
|
-
this.writeTypeDef( fName ctx wr)
|
|
598
|
-
if( fName.hasFlag('async') ) {
|
|
599
|
-
wr.out('>' false)
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
wr.out(' => { ' true)
|
|
603
|
-
wr.indent(1)
|
|
604
|
-
lambdaCtx.restartExpressionLevel()
|
|
605
|
-
for body.children item:CodeNode i {
|
|
606
|
-
; print "lambda row " + (item.getCode())
|
|
607
|
-
; if(has item.register_expressions) {
|
|
608
|
-
; print "Lambda had register expressions at : " + (item.getCode())
|
|
609
|
-
; }
|
|
610
|
-
this.WalkNode(item lambdaCtx wr)
|
|
611
|
-
}
|
|
612
|
-
wr.newline()
|
|
613
|
-
wr.indent(-1)
|
|
614
|
-
wr.out("}" false)
|
|
615
|
-
|
|
616
|
-
if ((ctx.expressionLevel()) > 0) {
|
|
617
|
-
wr.out(')' false)
|
|
618
|
-
} {
|
|
619
|
-
wr.out('' true)
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
fn writeArgsDef:void (fnDesc:RangerAppFunctionDesc ctx:RangerAppWriterContext wr:CodeWriter) {
|
|
625
|
-
def cnt 0
|
|
626
|
-
def pms (filter (fnDesc.params) {
|
|
627
|
-
if( item.nameNode.hasFlag('keyword')) {
|
|
628
|
-
return false
|
|
629
|
-
}
|
|
630
|
-
return true
|
|
631
|
-
})
|
|
632
|
-
for pms arg:RangerAppParamDesc i {
|
|
633
|
-
if (cnt > 0) {
|
|
634
|
-
wr.out(', ' false)
|
|
635
|
-
}
|
|
636
|
-
cnt = cnt + 1
|
|
637
|
-
wr.out( arg.compiledName false)
|
|
638
|
-
if target_typescript {
|
|
639
|
-
wr.out(' : ' false)
|
|
640
|
-
this.writeTypeDef( (unwrap arg.nameNode) ctx wr)
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
fn writeClass:void (node:CodeNode ctx:RangerAppWriterContext orig_wr:CodeWriter) {
|
|
646
|
-
|
|
647
|
-
def cl:RangerAppClassDesc node.clDesc
|
|
648
|
-
def is_react_native:boolean false
|
|
649
|
-
def is_rn_default false
|
|
650
|
-
|
|
651
|
-
target_typescript = (ctx.hasCompilerFlag("typescript"))
|
|
652
|
-
|
|
653
|
-
if( (ctx.hasCompilerFlag('dead4main')) || (ctx.hasCompilerSetting('dceclass'))) {
|
|
654
|
-
if(cl.is_used_by_main == false) {
|
|
655
|
-
return
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
if(cl.is_interface) {
|
|
660
|
-
orig_wr.out("// interface : " + cl.name , true)
|
|
661
|
-
return
|
|
662
|
-
}
|
|
663
|
-
if (null? cl) {
|
|
664
|
-
return
|
|
665
|
-
}
|
|
666
|
-
if(cl.nameNode.hasFlag("ReactNative")) {
|
|
667
|
-
is_react_native = true
|
|
668
|
-
set this.compFlags "ReactNative" true
|
|
669
|
-
}
|
|
670
|
-
if(cl.nameNode.hasFlag("default")) {
|
|
671
|
-
is_rn_default = true
|
|
672
|
-
}
|
|
673
|
-
def wr:CodeWriter orig_wr
|
|
674
|
-
def importFork:CodeWriter (wr.fork())
|
|
675
|
-
if (wrote_header == false) {
|
|
676
|
-
wrote_header = true
|
|
677
|
-
|
|
678
|
-
if(ctx.hasCompilerFlag("nodecli")) {
|
|
679
|
-
wr.out("#!/usr/bin/env node" true)
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
; write the npm exports at the end of the file if required...
|
|
683
|
-
if( (ctx.hasCompilerFlag("nodemodule")) && (target_typescript == false)) {
|
|
684
|
-
def root (ctx.getRoot())
|
|
685
|
-
root.definedClasses.forEach({
|
|
686
|
-
|
|
687
|
-
if( (ctx.hasCompilerFlag('dead4main')) || (ctx.hasCompilerSetting('dceclass'))) {
|
|
688
|
-
if(item.is_used_by_main == false) {
|
|
689
|
-
return
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
if(item.isNormalClass()) {
|
|
693
|
-
def theEnd (wr.getTag("file_end"))
|
|
694
|
-
theEnd.out( ("module.exports." + item.name + " = " + item.name + ";") true )
|
|
695
|
-
}
|
|
696
|
-
})
|
|
697
|
-
}
|
|
698
|
-
; javascript option for the flow types...
|
|
699
|
-
target_flow = (ctx.hasCompilerFlag("flow"))
|
|
700
|
-
if( target_typescript ) {
|
|
701
|
-
this.CreateTsUnions( (unwrap this.compiler.parser) ctx wr )
|
|
702
|
-
}
|
|
703
|
-
if(ctx.hasCompilerFlag("npm")) {
|
|
704
|
-
this.writeNpmPackage( node ctx wr )
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
def b_extd:boolean false
|
|
708
|
-
|
|
709
|
-
def do_export false
|
|
710
|
-
|
|
711
|
-
if( is_react_native || target_typescript ) {
|
|
712
|
-
do_export = true
|
|
713
|
-
if( cl.is_system || cl.is_operator_class ) {
|
|
714
|
-
do_export = false
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
if do_export {
|
|
719
|
-
wr.out("export " false)
|
|
720
|
-
if(is_rn_default) {
|
|
721
|
-
wr.out(" default " false)
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
wr.out("class " + cl.name +" " , false)
|
|
726
|
-
|
|
727
|
-
if is_react_native {
|
|
728
|
-
wr.out(" extends Component " false)
|
|
729
|
-
} {
|
|
730
|
-
for cl.extends_classes pName:string i {
|
|
731
|
-
if( i == 0) {
|
|
732
|
-
wr.out(" extends " false)
|
|
733
|
-
}
|
|
734
|
-
wr.out(pName false)
|
|
735
|
-
b_extd = true
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
wr.out( " {" true)
|
|
740
|
-
wr.indent(1)
|
|
741
|
-
; define the class variables
|
|
742
|
-
for cl.variables pvar:RangerAppParamDesc i {
|
|
743
|
-
this.writeClassVarDef( pvar ctx wr)
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
if(is_react_native == false) {
|
|
747
|
-
|
|
748
|
-
wr.out("constructor(" false)
|
|
749
|
-
|
|
750
|
-
if cl.has_constructor {
|
|
751
|
-
def constr:RangerAppFunctionDesc (unwrap cl.constructor_fn)
|
|
752
|
-
this.writeArgsDef(constr ctx wr)
|
|
753
|
-
}
|
|
754
|
-
wr.out(") {" true)
|
|
755
|
-
wr.indent(1)
|
|
756
|
-
|
|
757
|
-
if(b_extd) {
|
|
758
|
-
wr.out("super()" true)
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
for cl.variables pvar:RangerAppParamDesc i {
|
|
762
|
-
this.writeVarInitDef(( unwrap pvar.node ) ctx wr)
|
|
763
|
-
}
|
|
764
|
-
if cl.has_constructor {
|
|
765
|
-
def constr:RangerAppFunctionDesc cl.constructor_fn
|
|
766
|
-
wr.newline()
|
|
767
|
-
def subCtx:RangerAppWriterContext ( unwrap constr.fnCtx )
|
|
768
|
-
subCtx.is_function = true
|
|
769
|
-
this.WalkNode(( unwrap constr.fnBody ) subCtx wr)
|
|
770
|
-
}
|
|
771
|
-
wr.newline()
|
|
772
|
-
wr.indent(-1)
|
|
773
|
-
wr.out("}" true)
|
|
774
|
-
}
|
|
775
|
-
for cl.defined_variants fnVar:string i {
|
|
776
|
-
def mVs:RangerAppMethodVariants (get cl.method_variants fnVar)
|
|
777
|
-
for mVs.variants variant:RangerAppFunctionDesc i {
|
|
778
|
-
|
|
779
|
-
if( variant.nameNode.hasFlag('async') ) {
|
|
780
|
-
wr.out('async ' false)
|
|
781
|
-
}
|
|
782
|
-
wr.out((("" + variant.compiledName) + " (") false)
|
|
783
|
-
this.writeArgsDef(variant ctx wr)
|
|
784
|
-
wr.out(")" false)
|
|
785
|
-
|
|
786
|
-
if target_typescript {
|
|
787
|
-
wr.out(" : " false)
|
|
788
|
-
|
|
789
|
-
if( variant.nameNode.hasFlag('async') ) {
|
|
790
|
-
wr.out(' Promise<' false)
|
|
791
|
-
}
|
|
792
|
-
this.writeTypeDef( (unwrap variant.nameNode ) ctx wr)
|
|
793
|
-
if( variant.nameNode.hasFlag('async') ) {
|
|
794
|
-
wr.out('>' false)
|
|
795
|
-
}
|
|
796
|
-
wr.out(" " false)
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
wr.out(" {" true)
|
|
800
|
-
wr.indent(1)
|
|
801
|
-
wr.newline()
|
|
802
|
-
def subCtx:RangerAppWriterContext ( unwrap variant.fnCtx )
|
|
803
|
-
subCtx.is_function = true
|
|
804
|
-
subCtx.localVariables.forEach({
|
|
805
|
-
if(item.is_register) {
|
|
806
|
-
wr.out( ('// register ' + item.name) true)
|
|
807
|
-
}
|
|
808
|
-
})
|
|
809
|
-
this.WalkNode(( unwrap variant.fnBody ) subCtx wr)
|
|
810
|
-
wr.newline()
|
|
811
|
-
wr.indent(-1)
|
|
812
|
-
wr.out("};" true)
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
if target_typescript {
|
|
817
|
-
for cl.static_methods variant:RangerAppFunctionDesc i {
|
|
818
|
-
if (variant.nameNode.hasFlag("main")) {
|
|
819
|
-
continue _
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
wr.out("static " false)
|
|
823
|
-
if( variant.nameNode.hasFlag('async') ) {
|
|
824
|
-
wr.out('async ' false)
|
|
825
|
-
}
|
|
826
|
-
wr.out((("" + variant.compiledName) + " (") false)
|
|
827
|
-
this.writeArgsDef(variant ctx wr)
|
|
828
|
-
wr.out(")" false)
|
|
829
|
-
wr.out(" : " false)
|
|
830
|
-
|
|
831
|
-
if( variant.nameNode.hasFlag('async') ) {
|
|
832
|
-
wr.out(' Promise<' false)
|
|
833
|
-
}
|
|
834
|
-
this.writeTypeDef( (unwrap variant.nameNode ) ctx wr)
|
|
835
|
-
if( variant.nameNode.hasFlag('async') ) {
|
|
836
|
-
wr.out('> ' false)
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
wr.out(" " false)
|
|
841
|
-
wr.out(" {" true)
|
|
842
|
-
wr.indent(1)
|
|
843
|
-
wr.newline()
|
|
844
|
-
def subCtx:RangerAppWriterContext ( unwrap variant.fnCtx )
|
|
845
|
-
subCtx.is_function = true
|
|
846
|
-
this.WalkNode(( unwrap variant.fnBody ) subCtx wr)
|
|
847
|
-
wr.newline()
|
|
848
|
-
wr.indent(-1)
|
|
849
|
-
wr.out("};" true)
|
|
850
|
-
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
wr.indent(-1)
|
|
855
|
-
wr.out("}" true)
|
|
856
|
-
|
|
857
|
-
if ( target_typescript == false ) {
|
|
858
|
-
for cl.static_methods variant:RangerAppFunctionDesc i {
|
|
859
|
-
if (variant.nameNode.hasFlag("main")) {
|
|
860
|
-
continue _
|
|
861
|
-
} {
|
|
862
|
-
def asyncKeyword ""
|
|
863
|
-
if( variant.nameNode.hasFlag('async') ) {
|
|
864
|
-
asyncKeyword = 'async '
|
|
865
|
-
}
|
|
866
|
-
wr.out((((cl.name + ".") + variant.compiledName) + " = " + asyncKeyword + "function(") false)
|
|
867
|
-
this.writeArgsDef(variant ctx wr)
|
|
868
|
-
wr.out(") {" true)
|
|
869
|
-
}
|
|
870
|
-
wr.indent(1)
|
|
871
|
-
wr.newline()
|
|
872
|
-
def subCtx:RangerAppWriterContext ( unwrap variant.fnCtx )
|
|
873
|
-
subCtx.is_function = true
|
|
874
|
-
this.WalkNode(( unwrap variant.fnBody ) subCtx wr)
|
|
875
|
-
wr.newline()
|
|
876
|
-
wr.indent(-1)
|
|
877
|
-
wr.out("};" true)
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
if( (ctx.hasCompilerFlag("nodemodule")) == false ) {
|
|
881
|
-
for cl.static_methods variant:RangerAppFunctionDesc i {
|
|
882
|
-
ctx.disableCurrentClass()
|
|
883
|
-
if ( (variant.nameNode.hasFlag("main")) && (variant.nameNode.code.filename == (ctx.getRootFile()))) {
|
|
884
|
-
|
|
885
|
-
def asyncKeyword ""
|
|
886
|
-
if( variant.nameNode.hasFlag('async') ) {
|
|
887
|
-
asyncKeyword = 'async '
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
def theEnd (wr.getTag("file_end"))
|
|
891
|
-
theEnd.out("/* static JavaSript main routine at the end of the JS file */" false)
|
|
892
|
-
theEnd.newline()
|
|
893
|
-
theEnd.out( (asyncKeyword + "function __js_main() {") true)
|
|
894
|
-
theEnd.indent(1)
|
|
895
|
-
this.WalkNode(( unwrap variant.fnBody ) ctx theEnd)
|
|
896
|
-
theEnd.newline()
|
|
897
|
-
theEnd.indent(-1)
|
|
898
|
-
theEnd.out("}" true)
|
|
899
|
-
theEnd.out("__js_main();" true)
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
fn BuildAST:CodeNode ( code_string:string) {
|
|
906
|
-
def lang_code:SourceCode (new SourceCode ( code_string ) )
|
|
907
|
-
lang_code.filename = "services"
|
|
908
|
-
def lang_parser:RangerLispParser (new RangerLispParser (lang_code))
|
|
909
|
-
lang_parser.parse(false)
|
|
910
|
-
def node@(lives):CodeNode (unwrap lang_parser.rootNode)
|
|
911
|
-
return node
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
fn CreateServices (parser:RangerFlowParser ctx:RangerAppWriterContext orig_wr:CodeWriter) {
|
|
915
|
-
|
|
916
|
-
if(ctx.hasCompilerFlag("client")) {
|
|
917
|
-
ctx.addError( (CodeNode.blockNode()) "client service writing for target JavaScript is not implemented")
|
|
918
|
-
return
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
def root (ctx.getRoot())
|
|
922
|
-
|
|
923
|
-
def serviceBlock (CodeNode.blockNode())
|
|
924
|
-
|
|
925
|
-
def wr (new CodeWriter)
|
|
926
|
-
wr.out("class test_webservice {" true)
|
|
927
|
-
wr.indent(1)
|
|
928
|
-
wr.out("fn run () {" true)
|
|
929
|
-
wr.indent(1)
|
|
930
|
-
wr.out("def www (create_web_server)" true)
|
|
931
|
-
wr.out("prepare_server www" true);
|
|
932
|
-
root.appServices.forEach({
|
|
933
|
-
|
|
934
|
-
try {
|
|
935
|
-
|
|
936
|
-
def paramList (item.getThird())
|
|
937
|
-
def param (paramList.getFirst())
|
|
938
|
-
|
|
939
|
-
wr.out("www.post_route(\"/" + item.appGUID + "\" {" , true)
|
|
940
|
-
wr.indent(1)
|
|
941
|
-
wr.out("def obj (" + (param.type_name) + ".fromDictionary( (from_string (get_post_data req ))) )" , true)
|
|
942
|
-
wr.out("def service (new appServices)" true)
|
|
943
|
-
wr.out("def data (service." + item.appGUID + "(obj))" , true)
|
|
944
|
-
wr.out("res.send((to_string (data.toDictionary())))" , true)
|
|
945
|
-
wr.indent(-1)
|
|
946
|
-
wr.out("})" true)
|
|
947
|
-
|
|
948
|
-
def nn (item.getSecond())
|
|
949
|
-
nn.vref = item.appGUID
|
|
950
|
-
def params (item.getThird())
|
|
951
|
-
|
|
952
|
-
def block_index 3
|
|
953
|
-
def ch_len ( ( array_length item.children ) - 1)
|
|
954
|
-
for item.children cb:CodeNode i {
|
|
955
|
-
if( i > 3 ) {
|
|
956
|
-
if( (strlen cb.vref) > 0 ) {
|
|
957
|
-
if( ( ctx.hasCompilerFlag(cb.vref) ) && ( i < ch_len ) ) {
|
|
958
|
-
block_index = i + 1
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
def codeBlock (unwrap (item.getChild(block_index)) )
|
|
965
|
-
push serviceBlock.children (r.op "fn" nn params codeBlock)
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
} {
|
|
969
|
-
ctx.addError( item "Invalid service function")
|
|
970
|
-
}
|
|
971
|
-
})
|
|
972
|
-
wr.indent(-1)
|
|
973
|
-
wr.out("www.startServer( 1777, {" , true)
|
|
974
|
-
wr.indent(1)
|
|
975
|
-
wr.out("print \"Server started\"" true)
|
|
976
|
-
wr.indent(-1)
|
|
977
|
-
wr.out("}" true)
|
|
978
|
-
wr.out("}" true)
|
|
979
|
-
wr.indent(-1)
|
|
980
|
-
wr.out("}" true)
|
|
981
|
-
|
|
982
|
-
def codeNode (this.BuildAST( (wr.getCode() )) )
|
|
983
|
-
def serviceClassDef (r.op "class" (r.vref "appServices") serviceBlock )
|
|
984
|
-
|
|
985
|
-
def subCtx (root.fork())
|
|
986
|
-
def theEnd (orig_wr.getTag("file_end"))
|
|
987
|
-
|
|
988
|
-
parser.WalkCollectMethods( serviceClassDef root theEnd )
|
|
989
|
-
parser.WalkCollectMethods( codeNode root theEnd )
|
|
990
|
-
parser.WalkNode( serviceClassDef root theEnd )
|
|
991
|
-
parser.WalkNode( codeNode root theEnd )
|
|
992
|
-
|
|
993
|
-
theEnd.out("(new test_webservice).run();" true)
|
|
994
|
-
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
fn CreatePages (parser:RangerFlowParser ctx:RangerAppWriterContext orig_wr:CodeWriter) {
|
|
998
|
-
|
|
999
|
-
def wr:CodeWriter (orig_wr.getFileWriter("." ("pages.js")))
|
|
1000
|
-
|
|
1001
|
-
; TODO: the application container could be here
|
|
1002
|
-
wr.out("class theApplicationClass {" true)
|
|
1003
|
-
wr.indent(1)
|
|
1004
|
-
ctx.appPages.forEach({
|
|
1005
|
-
this.CreatePage(parser item ctx wr)
|
|
1006
|
-
})
|
|
1007
|
-
wr.indent(-1)
|
|
1008
|
-
wr.out("}" true)
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
fn CreatePage (parser:RangerFlowParser node:CodeNode ctx:RangerAppWriterContext orig_wr:CodeWriter) {
|
|
1012
|
-
def writer (new WebPageWriter)
|
|
1013
|
-
writer.classWriter = this
|
|
1014
|
-
writer.CreatePage( parser node ctx orig_wr )
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
fn writeNpmPackage ( node:CodeNode ctx:RangerAppWriterContext orig_wr:CodeWriter ) {
|
|
1018
|
-
def wr:CodeWriter (orig_wr.getFileWriter("." ("package.json")))
|
|
1019
|
-
def opts ([] "name" "version" "description" "author" "license")
|
|
1020
|
-
wr.out("{" true)
|
|
1021
|
-
wr.indent(1)
|
|
1022
|
-
opts.forEach({
|
|
1023
|
-
if( (ctx.hasCompilerSetting(item)) == false ) {
|
|
1024
|
-
ctx.addError( node ("NPM package requires option -" + item + "=<value>") )
|
|
1025
|
-
} {
|
|
1026
|
-
wr.out( ('"' + item + '" : "' + (ctx.getCompilerSetting(item)) + '",') true)
|
|
1027
|
-
}
|
|
1028
|
-
})
|
|
1029
|
-
def target_file (ctx.getCompilerSetting("o"))
|
|
1030
|
-
if( ctx.hasCompilerFlag("nodecli")) {
|
|
1031
|
-
wr.out( ('"bin": {"' + (ctx.getCompilerSetting("name")) +'":"' + target_file + '"},') true)
|
|
1032
|
-
}
|
|
1033
|
-
wr.out('"scripts":{},' true)
|
|
1034
|
-
wr.out( ('"main":"' + target_file + '"') true)
|
|
1035
|
-
wr.indent(-1)
|
|
1036
|
-
wr.out("}" true)
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
}
|
|
1040
|
-
|