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,1793 +0,0 @@
|
|
|
1
|
-
Import "ContextOperators.clj"
|
|
2
|
-
|
|
3
|
-
class TypeCounts {
|
|
4
|
-
def b_counted false
|
|
5
|
-
def interface_cnt 0
|
|
6
|
-
def operator_cnt 0
|
|
7
|
-
def immutable_cnt 0
|
|
8
|
-
def register_cnt 0
|
|
9
|
-
def opfn_cnt 0
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
class RangerNodeValue {
|
|
13
|
-
def double_value:double
|
|
14
|
-
def string_value:string
|
|
15
|
-
def int_value:int
|
|
16
|
-
def boolean_value:boolean
|
|
17
|
-
def expression_value:CodeNode
|
|
18
|
-
}
|
|
19
|
-
class RangerBackReference {
|
|
20
|
-
def from_class:string
|
|
21
|
-
def var_name:string
|
|
22
|
-
def ref_type:string
|
|
23
|
-
}
|
|
24
|
-
class RangerAppEnum {
|
|
25
|
-
def name:string ""
|
|
26
|
-
def cnt:int 0
|
|
27
|
-
def values:[string:int]
|
|
28
|
-
def node:CodeNode
|
|
29
|
-
fn add:void (n:string) {
|
|
30
|
-
set values n cnt
|
|
31
|
-
cnt = (cnt + 1)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
class OpFindResult {
|
|
36
|
-
def did_find:boolean false
|
|
37
|
-
def node:CodeNode
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
class RangerOperatorList {
|
|
41
|
-
def items:[RangerAppOperatorDesc]
|
|
42
|
-
}
|
|
43
|
-
class RangerNodeList {
|
|
44
|
-
def items:[CodeNode]
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
; - []
|
|
48
|
-
class ContextTransaction {
|
|
49
|
-
def name ''
|
|
50
|
-
def desc ''
|
|
51
|
-
def ended false
|
|
52
|
-
def failed false
|
|
53
|
-
def ctx@(weak):RangerAppWriterContext
|
|
54
|
-
def mutations@(weak):[ContextTransactionMutation]
|
|
55
|
-
def parent@(weak):ContextTransaction
|
|
56
|
-
def children@(weak):[ContextTransaction]
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
class ContextTransactionMutation {
|
|
60
|
-
def sourceNode@(weak):CodeNode
|
|
61
|
-
def targetNode@(weak):CodeNode
|
|
62
|
-
def addedNode@(weak):CodeNode
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
operator type:void all {
|
|
66
|
-
|
|
67
|
-
fn getActiveTransaction@(optional):ContextTransaction (c:RangerAppWriterContext) {
|
|
68
|
-
def rValue:ContextTransaction
|
|
69
|
-
if(has c.activeTransaction) {
|
|
70
|
-
rValue = (last c.activeTransaction)
|
|
71
|
-
} {
|
|
72
|
-
if(!null? c.parent) {
|
|
73
|
-
return (getActiveTransaction (unwrap c.parent))
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return rValue
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
fn transaction_depth:int (name:string c:RangerAppWriterContext) {
|
|
80
|
-
def t@(weak) (getActiveTransaction c)
|
|
81
|
-
def d 0
|
|
82
|
-
while(!null? t) {
|
|
83
|
-
if( t.name == name ) {
|
|
84
|
-
d = d + 1
|
|
85
|
-
}
|
|
86
|
-
t = t.parent
|
|
87
|
-
}
|
|
88
|
-
return d
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
fn start_transaction@(weak):ContextTransaction (name:string desc:string c:RangerAppWriterContext) {
|
|
92
|
-
def t (new ContextTransaction)
|
|
93
|
-
t.name = name
|
|
94
|
-
t.desc = desc
|
|
95
|
-
t.ctx = c
|
|
96
|
-
def currC@(lives) (getActiveTransaction c)
|
|
97
|
-
push c.activeTransaction t
|
|
98
|
-
push c.transactions t
|
|
99
|
-
if(!null? currC) {
|
|
100
|
-
push currC.children t
|
|
101
|
-
t.parent = currC
|
|
102
|
-
}
|
|
103
|
-
return t
|
|
104
|
-
}
|
|
105
|
-
fn end_transaction (t:ContextTransaction) {
|
|
106
|
-
def c (unwrap t.ctx)
|
|
107
|
-
def i (indexOf c.activeTransaction t)
|
|
108
|
-
if( i >= 0) {
|
|
109
|
-
remove c.activeTransaction i
|
|
110
|
-
}
|
|
111
|
-
t.ended = true
|
|
112
|
-
}
|
|
113
|
-
fn mutation (c:ContextTransaction s:CodeNode t:CodeNode a:CodeNode ) {
|
|
114
|
-
def m (new ContextTransactionMutation)
|
|
115
|
-
m.sourceNode = s
|
|
116
|
-
m.targetNode = t
|
|
117
|
-
m.addedNode = a
|
|
118
|
-
push c.mutations m
|
|
119
|
-
return m
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
class RangerRegisteredPlugin {
|
|
124
|
-
def name:string ""
|
|
125
|
-
def features:[string]
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
class RangerAppWriterContext {
|
|
129
|
-
def langOperators:CodeNode
|
|
130
|
-
def stdCommands:CodeNode
|
|
131
|
-
def operators:RangerActiveOperators
|
|
132
|
-
def op_list:[string:RangerOperatorList]
|
|
133
|
-
def reservedWords:CodeNode
|
|
134
|
-
def intRootCounter:int 1
|
|
135
|
-
def targetLangName:string ""
|
|
136
|
-
def parent:RangerAppWriterContext
|
|
137
|
-
def defined_imports:[string]
|
|
138
|
-
def already_imported:[string:boolean]
|
|
139
|
-
def fileSystem:CodeFileSystem
|
|
140
|
-
def is_function:boolean false
|
|
141
|
-
def class_level_context:boolean false
|
|
142
|
-
def function_level_context:boolean false
|
|
143
|
-
def in_main:boolean false
|
|
144
|
-
def is_block:boolean false
|
|
145
|
-
def is_lambda:boolean false
|
|
146
|
-
def is_capturing:boolean false
|
|
147
|
-
def is_catch_block:boolean false
|
|
148
|
-
def is_try_block:boolean false
|
|
149
|
-
def captured_variables:[string]
|
|
150
|
-
def has_block_exited:boolean false
|
|
151
|
-
def in_expression:boolean false
|
|
152
|
-
def expr_stack:[boolean]
|
|
153
|
-
def expr_restart:boolean false
|
|
154
|
-
def expr_restart_block:boolean false
|
|
155
|
-
def in_method:boolean false
|
|
156
|
-
def method_stack:[boolean]
|
|
157
|
-
def typeNames:[string]
|
|
158
|
-
def typeClasses:[string:RangerTypeClass]
|
|
159
|
-
def currentClassName:string
|
|
160
|
-
def in_class:boolean false
|
|
161
|
-
def in_static_method:boolean false
|
|
162
|
-
def currentClass@(weak):RangerAppClassDesc
|
|
163
|
-
def currentMethod@(weak):RangerAppFunctionDesc
|
|
164
|
-
def thisName:string "this"
|
|
165
|
-
def definedEnums:[string:RangerAppEnum]
|
|
166
|
-
def definedInterfaces:[string:RangerAppClassDesc]
|
|
167
|
-
def definedInterfaceList:[string]
|
|
168
|
-
def definedClasses:[string:RangerAppClassDesc]
|
|
169
|
-
def definedClassList:[string]
|
|
170
|
-
; NEW: list of tasks defined
|
|
171
|
-
def definedTasks:[string:RangerAppFunctionDesc]
|
|
172
|
-
def templateClassNodes@(weak):[string:CodeNode]
|
|
173
|
-
def templateClassList:[string]
|
|
174
|
-
def classSignatures:[string:string]
|
|
175
|
-
def classToSignature:[string:string]
|
|
176
|
-
def templateClasses:[string:RangerAppClassDesc]
|
|
177
|
-
def classStaticWriters@(weak):[string:CodeWriter]
|
|
178
|
-
def localVariables:[string:RangerAppParamDesc]
|
|
179
|
-
def localVarNames:[string]
|
|
180
|
-
|
|
181
|
-
def contextFlags:[string:boolean]
|
|
182
|
-
def settings:[string:string]
|
|
183
|
-
def compilerFlags:[string:boolean]
|
|
184
|
-
def compilerSettings:[string:string]
|
|
185
|
-
def parserErrors:[RangerCompilerMessage]
|
|
186
|
-
def compilerErrors:[RangerCompilerMessage]
|
|
187
|
-
def compilerMessages:[RangerCompilerMessage]
|
|
188
|
-
def compilerLog:[string:RangerCompilerMessage]
|
|
189
|
-
def todoList:[RangerAppTodo]
|
|
190
|
-
def definedMacro:[string:boolean]
|
|
191
|
-
def defCounts:[string:int]
|
|
192
|
-
def refTransform:[string:string]
|
|
193
|
-
def staticClassBodies:[CodeNode]
|
|
194
|
-
|
|
195
|
-
; operators reserved only for the plugin
|
|
196
|
-
def pluginSpecificOperators:[string:boolean]
|
|
197
|
-
|
|
198
|
-
def viewClassBody@(weak):[string:CodeNode]
|
|
199
|
-
def appPages@(weak):[string:CodeNode]
|
|
200
|
-
def appServices@(weak):[string:CodeNode]
|
|
201
|
-
|
|
202
|
-
def opNs:[string]
|
|
203
|
-
|
|
204
|
-
def langFilePath:string ""
|
|
205
|
-
def libraryPaths:[string]
|
|
206
|
-
def outputPath ""
|
|
207
|
-
|
|
208
|
-
def counters:TypeCounts (new TypeCounts)
|
|
209
|
-
def parser:RangerFlowParser
|
|
210
|
-
def compiler:LiveCompiler
|
|
211
|
-
def pluginNodes:[string:RangerNodeList]
|
|
212
|
-
def typedNodes:[string:RangerNodeList]
|
|
213
|
-
def registered_plugins:[RangerRegisteredPlugin]
|
|
214
|
-
|
|
215
|
-
def operatorFunction:(_:CodeNode (name:string) )
|
|
216
|
-
def lastBlockOp@(weak):CodeNode
|
|
217
|
-
|
|
218
|
-
def opFnsList@(weak):[string:CodeNode]
|
|
219
|
-
def test_compile:[boolean]
|
|
220
|
-
|
|
221
|
-
def activeTransaction:[ContextTransaction]
|
|
222
|
-
def transactions@(weak):[ContextTransaction]
|
|
223
|
-
|
|
224
|
-
def env@(weak):InputEnv
|
|
225
|
-
|
|
226
|
-
fn getEnv@(optional weak):InputEnv () {
|
|
227
|
-
def root (this.getRoot())
|
|
228
|
-
return root.env
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
fn setTestCompile () {
|
|
232
|
-
push test_compile true
|
|
233
|
-
}
|
|
234
|
-
fn unsetTestCompile () {
|
|
235
|
-
removeLast test_compile
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
fn isTestCompile:boolean () {
|
|
239
|
-
if (has test_compile) {
|
|
240
|
-
return true
|
|
241
|
-
}
|
|
242
|
-
if(!null? parent) {
|
|
243
|
-
return (parent.isTestCompile())
|
|
244
|
-
}
|
|
245
|
-
return false
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
fn addOpFn (name:string code@(strong):CodeNode) {
|
|
249
|
-
if(! (has opFnsList name)) {
|
|
250
|
-
set opFnsList name (r.expression)
|
|
251
|
-
}
|
|
252
|
-
def rootNode (unwrap (get opFnsList name))
|
|
253
|
-
push rootNode.children code
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
fn getOpFns:[CodeNode] (name:string) {
|
|
257
|
-
def rv:[CodeNode]
|
|
258
|
-
if (has opFnsList name) {
|
|
259
|
-
def ol (unwrap (get opFnsList name))
|
|
260
|
-
forEach ol.children {
|
|
261
|
-
def tmp@(temp) item
|
|
262
|
-
push rv tmp
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
if(!null? parent ) {
|
|
266
|
-
def list2 (this.parent.getOpFns(name))
|
|
267
|
-
forEach list2 {
|
|
268
|
-
def tmp@(temp) item
|
|
269
|
-
push rv tmp
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return rv
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
fn getLastBlockOp@(optional weak):CodeNode () {
|
|
276
|
-
if( this.isTestCompile()) {
|
|
277
|
-
def cn:CodeNode
|
|
278
|
-
cn = (r.expression)
|
|
279
|
-
return cn
|
|
280
|
-
}
|
|
281
|
-
if(!null? lastBlockOp) {
|
|
282
|
-
return lastBlockOp
|
|
283
|
-
}
|
|
284
|
-
if(!null? parent) {
|
|
285
|
-
return (this.parent.getLastBlockOp())
|
|
286
|
-
}
|
|
287
|
-
return lastBlockOp
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
fn removePluginOp( name:string ) {
|
|
291
|
-
def root (this.getRoot())
|
|
292
|
-
set root.pluginSpecificOperators name false
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
fn isPluginOp:boolean ( node:CodeNode ) {
|
|
296
|
-
if (has node.children) {
|
|
297
|
-
def fc (node.getFirst())
|
|
298
|
-
if( has fc.ns ) {
|
|
299
|
-
def firstNS (itemAt fc.ns 0)
|
|
300
|
-
def root (this.getRoot())
|
|
301
|
-
if(has root.pluginSpecificOperators firstNS) {
|
|
302
|
-
return (unwrap (get root.pluginSpecificOperators firstNS))
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
return false
|
|
307
|
-
}
|
|
308
|
-
fn addPlugin ( p@(temp):RangerRegisteredPlugin) {
|
|
309
|
-
def root (this.getRoot())
|
|
310
|
-
push root.registered_plugins p
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
fn findPluginsFor:[string] ( featureName:string ) {
|
|
314
|
-
def res:[string]
|
|
315
|
-
for registered_plugins p@(lives):RangerRegisteredPlugin i {
|
|
316
|
-
if( (indexOf p.features featureName) >= 0) {
|
|
317
|
-
push res p.name
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return res
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
fn addTypeClass@(weak):RangerTypeClass (name:string) {
|
|
324
|
-
def root (this.getRoot())
|
|
325
|
-
if( false == (has root.typeClasses name)) {
|
|
326
|
-
def newClass ( new RangerTypeClass )
|
|
327
|
-
set root.typeClasses name newClass
|
|
328
|
-
return newClass
|
|
329
|
-
}
|
|
330
|
-
return (unwrap (get root.typeClasses name))
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
fn getTypeClass@(optional):RangerTypeClass (name:string) {
|
|
334
|
-
def root (this.getRoot())
|
|
335
|
-
return (get root.typeClasses name)
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
fn getParser@(weak optional):RangerFlowParser () {
|
|
339
|
-
if(null? parser) {
|
|
340
|
-
if(!null? parent) {
|
|
341
|
-
return (parent.getParser())
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
return parser
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
fn getCompiler@(weak optional):LiveCompiler () {
|
|
348
|
-
if(null? compiler) {
|
|
349
|
-
if(!null? parent) {
|
|
350
|
-
return (parent.getCompiler())
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
return compiler
|
|
354
|
-
}
|
|
355
|
-
; typedNodes
|
|
356
|
-
fn getTypedNodes:[CodeNode] (name:string) {
|
|
357
|
-
def root (this.getRoot())
|
|
358
|
-
def res:[CodeNode]
|
|
359
|
-
def list (get root.typedNodes name)
|
|
360
|
-
if(!null? list) {
|
|
361
|
-
list.items.forEach({
|
|
362
|
-
def tmp@(lives) item
|
|
363
|
-
push res tmp
|
|
364
|
-
})
|
|
365
|
-
}
|
|
366
|
-
return res
|
|
367
|
-
}
|
|
368
|
-
fn addTypedNode ( name:string op@(temp):CodeNode ) {
|
|
369
|
-
def root (this.getRoot())
|
|
370
|
-
if( has root.typedNodes name ) {
|
|
371
|
-
def orig_list (unwrap (get root.typedNodes name))
|
|
372
|
-
push orig_list.items op
|
|
373
|
-
} {
|
|
374
|
-
def new_list (new RangerNodeList)
|
|
375
|
-
push new_list.items op
|
|
376
|
-
set root.typedNodes name new_list
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
fn getPluginNodes:[CodeNode] (name:string) {
|
|
381
|
-
def root (this.getRoot())
|
|
382
|
-
def res:[CodeNode]
|
|
383
|
-
def list (get root.pluginNodes name)
|
|
384
|
-
if(!null? list) {
|
|
385
|
-
list.items.forEach({
|
|
386
|
-
def tmp@(lives) item
|
|
387
|
-
push res tmp
|
|
388
|
-
})
|
|
389
|
-
}
|
|
390
|
-
return res
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
fn addPluginNode ( name:string op@(temp):CodeNode ) {
|
|
394
|
-
def root (this.getRoot())
|
|
395
|
-
if( has root.pluginNodes name ) {
|
|
396
|
-
def orig_list (unwrap (get root.pluginNodes name))
|
|
397
|
-
push orig_list.items op
|
|
398
|
-
} {
|
|
399
|
-
def new_list (new RangerNodeList)
|
|
400
|
-
push new_list.items op
|
|
401
|
-
set root.pluginNodes name new_list
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
; the operator listing
|
|
406
|
-
fn addOperator ( op@(temp strong):RangerAppOperatorDesc ) {
|
|
407
|
-
def root (this.getRoot())
|
|
408
|
-
if( (strlen op.name) > 0 ) {
|
|
409
|
-
if( has root.op_list op.name ) {
|
|
410
|
-
def orig_list (unwrap (get root.op_list op.name))
|
|
411
|
-
push orig_list.items op
|
|
412
|
-
} {
|
|
413
|
-
def new_list (new RangerOperatorList)
|
|
414
|
-
push new_list.items op
|
|
415
|
-
set root.op_list op.name new_list
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
fn getAllOperators:[RangerAppOperatorDesc] () {
|
|
421
|
-
def root (this.getRoot())
|
|
422
|
-
def res:[RangerAppOperatorDesc]
|
|
423
|
-
root.op_list.forEach({
|
|
424
|
-
item.items.forEach({
|
|
425
|
-
def tmp@(lives) item
|
|
426
|
-
push res tmp
|
|
427
|
-
})
|
|
428
|
-
})
|
|
429
|
-
return res
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
fn getOperatorsOf:[RangerAppOperatorDesc] (name:string) {
|
|
433
|
-
; support for context specific operators ?
|
|
434
|
-
def root (this.getRoot())
|
|
435
|
-
def res:[RangerAppOperatorDesc]
|
|
436
|
-
def list (get root.op_list name)
|
|
437
|
-
if(!null? list) {
|
|
438
|
-
return (clone list.items)
|
|
439
|
-
}
|
|
440
|
-
return res
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
fn initOpList () {
|
|
444
|
-
def root (this.getRoot())
|
|
445
|
-
if(!null? root.operators) {
|
|
446
|
-
def op (unwrap root.operators) ; RangerActiveOperators
|
|
447
|
-
|
|
448
|
-
op.initializeOpCache()
|
|
449
|
-
|
|
450
|
-
def foo (op.getOperators("+"))
|
|
451
|
-
if( (array_length foo) > 0 ) {
|
|
452
|
-
op.opHash.forEach({
|
|
453
|
-
def op_name index
|
|
454
|
-
item.list.forEach({
|
|
455
|
-
def fc:CodeNode (item.getFirst())
|
|
456
|
-
def nameNode@(lives):CodeNode (item.getSecond())
|
|
457
|
-
def args:CodeNode (item.getThird())
|
|
458
|
-
def newOp@(lives) (new RangerAppOperatorDesc)
|
|
459
|
-
newOp.name = op_name
|
|
460
|
-
newOp.node = item
|
|
461
|
-
newOp.nameNode = nameNode
|
|
462
|
-
newOp.op_params = args.children
|
|
463
|
-
if( (array_length args.children) > 0 ) {
|
|
464
|
-
newOp.firstArg = (itemAt args.children 0)
|
|
465
|
-
}
|
|
466
|
-
this.addOperator( newOp )
|
|
467
|
-
})
|
|
468
|
-
})
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
} {
|
|
472
|
-
|
|
473
|
-
; print ">> could not initialize the operator list!!!"
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
; assuming there is a node which defines the type, for example current function
|
|
478
|
-
; return value or something like that
|
|
479
|
-
|
|
480
|
-
fn incLambdaCnt() {
|
|
481
|
-
def root (this.getRoot())
|
|
482
|
-
root.counters.interface_cnt = root.counters.interface_cnt + 1
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
fn createNewRegName:string () {
|
|
486
|
-
def root (this.findFunctionCtx())
|
|
487
|
-
root.counters.register_cnt = root.counters.register_cnt + 1
|
|
488
|
-
return ( '__REGx' + root.counters.register_cnt )
|
|
489
|
-
}
|
|
490
|
-
fn createNewOpFnName:string () {
|
|
491
|
-
def root (this.findFunctionCtx())
|
|
492
|
-
root.counters.opfn_cnt = root.counters.opfn_cnt + 1
|
|
493
|
-
return ( '__tmpOpFn' + root.counters.opfn_cnt )
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
fn isTryBlock:boolean () {
|
|
497
|
-
if expr_restart {
|
|
498
|
-
return false
|
|
499
|
-
}
|
|
500
|
-
if is_try_block {
|
|
501
|
-
return true
|
|
502
|
-
}
|
|
503
|
-
if(!null? parent) {
|
|
504
|
-
return (parent.isTryBlock())
|
|
505
|
-
}
|
|
506
|
-
return false
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
fn isCatchBlock:boolean () {
|
|
510
|
-
if expr_restart {
|
|
511
|
-
return false
|
|
512
|
-
}
|
|
513
|
-
if is_catch_block {
|
|
514
|
-
return true
|
|
515
|
-
}
|
|
516
|
-
if(!null? parent) {
|
|
517
|
-
return (parent.isCatchBlock())
|
|
518
|
-
}
|
|
519
|
-
return false
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
fn pushAndCollectAst (rootNode:CodeNode wr:CodeWriter ) {
|
|
523
|
-
def myParser (new RangerFlowParser())
|
|
524
|
-
myParser.CollectMethods( rootNode this wr )
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
fn pushAndCompileAst (rootNode:CodeNode wr:CodeWriter ) {
|
|
528
|
-
def myParser (new RangerFlowParser())
|
|
529
|
-
myParser.CollectMethods( rootNode this wr )
|
|
530
|
-
myParser.StartWalk( rootNode this wr)
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
fn pushAst (source_code:string node:CodeNode wr:CodeWriter ) {
|
|
534
|
-
|
|
535
|
-
def code:SourceCode (new SourceCode ( source_code ))
|
|
536
|
-
code.filename = 'dynamically_generated'
|
|
537
|
-
def parser:RangerLispParser (new RangerLispParser (code))
|
|
538
|
-
parser.parse((this.hasCompilerFlag("no-op-transform")))
|
|
539
|
-
|
|
540
|
-
if(parser.rootNode) {
|
|
541
|
-
def root (unwrap parser.rootNode)
|
|
542
|
-
push node.children root
|
|
543
|
-
|
|
544
|
-
; def rootCtx (this.getRoot())
|
|
545
|
-
; myParser.CollectMethods( root rootCtx wr )
|
|
546
|
-
; myParser.StartWalk( root rootCtx wr)
|
|
547
|
-
; print "--> did push new source code"
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
fn pushAndCollectCode (source_code:string wr:CodeWriter ) {
|
|
552
|
-
def code:SourceCode (new SourceCode ( source_code ))
|
|
553
|
-
code.filename = 'dynamically_generated'
|
|
554
|
-
def parser:RangerLispParser (new RangerLispParser (code))
|
|
555
|
-
parser.parse((this.hasCompilerFlag("no-op-transform")))
|
|
556
|
-
if(parser.rootNode) {
|
|
557
|
-
def root (unwrap parser.rootNode)
|
|
558
|
-
def myParser (new RangerFlowParser())
|
|
559
|
-
def rootCtx (this.getRoot())
|
|
560
|
-
myParser.CollectMethods( root rootCtx wr )
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
fn pushCode (source_code:string wr:CodeWriter ) {
|
|
565
|
-
|
|
566
|
-
def code:SourceCode (new SourceCode ( source_code ))
|
|
567
|
-
code.filename = 'dynamically_generated'
|
|
568
|
-
def parser:RangerLispParser (new RangerLispParser (code))
|
|
569
|
-
parser.parse((this.hasCompilerFlag("no-op-transform")))
|
|
570
|
-
|
|
571
|
-
if(parser.rootNode) {
|
|
572
|
-
def root (unwrap parser.rootNode)
|
|
573
|
-
def myParser (new RangerFlowParser())
|
|
574
|
-
; def myParser (this.getParser())
|
|
575
|
-
def rootCtx (this.getRoot())
|
|
576
|
-
myParser.CollectMethods( root rootCtx wr )
|
|
577
|
-
myParser.StartWalk( root rootCtx wr)
|
|
578
|
-
; print "--> did push new source code"
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
fn addViewClassBody ( name:string classDef:CodeNode ) {
|
|
583
|
-
def root (this.getRoot())
|
|
584
|
-
set root.viewClassBody name classDef
|
|
585
|
-
}
|
|
586
|
-
fn addPage ( name:string classDef:CodeNode ) {
|
|
587
|
-
def root (this.getRoot())
|
|
588
|
-
set root.appPages name classDef
|
|
589
|
-
}
|
|
590
|
-
fn addService ( name:string classDef:CodeNode ) {
|
|
591
|
-
def root (this.getRoot())
|
|
592
|
-
set root.appServices name classDef
|
|
593
|
-
}
|
|
594
|
-
fn getViewClass@(optional):CodeNode (s_name:string) {
|
|
595
|
-
def res@(optional temp):CodeNode
|
|
596
|
-
if (has viewClassBody s_name) {
|
|
597
|
-
res = (get viewClassBody s_name)
|
|
598
|
-
return res
|
|
599
|
-
}
|
|
600
|
-
if (null? parent) {
|
|
601
|
-
return res
|
|
602
|
-
}
|
|
603
|
-
return (parent.getViewClass(s_name))
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
fn addOpNs ( n:string ) {
|
|
607
|
-
push opNs n
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
fn removeOpNs ( n:string ) {
|
|
611
|
-
def idx (indexOf opNs n )
|
|
612
|
-
if( idx >= 0 ) {
|
|
613
|
-
remove_index opNs idx
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
fn inLambda:boolean () {
|
|
618
|
-
if( is_lambda ) {
|
|
619
|
-
return true
|
|
620
|
-
}
|
|
621
|
-
if( !null? parent ) {
|
|
622
|
-
return (parent.inLambda())
|
|
623
|
-
}
|
|
624
|
-
return false
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
fn variableTypeUsage:[string] () {
|
|
628
|
-
def res:[string:boolean]
|
|
629
|
-
def cc@(optional weak) this
|
|
630
|
-
while(!null? cc) {
|
|
631
|
-
cc.localVariables.forEach({
|
|
632
|
-
if(!null? item.nameNode) {
|
|
633
|
-
set res item.nameNode.type_name true
|
|
634
|
-
set res item.nameNode.key_type true
|
|
635
|
-
set res item.nameNode.array_type true
|
|
636
|
-
}
|
|
637
|
-
})
|
|
638
|
-
cc = (cc.parent)
|
|
639
|
-
}
|
|
640
|
-
return (keys res)
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
fn writeContextVars( wr:CodeWriter ) {
|
|
645
|
-
localVariables.forEach({
|
|
646
|
-
; item, index
|
|
647
|
-
wr.out( ("def " + index + ":" ) false)
|
|
648
|
-
if(!null? item.nameNode) {
|
|
649
|
-
def r (new RangerRangerClassWriter)
|
|
650
|
-
r.writeTypeDef( (unwrap item.nameNode) this wr)
|
|
651
|
-
}
|
|
652
|
-
wr.out( ( "(" + item.compiledName + ")" ) false )
|
|
653
|
-
wr.out("" true)
|
|
654
|
-
})
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
fn writeContextInfo( wr:CodeWriter) {
|
|
658
|
-
def cList@(weak):[RangerAppWriterContext]
|
|
659
|
-
def c@(lives) (this)
|
|
660
|
-
|
|
661
|
-
cList.push(c)
|
|
662
|
-
while( (!null? c.parent) ) {
|
|
663
|
-
c = (unwrap c.parent)
|
|
664
|
-
cList.push(c)
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
def idx (array_length cList)
|
|
668
|
-
def cnt idx
|
|
669
|
-
while( idx > 0) {
|
|
670
|
-
idx = idx - 1
|
|
671
|
-
wr.out("{" true)
|
|
672
|
-
wr.indent(1)
|
|
673
|
-
def cc ( itemAt cList idx)
|
|
674
|
-
cc.writeContextVars( wr )
|
|
675
|
-
}
|
|
676
|
-
while (cnt > 0 ) {
|
|
677
|
-
wr.indent(-1)
|
|
678
|
-
wr.out("}" true)
|
|
679
|
-
cnt = cnt - 1
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
fn getContextInfo:string () {
|
|
684
|
-
def wr (new CodeWriter)
|
|
685
|
-
this.writeContextInfo( wr )
|
|
686
|
-
return (wr.getCode())
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
fn isCapturing:boolean () {
|
|
690
|
-
if(is_capturing) {
|
|
691
|
-
return true
|
|
692
|
-
}
|
|
693
|
-
if parent {
|
|
694
|
-
return (parent.isCapturing())
|
|
695
|
-
}
|
|
696
|
-
return false
|
|
697
|
-
}
|
|
698
|
-
fn forkWithOps:RangerAppWriterContext (opNode:CodeNode) {
|
|
699
|
-
def ops (this.getOperatorDef())
|
|
700
|
-
def new_ops (ops.fork(opNode))
|
|
701
|
-
def new_ctx (this.fork())
|
|
702
|
-
new_ctx.operators = new_ops
|
|
703
|
-
return new_ctx
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
fn getOperatorDef:RangerActiveOperators () {
|
|
707
|
-
if(!null? operators) {
|
|
708
|
-
return (unwrap operators)
|
|
709
|
-
}
|
|
710
|
-
if(!null? parent) {
|
|
711
|
-
return (parent.getOperatorDef())
|
|
712
|
-
}
|
|
713
|
-
def nothingFound:RangerActiveOperators (new RangerActiveOperators)
|
|
714
|
-
return nothingFound
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
fn getOperators:[CodeNode] (name:string) {
|
|
718
|
-
def root (this.getRoot())
|
|
719
|
-
def cc this
|
|
720
|
-
def opNamespace:[string]
|
|
721
|
-
if( (array_length opNs) > 0) {
|
|
722
|
-
for opNs nsName:string i {
|
|
723
|
-
push opNamespace nsName
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
while (!null? cc.parent) {
|
|
727
|
-
cc = (unwrap cc.parent)
|
|
728
|
-
if( (array_length cc.opNs) > 0) {
|
|
729
|
-
for cc.opNs nsName:string i {
|
|
730
|
-
push opNamespace nsName
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
if(!null? root.operators) {
|
|
735
|
-
def op (unwrap root.operators)
|
|
736
|
-
def listOfOps:[CodeNode]
|
|
737
|
-
def handled:[string:boolean]
|
|
738
|
-
for opNamespace ss:string i {
|
|
739
|
-
if( has handled ss ) {
|
|
740
|
-
continue
|
|
741
|
-
}
|
|
742
|
-
set handled ss true
|
|
743
|
-
def nsOps (op.getOperators(ss + "." + name))
|
|
744
|
-
for nsOps ns_op:CodeNode i {
|
|
745
|
-
push listOfOps ns_op
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
def plainOps (op.getOperators(name))
|
|
749
|
-
for plainOps ppn@(lives):CodeNode i {
|
|
750
|
-
push listOfOps ppn
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
if_javascript {
|
|
754
|
-
def cc@(weak):RangerAppWriterContext
|
|
755
|
-
cc = this
|
|
756
|
-
while(!null? cc) {
|
|
757
|
-
if(!null? cc.operatorFunction) {
|
|
758
|
-
def opFn:(_:CodeNode (name:string)) (unwrap cc.operatorFunction)
|
|
759
|
-
def suggestedOp (opFn(name))
|
|
760
|
-
suggestedOp.children.forEach({
|
|
761
|
-
insert listOfOps 0 (item.copy())
|
|
762
|
-
})
|
|
763
|
-
}
|
|
764
|
-
cc = cc.parent
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
return listOfOps
|
|
768
|
-
}
|
|
769
|
-
def nothingFound:[CodeNode]
|
|
770
|
-
return nothingFound
|
|
771
|
-
}
|
|
772
|
-
; 1. isVarDefined
|
|
773
|
-
; 2. isLocalToCapture, if false
|
|
774
|
-
; 3. addCapturedVariable
|
|
775
|
-
fn isLocalToCapture:boolean (name:string) {
|
|
776
|
-
if( (has localVariables name) ) {
|
|
777
|
-
return true
|
|
778
|
-
}
|
|
779
|
-
; not local, because this context is capturing
|
|
780
|
-
if(is_capturing) {
|
|
781
|
-
return false
|
|
782
|
-
}
|
|
783
|
-
if(parent) {
|
|
784
|
-
return (parent.isLocalToCapture(name))
|
|
785
|
-
}
|
|
786
|
-
return false
|
|
787
|
-
}
|
|
788
|
-
fn addCapturedVariable:void (name:string) {
|
|
789
|
-
|
|
790
|
-
if(is_capturing) {
|
|
791
|
-
if ( (indexOf captured_variables name) < 0 ) {
|
|
792
|
-
push captured_variables name
|
|
793
|
-
}
|
|
794
|
-
return
|
|
795
|
-
}
|
|
796
|
-
if(parent) {
|
|
797
|
-
parent.addCapturedVariable( name )
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
fn getCapturedVariables@(weak):[string] () {
|
|
801
|
-
if(is_capturing) {
|
|
802
|
-
return captured_variables
|
|
803
|
-
}
|
|
804
|
-
if(parent) {
|
|
805
|
-
def r@(weak):[string] ( parent.getCapturedVariables() )
|
|
806
|
-
return r
|
|
807
|
-
}
|
|
808
|
-
def res:[string]
|
|
809
|
-
return res
|
|
810
|
-
}
|
|
811
|
-
fn transformOpNameWord:string (input_word:string) {
|
|
812
|
-
def len (strlen input_word)
|
|
813
|
-
def i 0
|
|
814
|
-
def res ""
|
|
815
|
-
while (i < len) {
|
|
816
|
-
def cc (charAt input_word i)
|
|
817
|
-
if ( ((cc >= (ccode "a")) && (cc <= (ccode "z")) ) || ( ((cc >= (ccode "A")) && (cc <= (ccode "Y")) ) )) {
|
|
818
|
-
res = res + (strfromcode cc)
|
|
819
|
-
} {
|
|
820
|
-
res = res + "c"+ (cc)
|
|
821
|
-
}
|
|
822
|
-
i = i + 1
|
|
823
|
-
}
|
|
824
|
-
return res
|
|
825
|
-
}
|
|
826
|
-
fn transformWord:string (input_word:string) {
|
|
827
|
-
switch input_word {
|
|
828
|
-
case "map" {
|
|
829
|
-
return "_map"
|
|
830
|
-
}
|
|
831
|
-
default {
|
|
832
|
-
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
def root (this.getRoot())
|
|
836
|
-
root.initReservedWords()
|
|
837
|
-
if(has refTransform input_word) {
|
|
838
|
-
return (unwrap (get refTransform input_word))
|
|
839
|
-
}
|
|
840
|
-
return input_word
|
|
841
|
-
}
|
|
842
|
-
fn initReservedWords:boolean () {
|
|
843
|
-
; reserved_word_transformations
|
|
844
|
-
if(!null? reservedWords) {
|
|
845
|
-
return true
|
|
846
|
-
}
|
|
847
|
-
def main:CodeNode langOperators
|
|
848
|
-
def lang:CodeNode
|
|
849
|
-
for main.children m:CodeNode i {
|
|
850
|
-
def fc:CodeNode (m.getFirst())
|
|
851
|
-
if (fc.vref == "language") {
|
|
852
|
-
lang = m
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
def cmds:CodeNode
|
|
856
|
-
def langNodes:CodeNode (itemAt lang.children 1)
|
|
857
|
-
for langNodes.children lch:CodeNode i {
|
|
858
|
-
def fc:CodeNode (lch.getFirst())
|
|
859
|
-
if (fc.vref == "reserved_words") {
|
|
860
|
-
def n:CodeNode (lch.getSecond())
|
|
861
|
-
reservedWords = (lch.getSecond())
|
|
862
|
-
for reservedWords.children ch:CodeNode i {
|
|
863
|
-
def word (ch.getFirst())
|
|
864
|
-
def transform (ch.getSecond())
|
|
865
|
-
set refTransform word.vref transform.vref
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
return true
|
|
870
|
-
}
|
|
871
|
-
fn initStdCommands:boolean () {
|
|
872
|
-
if (!null? stdCommands) {
|
|
873
|
-
return true
|
|
874
|
-
}
|
|
875
|
-
if (null? langOperators) {
|
|
876
|
-
return true
|
|
877
|
-
}
|
|
878
|
-
def main:CodeNode langOperators
|
|
879
|
-
def lang:CodeNode
|
|
880
|
-
for main.children m:CodeNode i {
|
|
881
|
-
def fc:CodeNode (m.getFirst())
|
|
882
|
-
if (fc.vref == "language") {
|
|
883
|
-
lang = m
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
def cmds:CodeNode
|
|
887
|
-
def langNodes:CodeNode (itemAt lang.children 1)
|
|
888
|
-
for langNodes.children lch:CodeNode i {
|
|
889
|
-
def fc:CodeNode (lch.getFirst())
|
|
890
|
-
if (fc.vref == "commands") {
|
|
891
|
-
|
|
892
|
-
def n:CodeNode (lch.getSecond())
|
|
893
|
-
stdCommands = (lch.getSecond())
|
|
894
|
-
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
return true
|
|
898
|
-
}
|
|
899
|
-
fn transformTypeName:string (typeName:string) {
|
|
900
|
-
if (this.isPrimitiveType(typeName)) {
|
|
901
|
-
return typeName
|
|
902
|
-
}
|
|
903
|
-
if (this.isEnumDefined(typeName)) {
|
|
904
|
-
return typeName
|
|
905
|
-
}
|
|
906
|
-
if (this.isDefinedClass(typeName)) {
|
|
907
|
-
def cl:RangerAppClassDesc (this.findClass(typeName))
|
|
908
|
-
if cl.is_system {
|
|
909
|
-
return (unwrap (get cl.systemNames (this.getTargetLang())))
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
return typeName
|
|
913
|
-
}
|
|
914
|
-
fn isPrimitiveType:boolean (typeName:string) {
|
|
915
|
-
if ((((((typeName == "double") || (typeName == "string")) || (typeName == "int")) || (typeName == "char")) || (typeName == "charbuffer")) || (typeName == "boolean")) {
|
|
916
|
-
return true
|
|
917
|
-
}
|
|
918
|
-
return false
|
|
919
|
-
}
|
|
920
|
-
fn isDefinedType:boolean (typeName:string) {
|
|
921
|
-
if( typeName == "Any") {
|
|
922
|
-
return true
|
|
923
|
-
}
|
|
924
|
-
if ((((((typeName == "double") || (typeName == "string")) || (typeName == "int")) || (typeName == "char")) || (typeName == "charbuffer")) || (typeName == "boolean")) {
|
|
925
|
-
return true
|
|
926
|
-
}
|
|
927
|
-
if (this.isEnumDefined(typeName)) {
|
|
928
|
-
return true
|
|
929
|
-
}
|
|
930
|
-
if (this.isDefinedClass(typeName)) {
|
|
931
|
-
return true
|
|
932
|
-
}
|
|
933
|
-
return false
|
|
934
|
-
}
|
|
935
|
-
fn hadValidType:boolean (node@(weak):CodeNode) {
|
|
936
|
-
if ((node.isPrimitiveType()) || (node.isPrimitive())) {
|
|
937
|
-
return true
|
|
938
|
-
}
|
|
939
|
-
if(node.value_type == RangerNodeType.Array) {
|
|
940
|
-
if (this.isDefinedType(node.array_type)) {
|
|
941
|
-
return true
|
|
942
|
-
} {
|
|
943
|
-
this.addError(node ('Unknown type for array values: ' + node.array_type))
|
|
944
|
-
return false
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
if(node.value_type == RangerNodeType.Hash) {
|
|
948
|
-
if ( (this.isDefinedType(node.array_type)) && (this.isPrimitiveType(node.key_type)) ) {
|
|
949
|
-
return true
|
|
950
|
-
} {
|
|
951
|
-
if( (this.isDefinedType(node.array_type)) == false) {
|
|
952
|
-
this.addError(node ('Unknown type for map values: ' + node.array_type))
|
|
953
|
-
}
|
|
954
|
-
if( (this.isDefinedType(node.key_type)) == false) {
|
|
955
|
-
this.addError(node ('Unknown type for map keys: ' + node.key_type))
|
|
956
|
-
}
|
|
957
|
-
return false
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
if (this.isEnumDefined(node.type_name)) {
|
|
961
|
-
return true
|
|
962
|
-
}
|
|
963
|
-
if (this.isDefinedType(node.type_name)) {
|
|
964
|
-
return true
|
|
965
|
-
} {
|
|
966
|
-
if (node.value_type == RangerNodeType.ExpressionType) {
|
|
967
|
-
; def sec:CodeNode (itemAt node.expression_value.children 1)
|
|
968
|
-
; def fc:CodeNode (sec.getFirst())
|
|
969
|
-
} {
|
|
970
|
-
this.addError(node ('Unknown type: ' + node.type_name + " type ID : " + node.value_type))
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
; this.addError(node ((((('Invalid or missing type definition: ' + node.type_name) + " ") + node.key_type) + " ") + node.array_type))
|
|
974
|
-
return false
|
|
975
|
-
}
|
|
976
|
-
fn findOperator:CodeNode (node:CodeNode) {
|
|
977
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
978
|
-
root.initStdCommands()
|
|
979
|
-
if(!null? node.operator_node) {
|
|
980
|
-
return (unwrap node.operator_node)
|
|
981
|
-
}
|
|
982
|
-
return (itemAt root.stdCommands.children node.op_index)
|
|
983
|
-
}
|
|
984
|
-
fn getStdCommands@(weak):CodeNode () {
|
|
985
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
986
|
-
root.initStdCommands()
|
|
987
|
-
return (unwrap root.stdCommands)
|
|
988
|
-
}
|
|
989
|
-
fn findOperatorsWithName@(weak):[CodeNode] (name:string) {
|
|
990
|
-
def res@(weak lives):[CodeNode]
|
|
991
|
-
forEach ((this.getStdCommands()) .children) {
|
|
992
|
-
if(item.isFirstVref(name)) {
|
|
993
|
-
push res item
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
return res
|
|
997
|
-
}
|
|
998
|
-
fn findClassWithSign:RangerAppClassDesc (node:CodeNode) {
|
|
999
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1000
|
-
def tplArgs:CodeNode node.vref_annotation
|
|
1001
|
-
def sign:string (node.vref + (tplArgs.getCode()))
|
|
1002
|
-
def theName:string (get root.classSignatures sign)
|
|
1003
|
-
return (this.findClass((unwrap theName)))
|
|
1004
|
-
}
|
|
1005
|
-
fn createSignature:string (origClass:string classSig:string) {
|
|
1006
|
-
if (has classSignatures classSig) {
|
|
1007
|
-
return (unwrap (get classSignatures classSig))
|
|
1008
|
-
}
|
|
1009
|
-
def ii:int 1
|
|
1010
|
-
def sigName:string ((origClass + "V") + ii)
|
|
1011
|
-
while (has classToSignature sigName) {
|
|
1012
|
-
ii = (ii + 1)
|
|
1013
|
-
sigName = ((origClass + "V") + ii)
|
|
1014
|
-
}
|
|
1015
|
-
set classToSignature sigName classSig
|
|
1016
|
-
set classSignatures classSig sigName
|
|
1017
|
-
return sigName
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
fn createStaticMethod:RangerAppFunctionDesc (withName:string currC:RangerAppClassDesc nameNode:CodeNode argsNode:CodeNode fnBody:CodeNode parser:RangerFlowParser wr:CodeWriter ) {
|
|
1021
|
-
def s:string withName
|
|
1022
|
-
def m@(lives):RangerAppFunctionDesc (new RangerAppFunctionDesc ())
|
|
1023
|
-
|
|
1024
|
-
;print "createStaticMethod -> name " + withName + " namenode type == " + nameNode.type_name + " class " + currC.name
|
|
1025
|
-
;print "body of the static method ==> " + (fnBody.getCode())
|
|
1026
|
-
;print "arguments of static => " + (argsNode.getCode())
|
|
1027
|
-
|
|
1028
|
-
m.name = s
|
|
1029
|
-
m.compiledName = (this.transformWord(s))
|
|
1030
|
-
m.node = nameNode
|
|
1031
|
-
m.nameNode = nameNode
|
|
1032
|
-
def rCtx (this.getRoot())
|
|
1033
|
-
m.fnCtx = (rCtx.fork())
|
|
1034
|
-
m.is_static = true
|
|
1035
|
-
m.nameNode.ifNoTypeSetToVoid()
|
|
1036
|
-
def args:CodeNode argsNode
|
|
1037
|
-
m.fnBody = fnBody
|
|
1038
|
-
parser.CheckTypeAnnotationOf( (unwrap m.nameNode) rCtx wr )
|
|
1039
|
-
|
|
1040
|
-
; print "---> compiled to " + m.compiledName
|
|
1041
|
-
|
|
1042
|
-
for args.children arg@(lives):CodeNode ii {
|
|
1043
|
-
|
|
1044
|
-
if(arg.hasFlag("noeval")) {
|
|
1045
|
-
continue
|
|
1046
|
-
}
|
|
1047
|
-
; if(arg.hasFlag("keyword")) {
|
|
1048
|
-
; continue
|
|
1049
|
-
; }
|
|
1050
|
-
|
|
1051
|
-
def p@(lives temp):RangerAppParamDesc (new RangerAppParamDesc ())
|
|
1052
|
-
p.name = arg.vref
|
|
1053
|
-
if(p.name == "self") {
|
|
1054
|
-
p.compiledName = "__self"
|
|
1055
|
-
}
|
|
1056
|
-
p.value_type = arg.value_type
|
|
1057
|
-
p.node = arg
|
|
1058
|
-
p.init_cnt = 1
|
|
1059
|
-
p.nameNode = arg
|
|
1060
|
-
|
|
1061
|
-
parser.CheckTypeAnnotationOf( arg rCtx wr )
|
|
1062
|
-
|
|
1063
|
-
p.refType = RangerNodeRefType.Weak
|
|
1064
|
-
p.varType = RangerContextVarType.FunctionParameter
|
|
1065
|
-
push m.params p
|
|
1066
|
-
arg.hasParamDesc = true
|
|
1067
|
-
arg.paramDesc = p
|
|
1068
|
-
arg.eval_type = arg.value_type
|
|
1069
|
-
arg.eval_type_name = arg.type_name
|
|
1070
|
-
if (arg.hasFlag("strong")) {
|
|
1071
|
-
p.changeStrength(1 1 (unwrap p.nameNode))
|
|
1072
|
-
} {
|
|
1073
|
-
arg.setFlag("lives")
|
|
1074
|
-
p.changeStrength(0 1 (unwrap p.nameNode))
|
|
1075
|
-
}
|
|
1076
|
-
;m.fnCtx.defineVariable( arg.vref p)
|
|
1077
|
-
}
|
|
1078
|
-
currC.addStaticMethod(m)
|
|
1079
|
-
return m
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
fn canUseTypeInference:boolean ( nameNode:CodeNode ) {
|
|
1083
|
-
def b_allow_ti (this.hasCompilerFlag('allowti'))
|
|
1084
|
-
def b_multitype false
|
|
1085
|
-
if( b_allow_ti ) {
|
|
1086
|
-
def t_name (nameNode.type_name)
|
|
1087
|
-
if( has nameNode.eval_type_name) {
|
|
1088
|
-
t_name = nameNode.eval_type_name
|
|
1089
|
-
}
|
|
1090
|
-
if(this.isDefinedClass(t_name)) {
|
|
1091
|
-
def cc (this.findClass(t_name))
|
|
1092
|
-
b_multitype = cc.is_union || cc.is_system || cc.is_system_union || cc.is_trait || cc.is_inherited || ( (array_length cc.extends_classes) > 0 )
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
return (b_allow_ti && (false == b_multitype) )
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
fn createOpStaticClass@(weak):RangerAppClassDesc (name:string) {
|
|
1099
|
-
def nameWillBe ("operatorsOf" + name)
|
|
1100
|
-
def str ""
|
|
1101
|
-
def i 0
|
|
1102
|
-
def len (strlen nameWillBe)
|
|
1103
|
-
while( i < len ) {
|
|
1104
|
-
def c (charAt nameWillBe i)
|
|
1105
|
-
if(c == (charcode ".")) {
|
|
1106
|
-
str = str + "_"
|
|
1107
|
-
} {
|
|
1108
|
-
str = str + (substring nameWillBe i (i + 1))
|
|
1109
|
-
}
|
|
1110
|
-
i = i + 1
|
|
1111
|
-
}
|
|
1112
|
-
if(this.isDefinedClass(str)) {
|
|
1113
|
-
return (this.findClass(str))
|
|
1114
|
-
}
|
|
1115
|
-
; return
|
|
1116
|
-
|
|
1117
|
-
def tpl_code ("class " + str + " {
|
|
1118
|
-
}")
|
|
1119
|
-
|
|
1120
|
-
def code:SourceCode (new SourceCode ( tpl_code ))
|
|
1121
|
-
code.filename = str + ".ranger"
|
|
1122
|
-
def parser:RangerLispParser (new RangerLispParser (code))
|
|
1123
|
-
parser.parse(false)
|
|
1124
|
-
|
|
1125
|
-
; this.CheckTypeAnnotationOf( (unwrap m.nameNode) ctx wr )
|
|
1126
|
-
|
|
1127
|
-
def classRoot@(lives) (itemAt parser.rootNode.children 0)
|
|
1128
|
-
def classNameNode@(lives) (classRoot.getSecond())
|
|
1129
|
-
classNameNode.vref = str
|
|
1130
|
-
def new_class@(lives):RangerAppClassDesc (new RangerAppClassDesc ())
|
|
1131
|
-
new_class.name = str
|
|
1132
|
-
new_class.compiledName = str
|
|
1133
|
-
new_class.is_operator_class = true
|
|
1134
|
-
new_class.nameNode = classNameNode
|
|
1135
|
-
new_class.classNode = classRoot
|
|
1136
|
-
|
|
1137
|
-
def subCtx@(lives):RangerAppWriterContext (this.fork())
|
|
1138
|
-
subCtx.setCurrentClass(new_class)
|
|
1139
|
-
new_class.ctx = subCtx
|
|
1140
|
-
|
|
1141
|
-
def root (this.getRoot())
|
|
1142
|
-
root.addClass(str new_class)
|
|
1143
|
-
classNameNode.clDesc = new_class
|
|
1144
|
-
push staticClassBodies classRoot
|
|
1145
|
-
return new_class
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
fn createTraitInstanceClass@(optional weak):RangerAppClassDesc ( traitName:string instanceName:string initParams:CodeNode flowParser:RangerFlowParser wr:CodeWriter ) {
|
|
1149
|
-
def res@(optional weak):RangerAppClassDesc
|
|
1150
|
-
def ctx (this.fork())
|
|
1151
|
-
if(this.isDefinedClass( instanceName) ) {
|
|
1152
|
-
return res
|
|
1153
|
-
}
|
|
1154
|
-
if( (this.isDefinedClass( traitName )) == false) {
|
|
1155
|
-
this.addError( initParams ( "Could not find the trait " + traitName ) )
|
|
1156
|
-
return res
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
; 1. create the base class
|
|
1160
|
-
def tpl_code ("class " + instanceName + " {
|
|
1161
|
-
}")
|
|
1162
|
-
|
|
1163
|
-
def code:SourceCode (new SourceCode ( tpl_code ))
|
|
1164
|
-
code.filename = instanceName + ".ranger"
|
|
1165
|
-
def parser:RangerLispParser (new RangerLispParser (code))
|
|
1166
|
-
parser.parse(false)
|
|
1167
|
-
|
|
1168
|
-
def classRoot@(lives) (itemAt parser.rootNode.children 0)
|
|
1169
|
-
def classNameNode@(lives) (classRoot.getSecond())
|
|
1170
|
-
classNameNode.vref = instanceName
|
|
1171
|
-
def new_class@(lives):RangerAppClassDesc (new RangerAppClassDesc ())
|
|
1172
|
-
new_class.name = instanceName
|
|
1173
|
-
new_class.compiledName = instanceName
|
|
1174
|
-
new_class.nameNode = classNameNode
|
|
1175
|
-
new_class.node = classRoot
|
|
1176
|
-
new_class.classNode = classRoot
|
|
1177
|
-
new_class.is_generic_instance = true
|
|
1178
|
-
push new_class.consumes_traits traitName
|
|
1179
|
-
def root (this.getRoot())
|
|
1180
|
-
|
|
1181
|
-
new_class.ctx = (root.fork())
|
|
1182
|
-
root.addClass(instanceName new_class)
|
|
1183
|
-
classNameNode.clDesc = new_class
|
|
1184
|
-
|
|
1185
|
-
def cl:RangerAppClassDesc new_class
|
|
1186
|
-
def t:RangerAppClassDesc (this.findClass(traitName))
|
|
1187
|
-
|
|
1188
|
-
def traitClassDef@(lives):CodeNode (unwrap t.node)
|
|
1189
|
-
def name:string t.name
|
|
1190
|
-
|
|
1191
|
-
; print "creating a new trait " + name + " to class " + cl.name
|
|
1192
|
-
def t:RangerAppClassDesc (ctx.findClass(name))
|
|
1193
|
-
if( (array_length t.extends_classes) > 0 ) {
|
|
1194
|
-
ctx.addError( traitClassDef ("Can not join trait " + name + " because it is inherited. Currently on base classes can be used as traits." ))
|
|
1195
|
-
return res
|
|
1196
|
-
}
|
|
1197
|
-
if(t.has_constructor) {
|
|
1198
|
-
ctx.addError( traitClassDef ("Can not join trait " + name + " because it has a constructor function" ))
|
|
1199
|
-
} {
|
|
1200
|
-
def origBody:CodeNode (itemAt cl.node.children 2)
|
|
1201
|
-
def match:RangerArgMatch (new RangerArgMatch ())
|
|
1202
|
-
|
|
1203
|
-
def params (t.node.getExpressionProperty("params"))
|
|
1204
|
-
def traitParams (new RangerTraitParams)
|
|
1205
|
-
|
|
1206
|
-
if( (!null? params) ) {
|
|
1207
|
-
for params.children typeName:CodeNode i {
|
|
1208
|
-
def set_value ""
|
|
1209
|
-
if( ( array_length initParams.children) > i ) {
|
|
1210
|
-
def pArg (itemAt initParams.children i)
|
|
1211
|
-
match.add(typeName.vref pArg.vref ctx)
|
|
1212
|
-
;print "- match " + typeName.vref + " -> " + pArg.vref
|
|
1213
|
-
set_value = pArg.vref
|
|
1214
|
-
} {
|
|
1215
|
-
match.add(typeName.vref instanceName ctx)
|
|
1216
|
-
;print "- match " + typeName.vref + " -> " + instanceName
|
|
1217
|
-
set_value = instanceName
|
|
1218
|
-
}
|
|
1219
|
-
push traitParams.param_names typeName.vref
|
|
1220
|
-
set traitParams.values typeName.vref set_value
|
|
1221
|
-
}
|
|
1222
|
-
set cl.trait_params name traitParams
|
|
1223
|
-
} {
|
|
1224
|
-
match.add("T" cl.name ctx)
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
ctx.setCurrentClass( cl )
|
|
1228
|
-
|
|
1229
|
-
def traitClass t
|
|
1230
|
-
for traitClass.variables pvar:RangerAppParamDesc i {
|
|
1231
|
-
def ccopy:CodeNode (pvar.node.rebuildWithType(match true))
|
|
1232
|
-
flowParser.WalkCollectMethods( ccopy ctx wr )
|
|
1233
|
-
push origBody.children ccopy
|
|
1234
|
-
}
|
|
1235
|
-
for traitClass.defined_variants fnVar:string i {
|
|
1236
|
-
def mVs:RangerAppMethodVariants (get traitClass.method_variants fnVar)
|
|
1237
|
-
for mVs.variants variant:RangerAppFunctionDesc i {
|
|
1238
|
-
def ccopy:CodeNode (variant.node.rebuildWithType(match true))
|
|
1239
|
-
flowParser.WalkCollectMethods( ccopy ctx wr )
|
|
1240
|
-
push origBody.children ccopy
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
res = new_class
|
|
1244
|
-
; --> try to walk immediately...
|
|
1245
|
-
def rootCtx (this.getRoot())
|
|
1246
|
-
flowParser.WalkNode( (unwrap new_class.node) ctx wr)
|
|
1247
|
-
; push flowParser.walkAlso (unwrap new_class.node)
|
|
1248
|
-
}
|
|
1249
|
-
return res
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
fn createOperator:void (fromNode@(strong):CodeNode) {
|
|
1253
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1254
|
-
if (root.initStdCommands()) {
|
|
1255
|
-
push root.stdCommands.children fromNode
|
|
1256
|
-
|
|
1257
|
-
; def fc:CodeNode (itemAt fromNode.children 0)
|
|
1258
|
-
; print ":: created op" + (fromNode.getCode())
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
fn findClassMethod@(weak optional):RangerAppFunctionDesc (cname:string fname:string) {
|
|
1262
|
-
def res:RangerAppFunctionDesc
|
|
1263
|
-
if(this.isDefinedClass(cname)) {
|
|
1264
|
-
def cl (this.findClass(cname))
|
|
1265
|
-
for cl.defined_variants fnVar:string i {
|
|
1266
|
-
if(fnVar == fname) {
|
|
1267
|
-
def mVs:RangerAppMethodVariants (get cl.method_variants fnVar)
|
|
1268
|
-
for mVs.variants variant:RangerAppFunctionDesc i {
|
|
1269
|
-
res = variant
|
|
1270
|
-
return res
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
return res
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
fn getFileWriter:CodeWriter (path:string fileName:string) {
|
|
1279
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1280
|
-
def fs:CodeFileSystem root.fileSystem
|
|
1281
|
-
def file:CodeFile (fs.getFile(path fileName))
|
|
1282
|
-
def wr:CodeWriter
|
|
1283
|
-
wr = (file.getWriter())
|
|
1284
|
-
return (unwrap wr)
|
|
1285
|
-
}
|
|
1286
|
-
fn addTodo:void (node@(lives):CodeNode descr:string) {
|
|
1287
|
-
def e:RangerAppTodo (new RangerAppTodo ())
|
|
1288
|
-
e.description = descr
|
|
1289
|
-
e.todonode = node
|
|
1290
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1291
|
-
push root.todoList e
|
|
1292
|
-
}
|
|
1293
|
-
fn setThisName:void (the_name:string) {
|
|
1294
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1295
|
-
root.thisName = the_name
|
|
1296
|
-
}
|
|
1297
|
-
fn getThisName:string () {
|
|
1298
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1299
|
-
return root.thisName
|
|
1300
|
-
}
|
|
1301
|
-
fn printLogs:void (logName:string) {
|
|
1302
|
-
|
|
1303
|
-
}
|
|
1304
|
-
fn log:void (node:CodeNode logName:string descr:string) {
|
|
1305
|
-
|
|
1306
|
-
}
|
|
1307
|
-
fn addMessage:void (node@(lives):CodeNode descr:string) {
|
|
1308
|
-
def e:RangerCompilerMessage (new RangerCompilerMessage ())
|
|
1309
|
-
e.description = descr
|
|
1310
|
-
e.node = node
|
|
1311
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1312
|
-
push root.compilerMessages e
|
|
1313
|
-
}
|
|
1314
|
-
fn errCnt:int() {
|
|
1315
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1316
|
-
return (size root.compilerErrors)
|
|
1317
|
-
}
|
|
1318
|
-
fn addError:void (targetnode@(weak lives):CodeNode descr:string) {
|
|
1319
|
-
def e:RangerCompilerMessage (new RangerCompilerMessage ())
|
|
1320
|
-
e.description = descr
|
|
1321
|
-
e.node = targetnode
|
|
1322
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1323
|
-
push root.compilerErrors e
|
|
1324
|
-
}
|
|
1325
|
-
fn addParserError:void (targetnode@(weak lives):CodeNode descr:string) {
|
|
1326
|
-
def e:RangerCompilerMessage (new RangerCompilerMessage ())
|
|
1327
|
-
e.description = descr
|
|
1328
|
-
e.node = targetnode
|
|
1329
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1330
|
-
push root.parserErrors e
|
|
1331
|
-
}
|
|
1332
|
-
fn addTemplateClass:void (name:string node@(lives):CodeNode) {
|
|
1333
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1334
|
-
push root.templateClassList name
|
|
1335
|
-
set root.templateClassNodes name node
|
|
1336
|
-
}
|
|
1337
|
-
fn hasTemplateNode:boolean (name:string) {
|
|
1338
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1339
|
-
return (has root.templateClassNodes name)
|
|
1340
|
-
}
|
|
1341
|
-
fn findTemplateNode:CodeNode (name:string) {
|
|
1342
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1343
|
-
return (unwrap (get root.templateClassNodes name))
|
|
1344
|
-
}
|
|
1345
|
-
fn setStaticWriter:void (className:string writer@(lives):CodeWriter) {
|
|
1346
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1347
|
-
set root.classStaticWriters className writer
|
|
1348
|
-
}
|
|
1349
|
-
fn getStaticWriter:CodeWriter (className:string) {
|
|
1350
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1351
|
-
return (unwrap (get root.classStaticWriters className))
|
|
1352
|
-
}
|
|
1353
|
-
fn isEnumDefined:boolean (n:string) {
|
|
1354
|
-
if (has definedEnums n) {
|
|
1355
|
-
return true
|
|
1356
|
-
}
|
|
1357
|
-
if (null? parent) {
|
|
1358
|
-
return false
|
|
1359
|
-
}
|
|
1360
|
-
return (parent.isEnumDefined(n))
|
|
1361
|
-
}
|
|
1362
|
-
fn getEnum@(optional weak):RangerAppEnum (n:string) {
|
|
1363
|
-
def res@(optional):RangerAppEnum
|
|
1364
|
-
if (has definedEnums n) {
|
|
1365
|
-
res = (get definedEnums n)
|
|
1366
|
-
return res
|
|
1367
|
-
}
|
|
1368
|
-
if (!null? parent) {
|
|
1369
|
-
return (parent.getEnum(n))
|
|
1370
|
-
}
|
|
1371
|
-
return res
|
|
1372
|
-
}
|
|
1373
|
-
fn isVarDefined:boolean (name:string) {
|
|
1374
|
-
if (has localVariables name) {
|
|
1375
|
-
return true
|
|
1376
|
-
}
|
|
1377
|
-
if (null? parent) {
|
|
1378
|
-
return false
|
|
1379
|
-
}
|
|
1380
|
-
return (parent.isVarDefined(name))
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
fn setFlag(name:string value:boolean) {
|
|
1384
|
-
set contextFlags name value
|
|
1385
|
-
}
|
|
1386
|
-
fn getFlag:boolean (name:string) {
|
|
1387
|
-
if(has contextFlags name) {
|
|
1388
|
-
return (unwrap (get contextFlags name))
|
|
1389
|
-
}
|
|
1390
|
-
if(!null? parent) {
|
|
1391
|
-
return (parent.getFlag(name))
|
|
1392
|
-
}
|
|
1393
|
-
return false
|
|
1394
|
-
}
|
|
1395
|
-
fn setSetting(name:string value:string) {
|
|
1396
|
-
set settings name value
|
|
1397
|
-
}
|
|
1398
|
-
fn hasSetting:boolean (name:string) {
|
|
1399
|
-
if(has settings name) {
|
|
1400
|
-
return true
|
|
1401
|
-
}
|
|
1402
|
-
if(!null? parent) {
|
|
1403
|
-
return (parent.hasSetting(name))
|
|
1404
|
-
}
|
|
1405
|
-
return false
|
|
1406
|
-
}
|
|
1407
|
-
fn getSetting:string (name:string) {
|
|
1408
|
-
if(has settings name) {
|
|
1409
|
-
return (unwrap (get settings name))
|
|
1410
|
-
}
|
|
1411
|
-
if(!null? parent) {
|
|
1412
|
-
return (parent.getSetting(name))
|
|
1413
|
-
}
|
|
1414
|
-
return ""
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
fn setCompilerFlag:void (name:string value:boolean) {
|
|
1418
|
-
def root (this.getRoot())
|
|
1419
|
-
set root.compilerFlags name value
|
|
1420
|
-
}
|
|
1421
|
-
fn hasCompilerFlag:boolean (s_name:string) {
|
|
1422
|
-
if (has compilerFlags s_name) {
|
|
1423
|
-
return ( unwrap (get compilerFlags s_name) )
|
|
1424
|
-
}
|
|
1425
|
-
if (null? parent) {
|
|
1426
|
-
return false
|
|
1427
|
-
}
|
|
1428
|
-
return (parent.hasCompilerFlag(s_name))
|
|
1429
|
-
}
|
|
1430
|
-
fn setCompilerSetting:void (name:string value:string) {
|
|
1431
|
-
def root (this.getRoot())
|
|
1432
|
-
set root.compilerSettings name value
|
|
1433
|
-
}
|
|
1434
|
-
fn getCompilerSetting:string (s_name:string) {
|
|
1435
|
-
if (has compilerSettings s_name) {
|
|
1436
|
-
return (unwrap (get compilerSettings s_name) )
|
|
1437
|
-
}
|
|
1438
|
-
if (null? parent) {
|
|
1439
|
-
return ""
|
|
1440
|
-
}
|
|
1441
|
-
return (parent.getCompilerSetting(s_name))
|
|
1442
|
-
}
|
|
1443
|
-
fn hasCompilerSetting:boolean (s_name:string) {
|
|
1444
|
-
if (has compilerSettings s_name) {
|
|
1445
|
-
return true
|
|
1446
|
-
}
|
|
1447
|
-
if (null? parent) {
|
|
1448
|
-
return false
|
|
1449
|
-
}
|
|
1450
|
-
return (parent.hasCompilerSetting(s_name))
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
fn getVariableDef:RangerAppParamDesc (name:string) {
|
|
1454
|
-
if (has localVariables name) {
|
|
1455
|
-
return (unwrap (get localVariables name))
|
|
1456
|
-
}
|
|
1457
|
-
if (null? parent) {
|
|
1458
|
-
def tmp:RangerAppParamDesc (new RangerAppParamDesc ())
|
|
1459
|
-
return tmp
|
|
1460
|
-
}
|
|
1461
|
-
return (parent.getVariableDef(name))
|
|
1462
|
-
}
|
|
1463
|
-
fn findFunctionCtx:RangerAppWriterContext () {
|
|
1464
|
-
if is_function {
|
|
1465
|
-
return this
|
|
1466
|
-
}
|
|
1467
|
-
if (null? parent) {
|
|
1468
|
-
return this
|
|
1469
|
-
}
|
|
1470
|
-
return (parent.findFunctionCtx())
|
|
1471
|
-
}
|
|
1472
|
-
fn getFnVarCnt:int (name:string) {
|
|
1473
|
-
def fnCtx:RangerAppWriterContext (this.findFunctionCtx())
|
|
1474
|
-
def ii:int 0
|
|
1475
|
-
if (has fnCtx.defCounts name) {
|
|
1476
|
-
ii = (unwrap (get fnCtx.defCounts name))
|
|
1477
|
-
ii = (1 + ii)
|
|
1478
|
-
} {
|
|
1479
|
-
set fnCtx.defCounts name ii
|
|
1480
|
-
return 0
|
|
1481
|
-
}
|
|
1482
|
-
def scope_has:boolean (this.isVarDefined((name + "_" + ii)))
|
|
1483
|
-
while scope_has {
|
|
1484
|
-
ii = (1 + ii)
|
|
1485
|
-
scope_has = (this.isVarDefined((name + "_" + ii)))
|
|
1486
|
-
}
|
|
1487
|
-
set fnCtx.defCounts name ii
|
|
1488
|
-
return ii
|
|
1489
|
-
}
|
|
1490
|
-
fn debugVars:void () {
|
|
1491
|
-
print "--- context vars ---"
|
|
1492
|
-
for localVarNames na:string i {
|
|
1493
|
-
print ("var => " + na)
|
|
1494
|
-
}
|
|
1495
|
-
if (!null? parent) {
|
|
1496
|
-
parent.debugVars()
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
fn getVarTotalCnt:int (name:string) {
|
|
1500
|
-
def fnCtx:RangerAppWriterContext this
|
|
1501
|
-
def ii:int 0
|
|
1502
|
-
if (has fnCtx.defCounts name) {
|
|
1503
|
-
ii = (unwrap (get fnCtx.defCounts name))
|
|
1504
|
-
}
|
|
1505
|
-
if (!null? fnCtx.parent) {
|
|
1506
|
-
ii = (ii + (fnCtx.parent.getVarTotalCnt(name)))
|
|
1507
|
-
}
|
|
1508
|
-
if (this.isVarDefined(name )) {
|
|
1509
|
-
ii = ii + 1
|
|
1510
|
-
}
|
|
1511
|
-
return ii
|
|
1512
|
-
}
|
|
1513
|
-
fn getFnVarCnt2:int (name:string) {
|
|
1514
|
-
def fnCtx:RangerAppWriterContext this
|
|
1515
|
-
def ii:int 0
|
|
1516
|
-
if (has fnCtx.defCounts name) {
|
|
1517
|
-
ii = (unwrap (get fnCtx.defCounts name))
|
|
1518
|
-
ii = (1 + ii)
|
|
1519
|
-
set fnCtx.defCounts name ii
|
|
1520
|
-
} {
|
|
1521
|
-
set fnCtx.defCounts name 1
|
|
1522
|
-
}
|
|
1523
|
-
if (!null? fnCtx.parent) {
|
|
1524
|
-
ii = (ii + (fnCtx.parent.getFnVarCnt2(name)))
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
def scope_has:boolean (this.isVarDefined(name ))
|
|
1528
|
-
if scope_has {
|
|
1529
|
-
ii = (1 + ii)
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
def scope_has:boolean (this.isVarDefined((name + "_" + ii)))
|
|
1533
|
-
while scope_has {
|
|
1534
|
-
ii = (1 + ii)
|
|
1535
|
-
scope_has = (this.isVarDefined((name + "_" + ii)))
|
|
1536
|
-
}
|
|
1537
|
-
return ii
|
|
1538
|
-
}
|
|
1539
|
-
fn getFnVarCnt3:int (name:string) {
|
|
1540
|
-
def classLevel (this.findMethodLevelContext())
|
|
1541
|
-
def fnCtx:RangerAppWriterContext this
|
|
1542
|
-
def ii:int 0
|
|
1543
|
-
if (has fnCtx.defCounts name) {
|
|
1544
|
-
ii = (unwrap (get fnCtx.defCounts name))
|
|
1545
|
-
set fnCtx.defCounts name ( ii + 1)
|
|
1546
|
-
} {
|
|
1547
|
-
set fnCtx.defCounts name 1
|
|
1548
|
-
}
|
|
1549
|
-
if(classLevel.isVarDefined(name)) {
|
|
1550
|
-
ii = ii + 1
|
|
1551
|
-
}
|
|
1552
|
-
def scope_has:boolean (this.isVarDefined((name + "_" + ii)))
|
|
1553
|
-
while scope_has {
|
|
1554
|
-
ii = (1 + ii)
|
|
1555
|
-
scope_has = (this.isVarDefined((name + "_" + ii)))
|
|
1556
|
-
}
|
|
1557
|
-
return ii
|
|
1558
|
-
}
|
|
1559
|
-
fn isMemberVariable:boolean (name:string) {
|
|
1560
|
-
if (this.isVarDefined(name)) {
|
|
1561
|
-
def vDef:RangerAppParamDesc (this.getVariableDef(name))
|
|
1562
|
-
if (vDef.varType == RangerContextVarType.Property) {
|
|
1563
|
-
return true
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
return false
|
|
1567
|
-
}
|
|
1568
|
-
fn defineVariable:void (name:string desc@(strong):RangerAppParamDesc) {
|
|
1569
|
-
def cnt:int 0
|
|
1570
|
-
|
|
1571
|
-
; *** code to warn about variable name and operator name clash **
|
|
1572
|
-
; def opList (this.findOperatorsWithName(name))
|
|
1573
|
-
; if( (size opList) > 0) {
|
|
1574
|
-
; this.addError( (unwrap desc.nameNode) ('variable clashes with operator ' + name) )
|
|
1575
|
-
; }
|
|
1576
|
-
|
|
1577
|
-
def fnLevel (this.findMethodLevelContext())
|
|
1578
|
-
if (false == ((desc.varType == RangerContextVarType.Property) || (desc.varType == RangerContextVarType.FunctionParameter) || (desc.varType == RangerContextVarType.Function))) {
|
|
1579
|
-
cnt = (fnLevel.getFnVarCnt3(name))
|
|
1580
|
-
}
|
|
1581
|
-
if (0 == cnt) {
|
|
1582
|
-
switch name {
|
|
1583
|
-
case "self" {
|
|
1584
|
-
desc.compiledName = "__self"
|
|
1585
|
-
}
|
|
1586
|
-
case "process" {
|
|
1587
|
-
desc.compiledName = "_process"
|
|
1588
|
-
}
|
|
1589
|
-
case "len" {
|
|
1590
|
-
desc.compiledName = "__len"
|
|
1591
|
-
}
|
|
1592
|
-
default {
|
|
1593
|
-
desc.compiledName = name
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
} {
|
|
1597
|
-
desc.compiledName = (name + "_" + cnt)
|
|
1598
|
-
}
|
|
1599
|
-
if( desc.varType == RangerContextVarType.Property) {
|
|
1600
|
-
|
|
1601
|
-
; if( (this.getCompilerSetting("l")) == "go" ) {
|
|
1602
|
-
; def ss ( desc.compiledName)
|
|
1603
|
-
; def firstC (substring ss 0 1)
|
|
1604
|
-
; def restOf (substring ss 1 (strlen ss))
|
|
1605
|
-
; def res_str ( (to_uppercase firstC) + restOf )
|
|
1606
|
-
; desc.compiledName = res_str
|
|
1607
|
-
; }
|
|
1608
|
-
|
|
1609
|
-
}
|
|
1610
|
-
set localVariables name desc
|
|
1611
|
-
push localVarNames name
|
|
1612
|
-
}
|
|
1613
|
-
fn isDefinedClass:boolean (name:string) {
|
|
1614
|
-
if (has definedClasses name) {
|
|
1615
|
-
return true
|
|
1616
|
-
} {
|
|
1617
|
-
if (!null? parent) {
|
|
1618
|
-
return (parent.isDefinedClass(name))
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
return false
|
|
1622
|
-
}
|
|
1623
|
-
fn getRoot:RangerAppWriterContext () {
|
|
1624
|
-
if (null? parent) {
|
|
1625
|
-
return this
|
|
1626
|
-
}
|
|
1627
|
-
return (parent.getRoot())
|
|
1628
|
-
}
|
|
1629
|
-
fn getClasses:[RangerAppClassDesc] () {
|
|
1630
|
-
def list:[RangerAppClassDesc]
|
|
1631
|
-
for definedClassList n:string i {
|
|
1632
|
-
push list (unwrap (get definedClasses n))
|
|
1633
|
-
}
|
|
1634
|
-
return list
|
|
1635
|
-
}
|
|
1636
|
-
fn addClass:void (name:string desc@(strong):RangerAppClassDesc) {
|
|
1637
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1638
|
-
if (has root.definedClasses name) {
|
|
1639
|
-
; skip definition...
|
|
1640
|
-
} {
|
|
1641
|
-
set root.definedClasses name desc
|
|
1642
|
-
push root.definedClassList name
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
fn findClass:RangerAppClassDesc (name:string) {
|
|
1646
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1647
|
-
return (unwrap (get root.definedClasses name))
|
|
1648
|
-
}
|
|
1649
|
-
fn hasClass:boolean (name:string) {
|
|
1650
|
-
def root:RangerAppWriterContext (this.getRoot())
|
|
1651
|
-
return (has root.definedClasses name)
|
|
1652
|
-
}
|
|
1653
|
-
fn getCurrentMethod@(weak):RangerAppFunctionDesc () {
|
|
1654
|
-
if (!null? currentMethod) {
|
|
1655
|
-
return (unwrap currentMethod)
|
|
1656
|
-
}
|
|
1657
|
-
if (!null? parent) {
|
|
1658
|
-
return (parent.getCurrentMethod())
|
|
1659
|
-
}
|
|
1660
|
-
return (new RangerAppFunctionDesc ())
|
|
1661
|
-
}
|
|
1662
|
-
fn setCurrentClass:void (cc@(lives):RangerAppClassDesc) {
|
|
1663
|
-
in_class = true
|
|
1664
|
-
currentClass = cc
|
|
1665
|
-
}
|
|
1666
|
-
fn disableCurrentClass:void () {
|
|
1667
|
-
if in_class {
|
|
1668
|
-
in_class = false
|
|
1669
|
-
}
|
|
1670
|
-
if (!null? parent) {
|
|
1671
|
-
parent.disableCurrentClass()
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
fn hasCurrentClass:boolean () {
|
|
1675
|
-
if (in_class && (!null? currentClass)) {
|
|
1676
|
-
return true
|
|
1677
|
-
}
|
|
1678
|
-
if (!null? parent) {
|
|
1679
|
-
return (parent.hasCurrentClass())
|
|
1680
|
-
}
|
|
1681
|
-
return false
|
|
1682
|
-
}
|
|
1683
|
-
fn getCurrentClass@(optional weak):RangerAppClassDesc () {
|
|
1684
|
-
def non:RangerAppClassDesc currentClass
|
|
1685
|
-
if (in_class && (!null? non)) {
|
|
1686
|
-
return non
|
|
1687
|
-
}
|
|
1688
|
-
if (!null? parent) {
|
|
1689
|
-
return (parent.getCurrentClass())
|
|
1690
|
-
}
|
|
1691
|
-
return non
|
|
1692
|
-
}
|
|
1693
|
-
fn restartExpressionLevel:void () {
|
|
1694
|
-
expr_restart = true
|
|
1695
|
-
}
|
|
1696
|
-
fn newBlock () {
|
|
1697
|
-
expr_restart_block = true
|
|
1698
|
-
}
|
|
1699
|
-
fn isInExpression:boolean () {
|
|
1700
|
-
if ((array_length expr_stack) > 0) {
|
|
1701
|
-
return true
|
|
1702
|
-
}
|
|
1703
|
-
if ((!null? parent) && (expr_restart_block == false) && (expr_restart == false )) {
|
|
1704
|
-
return (parent.isInExpression())
|
|
1705
|
-
}
|
|
1706
|
-
return false
|
|
1707
|
-
}
|
|
1708
|
-
fn expressionLevel:int () {
|
|
1709
|
-
def level:int (array_length expr_stack)
|
|
1710
|
-
if ((!null? parent) && (expr_restart == false) && (expr_restart_block == false)) {
|
|
1711
|
-
return (level + (parent.expressionLevel()))
|
|
1712
|
-
}
|
|
1713
|
-
return level
|
|
1714
|
-
}
|
|
1715
|
-
fn setInExpr:void () {
|
|
1716
|
-
push expr_stack true
|
|
1717
|
-
}
|
|
1718
|
-
fn unsetInExpr:void () {
|
|
1719
|
-
removeLast expr_stack
|
|
1720
|
-
}
|
|
1721
|
-
fn getErrorCount:int () {
|
|
1722
|
-
def cnt:int (array_length compilerErrors)
|
|
1723
|
-
if parent {
|
|
1724
|
-
cnt = cnt + (parent.getErrorCount())
|
|
1725
|
-
}
|
|
1726
|
-
return cnt
|
|
1727
|
-
}
|
|
1728
|
-
fn isInStatic:boolean() {
|
|
1729
|
-
if in_static_method {
|
|
1730
|
-
return true
|
|
1731
|
-
}
|
|
1732
|
-
if parent {
|
|
1733
|
-
return (parent.isInStatic())
|
|
1734
|
-
}
|
|
1735
|
-
return false
|
|
1736
|
-
}
|
|
1737
|
-
fn isInMain:boolean() {
|
|
1738
|
-
if in_main {
|
|
1739
|
-
return true
|
|
1740
|
-
}
|
|
1741
|
-
if parent {
|
|
1742
|
-
return (parent.isInMain())
|
|
1743
|
-
}
|
|
1744
|
-
return false
|
|
1745
|
-
}
|
|
1746
|
-
fn isInMethod:boolean () {
|
|
1747
|
-
if ((array_length method_stack) > 0) {
|
|
1748
|
-
return true
|
|
1749
|
-
}
|
|
1750
|
-
if (!null? parent) {
|
|
1751
|
-
return (parent.isInMethod())
|
|
1752
|
-
}
|
|
1753
|
-
return false
|
|
1754
|
-
}
|
|
1755
|
-
fn setInMethod:void () {
|
|
1756
|
-
push method_stack true
|
|
1757
|
-
}
|
|
1758
|
-
fn unsetInMethod:void () {
|
|
1759
|
-
removeLast method_stack
|
|
1760
|
-
}
|
|
1761
|
-
fn findMethodLevelContext@(weak optional):RangerAppWriterContext () {
|
|
1762
|
-
def res@(weak optional):RangerAppWriterContext
|
|
1763
|
-
if function_level_context {
|
|
1764
|
-
res = this
|
|
1765
|
-
return res
|
|
1766
|
-
}
|
|
1767
|
-
if(parent) {
|
|
1768
|
-
return (parent.findMethodLevelContext())
|
|
1769
|
-
}
|
|
1770
|
-
res = this
|
|
1771
|
-
return res
|
|
1772
|
-
}
|
|
1773
|
-
fn findClassLevelContext@(weak optional):RangerAppWriterContext () {
|
|
1774
|
-
def res@(weak optional):RangerAppWriterContext
|
|
1775
|
-
if class_level_context {
|
|
1776
|
-
res = this
|
|
1777
|
-
return res
|
|
1778
|
-
}
|
|
1779
|
-
if(parent) {
|
|
1780
|
-
return (parent.findClassLevelContext())
|
|
1781
|
-
}
|
|
1782
|
-
res = this
|
|
1783
|
-
return res
|
|
1784
|
-
}
|
|
1785
|
-
fn fork:RangerAppWriterContext () {
|
|
1786
|
-
def new_ctx:RangerAppWriterContext (new RangerAppWriterContext ())
|
|
1787
|
-
new_ctx.parent = this
|
|
1788
|
-
return new_ctx
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
}
|
|
1793
|
-
|