-
Notifications
You must be signed in to change notification settings - Fork 0
/
out.lua
2465 lines (2384 loc) · 74.9 KB
/
out.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Generated by Haxe 4.1.5
local _hx_hidden = {__id__=true, hx__closures=true, super=true, prototype=true, __fields__=true, __ifields__=true, __class__=true, __properties__=true, __fields__=true, __name__=true}
_hx_array_mt = {
__newindex = function(t,k,v)
local len = t.length
t.length = k >= len and (k + 1) or len
rawset(t,k,v)
end
}
function _hx_is_array(o)
return type(o) == "table"
and o.__enum__ == nil
and getmetatable(o) == _hx_array_mt
end
function _hx_tab_array(tab, length)
tab.length = length
return setmetatable(tab, _hx_array_mt)
end
function _hx_print_class(obj, depth)
local first = true
local result = ''
for k,v in pairs(obj) do
if _hx_hidden[k] == nil then
if first then
first = false
else
result = result .. ', '
end
if _hx_hidden[k] == nil then
result = result .. k .. ':' .. _hx_tostring(v, depth+1)
end
end
end
return '{ ' .. result .. ' }'
end
function _hx_print_enum(o, depth)
if o.length == 2 then
return o[0]
else
local str = o[0] .. "("
for i = 2, (o.length-1) do
if i ~= 2 then
str = str .. "," .. _hx_tostring(o[i], depth+1)
else
str = str .. _hx_tostring(o[i], depth+1)
end
end
return str .. ")"
end
end
function _hx_tostring(obj, depth)
if depth == nil then
depth = 0
elseif depth > 5 then
return "<...>"
end
local tstr = _G.type(obj)
if tstr == "string" then return obj
elseif tstr == "nil" then return "null"
elseif tstr == "number" then
if obj == _G.math.POSITIVE_INFINITY then return "Infinity"
elseif obj == _G.math.NEGATIVE_INFINITY then return "-Infinity"
elseif obj == 0 then return "0"
elseif obj ~= obj then return "NaN"
else return _G.tostring(obj)
end
elseif tstr == "boolean" then return _G.tostring(obj)
elseif tstr == "userdata" then
local mt = _G.getmetatable(obj)
if mt ~= nil and mt.__tostring ~= nil then
return _G.tostring(obj)
else
return "<userdata>"
end
elseif tstr == "function" then return "<function>"
elseif tstr == "thread" then return "<thread>"
elseif tstr == "table" then
if obj.__enum__ ~= nil then
return _hx_print_enum(obj, depth)
elseif obj.toString ~= nil and not _hx_is_array(obj) then return obj:toString()
elseif _hx_is_array(obj) then
if obj.length > 5 then
return "[...]"
else
str = ""
for i=0, (obj.length-1) do
if i == 0 then
str = str .. _hx_tostring(obj[i], depth+1)
else
str = str .. "," .. _hx_tostring(obj[i], depth+1)
end
end
return "[" .. str .. "]"
end
elseif obj.__class__ ~= nil then
return _hx_print_class(obj, depth)
else
first = true
buffer = {}
for k,v in pairs(obj) do
if _hx_hidden[k] == nil then
_G.table.insert(buffer, _hx_tostring(k, depth+1) .. ' : ' .. _hx_tostring(obj[k], depth+1))
end
end
return "{ " .. table.concat(buffer, ", ") .. " }"
end
else
_G.error("Unknown Lua type", 0)
return ""
end
end
function _hx_error(obj)
print(obj)
if obj.value then
_G.print("Runtime Error: " .. _hx_tostring(obj.value));
else
_G.print("Runtime Error: " .. tostring(obj));
end
if _G.debug and _G.debug.traceback then
_G.print(debug.traceback());
end
end
local function _hx_obj_newindex(t,k,v)
t.__fields__[k] = true
rawset(t,k,v)
end
local _hx_obj_mt = {__newindex=_hx_obj_newindex, __tostring=_hx_tostring}
local function _hx_a(...)
local __fields__ = {};
local ret = {__fields__ = __fields__};
local max = select('#',...);
local tab = {...};
local cur = 1;
while cur < max do
local v = tab[cur];
__fields__[v] = true;
ret[v] = tab[cur+1];
cur = cur + 2
end
return setmetatable(ret, _hx_obj_mt)
end
local function _hx_e()
return setmetatable({__fields__ = {}}, _hx_obj_mt)
end
local function _hx_o(obj)
return setmetatable(obj, _hx_obj_mt)
end
local function _hx_new(prototype)
return setmetatable({__fields__ = {}}, {__newindex=_hx_obj_newindex, __index=prototype, __tostring=_hx_tostring})
end
function _hx_field_arr(obj)
res = {}
idx = 0
if obj.__fields__ ~= nil then
obj = obj.__fields__
end
for k,v in pairs(obj) do
if _hx_hidden[k] == nil then
res[idx] = k
idx = idx + 1
end
end
return _hx_tab_array(res, idx)
end
local _hxClasses = {}
local Int = _hx_e();
local Dynamic = _hx_e();
local Float = _hx_e();
local Bool = _hx_e();
local Class = _hx_e();
local Enum = _hx_e();
local Array = _hx_e()
__lua_lib_lrexlib_Rex = _G.require("rex_pcre")
__lua_lib_luautf8_Utf8 = _G.require("lua-utf8")
local EReg = _hx_e()
local Math = _hx_e()
local String = _hx_e()
local Std = _hx_e()
local StringBuf = _hx_e()
local StringTools = _hx_e()
___Xml_XmlType_Impl_ = _hx_e()
local Xml = _hx_e()
__haxe_IMap = _hx_e()
__haxe_Exception = _hx_e()
__haxe_NativeStackTrace = _hx_e()
__haxe_ValueException = _hx_e()
__haxe_ds_StringMap = _hx_e()
__haxe_iterators_ArrayIterator = _hx_e()
__haxe_iterators_ArrayKeyValueIterator = _hx_e()
__haxe_xml__Access_NodeAccess_Impl_ = _hx_e()
__haxe_xml__Access_AttribAccess_Impl_ = _hx_e()
__haxe_xml__Access_HasAttribAccess_Impl_ = _hx_e()
__haxe_xml__Access_NodeListAccess_Impl_ = _hx_e()
__haxe_xml_Printer = _hx_e()
__lua_Boot = _hx_e()
__lua_UserData = _hx_e()
__lua_Thread = _hx_e()
__parallax_Parallax = _hx_e()
__parallax_ParallaxCamera = _hx_e()
__parallax_ParallaxLayer = _hx_e()
__parallax_ParallaxSprite = _hx_e()
local _hx_bind, _hx_bit, _hx_staticToInstance, _hx_funcToField, _hx_maxn, _hx_print, _hx_apply_self, _hx_box_mr, _hx_bit_clamp, _hx_table, _hx_bit_raw
local _hx_pcall_default = {};
local _hx_pcall_break = {};
Array.new = function()
local self = _hx_new(Array.prototype)
Array.super(self)
return self
end
Array.super = function(self)
_hx_tab_array(self, 0);
end
Array.__name__ = true
Array.prototype = _hx_e();
Array.prototype.concat = function(self,a)
local _g = _hx_tab_array({}, 0);
local _g1 = 0;
local _g2 = self;
while (_g1 < _g2.length) do
local i = _g2[_g1];
_g1 = _g1 + 1;
_g:push(i);
end;
local ret = _g;
local _g = 0;
while (_g < a.length) do
local i = a[_g];
_g = _g + 1;
ret:push(i);
end;
do return ret end
end
Array.prototype.join = function(self,sep)
local tbl = ({});
local _g_current = 0;
local _g_array = self;
while (_g_current < _g_array.length) do
_g_current = _g_current + 1;
local i = _g_array[_g_current - 1];
_G.table.insert(tbl, Std.string(i));
end;
do return _G.table.concat(tbl, sep) end
end
Array.prototype.pop = function(self)
if (self.length == 0) then
do return nil end;
end;
local ret = self[self.length - 1];
self[self.length - 1] = nil;
self.length = self.length - 1;
do return ret end
end
Array.prototype.push = function(self,x)
self[self.length] = x;
do return self.length end
end
Array.prototype.reverse = function(self)
local tmp;
local i = 0;
while (i < Std.int(self.length / 2)) do
tmp = self[i];
self[i] = self[(self.length - i) - 1];
self[(self.length - i) - 1] = tmp;
i = i + 1;
end;
end
Array.prototype.shift = function(self)
if (self.length == 0) then
do return nil end;
end;
local ret = self[0];
if (self.length == 1) then
self[0] = nil;
else
if (self.length > 1) then
self[0] = self[1];
_G.table.remove(self, 1);
end;
end;
local tmp = self;
tmp.length = tmp.length - 1;
do return ret end
end
Array.prototype.slice = function(self,pos,_end)
if ((_end == nil) or (_end > self.length)) then
_end = self.length;
else
if (_end < 0) then
_end = _G.math.fmod((self.length - (_G.math.fmod(-_end, self.length))), self.length);
end;
end;
if (pos < 0) then
pos = _G.math.fmod((self.length - (_G.math.fmod(-pos, self.length))), self.length);
end;
if ((pos > _end) or (pos > self.length)) then
do return _hx_tab_array({}, 0) end;
end;
local ret = _hx_tab_array({}, 0);
local _g = pos;
local _g1 = _end;
while (_g < _g1) do
_g = _g + 1;
local i = _g - 1;
ret:push(self[i]);
end;
do return ret end
end
Array.prototype.sort = function(self,f)
local i = 0;
local l = self.length;
while (i < l) do
local swap = false;
local j = 0;
local max = (l - i) - 1;
while (j < max) do
if (f(self[j], self[j + 1]) > 0) then
local tmp = self[j + 1];
self[j + 1] = self[j];
self[j] = tmp;
swap = true;
end;
j = j + 1;
end;
if (not swap) then
break;
end;
i = i + 1;
end;
end
Array.prototype.splice = function(self,pos,len)
if ((len < 0) or (pos > self.length)) then
do return _hx_tab_array({}, 0) end;
else
if (pos < 0) then
pos = self.length - (_G.math.fmod(-pos, self.length));
end;
end;
len = Math.min(len, self.length - pos);
local ret = _hx_tab_array({}, 0);
local _g = pos;
local _g1 = pos + len;
while (_g < _g1) do
_g = _g + 1;
local i = _g - 1;
ret:push(self[i]);
self[i] = self[i + len];
end;
local _g = pos + len;
local _g1 = self.length;
while (_g < _g1) do
_g = _g + 1;
local i = _g - 1;
self[i] = self[i + len];
end;
local tmp = self;
tmp.length = tmp.length - len;
do return ret end
end
Array.prototype.toString = function(self)
local tbl = ({});
_G.table.insert(tbl, "[");
_G.table.insert(tbl, self:join(","));
_G.table.insert(tbl, "]");
do return _G.table.concat(tbl, "") end
end
Array.prototype.unshift = function(self,x)
local len = self.length;
local _g = 0;
local _g1 = len;
while (_g < _g1) do
_g = _g + 1;
local i = _g - 1;
self[len - i] = self[(len - i) - 1];
end;
self[0] = x;
end
Array.prototype.insert = function(self,pos,x)
if (pos > self.length) then
pos = self.length;
end;
if (pos < 0) then
pos = self.length + pos;
if (pos < 0) then
pos = 0;
end;
end;
local cur_len = self.length;
while (cur_len > pos) do
self[cur_len] = self[cur_len - 1];
cur_len = cur_len - 1;
end;
self[pos] = x;
end
Array.prototype.remove = function(self,x)
local _g = 0;
local _g1 = self.length;
while (_g < _g1) do
_g = _g + 1;
local i = _g - 1;
if (self[i] == x) then
local _g = i;
local _g1 = self.length - 1;
while (_g < _g1) do
_g = _g + 1;
local j = _g - 1;
self[j] = self[j + 1];
end;
self[self.length - 1] = nil;
self.length = self.length - 1;
do return true end;
end;
end;
do return false end
end
Array.prototype.contains = function(self,x)
local _g = 0;
local _g1 = self.length;
while (_g < _g1) do
_g = _g + 1;
local i = _g - 1;
if (self[i] == x) then
do return true end;
end;
end;
do return false end
end
Array.prototype.indexOf = function(self,x,fromIndex)
local _end = self.length;
if (fromIndex == nil) then
fromIndex = 0;
else
if (fromIndex < 0) then
fromIndex = self.length + fromIndex;
if (fromIndex < 0) then
fromIndex = 0;
end;
end;
end;
local _g = fromIndex;
local _g1 = _end;
while (_g < _g1) do
_g = _g + 1;
local i = _g - 1;
if (x == self[i]) then
do return i end;
end;
end;
do return -1 end
end
Array.prototype.lastIndexOf = function(self,x,fromIndex)
if ((fromIndex == nil) or (fromIndex >= self.length)) then
fromIndex = self.length - 1;
else
if (fromIndex < 0) then
fromIndex = self.length + fromIndex;
if (fromIndex < 0) then
do return -1 end;
end;
end;
end;
local i = fromIndex;
while (i >= 0) do
if (self[i] == x) then
do return i end;
else
i = i - 1;
end;
end;
do return -1 end
end
Array.prototype.copy = function(self)
local _g = _hx_tab_array({}, 0);
local _g1 = 0;
local _g2 = self;
while (_g1 < _g2.length) do
local i = _g2[_g1];
_g1 = _g1 + 1;
_g:push(i);
end;
do return _g end
end
Array.prototype.map = function(self,f)
local _g = _hx_tab_array({}, 0);
local _g1 = 0;
local _g2 = self;
while (_g1 < _g2.length) do
local i = _g2[_g1];
_g1 = _g1 + 1;
_g:push(f(i));
end;
do return _g end
end
Array.prototype.filter = function(self,f)
local _g = _hx_tab_array({}, 0);
local _g1 = 0;
local _g2 = self;
while (_g1 < _g2.length) do
local i = _g2[_g1];
_g1 = _g1 + 1;
if (f(i)) then
_g:push(i);
end;
end;
do return _g end
end
Array.prototype.iterator = function(self)
do return __haxe_iterators_ArrayIterator.new(self) end
end
Array.prototype.keyValueIterator = function(self)
do return __haxe_iterators_ArrayKeyValueIterator.new(self) end
end
Array.prototype.resize = function(self,len)
if (self.length < len) then
self.length = len;
else
if (self.length > len) then
local _g = len;
local _g1 = self.length;
while (_g < _g1) do
_g = _g + 1;
local i = _g - 1;
self[i] = nil;
end;
self.length = len;
end;
end;
end
Array.prototype.__class__ = Array
EReg.new = function(r,opt)
local self = _hx_new(EReg.prototype)
EReg.super(self,r,opt)
return self
end
EReg.super = function(self,r,opt)
local ropt = 0;
local _g = 0;
local _g1 = __lua_lib_luautf8_Utf8.len(opt);
while (_g < _g1) do
_g = _g + 1;
local i = _g - 1;
local _g = __lua_lib_luautf8_Utf8.sub(opt, i + 1, i + 1);
if (_g) == "g" then
self.global = true;
elseif (_g) == "i" then
ropt = _hx_bit.bor(ropt,EReg.FLAGS.CASELESS);
elseif (_g) == "m" then
ropt = _hx_bit.bor(ropt,EReg.FLAGS.MULTILINE);
elseif (_g) == "s" then
ropt = _hx_bit.bor(ropt,EReg.FLAGS.DOTALL);else end;
end;
ropt = _hx_bit.bor(ropt,EReg.FLAGS.UTF8);
ropt = _hx_bit.bor(ropt,EReg.FLAGS.UCP);
if (self.global == nil) then
self.global = false;
end;
self.r = __lua_lib_lrexlib_Rex.new(r, ropt);
end
EReg.__name__ = true
EReg.prototype = _hx_e();
EReg.prototype.replace = function(self,s,by)
local idx = 1;
local ret = _hx_tab_array({}, 0);
while (idx ~= nil) do
local newidx = 0;
if (__lua_lib_luautf8_Utf8.len("$$") > 0) then
newidx = __lua_lib_luautf8_Utf8.find(by, "$$", idx, true);
else
if (idx >= __lua_lib_luautf8_Utf8.len(by)) then
newidx = nil;
else
newidx = idx + 1;
end;
end;
if (newidx ~= nil) then
local match = __lua_lib_luautf8_Utf8.sub(by, idx, newidx - 1);
ret:push(match);
idx = newidx + __lua_lib_luautf8_Utf8.len("$$");
else
ret:push(__lua_lib_luautf8_Utf8.sub(by, idx, __lua_lib_luautf8_Utf8.len(by)));
idx = nil;
end;
end;
local chunks = ret;
local _g = _hx_tab_array({}, 0);
local _g1 = 0;
while (_g1 < chunks.length) do
local chunk = chunks[_g1];
_g1 = _g1 + 1;
_g:push(__lua_lib_lrexlib_Rex.gsub(chunk, "\\$(\\d)", "%%%1", 1));
end;
chunks = _g;
by = chunks:join("$");
do return __lua_lib_lrexlib_Rex.gsub(s, self.r, by, (function()
local _hx_1
if (self.global) then
_hx_1 = nil; else
_hx_1 = 1; end
return _hx_1
end )()) end
end
EReg.prototype.__class__ = EReg
Math.new = {}
Math.__name__ = true
Math.isNaN = function(f)
do return f ~= f end;
end
Math.isFinite = function(f)
if (f > -_G.math.huge) then
do return f < _G.math.huge end;
else
do return false end;
end;
end
Math.max = function(a,b)
if (Math.isNaN(a) or Math.isNaN(b)) then
do return (0/0) end;
else
do return _G.math.max(a, b) end;
end;
end
Math.min = function(a,b)
if (Math.isNaN(a) or Math.isNaN(b)) then
do return (0/0) end;
else
do return _G.math.min(a, b) end;
end;
end
String.new = function(string)
local self = _hx_new(String.prototype)
String.super(self,string)
self = string
return self
end
String.super = function(self,string)
end
String.__name__ = true
String.__index = function(s,k)
if (k == "length") then
do return __lua_lib_luautf8_Utf8.len(s) end;
else
local o = String.prototype;
local field = k;
if ((function()
local _hx_1
if ((_G.type(o) == "string") and ((String.prototype[field] ~= nil) or (field == "length"))) then
_hx_1 = true; elseif (o.__fields__ ~= nil) then
_hx_1 = o.__fields__[field] ~= nil; else
_hx_1 = o[field] ~= nil; end
return _hx_1
end )()) then
do return String.prototype[k] end;
else
if (String.__oldindex ~= nil) then
if (_G.type(String.__oldindex) == "function") then
do return String.__oldindex(s, k) end;
else
if (_G.type(String.__oldindex) == "table") then
do return String.__oldindex[k] end;
end;
end;
do return nil end;
else
do return nil end;
end;
end;
end;
end
String.indexOfEmpty = function(s,startIndex)
local length = __lua_lib_luautf8_Utf8.len(s);
if (startIndex < 0) then
startIndex = length + startIndex;
if (startIndex < 0) then
startIndex = 0;
end;
end;
if (startIndex > length) then
do return length end;
else
do return startIndex end;
end;
end
String.fromCharCode = function(code)
do return __lua_lib_luautf8_Utf8.char(code) end;
end
String.prototype = _hx_e();
String.prototype.toUpperCase = function(self)
do return __lua_lib_luautf8_Utf8.upper(self) end
end
String.prototype.toLowerCase = function(self)
do return __lua_lib_luautf8_Utf8.lower(self) end
end
String.prototype.indexOf = function(self,str,startIndex)
if (startIndex == nil) then
startIndex = 1;
else
startIndex = startIndex + 1;
end;
if (str == "") then
do return String.indexOfEmpty(self, startIndex - 1) end;
end;
local r = __lua_lib_luautf8_Utf8.find(self, str, startIndex, true);
if ((r ~= nil) and (r > 0)) then
do return r - 1 end;
else
do return -1 end;
end;
end
String.prototype.lastIndexOf = function(self,str,startIndex)
local ret = -1;
if (startIndex == nil) then
startIndex = __lua_lib_luautf8_Utf8.len(self);
end;
while (true) do
local startIndex1 = ret + 1;
if (startIndex1 == nil) then
startIndex1 = 1;
else
startIndex1 = startIndex1 + 1;
end;
local p;
if (str == "") then
p = String.indexOfEmpty(self, startIndex1 - 1);
else
local r = __lua_lib_luautf8_Utf8.find(self, str, startIndex1, true);
p = (function()
local _hx_1
if ((r ~= nil) and (r > 0)) then
_hx_1 = r - 1; else
_hx_1 = -1; end
return _hx_1
end )();
end;
if (((p == -1) or (p > startIndex)) or (p == ret)) then
break;
end;
ret = p;
end;
do return ret end
end
String.prototype.split = function(self,delimiter)
local idx = 1;
local ret = _hx_tab_array({}, 0);
while (idx ~= nil) do
local newidx = 0;
if (__lua_lib_luautf8_Utf8.len(delimiter) > 0) then
newidx = __lua_lib_luautf8_Utf8.find(self, delimiter, idx, true);
else
if (idx >= __lua_lib_luautf8_Utf8.len(self)) then
newidx = nil;
else
newidx = idx + 1;
end;
end;
if (newidx ~= nil) then
local match = __lua_lib_luautf8_Utf8.sub(self, idx, newidx - 1);
ret:push(match);
idx = newidx + __lua_lib_luautf8_Utf8.len(delimiter);
else
ret:push(__lua_lib_luautf8_Utf8.sub(self, idx, __lua_lib_luautf8_Utf8.len(self)));
idx = nil;
end;
end;
do return ret end
end
String.prototype.toString = function(self)
do return self end
end
String.prototype.substring = function(self,startIndex,endIndex)
if (endIndex == nil) then
endIndex = __lua_lib_luautf8_Utf8.len(self);
end;
if (endIndex < 0) then
endIndex = 0;
end;
if (startIndex < 0) then
startIndex = 0;
end;
if (endIndex < startIndex) then
do return __lua_lib_luautf8_Utf8.sub(self, endIndex + 1, startIndex) end;
else
do return __lua_lib_luautf8_Utf8.sub(self, startIndex + 1, endIndex) end;
end;
end
String.prototype.charAt = function(self,index)
do return __lua_lib_luautf8_Utf8.sub(self, index + 1, index + 1) end
end
String.prototype.charCodeAt = function(self,index)
do return __lua_lib_luautf8_Utf8.byte(self, index + 1) end
end
String.prototype.substr = function(self,pos,len)
if ((len == nil) or (len > (pos + __lua_lib_luautf8_Utf8.len(self)))) then
len = __lua_lib_luautf8_Utf8.len(self);
else
if (len < 0) then
len = __lua_lib_luautf8_Utf8.len(self) + len;
end;
end;
if (pos < 0) then
pos = __lua_lib_luautf8_Utf8.len(self) + pos;
end;
if (pos < 0) then
pos = 0;
end;
do return __lua_lib_luautf8_Utf8.sub(self, pos + 1, pos + len) end
end
String.prototype.__class__ = String
Std.new = {}
Std.__name__ = true
Std.string = function(s)
do return _hx_tostring(s, 0) end;
end
Std.int = function(x)
if (not Math.isFinite(x) or Math.isNaN(x)) then
do return 0 end;
else
do return _hx_bit_clamp(x) end;
end;
end
Std.parseInt = function(x)
if (x == nil) then
do return nil end;
end;
local hexMatch = _G.string.match(x, "^[ \t\r\n]*([%-+]*0[xX][%da-fA-F]*)");
if (hexMatch ~= nil) then
local sign;
local _g = __lua_lib_luautf8_Utf8.byte(hexMatch, 1);
if (_g) == 43 then
sign = 1;
elseif (_g) == 45 then
sign = -1;else
sign = 0; end;
local pos = (function()
local _hx_1
if (sign == 0) then
_hx_1 = 2; else
_hx_1 = 3; end
return _hx_1
end )();
local len = nil;
if ((len == nil) or (len > (pos + __lua_lib_luautf8_Utf8.len(hexMatch)))) then
len = __lua_lib_luautf8_Utf8.len(hexMatch);
else
if (len < 0) then
len = __lua_lib_luautf8_Utf8.len(hexMatch) + len;
end;
end;
if (pos < 0) then
pos = __lua_lib_luautf8_Utf8.len(hexMatch) + pos;
end;
if (pos < 0) then
pos = 0;
end;
do return (function()
local _hx_2
if (sign == -1) then
_hx_2 = -1; else
_hx_2 = 1; end
return _hx_2
end )() * _G.tonumber(__lua_lib_luautf8_Utf8.sub(hexMatch, pos + 1, pos + len), 16) end;
else
local intMatch = _G.string.match(x, "^ *[%-+]?%d*");
if (intMatch ~= nil) then
do return _G.tonumber(intMatch) end;
else
do return nil end;
end;
end;
end
Std.parseFloat = function(x)
if ((x == nil) or (x == "")) then
do return (0/0) end;
end;
local digitMatch = _G.string.match(x, "^ *[%.%-+]?[0-9]%d*");
if (digitMatch == nil) then
do return (0/0) end;
end;
local pos = __lua_lib_luautf8_Utf8.len(digitMatch);
local len = nil;
if ((len == nil) or (len > (pos + __lua_lib_luautf8_Utf8.len(x)))) then
len = __lua_lib_luautf8_Utf8.len(x);
else
if (len < 0) then
len = __lua_lib_luautf8_Utf8.len(x) + len;
end;
end;
if (pos < 0) then
pos = __lua_lib_luautf8_Utf8.len(x) + pos;
end;
if (pos < 0) then
pos = 0;
end;
x = __lua_lib_luautf8_Utf8.sub(x, pos + 1, pos + len);
local decimalMatch = _G.string.match(x, "^%.%d*");
if (decimalMatch == nil) then
decimalMatch = "";
end;
local pos = __lua_lib_luautf8_Utf8.len(decimalMatch);
local len = nil;
if ((len == nil) or (len > (pos + __lua_lib_luautf8_Utf8.len(x)))) then
len = __lua_lib_luautf8_Utf8.len(x);
else
if (len < 0) then
len = __lua_lib_luautf8_Utf8.len(x) + len;
end;
end;
if (pos < 0) then
pos = __lua_lib_luautf8_Utf8.len(x) + pos;
end;
if (pos < 0) then
pos = 0;
end;
x = __lua_lib_luautf8_Utf8.sub(x, pos + 1, pos + len);
local eMatch = _G.string.match(x, "^[eE][+%-]?%d+");
if (eMatch == nil) then
eMatch = "";
end;
local result = _G.tonumber(Std.string(Std.string(digitMatch) .. Std.string(decimalMatch)) .. Std.string(eMatch));
if (result ~= nil) then
do return result end;
else
do return (0/0) end;
end;
end
StringBuf.new = function()
local self = _hx_new(StringBuf.prototype)
StringBuf.super(self)
return self
end
StringBuf.super = function(self)
self.b = ({});
self.length = 0;
end
StringBuf.__name__ = true
StringBuf.prototype = _hx_e();
StringBuf.prototype.__class__ = StringBuf
StringTools.new = {}
StringTools.__name__ = true
StringTools.htmlEscape = function(s,quotes)
local buf_b = ({});
local buf_length = 0;
local _g_offset = 0;
local _g_s = s;
while (_g_offset < __lua_lib_luautf8_Utf8.len(_g_s)) do
_g_offset = _g_offset + 1;
local code = __lua_lib_luautf8_Utf8.byte(_g_s, (_g_offset - 1) + 1);
local code1 = code;
if (code1) == 34 then
if (quotes) then
local str = """;
_G.table.insert(buf_b, str);
buf_length = buf_length + __lua_lib_luautf8_Utf8.len(str);
else
_G.table.insert(buf_b, __lua_lib_luautf8_Utf8.char(code));
buf_length = buf_length + 1;
end;
elseif (code1) == 38 then
local str = "&";
_G.table.insert(buf_b, str);
buf_length = buf_length + __lua_lib_luautf8_Utf8.len(str);
elseif (code1) == 39 then
if (quotes) then
local str = "'";
_G.table.insert(buf_b, str);
buf_length = buf_length + __lua_lib_luautf8_Utf8.len(str);
else