ranger-compiler 3.1.0 → 3.2.0

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/dist/Lang.rgr CHANGED
@@ -57,9 +57,10 @@ language {
57
57
  php PHP php
58
58
  python Python py
59
59
  nim Nim nim
60
+ llvm LLVM IR ll
60
61
  }
61
62
 
62
- toplevel_keywords (class systemclass Constructor fn sfn Import Extend Enum def let operators)
63
+ toplevel_keywords (class record systemclass Constructor fn sfn Import Extend Enum def let operators)
63
64
  annotation_keywors (weak strong lives temp)
64
65
 
65
66
  ; transformations for the reserved words for function names or other keywords
@@ -79,12 +80,34 @@ language {
79
80
  class _class
80
81
  new _new
81
82
  delete _delete
83
+ and _and
84
+ or _or
85
+ not _not
86
+ xor _xor
87
+ compl _compl
88
+ bitand _bitand
89
+ bitor _bitor
90
+ and_eq _and_eq
91
+ or_eq _or_eq
92
+ xor_eq _xor_eq
93
+ not_eq _not_eq
82
94
  template _template
83
95
  namespace _namespace
84
96
  virtual _virtual
85
97
  public _public
86
98
  private _private
87
99
  protected _protected
100
+ signed _signed
101
+ unsigned _unsigned
102
+ register _register
103
+ volatile _volatile
104
+ mutable _mutable
105
+ friend _friend
106
+ typename _typename
107
+ typedef _typedef
108
+ extern _extern
109
+ explicit _explicit
110
+ goto _goto
88
111
  }
89
112
  go {
90
113
  type _type
@@ -92,6 +115,40 @@ language {
92
115
  }
93
116
  kotlin {
94
117
  object _object
118
+ val _val
119
+ var _var
120
+ fun _fun
121
+ class _class
122
+ when _when
123
+ is _is
124
+ in _in
125
+ as _as
126
+ null _null
127
+ interface _interface
128
+ package _package
129
+ typealias _typealias
130
+ companion _companion
131
+ init _init
132
+ override _override
133
+ open _open
134
+ abstract _abstract
135
+ sealed _sealed
136
+ data _data
137
+ internal _internal
138
+ private _private
139
+ protected _protected
140
+ public _public
141
+ operator _operator
142
+ inline _inline
143
+ lateinit _lateinit
144
+ vararg _vararg
145
+ reified _reified
146
+ suspend _suspend
147
+ tailrec _tailrec
148
+ where _where
149
+ get _get
150
+ set _set
151
+ field _field
95
152
  }
96
153
  rust {
97
154
  type r#type
@@ -186,6 +243,20 @@ language {
186
243
  random _:double () {
187
244
  templates {
188
245
  es6 ('Math.random()')
246
+ kotlin ('Math.random()' (imp "java.lang.Math"))
247
+ cpp ( "rg_random_double()" (imp "<random>")
248
+ (create_polyfill "
249
+ double rg_random_double() {
250
+ static thread_local std::mt19937 _rg{std::random_device{}()};
251
+ static thread_local std::uniform_real_distribution<double> _rd(0.0, 1.0);
252
+ return _rd(_rg);
253
+ }
254
+ ")
255
+ )
256
+ go ( 'rand.Float64()' (imp "math/rand") )
257
+ ; std-only (rustc, no crates): each RandomState::new() draws a fresh
258
+ ; OS-seeded key, so hashing a constant yields a varying 53-bit value.
259
+ rust ( '{ use std::hash::{BuildHasher, Hasher}; let mut h = std::collections::hash_map::RandomState::new().build_hasher(); h.write_u64(0); ((h.finish() >> 11) as f64) / ((1u64 << 53) as f64) }' )
189
260
  }
190
261
  }
191
262
 
@@ -210,6 +281,7 @@ language {
210
281
  random _:int ( min:int max:int) {
211
282
  templates {
212
283
  es6 ('Math.floor(Math.random()*(' (e 2) ' - ' (e 1)' + 1) + ' (e 1)')')
284
+ kotlin ('(Math.floor(Math.random() * (' (e 2) ' - ' (e 1) ' + 1)).toInt() + ' (e 1) ')' (imp "java.lang.Math"))
213
285
  }
214
286
  }
215
287
 
@@ -376,11 +448,27 @@ func _r_md5(value string) string {
376
448
  tan tan:double ( v:double ) {
377
449
  templates {
378
450
  es6 ("Math.tan(" (e 1) ")")
379
- go ( "math.Tan(" (e 1) ")" (imp "math"))
380
- swift3 ( "tan(" (e 1) ")" (imp "Foundation"))
381
- java7 ( "Math.tan(" (e 1) ")" (imp "java.lang.Math"))
382
- php ( "tan(" (e 1) ")")
383
- cpp ("tan(" (e 1) ")" (imp "<math.h>"))
451
+ go ( "math.Tan(" (e 1) ")" (imp "math"))
452
+ swift3 ( "tan(" (e 1) ")" (imp "Foundation"))
453
+ java7 ( "Math.tan(" (e 1) ")" (imp "java.lang.Math"))
454
+ php ( "tan(" (e 1) ")")
455
+ cpp ("tan(" (e 1) ")" (imp "<math.h>"))
456
+ }
457
+ }
458
+
459
+ atan2 atan2:double ( y:double x:double ) {
460
+ templates {
461
+ ranger ( "(atan2 " (e 1) " " (e 2) ")" )
462
+ es6 ( "Math.atan2(" (e 1) ", " (e 2) ")" )
463
+ go ( "math.Atan2(" (e 1) ", " (e 2) ")" (imp "math"))
464
+ swift3 ( "atan2(" (e 1) ", " (e 2) ")" (imp "Foundation"))
465
+ java7 ( "Math.atan2(" (e 1) ", " (e 2) ")" (imp "java.lang.Math"))
466
+ php ( "atan2(" (e 1) ", " (e 2) ")" )
467
+ csharp ( "Math.Atan2(" (e 1) ", " (e 2) ")" (imp "System"))
468
+ rust ( "" (e 1) ".atan2(" (e 2) ")" )
469
+ scala ( "math.atan2(" (e 1) ", " (e 2) ")" (imp "scala.math"))
470
+ cpp ( "atan2(" (e 1) ", " (e 2) ")" (imp "<math.h>"))
471
+ * ( "Math.atan2(" (e 1) ", " (e 2) ")" )
384
472
  }
385
473
  }
386
474
 
@@ -486,6 +574,7 @@ func r_io_get_env( name string) *GoNullable {
486
574
  ; Command line arguments
487
575
  shell_arg cmdArg:string (index:int) {
488
576
  templates {
577
+ llvm ( "(shell_arg " (e 1) ")")
489
578
  cpp ( "std::string(__g_argv[" (e 1) " + 1])")
490
579
  php ( "$argv[" (e 1) " + 1]" )
491
580
  java7 ( "args[" (e 1) "]")
@@ -502,6 +591,7 @@ func r_io_get_env( name string) *GoNullable {
502
591
 
503
592
  shell_arg_cnt cmdArg:int () @doc("return the number of arguments for command line utility") {
504
593
  templates {
594
+ llvm ( "(shell_arg_cnt)")
505
595
  cpp ( "__g_argc - 1")
506
596
  swift3 ("CommandLine.arguments.count - 1")
507
597
  swift6 ("CommandLine.arguments.count - 1")
@@ -674,7 +764,7 @@ func r_dir_exists(pathName string) bool {
674
764
  }
675
765
  }
676
766
 
677
- ; Returns the file modification time as Unix timestamp (seconds since epoch)
767
+ ; Returns the file modification time (ms on es6/cpp; seconds on go)
678
768
  file_mtime cmdFileMTime:int (path:string filename:string) {
679
769
  templates {
680
770
  go ( "r_file_mtime(" (e 1) ", " (e 2) ")"
@@ -691,6 +781,18 @@ func r_file_mtime(pathName string, fileName string) int64 {
691
781
  )
692
782
  )
693
783
  es6 ( "require('fs').statSync(" (e 1) " + '/' + " (e 2) ").mtimeMs" )
784
+ cpp ( "r_file_mtime(" (e 1) ", " (e 2) ")" (imp "<sys/stat.h>") (imp "<string>")
785
+ (create_polyfill "
786
+ int64_t r_file_mtime(const std::string& path, const std::string& filename) {
787
+ struct stat st;
788
+ std::string full = path + \"/\" + filename;
789
+ if (stat(full.c_str(), &st) != 0) {
790
+ return 0;
791
+ }
792
+ return (int64_t)st.st_mtime * 1000;
793
+ }
794
+ ")
795
+ )
694
796
  ranger ( "(file_mtime " (e 1) " " (e 2) ")" )
695
797
  }
696
798
  }
@@ -845,6 +947,7 @@ fn r_write_file(path: &str, filename: &str, data: &str) {
845
947
  read_file cmdReadFile@(optional async):string (path:string filename:string) {
846
948
 
847
949
  templates {
950
+ llvm ( "(read_file " (e 1) " " (e 2) ")")
848
951
  ts ( "await (new Promise<string>(resolve => { require('fs').readFile( " (e 1) " + '/' + " (e 2) " , 'utf8', (err,data)=>{ resolve(data) }) } ))" )
849
952
  es6 ( "await (new Promise(resolve => { require('fs').readFile( " (e 1) " + '/' + " (e 2) " , 'utf8', (err,data)=>{ resolve(data) }) } ))" )
850
953
  ranger ( "(read_file " (e 1) " " (e 2) ")" )
@@ -1270,6 +1373,24 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
1270
1373
  }
1271
1374
  }
1272
1375
 
1376
+ ; Integer division (truncates toward zero). Use instead of / when both
1377
+ ; operands are int — plain / returns double for int/int in Ranger.
1378
+ idiv _:int (left:int right:int) {
1379
+ templates {
1380
+ ranger @macro(true) ( "(/ " (e 1) " " (e 2) ")" )
1381
+ cpp ( "((" (e 1) ") / (" (e 2) "))" )
1382
+ llvm ( "(idiv " (e 1) " " (e 2) ")" )
1383
+ es6 ( "((" (e 1) " / " (e 2) ") | 0)" )
1384
+ go ( (e 1) " / " (e 2) )
1385
+ rust ( "((" (e 1) ") / (" (e 2) "))" )
1386
+ kotlin ( (e 1) " / " (e 2) )
1387
+ python ( "((" (e 1) ") // (" (e 2) "))" )
1388
+ java7 ( "((" (e 1) ") / (" (e 2) "))" )
1389
+ php ( "intdiv(" (e 1) ", " (e 2) ")" )
1390
+ * ( (e 1) " / " (e 2) )
1391
+ }
1392
+ }
1393
+
1273
1394
  ; ============================================================================
1274
1395
  ; Bitwise operators for integer manipulation
1275
1396
  ; ============================================================================
@@ -1409,12 +1530,16 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
1409
1530
  * cmdMulOp:double ( left:double right:double ) { templates { * ( (e 1) " * " (e 2) ) } }
1410
1531
  * cmdMulOp:int ( left:int right:int ) { templates { * ( (e 1) " * " (e 2) ) } }
1411
1532
 
1412
- / cmdDivOp:double ( left:double right:double ) { templates { * ( (e 1) " / " (e 2) ) } }
1413
- / cmdDivOp:double ( left:int right:int ) { templates {
1533
+ / cmdDivOp:double ( left:double right:double ) { templates {
1534
+ cpp ( "((double)(" (e 1) ") / (double)(" (e 2) "))" )
1535
+ * ( (e 1) " / " (e 2) )
1536
+ } }
1537
+ / cmdDivOp:double ( left:int right:int ) { templates {
1414
1538
  go ( "float64(" (e 1) ") / float64(" (e 2) ")" )
1415
1539
  rust ( "(" (e 1) " as f64) / (" (e 2) " as f64)" )
1416
1540
  kotlin ( (e 1) ".toDouble() / " (e 2) ".toDouble()" )
1417
- * ( (e 1) " / " (e 2) )
1541
+ cpp ( "((double)(" (e 1) ") / (double)(" (e 2) "))" )
1542
+ * ( (e 1) " / " (e 2) )
1418
1543
  } }
1419
1544
 
1420
1545
  ; optional string operator...
@@ -1462,6 +1587,8 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
1462
1587
  int2double cmdIntToDouble:double ( value:int ) {
1463
1588
  templates {
1464
1589
  ranger ( "(int2double " (e 1) ")" )
1590
+ kotlin ( (e 1) ".toDouble()" )
1591
+ swift6 ( "Double(" (e 1) ")" )
1465
1592
  * ( "parseFloat(" (e 1) ")" )
1466
1593
  }
1467
1594
  }
@@ -1504,6 +1631,7 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
1504
1631
  rust ( "" (e 1) ".floor() as i64" )
1505
1632
  scala ( "math.floor(" (e 1) ").toInt" (imp "scala.math"))
1506
1633
  java7 ( "(int)Math.floor(" (e 1) ")" (imp "java.lang.Math"))
1634
+ kotlin ( "(Math.floor(" (e 1) ")).toInt()" (imp "java.lang.Math"))
1507
1635
  * ( "Math.floor(" (e 1) ")")
1508
1636
  }
1509
1637
  }
@@ -1644,7 +1772,22 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
1644
1772
  templates {
1645
1773
  cpp ( "if ( " (e 1) ".has_value ) {" nl I (block 2) i nl "}" nl )
1646
1774
  }
1647
- }
1775
+ }
1776
+
1777
+ ; typed optional int/double with an else branch: r_optional_primitive is
1778
+ ; a value type (has_value field), not a pointer, so the generic :T
1779
+ ; `!= NULL` form below does not compile under clang. Emit `.has_value`.
1780
+ if cmdIf:void ( condition@(optional):int then_block:block else_block ) {
1781
+ templates {
1782
+ cpp ( "if ( " (e 1) ".has_value ) {" I nl (block 2) i nl "} else {" nl I (block 3) i "}" nl )
1783
+ }
1784
+ }
1785
+
1786
+ if cmdIf:void ( condition@(optional):double then_block:block else_block ) {
1787
+ templates {
1788
+ cpp ( "if ( " (e 1) ".has_value ) {" I nl (block 2) i nl "} else {" nl I (block 3) i "}" nl )
1789
+ }
1790
+ }
1648
1791
 
1649
1792
  if cmdIf:void ( condition@(optional):T then_block:block ) {
1650
1793
  templates {
@@ -1845,6 +1988,7 @@ fn r_read_file(path: &str, filename: &str) -> Option<String> {
1845
1988
  csharp ( "new " (typeof 1) "( new " (r_atype 1) "[" (e 2)"])")
1846
1989
  swift3 ( "" (typeof 1)"(repeating:" (e 3) ", count:" (e 2) ")" )
1847
1990
  ranger ( "(make _:" (typeof 1) " " (e 2) ")" )
1991
+ llvm ( "(make _:" (typeof 1) " " (e 2) ")" )
1848
1992
  go ( "make(" (typeof 1) "," (e 2) ")" )
1849
1993
  cpp ( (typeof 1) "(" (e 2) ")")
1850
1994
  ; new ArrayList<Double>( Arrays.asList( new Double[len_2] ) );
@@ -1886,9 +2030,18 @@ std::vector<T> r_make_vector_from_array( const T (&data)[N] )
1886
2030
  }
1887
2031
  null? cmdIsNotNull:boolean ( arg@(optional):string ) {
1888
2032
  templates {
1889
- cpp ((e 1) ".empty()")
2033
+ cpp ((e 1) ".empty()")
1890
2034
  }
1891
- }
2035
+ }
2036
+
2037
+ ; buffer is a value type (std::vector<uint8_t>) in C++, so the generic
2038
+ ; `!= NULL` path below does not compile. Treat empty/absent as null,
2039
+ ; mirroring the string overload above.
2040
+ null? cmdIsNotNull:boolean ( arg@(optional):buffer ) {
2041
+ templates {
2042
+ cpp ((e 1) ".empty()")
2043
+ }
2044
+ }
1892
2045
 
1893
2046
  null? cmdIsNull:boolean ( arg@(optional):T ) {
1894
2047
  templates {
@@ -1920,9 +2073,18 @@ std::vector<T> r_make_vector_from_array( const T (&data)[N] )
1920
2073
  }
1921
2074
  !null? cmdIsNotNull:boolean ( arg@(optional):string ) {
1922
2075
  templates {
1923
- cpp ((e 1) ".empty() == false ")
2076
+ cpp ((e 1) ".empty() == false ")
1924
2077
  }
1925
- }
2078
+ }
2079
+
2080
+ ; buffer is a value type (std::vector<uint8_t>) in C++; the generic
2081
+ ; `!= NULL` path below does not compile. Present == non-empty, matching
2082
+ ; the string overload above.
2083
+ !null? cmdIsNotNull:boolean ( arg@(optional):buffer ) {
2084
+ templates {
2085
+ cpp ((e 1) ".empty() == false ")
2086
+ }
2087
+ }
1926
2088
 
1927
2089
  !null? cmdIsNotNull:boolean ( arg@(optional):T ) {
1928
2090
  templates {
@@ -2037,7 +2199,7 @@ case class customException(smth:String) extends Exception
2037
2199
  i
2038
2200
  "}" nl
2039
2201
  )
2040
- go ( (def 2) (def 3) "var " (e 3) " int64 = 0; " nl "for ; " (e 3) " < int64(len(" (e 1) ")) ; " (e 3) "++ {" nl I nl (e 2) " := " (e 1) "[" (e 3) "];" nl (block 4) nl i "}" )
2202
+ go ( (forkctx _ ) (def 3) "var " (e 3) " int64 = 0; " nl "for ; " (e 3) " < int64(len(" (e 1) ")) ; " (e 3) "++ {" nl I nl (go_for_bind 2) nl (block 4) nl i "}" )
2041
2203
 
2042
2204
  php ( (forkctx _ ) (def 2) (def 3) "for ( " (e 3) " = 0; " (e 3) " < count(" (e 1) "); " (e 3) "++) {" nl I (e 2) " = " (e 1) "[" (e 3) "];" nl (block 4) nl i "}" )
2043
2205
  java7 ( (forkctx _ ) (def 2) (def 3) "for ( int " (e 3) " = 0; " (e 3) " < " (e 1) ".size(); " (e 3) "++) {" nl I (typeof 2) " " (e 2) " = " (e 1) ".get(" (e 3) ");" nl (block 4) nl i "}" )
@@ -2079,7 +2241,7 @@ case class customException(smth:String) extends Exception
2079
2241
  php ( "trim(" (e 1 ) ")")
2080
2242
  cpp ( "r_cpp_trim( " (e 1) ")" (imp "<cctype>") (imp "<string>") (imp "<algorithm>")
2081
2243
  (create_polyfill "
2082
- inline std::string r_cpp_trim(std::string &s)
2244
+ inline std::string r_cpp_trim(const std::string &s)
2083
2245
  {
2084
2246
  auto wsfront=std::find_if_not(s.begin(),s.end(),[](int c){return std::isspace(c);});
2085
2247
  auto wsback=std::find_if_not(s.rbegin(),s.rend(),[](int c){return std::isspace(c);}).base();
@@ -2188,6 +2350,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
2188
2350
 
2189
2351
  strlen cmdStrlen:int ( text:string ) {
2190
2352
  templates {
2353
+ llvm ( "(strlen " (e 1) ")")
2191
2354
  ranger ( "( strlen (" (e 1 ) "))")
2192
2355
  cpp ( '(int)('(e 1) ".length())")
2193
2356
  java7 ( (e 1) ".length()")
@@ -2203,6 +2366,50 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
2203
2366
  }
2204
2367
  }
2205
2368
 
2369
+ ; ISO calendar dates (YYYY-MM-DD). See lib/IsoDate/ and ai/ISO_DATE.md.
2370
+ iso_add_days cmdIsoAddDays:string ( iso:string days:int ) {
2371
+ templates {
2372
+ ranger ( "(DateMath.addDays " (e 1) " " (e 2) ")")
2373
+ kotlin ( "java.time.LocalDate.parse(" (e 1) ").plusDays(" (e 2) ".toLong()).toString()" (imp "java.time.LocalDate"))
2374
+ java7 ( "java.time.LocalDate.parse(" (e 1) ").plusDays(" (e 2) ").toString()" (imp "java.time.LocalDate"))
2375
+ es6 ( "((iso,d)=>{const p=iso.split('-').map(Number);const t=new Date(Date.UTC(p[0],p[1]-1,p[2]+d));return t.toISOString().slice(0,10)})(" (e 1) "," (e 2) ")")
2376
+ * ( "(DateMath.addDays " (e 1) " " (e 2) ")")
2377
+ }
2378
+ }
2379
+
2380
+ iso_compare cmdIsoCompare:int ( a:string b:string ) {
2381
+ templates {
2382
+ ranger ( "(DateMath.compareIso " (e 1) " " (e 2) ")")
2383
+ kotlin ( "java.time.LocalDate.parse(" (e 1) ").compareTo(java.time.LocalDate.parse(" (e 2) "))" (imp "java.time.LocalDate"))
2384
+ java7 ( "java.time.LocalDate.parse(" (e 1) ").compareTo(java.time.LocalDate.parse(" (e 2) "))" (imp "java.time.LocalDate"))
2385
+ es6 ( "((a,b)=>a<b?-1:a>b?1:0)(" (e 1) "," (e 2) ")")
2386
+ * ( "(DateMath.compareIso " (e 1) " " (e 2) ")")
2387
+ }
2388
+ }
2389
+
2390
+ iso_between cmdIsoBetween:boolean ( d:string start:string end:string ) {
2391
+ templates {
2392
+ ranger ( "(DateMath.isBetween " (e 1) " " (e 2) " " (e 3) ")")
2393
+ kotlin ( "(!java.time.LocalDate.parse(" (e 1) ").isBefore(java.time.LocalDate.parse(" (e 2) ")) && !java.time.LocalDate.parse(" (e 1) ").isAfter(java.time.LocalDate.parse(" (e 3) ")))" (imp "java.time.LocalDate"))
2394
+ java7 ( "(!java.time.LocalDate.parse(" (e 1) ").isBefore(java.time.LocalDate.parse(" (e 2) ")) && !java.time.LocalDate.parse(" (e 1) ").isAfter(java.time.LocalDate.parse(" (e 3) ")))" (imp "java.time.LocalDate"))
2395
+ es6 ( "((d,s,e)=>d>=s&&d<=e)(" (e 1) "," (e 2) "," (e 3) ")")
2396
+ * ( "(DateMath.isBetween " (e 1) " " (e 2) " " (e 3) ")")
2397
+ }
2398
+ }
2399
+
2400
+ ; Case-insensitive regex substring search. Pattern is a string (no /literal/). See lib/Regex/ and ai/REGEX.md.
2401
+ regex_test cmdRegexTest:boolean ( pattern:string haystack:string ) {
2402
+ templates {
2403
+ ranger ( "(RegexMatch.testIgnoreCase(" (e 1) " " (e 2) "))")
2404
+ kotlin ( "try { Regex(" (e 1) ", RegexOption.IGNORE_CASE).containsMatchIn(" (e 2) ") } catch (_: Exception) { false }" )
2405
+ java7 ( "try { java.util.regex.Pattern.compile(" (e 1) ", java.util.regex.Pattern.CASE_INSENSITIVE).matcher(" (e 2) ").find() } catch (Exception e) { false }" (imp "java.util.regex.Pattern"))
2406
+ es6 ( "(()=>{try{return new RegExp(" (e 1) ",'i').test(" (e 2) ");}catch{return false;}})()" )
2407
+ swift6 ( (e 2) ".range(of: " (e 1) ", options: [.regularExpression, .caseInsensitive]) != nil" )
2408
+ swift3 ( (e 2) ".range(of: " (e 1) ", options: [.regularExpression, .caseInsensitive]) != nil" )
2409
+ * ( "(RegexMatch.testIgnoreCase(" (e 1) " " (e 2) "))")
2410
+ }
2411
+ }
2412
+
2206
2413
  ; String s = new String(a, 2, 4)
2207
2414
 
2208
2415
  ; C#
@@ -2277,6 +2484,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
2277
2484
  ; Allocate a new buffer of specified size (zero-filled)
2278
2485
  buffer_alloc cmdBufferAlloc:buffer ( size:int ) {
2279
2486
  templates {
2487
+ llvm ( "(buffer_alloc " (e 1) ")" )
2280
2488
  ranger ( "(buffer_alloc " (e 1) ")" )
2281
2489
  es6 ( "(function(){ var b = new ArrayBuffer(" (e 1) "); b._view = new DataView(b); return b; })()" )
2282
2490
  go ( "make([]byte, " (e 1) ")" )
@@ -2292,6 +2500,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
2292
2500
  ; Get the length of a buffer in bytes
2293
2501
  buffer_length cmdBufferLength:int ( buf:buffer ) {
2294
2502
  templates {
2503
+ llvm ( "(buffer_length " (e 1) ")" )
2295
2504
  ranger ( "(buffer_length " (e 1) ")" )
2296
2505
  es6 ( (e 1) ".byteLength" )
2297
2506
  go ( "int64(len(" (e 1) "))" )
@@ -2307,6 +2516,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
2307
2516
  ; Read a single byte at offset (returns 0-255)
2308
2517
  buffer_get cmdBufferGet:int ( buf:buffer offset:int ) {
2309
2518
  templates {
2519
+ llvm ( "(buffer_get " (e 1) " " (e 2) ")" )
2310
2520
  ranger ( "(buffer_get " (e 1) " " (e 2) ")" )
2311
2521
  es6 ( (e 1) "._view.getUint8(" (e 2) ")" )
2312
2522
  go ( "int64(" (e 1) "[" (e 2) "])" )
@@ -2322,6 +2532,7 @@ std::vector<std::string> r_str_split(std::string data, std::string token) {
2322
2532
  ; Write a single byte at offset (value should be 0-255)
2323
2533
  buffer_set cmdBufferSet:void ( buf:buffer offset:int value:int ) {
2324
2534
  templates {
2535
+ llvm ( "(buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
2325
2536
  ranger ( "(buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
2326
2537
  es6 ( (e 1) "._view.setUint8(" (e 2) ", " (e 3) ")" )
2327
2538
  go ( (e 1) "[" (e 2) "] = byte(" (e 3) ")" )
@@ -2400,6 +2611,7 @@ std::string r_buffer_to_base64(const std::vector<uint8_t>& data) {
2400
2611
  ; Write buffer to a binary file
2401
2612
  buffer_write_file cmdBufferWriteFile:void ( path:string filename:string buf:buffer ) {
2402
2613
  templates {
2614
+ llvm ( "(buffer_write_file " (e 1) " " (e 2) " " (e 3) ")" )
2403
2615
  ranger ( "(buffer_write_file " (e 1) " " (e 2) " " (e 3) ")" )
2404
2616
  es6 ( "require('fs').writeFileSync(" (e 1) " + '/' + " (e 2) ", Buffer.from(" (e 3) "))" )
2405
2617
  go ( "os.WriteFile(" (e 1) " + \"/\" + " (e 2) ", " (e 3) ", 0644)" (imp "os") )
@@ -2422,6 +2634,7 @@ void r_buffer_write_file(const std::string& path, const std::string& filename, c
2422
2634
  ; Read a binary file into a buffer
2423
2635
  buffer_read_file cmdBufferReadFile:buffer ( path:string filename:string ) {
2424
2636
  templates {
2637
+ llvm ( "(buffer_read_file " (e 1) " " (e 2) ")" )
2425
2638
  ranger ( "(buffer_read_file " (e 1) " " (e 2) ")" )
2426
2639
  es6 ( "(function(){ var b = require('fs').readFileSync(" (e 1) " + '/' + " (e 2) "); var ab = new ArrayBuffer(b.length); var v = new Uint8Array(ab); for(var i=0;i<b.length;i++)v[i]=b[i]; ab._view = new DataView(ab); return ab; })()" )
2427
2640
  go ( "func() []byte { d, _ := os.ReadFile(filepath.Join(" (e 1) ", " (e 2) ")); return d }()" (imp "os") (imp "path/filepath") )
@@ -2497,6 +2710,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
2497
2710
  ; Allocate a new int_buffer of specified size (zero-filled)
2498
2711
  int_buffer_alloc cmdIntBufferAlloc:int_buffer ( size:int ) {
2499
2712
  templates {
2713
+ llvm ( "(int_buffer_alloc " (e 1) ")" )
2500
2714
  ranger ( "(int_buffer_alloc " (e 1) ")" )
2501
2715
  es6 ( "new Int32Array(" (e 1) ")" )
2502
2716
  go ( "make([]int64, " (e 1) ")" )
@@ -2527,6 +2741,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
2527
2741
  ; Read an int64 at index
2528
2742
  int_buffer_get cmdIntBufferGet:int ( buf:int_buffer index:int ) {
2529
2743
  templates {
2744
+ llvm ( "(int_buffer_get " (e 1) " " (e 2) ")" )
2530
2745
  ranger ( "(int_buffer_get " (e 1) " " (e 2) ")" )
2531
2746
  es6 ( (e 1) "[" (e 2) "]" )
2532
2747
  go ( (e 1) "[" (e 2) "]" )
@@ -2542,6 +2757,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
2542
2757
  ; Write an int64 at index
2543
2758
  int_buffer_set cmdIntBufferSet:void ( buf:int_buffer index:int value:int ) {
2544
2759
  templates {
2760
+ llvm ( "(int_buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
2545
2761
  ranger ( "(int_buffer_set " (e 1) " " (e 2) " " (e 3) ")" )
2546
2762
  es6 ( (e 1) "[" (e 2) "] = " (e 3) )
2547
2763
  go ( (e 1) "[" (e 2) "] = " (e 3) )
@@ -2557,6 +2773,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
2557
2773
  ; Fill int_buffer with a value in range [start, end)
2558
2774
  int_buffer_fill cmdIntBufferFill:void ( buf:int_buffer value:int start:int end:int ) {
2559
2775
  templates {
2776
+ llvm ( "(int_buffer_fill " (e 1) " " (e 2) " " (e 3) " " (e 4) ")" )
2560
2777
  ranger ( "(int_buffer_fill " (e 1) " " (e 2) " " (e 3) " " (e 4) ")" )
2561
2778
  es6 ( (e 1) ".fill(" (e 2) ", " (e 3) ", " (e 4) ")" )
2562
2779
  go ( "for i := " (e 3) "; i < " (e 4) "; i++ { " (e 1) "[i] = " (e 2) " }" )
@@ -2718,6 +2935,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
2718
2935
 
2719
2936
  to_int cmdToInt:int ( value:double ) {
2720
2937
  templates {
2938
+ llvm ( "(to_int " (e 1) ")" )
2721
2939
  ranger ( "(to_int " (e 1) ")")
2722
2940
  csharp ( "(int)" (e 1 ) "" )
2723
2941
  swift3 ( "Int(" (e 1 ) ")" )
@@ -2787,6 +3005,7 @@ std::vector<uint8_t> r_buffer_read_file(const std::string& path, const std::stri
2787
3005
  at _:string ( text:string position:int ) {
2788
3006
  templates {
2789
3007
  ranger ( '(at ' (e 1) ' ' ( e 2 ) ')')
3008
+ llvm ( "(at " (e 1) " " (e 2) ")")
2790
3009
  cpp ( 'r_utf8_char_at(' (e 1) ', ' (e 2) ')'
2791
3010
  (create_polyfill '
2792
3011
  std::string r_utf8_char_at(const std::string& str, int pos_i)
@@ -2835,6 +3054,7 @@ std::string r_utf8_char_at(const std::string& str, int pos_i)
2835
3054
 
2836
3055
  charAt cmdCharAt:int ( text:string position:int ) {
2837
3056
  templates {
3057
+ llvm ( "(charAt " (e 1) " " (e 2) ")")
2838
3058
  ranger ( "(charAt " (e 1) " " ( e 2 ) ")")
2839
3059
  cpp ( (e 1) ".at(" (e 2) ")")
2840
3060
  csharp ( (e 1) "[" (e 2) "]")
@@ -2914,10 +3134,10 @@ std::vector<std::string> r_get_keys_of_map( std::map<std::string, T> orig_map )
2914
3134
  (create_polyfill '
2915
3135
  std::string r_utf8_substr(const std::string& str, int start_i, int leng_i)
2916
3136
  {
2917
- unsigned int start ((unsigned int)start_i);
2918
- unsigned int leng ((unsigned int)leng_i);
3137
+ size_t start = (size_t)start_i;
3138
+ size_t leng = (size_t)leng_i;
2919
3139
  if (leng==0) { return ""; }
2920
- unsigned int c, i, ix, q, min= (unsigned int) std::string::npos, max=(unsigned int)std::string::npos;
3140
+ size_t c, i, ix, q, min= std::string::npos, max= std::string::npos;
2921
3141
  for (q=0, i=0, ix=str.length(); i < ix; i++, q++)
2922
3142
  {
2923
3143
  if (q==start){ min=i; }
@@ -2972,7 +3192,9 @@ std::string r_utf8_substr(const std::string& str, int start_i, int leng_i)
2972
3192
  ranger ( "(strfromcode " (e 1) ")")
2973
3193
  csharp ( "((char)" (e 1) ").toString()")
2974
3194
  java7 ( "(new String( new char[] {" (e 1) " }))")
3195
+ kotlin ( (e 1) ".toChar().toString()")
2975
3196
  swift3 ( "(String( Character( UnicodeScalar(" (e 1) " ) )))")
3197
+ swift6 ( "String(UnicodeScalar(" (e 1) ")!)")
2976
3198
  php ( "chr(" (e 1) ")")
2977
3199
  scala ( "(" (e 1) ".toChar)")
2978
3200
  go ("string([]rune{rune(" (e 1) ")})")
@@ -2988,7 +3210,9 @@ std::string r_utf8_substr(const std::string& str, int start_i, int leng_i)
2988
3210
  ranger ( "(strfromcode " (e 1) ")")
2989
3211
  csharp ( "((char)" (e 1) ").toString()")
2990
3212
  java7 ( "(new String( Character.toChars(" (e 1) ")))")
3213
+ kotlin ( (e 1) ".toChar().toString()")
2991
3214
  swift3 ( "(String( Character( UnicodeScalar(" (e 1) " )! )))")
3215
+ swift6 ( "String(UnicodeScalar(" (e 1) ")!)")
2992
3216
  php ( "chr(" (e 1) ")")
2993
3217
  scala ( "(" (e 1) ".toChar)")
2994
3218
  go ("string([]rune{rune(" (e 1) ")})")
@@ -3384,6 +3608,9 @@ std::string join(const T& v, const std::string& delim) {
3384
3608
  get cmdGet@(optional):T ( a:[T] index:int ) {
3385
3609
  templates {
3386
3610
  es6 ('( ' (e 1) '.length > ' (e 2)' && ' (e 2)' >= 0 ? '(e 1) '[' (e 2)'] : null ) ')
3611
+ ranger ( "(get " (e 1) " " (e 2) ")")
3612
+ llvm ( "(get " (e 1) " " (e 2) ")")
3613
+ * ( (e 1) "[" (e 2) "]" )
3387
3614
  }
3388
3615
  }
3389
3616
 
@@ -3429,12 +3656,71 @@ r_optional_primitive<int> cpp_get_map_int_value( std::map<" (r_ktype 1) ", int>
3429
3656
  )
3430
3657
  }
3431
3658
  }
3659
+
3660
+ get cmdGet@(optional weak):double ( map:[K:double] key:K ) {
3661
+ templates {
3662
+ cpp( "cpp_get_map_string_double_value(" (e 1) ", " (e 2) ")"
3663
+ (create_polyfill
3664
+ "
3665
+ template <class T>
3666
+ class r_optional_primitive {
3667
+ public:
3668
+ bool has_value;
3669
+ T value;
3670
+ r_optional_primitive<T> & operator=(const r_optional_primitive<T> & rhs) {
3671
+ has_value = rhs.has_value;
3672
+ value = rhs.value;
3673
+ return *this;
3674
+ }
3675
+ r_optional_primitive<T> & operator=(const T a_value) {
3676
+ has_value = true;
3677
+ value = a_value;
3678
+ return *this;
3679
+ }
3680
+ };
3681
+ "
3682
+ )
3683
+ (macro
3684
+ ("
3685
+ r_optional_primitive<double> cpp_get_map_string_double_value( std::map<std::string, double> m , std::string key) {
3686
+ r_optional_primitive<double> result;
3687
+ auto it = m.find(key);
3688
+ if (it != m.end()) {
3689
+ result.value = it->second;
3690
+ result.has_value = true;
3691
+ }
3692
+ return result;
3693
+ }")
3694
+ )
3695
+ )
3696
+ ranger ( "(get " (e 1) " " (e 2) ")")
3697
+ llvm ( "(get " (e 1) " " (e 2) ")")
3698
+ es6 ( "( " (e 1) ".hasOwnProperty(" (e 2) ") ? " (e 1) "[" (e 2) "] : undefined )" )
3699
+ * ( (e 1) "[" (e 2) "]" )
3700
+ }
3701
+ }
3432
3702
 
3433
3703
  get cmdGet@(optional weak):T ( map:[K:T] key:K ) {
3434
3704
  templates {
3435
3705
  ranger ( "(get " (e 1) " " (e 2) ")")
3706
+ llvm ( "(get " (e 1) " " (e 2) ")")
3436
3707
  java7 ( (e 1) ".get(" (e 2) ")" )
3437
3708
  rust ( (e 1) ".get(" (e 2) ")" )
3709
+ cpp ( "r_map_get_val(" (e 1) ", " (e 2) ")"
3710
+ (create_polyfill
3711
+ "
3712
+ // Map read that never inserts on miss (unlike std::map::operator[]) and does a
3713
+ // single lookup. Returns a default-constructed value (e.g. null shared_ptr)
3714
+ // when the key is absent.
3715
+ template<typename M, typename K>
3716
+ typename M::mapped_type r_map_get_val( const M & m , const K & key) {
3717
+ auto it = m.find(key);
3718
+ if ( it != m.end() ) { return it->second; }
3719
+ return typename M::mapped_type();
3720
+ }
3721
+ "
3722
+ )
3723
+ )
3438
3724
 
3439
3725
  scala ( (e 1) ".get(" (e 2) ")" )
3440
3726
 
@@ -3465,6 +3751,7 @@ i "}" nl ))
3465
3751
  set cmdSet@(moves@( 3 1 ) ):void ( array@(mutates):[T] index:int value@( refto@(1) ):T ) {
3466
3752
  templates {
3467
3753
  ranger ( "set " (e 1) " " (e 2) " " (e 3) )
3754
+ llvm ( "set " (e 1) " " (e 2) " " (e 3) )
3468
3755
  java7 ( (e 1) ".set(" (e 2) ", " (e 3) ");" )
3469
3756
  rust ( (e 1) "[" (e 2) " as usize] = " (e 3) ";" )
3470
3757
  scala ( (e 1) "(" (e 2) ") = " (e 3) )
@@ -3479,6 +3766,7 @@ i "}" nl ))
3479
3766
  set cmdSet@(moves@( 3 1 ) ):void ( map@(mutates):[K:T] key:K value@( refto@(1) ):T ) {
3480
3767
  templates {
3481
3768
  ranger ( "set " (e 1) " " (e 2) " " (e 3) )
3769
+ llvm ( "set " (e 1) " " (e 2) " " (e 3) )
3482
3770
  java7 ( (e 1) ".put(" (e 2) ", " (e 3) ");" )
3483
3771
  rust ( (e 1) ".insert(" (e 2) ", " (e 3) ");" )
3484
3772
  scala ( (e 1) ".put(" (e 2) ", " (e 3) ")" )
@@ -3504,6 +3792,7 @@ i "}" nl ))
3504
3792
  itemAt cmdItemAt@(weak):T ( array:[T] index:int ) {
3505
3793
  templates {
3506
3794
  ranger ( "(itemAt " (e 1) " " (e 2) ")" )
3795
+ llvm ( "(itemAt " (e 1) " " (e 2) ")" )
3507
3796
  cpp ( (e 1) ".at(" (e 2) ")" (imp "<vector>"))
3508
3797
  java7 ( (e 1) ".get(" (e 2) ")" )
3509
3798
  ; lift return optional type => safer
@@ -3565,6 +3854,7 @@ int r_string_index_of_from( std::string str, std::string key, int start ) {
3565
3854
  " )
3566
3855
  )
3567
3856
  rust ( "(" (e 1) "[" (e 3) " as usize..].find(&*" (e 2) ").map(|i| (i + " (e 3) " as usize) as i64).unwrap_or(-1))" )
3857
+ kotlin ( (e 1) ".indexOf(" (e 2 ) ", " (e 3) ")" )
3568
3858
  ranger ( "(indexOfFrom " (e 1) " " (e 2) " " (e 3) ")")
3569
3859
  }
3570
3860
  }
@@ -3869,6 +4159,7 @@ func r_index_of ( arr:" (typeof 1) " , elem: " (typeof 2) ") -> Int { " nl I
3869
4159
 
3870
4160
  length cmdStrlen:int ( text:string ) {
3871
4161
  templates {
4162
+ llvm ( "(length " (e 1) ")")
3872
4163
  ranger ( "(length " (e 1) ")")
3873
4164
  cpp ( (e 1) ".length()")
3874
4165
  java7 ( (e 1) ".length()")
@@ -3964,6 +4255,7 @@ func r_index_of ( arr:" (typeof 1) " , elem: " (typeof 2) ") -> Int { " nl I
3964
4255
  array_length cmdArrayLength:int ( array:[T] ) {
3965
4256
  templates {
3966
4257
  ranger ( "(array_length " (e 1) ")")
4258
+ llvm ( "(array_length " (e 1) ")")
3967
4259
  cpp ( '(int)(' (e 1) ".size())" )
3968
4260
  swift3 ( (e 1) ".count")
3969
4261
  swift6 ( (e 1) ".count")
@@ -4027,6 +4319,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
4027
4319
  print cmdPrint:void ( text:string) {
4028
4320
  templates {
4029
4321
  ranger ( nl "print " (e 1) nl)
4322
+ llvm ( nl "print " (e 1) nl)
4030
4323
  cpp (ln "std::cout << " (e 1) " << std::endl;" nl (imp "<iostream>") (imp "<string>"))
4031
4324
  kotlin ( nl "println( " (e 1) " )" nl )
4032
4325
  scala ( "println( " (e 1) " )" )
@@ -4046,6 +4339,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
4046
4339
  ; Write text without newline
4047
4340
  write cmdWrite:void ( text:string) {
4048
4341
  templates {
4342
+ llvm ( nl "write " (e 1) nl)
4049
4343
  cpp ( nl "std::cout << " (e 1) " << std::flush;" nl (imp "<iostream>"))
4050
4344
  go ( nl "fmt.Print( " (e 1) " )" nl (imp "fmt"))
4051
4345
  rust ( nl "print!(\"{}\", " (e 1) ");" nl)
@@ -4063,6 +4357,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
4063
4357
  ; Clear the terminal screen
4064
4358
  clear_screen cmdClearScreen:void () {
4065
4359
  templates {
4360
+ llvm ( nl "clear_screen" nl)
4066
4361
  cpp ( nl "std::cout << \"\\x1b[2J\\x1b[H\" << std::flush;" nl (imp "<iostream>"))
4067
4362
  go ( nl "fmt.Print(\"\\x1b[2J\\x1b[H\")" nl (imp "fmt"))
4068
4363
  rust ( nl "print!(\"\\x1b[2J\\x1b[H\");" nl)
@@ -4080,6 +4375,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
4080
4375
  ; Move cursor to position (1-based coordinates)
4081
4376
  move_cursor cmdMoveCursor:void ( x:int y:int) {
4082
4377
  templates {
4378
+ llvm ( nl "move_cursor " (e 1) " " (e 2) nl)
4083
4379
  cpp ( nl "std::cout << \"\\x1b[\" << (" (e 2) ") << \";\" << (" (e 1) ") << \"H\" << std::flush;" nl (imp "<iostream>"))
4084
4380
  go ( nl "fmt.Printf(\"\\x1b[%d;%dH\", " (e 2) ", " (e 1) ")" nl (imp "fmt"))
4085
4381
  rust ( nl "print!(\"\\x1b[{};{}H\", " (e 2) ", " (e 1) ");" nl)
@@ -4097,6 +4393,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
4097
4393
  ; Hide terminal cursor
4098
4394
  hide_cursor cmdHideCursor:void () {
4099
4395
  templates {
4396
+ llvm ( nl "hide_cursor" nl)
4100
4397
  cpp ( nl "std::cout << \"\\x1b[?25l\" << std::flush;" nl (imp "<iostream>"))
4101
4398
  go ( nl "fmt.Print(\"\\x1b[?25l\")" nl (imp "fmt"))
4102
4399
  rust ( nl "print!(\"\\x1b[?25l\");" nl)
@@ -4114,6 +4411,7 @@ public <T> T _arr_extract( ArrayList<T> list, Integer i ) {
4114
4411
  ; Show terminal cursor
4115
4412
  show_cursor cmdShowCursor:void () {
4116
4413
  templates {
4414
+ llvm ( nl "show_cursor" nl)
4117
4415
  cpp ( nl "std::cout << \"\\x1b[?25h\" << std::flush;" nl (imp "<iostream>"))
4118
4416
  go ( nl "fmt.Print(\"\\x1b[?25h\")" nl (imp "fmt"))
4119
4417
  rust ( nl "print!(\"\\x1b[?25h\");" nl)
@@ -4839,6 +5137,7 @@ fun r_read_key(): String {
4839
5137
  ; Sleep for specified milliseconds (blocking)
4840
5138
  sleep_ms cmdSleepMs@(async):void (ms:int) {
4841
5139
  templates {
5140
+ llvm ( nl "sleep_ms " (e 1) nl)
4842
5141
  es6 ( nl "await new Promise(r => setTimeout(r, " (e 1) "));" nl )
4843
5142
  rust ( nl "std::thread::sleep(std::time::Duration::from_millis(" (e 1) " as u64));" nl )
4844
5143
  go ( nl "time.Sleep(time.Duration(" (e 1) ") * time.Millisecond)" nl (imp "time"))
@@ -4856,6 +5155,7 @@ fun r_read_key(): String {
4856
5155
 
4857
5156
  exit cmdExit:void ( code:int) {
4858
5157
  templates {
5158
+ llvm ( nl "exit " (e 1) nl)
4859
5159
  ranger ( nl "exit " (e 1) nl)
4860
5160
  cpp ( nl "exit(" (e 1) ");" nl (imp "<cstdlib>"))
4861
5161
  kotlin ( nl "System.exit(" (e 1) ")" nl )
@@ -4875,17 +5175,35 @@ fun r_read_key(): String {
4875
5175
  templates {
4876
5176
  es6 ((e 1) '.toLowerCase()')
4877
5177
  java7 ((e 1) '.toLowerCase()')
5178
+ kotlin ((e 1) '.lowercase()')
4878
5179
  go ( "strings.ToLower(" (e 1) ")" (imp "strings"))
4879
5180
  php ("strtolower(" (e 1) ")")
4880
5181
  csharp ((e 1) ".ToLower()")
4881
5182
  swift3 ((e 1) ".lowercased()")
5183
+ swift6 ((e 1) ".lowercased()")
4882
5184
  scala ((e 1) ".toLowerCase()")
4883
5185
  python ((e 1) ".lower()")
5186
+ cpp (
5187
+ "r_cpp_str_to_lowercase(" (e 1) ")"
5188
+ (imp "<algorithm>")
5189
+ (imp "<string>")
5190
+ (create_polyfill "
5191
+ std::string r_cpp_str_to_lowercase(std::string original)
5192
+ {
5193
+ std::string str = original;
5194
+ std::transform(str.begin(), str.end(), str.begin(), ::tolower);
5195
+ return str;
5196
+ }
5197
+ ")
5198
+
5199
+ )
4884
5200
  }
4885
5201
  }
4886
5202
  to_uppercase _:string (s:string) {
4887
5203
  templates {
4888
5204
  swift3 ( (e 1) ".uppercased()")
5205
+ swift6 ( (e 1) ".uppercased()")
5206
+ kotlin ( (e 1) ".uppercase()" )
4889
5207
  scala ( (e 1 ) ".toUpperCase()" )
4890
5208
  ranger ("(to_uppercase " (e 1) ")")
4891
5209
  es6 ( (e 1) ".toUpperCase()")
@@ -4917,6 +5235,7 @@ std::string r_cpp_str_to_uppercase(std::string original)
4917
5235
 
4918
5236
  to_double toDouble:double ( input:int ) {
4919
5237
  templates {
5238
+ llvm ( "(to_double " (e 1) ")" )
4920
5239
  ranger ("( to_double " (e 1) " )")
4921
5240
  go ("float64( " (e 1) " )")
4922
5241
  es6 ( (e 1) )
@@ -5353,6 +5672,26 @@ std::string r_cpp_str_to_uppercase(std::string original)
5353
5672
 
5354
5673
  ; proc_send is lowered in ng_RangerProcessProcSend.rgr (typed handler methods, overload match).
5355
5674
 
5675
+ begin_dispatch_turn@(moves@( 1 )) cmdBeginDispatchTurn:void (root:RangerProcessBase) {
5676
+ templates {
5677
+ es6 ( "ProcessRuntime.beginDispatchTurn(" (e 1) ")" )
5678
+ kotlin ( "ProcessRuntime.beginDispatchTurn(" (e 1) ")" )
5679
+ swift6 ( "ProcessRuntime.beginDispatchTurn(root: " (e 1) ")" )
5680
+ swift3 ( "ProcessRuntime.beginDispatchTurn(root: " (e 1) ")" )
5681
+ * ( "/* begin_dispatch_turn not implemented */" )
5682
+ }
5683
+ }
5684
+
5685
+ end_dispatch_turn@(moves@( 1 )) cmdEndDispatchTurn:void (root:RangerProcessBase) {
5686
+ templates {
5687
+ es6 ( "ProcessRuntime.endDispatchTurn(" (e 1) ")" )
5688
+ kotlin ( "ProcessRuntime.endDispatchTurn(" (e 1) ")" )
5689
+ swift6 ( "ProcessRuntime.endDispatchTurn(root: " (e 1) ")" )
5690
+ swift3 ( "ProcessRuntime.endDispatchTurn(root: " (e 1) ")" )
5691
+ * ( "/* end_dispatch_turn not implemented */" )
5692
+ }
5693
+ }
5694
+
5356
5695
  proc_start@(moves@( 1 )) cmdProcStart:void (proc:RangerProcessBase) {
5357
5696
  templates {
5358
5697
  es6 ( "ProcessRuntime.startInstance(" (e 1) ")" )
@@ -5437,6 +5776,7 @@ systemclass buffer {
5437
5776
  csharp "byte[]"
5438
5777
  kotlin ByteArray
5439
5778
  scala "Array[Byte]"
5779
+ llvm i64
5440
5780
  }
5441
5781
 
5442
5782
  ; SYSTEM CLASS: int_buffer
@@ -5456,6 +5796,7 @@ systemclass int_buffer {
5456
5796
  csharp "long[]"
5457
5797
  kotlin LongArray
5458
5798
  scala "Array[Long]"
5799
+ llvm i64
5459
5800
  }
5460
5801
 
5461
5802
  ; SYSTEM CLASS: double_buffer
@@ -5475,6 +5816,7 @@ systemclass double_buffer {
5475
5816
  csharp "double[]"
5476
5817
  kotlin DoubleArray
5477
5818
  scala "Array[Double]"
5819
+ llvm i64
5478
5820
  }
5479
5821
 
5480
5822
  ; ============================================================================