gitlab.com/thomasboni/go-enry/v2@v2.8.3-0.20220418031202-30b0d7a3de98/_testdata/Generated/Haxe/main.lua (about) 1 -- Generated by Haxe 4.0.5 2 local _hx_array_mt = { 3 __newindex = function(t,k,v) 4 local len = t.length 5 t.length = k >= len and (k + 1) or len 6 rawset(t,k,v) 7 end 8 } 9 10 local function _hx_tab_array(tab,length) 11 tab.length = length 12 return setmetatable(tab, _hx_array_mt) 13 end 14 15 local function _hx_anon_newindex(t,k,v) t.__fields__[k] = true; rawset(t,k,v); end 16 local _hx_anon_mt = {__newindex=_hx_anon_newindex} 17 local function _hx_a(...) 18 local __fields__ = {}; 19 local ret = {__fields__ = __fields__}; 20 local max = select('#',...); 21 local tab = {...}; 22 local cur = 1; 23 while cur < max do 24 local v = tab[cur]; 25 __fields__[v] = true; 26 ret[v] = tab[cur+1]; 27 cur = cur + 2 28 end 29 return setmetatable(ret, _hx_anon_mt) 30 end 31 32 local function _hx_e() 33 return setmetatable({__fields__ = {}}, _hx_anon_mt) 34 end 35 36 local function _hx_o(obj) 37 return setmetatable(obj, _hx_anon_mt) 38 end 39 40 local function _hx_new(prototype) 41 return setmetatable({__fields__ = {}}, {__newindex=_hx_anon_newindex, __index=prototype}) 42 end 43 44 local _hxClasses = {} 45 local Int = _hx_e(); 46 local Dynamic = _hx_e(); 47 local Float = _hx_e(); 48 local Bool = _hx_e(); 49 local Class = _hx_e(); 50 local Enum = _hx_e(); 51 52 local Array = _hx_e() 53 __lua_lib_luautf8_Utf8 = _G.require("lua-utf8") 54 local Main = _hx_e() 55 local Math = _hx_e() 56 local String = _hx_e() 57 local Std = _hx_e() 58 __haxe_Log = _hx_e() 59 __lua_Boot = _hx_e() 60 61 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 62 local _hx_pcall_default = {}; 63 local _hx_pcall_break = {}; 64 65 Array.new = function() 66 local self = _hx_new(Array.prototype) 67 Array.super(self) 68 return self 69 end 70 Array.super = function(self) 71 _hx_tab_array(self, 0); 72 end 73 Array.prototype = _hx_a(); 74 Array.prototype.concat = function(self,a) 75 local _g = _hx_tab_array({}, 0); 76 local _g1 = 0; 77 local _g2 = self; 78 while (_g1 < _g2.length) do 79 local i = _g2[_g1]; 80 _g1 = _g1 + 1; 81 _g:push(i); 82 end; 83 local ret = _g; 84 local _g3 = 0; 85 while (_g3 < a.length) do 86 local i1 = a[_g3]; 87 _g3 = _g3 + 1; 88 ret:push(i1); 89 end; 90 do return ret end 91 end 92 Array.prototype.join = function(self,sep) 93 local tbl = ({}); 94 local _gthis = self; 95 local cur_length = 0; 96 local i = _hx_o({__fields__={hasNext=true,next=true},hasNext=function(self) 97 do return cur_length < _gthis.length end; 98 end,next=function(self) 99 cur_length = cur_length + 1; 100 do return _gthis[cur_length - 1] end; 101 end}); 102 while (i:hasNext()) do 103 local i1 = i:next(); 104 _G.table.insert(tbl, Std.string(i1)); 105 end; 106 do return _G.table.concat(tbl, sep) end 107 end 108 Array.prototype.pop = function(self) 109 if (self.length == 0) then 110 do return nil end; 111 end; 112 local ret = self[self.length - 1]; 113 self[self.length - 1] = nil; 114 self.length = self.length - 1; 115 do return ret end 116 end 117 Array.prototype.push = function(self,x) 118 self[self.length] = x; 119 do return self.length end 120 end 121 Array.prototype.reverse = function(self) 122 local tmp; 123 local i = 0; 124 while (i < Std.int(self.length / 2)) do 125 tmp = self[i]; 126 self[i] = self[(self.length - i) - 1]; 127 self[(self.length - i) - 1] = tmp; 128 i = i + 1; 129 end; 130 end 131 Array.prototype.shift = function(self) 132 if (self.length == 0) then 133 do return nil end; 134 end; 135 local ret = self[0]; 136 if (self.length == 1) then 137 self[0] = nil; 138 else 139 if (self.length > 1) then 140 self[0] = self[1]; 141 _G.table.remove(self, 1); 142 end; 143 end; 144 local tmp = self; 145 tmp.length = tmp.length - 1; 146 do return ret end 147 end 148 Array.prototype.slice = function(self,pos,_end) 149 if ((_end == nil) or (_end > self.length)) then 150 _end = self.length; 151 else 152 if (_end < 0) then 153 _end = _G.math.fmod((self.length - (_G.math.fmod(-_end, self.length))), self.length); 154 end; 155 end; 156 if (pos < 0) then 157 pos = _G.math.fmod((self.length - (_G.math.fmod(-pos, self.length))), self.length); 158 end; 159 if ((pos > _end) or (pos > self.length)) then 160 do return _hx_tab_array({}, 0) end; 161 end; 162 local ret = _hx_tab_array({}, 0); 163 local _g = pos; 164 local _g1 = _end; 165 while (_g < _g1) do 166 _g = _g + 1; 167 local i = _g - 1; 168 ret:push(self[i]); 169 end; 170 do return ret end 171 end 172 Array.prototype.sort = function(self,f) 173 local i = 0; 174 local l = self.length; 175 while (i < l) do 176 local swap = false; 177 local j = 0; 178 local max = (l - i) - 1; 179 while (j < max) do 180 if (f(self[j], self[j + 1]) > 0) then 181 local tmp = self[j + 1]; 182 self[j + 1] = self[j]; 183 self[j] = tmp; 184 swap = true; 185 end; 186 j = j + 1; 187 end; 188 if (not swap) then 189 break; 190 end; 191 i = i + 1; 192 end; 193 end 194 Array.prototype.splice = function(self,pos,len) 195 if ((len < 0) or (pos > self.length)) then 196 do return _hx_tab_array({}, 0) end; 197 else 198 if (pos < 0) then 199 pos = self.length - (_G.math.fmod(-pos, self.length)); 200 end; 201 end; 202 len = Math.min(len, self.length - pos); 203 local ret = _hx_tab_array({}, 0); 204 local _g = pos; 205 local _g1 = pos + len; 206 while (_g < _g1) do 207 _g = _g + 1; 208 local i = _g - 1; 209 ret:push(self[i]); 210 self[i] = self[i + len]; 211 end; 212 local _g2 = pos + len; 213 local _g3 = self.length; 214 while (_g2 < _g3) do 215 _g2 = _g2 + 1; 216 local i1 = _g2 - 1; 217 self[i1] = self[i1 + len]; 218 end; 219 local tmp = self; 220 tmp.length = tmp.length - len; 221 do return ret end 222 end 223 Array.prototype.toString = function(self) 224 local tbl = ({}); 225 _G.table.insert(tbl, "["); 226 _G.table.insert(tbl, self:join(",")); 227 _G.table.insert(tbl, "]"); 228 do return _G.table.concat(tbl, "") end 229 end 230 Array.prototype.unshift = function(self,x) 231 local len = self.length; 232 local _g = 0; 233 local _g1 = len; 234 while (_g < _g1) do 235 _g = _g + 1; 236 local i = _g - 1; 237 self[len - i] = self[(len - i) - 1]; 238 end; 239 self[0] = x; 240 end 241 Array.prototype.insert = function(self,pos,x) 242 if (pos > self.length) then 243 pos = self.length; 244 end; 245 if (pos < 0) then 246 pos = self.length + pos; 247 if (pos < 0) then 248 pos = 0; 249 end; 250 end; 251 local cur_len = self.length; 252 while (cur_len > pos) do 253 self[cur_len] = self[cur_len - 1]; 254 cur_len = cur_len - 1; 255 end; 256 self[pos] = x; 257 end 258 Array.prototype.remove = function(self,x) 259 local _g = 0; 260 local _g1 = self.length; 261 while (_g < _g1) do 262 _g = _g + 1; 263 local i = _g - 1; 264 if (self[i] == x) then 265 local _g2 = i; 266 local _g11 = self.length - 1; 267 while (_g2 < _g11) do 268 _g2 = _g2 + 1; 269 local j = _g2 - 1; 270 self[j] = self[j + 1]; 271 end; 272 self[self.length - 1] = nil; 273 self.length = self.length - 1; 274 do return true end; 275 end; 276 end; 277 do return false end 278 end 279 Array.prototype.indexOf = function(self,x,fromIndex) 280 local _end = self.length; 281 if (fromIndex == nil) then 282 fromIndex = 0; 283 else 284 if (fromIndex < 0) then 285 fromIndex = self.length + fromIndex; 286 if (fromIndex < 0) then 287 fromIndex = 0; 288 end; 289 end; 290 end; 291 local _g = fromIndex; 292 local _g1 = _end; 293 while (_g < _g1) do 294 _g = _g + 1; 295 local i = _g - 1; 296 if (x == self[i]) then 297 do return i end; 298 end; 299 end; 300 do return -1 end 301 end 302 Array.prototype.lastIndexOf = function(self,x,fromIndex) 303 if ((fromIndex == nil) or (fromIndex >= self.length)) then 304 fromIndex = self.length - 1; 305 else 306 if (fromIndex < 0) then 307 fromIndex = self.length + fromIndex; 308 if (fromIndex < 0) then 309 do return -1 end; 310 end; 311 end; 312 end; 313 local i = fromIndex; 314 while (i >= 0) do 315 if (self[i] == x) then 316 do return i end; 317 else 318 i = i - 1; 319 end; 320 end; 321 do return -1 end 322 end 323 Array.prototype.copy = function(self) 324 local _g = _hx_tab_array({}, 0); 325 local _g1 = 0; 326 local _g2 = self; 327 while (_g1 < _g2.length) do 328 local i = _g2[_g1]; 329 _g1 = _g1 + 1; 330 _g:push(i); 331 end; 332 do return _g end 333 end 334 Array.prototype.map = function(self,f) 335 local _g = _hx_tab_array({}, 0); 336 local _g1 = 0; 337 local _g2 = self; 338 while (_g1 < _g2.length) do 339 local i = _g2[_g1]; 340 _g1 = _g1 + 1; 341 _g:push(f(i)); 342 end; 343 do return _g end 344 end 345 Array.prototype.filter = function(self,f) 346 local _g = _hx_tab_array({}, 0); 347 local _g1 = 0; 348 local _g2 = self; 349 while (_g1 < _g2.length) do 350 local i = _g2[_g1]; 351 _g1 = _g1 + 1; 352 if (f(i)) then 353 _g:push(i); 354 end; 355 end; 356 do return _g end 357 end 358 Array.prototype.iterator = function(self) 359 local _gthis = self; 360 local cur_length = 0; 361 do return _hx_o({__fields__={hasNext=true,next=true},hasNext=function(self) 362 do return cur_length < _gthis.length end; 363 end,next=function(self) 364 cur_length = cur_length + 1; 365 do return _gthis[cur_length - 1] end; 366 end}) end 367 end 368 Array.prototype.resize = function(self,len) 369 if (self.length < len) then 370 self.length = len; 371 else 372 if (self.length > len) then 373 local _g = len; 374 local _g1 = self.length; 375 while (_g < _g1) do 376 _g = _g + 1; 377 local i = _g - 1; 378 self[i] = nil; 379 end; 380 self.length = len; 381 end; 382 end; 383 end 384 385 Main.new = {} 386 Main.main = function() 387 __haxe_Log.trace("Hello World", _hx_o({__fields__={fileName=true,lineNumber=true,className=true,methodName=true},fileName="source/Main.hx",lineNumber=3,className="Main",methodName="main"})); 388 end 389 390 Math.new = {} 391 Math.isNaN = function(f) 392 do return f ~= f end; 393 end 394 Math.isFinite = function(f) 395 if (f > -_G.math.huge) then 396 do return f < _G.math.huge end; 397 else 398 do return false end; 399 end; 400 end 401 Math.min = function(a,b) 402 if (Math.isNaN(a) or Math.isNaN(b)) then 403 do return (0/0) end; 404 else 405 do return _G.math.min(a, b) end; 406 end; 407 end 408 409 String.new = function(string) 410 local self = _hx_new(String.prototype) 411 String.super(self,string) 412 self = string 413 return self 414 end 415 String.super = function(self,string) 416 end 417 String.__index = function(s,k) 418 if (k == "length") then 419 do return __lua_lib_luautf8_Utf8.len(s) end; 420 else 421 local o = String.prototype; 422 local field = k; 423 if ((function() 424 local _hx_1 425 if ((_G.type(o) == "string") and ((String.prototype[field] ~= nil) or (field == "length"))) then 426 _hx_1 = true; elseif (o.__fields__ ~= nil) then 427 _hx_1 = o.__fields__[field] ~= nil; else 428 _hx_1 = o[field] ~= nil; end 429 return _hx_1 430 end )()) then 431 do return String.prototype[k] end; 432 else 433 if (String.__oldindex ~= nil) then 434 if (_G.type(String.__oldindex) == "function") then 435 do return String.__oldindex(s, k) end; 436 else 437 if (_G.type(String.__oldindex) == "table") then 438 do return String.__oldindex[k] end; 439 end; 440 end; 441 do return nil end; 442 else 443 do return nil end; 444 end; 445 end; 446 end; 447 end 448 String.fromCharCode = function(code) 449 do return __lua_lib_luautf8_Utf8.char(code) end; 450 end 451 String.prototype = _hx_a(); 452 String.prototype.toUpperCase = function(self) 453 do return __lua_lib_luautf8_Utf8.upper(self) end 454 end 455 String.prototype.toLowerCase = function(self) 456 do return __lua_lib_luautf8_Utf8.lower(self) end 457 end 458 String.prototype.indexOf = function(self,str,startIndex) 459 if (startIndex == nil) then 460 startIndex = 1; 461 else 462 startIndex = startIndex + 1; 463 end; 464 local r = __lua_lib_luautf8_Utf8.find(self, str, startIndex, true); 465 if ((r ~= nil) and (r > 0)) then 466 do return r - 1 end; 467 else 468 do return -1 end; 469 end; 470 end 471 String.prototype.lastIndexOf = function(self,str,startIndex) 472 local i = 0; 473 local ret = -1; 474 if (startIndex == nil) then 475 startIndex = __lua_lib_luautf8_Utf8.len(self); 476 end; 477 while (true) do 478 local startIndex1 = ret + 1; 479 if (startIndex1 == nil) then 480 startIndex1 = 1; 481 else 482 startIndex1 = startIndex1 + 1; 483 end; 484 local r = __lua_lib_luautf8_Utf8.find(self, str, startIndex1, true); 485 local p = (function() 486 local _hx_1 487 if ((r ~= nil) and (r > 0)) then 488 _hx_1 = r - 1; else 489 _hx_1 = -1; end 490 return _hx_1 491 end )(); 492 if ((p == -1) or (p > startIndex)) then 493 break; 494 end; 495 ret = p; 496 end; 497 do return ret end 498 end 499 String.prototype.split = function(self,delimiter) 500 local idx = 1; 501 local ret = _hx_tab_array({}, 0); 502 local delim_offset = (function() 503 local _hx_1 504 if (__lua_lib_luautf8_Utf8.len(delimiter) > 0) then 505 _hx_1 = __lua_lib_luautf8_Utf8.len(delimiter); else 506 _hx_1 = 1; end 507 return _hx_1 508 end )(); 509 while (idx ~= nil) do 510 local newidx = 0; 511 if (__lua_lib_luautf8_Utf8.len(delimiter) > 0) then 512 newidx = __lua_lib_luautf8_Utf8.find(self, delimiter, idx, true); 513 else 514 if (idx >= __lua_lib_luautf8_Utf8.len(self)) then 515 newidx = nil; 516 else 517 newidx = idx + 1; 518 end; 519 end; 520 if (newidx ~= nil) then 521 local match = __lua_lib_luautf8_Utf8.sub(self, idx, newidx - 1); 522 ret:push(match); 523 idx = newidx + __lua_lib_luautf8_Utf8.len(delimiter); 524 else 525 ret:push(__lua_lib_luautf8_Utf8.sub(self, idx, __lua_lib_luautf8_Utf8.len(self))); 526 idx = nil; 527 end; 528 end; 529 do return ret end 530 end 531 String.prototype.toString = function(self) 532 do return self end 533 end 534 String.prototype.substring = function(self,startIndex,endIndex) 535 if (endIndex == nil) then 536 endIndex = __lua_lib_luautf8_Utf8.len(self); 537 end; 538 if (endIndex < 0) then 539 endIndex = 0; 540 end; 541 if (startIndex < 0) then 542 startIndex = 0; 543 end; 544 if (endIndex < startIndex) then 545 do return __lua_lib_luautf8_Utf8.sub(self, endIndex + 1, startIndex) end; 546 else 547 do return __lua_lib_luautf8_Utf8.sub(self, startIndex + 1, endIndex) end; 548 end; 549 end 550 String.prototype.charAt = function(self,index) 551 do return __lua_lib_luautf8_Utf8.sub(self, index + 1, index + 1) end 552 end 553 String.prototype.charCodeAt = function(self,index) 554 do return __lua_lib_luautf8_Utf8.byte(self, index + 1) end 555 end 556 String.prototype.substr = function(self,pos,len) 557 if ((len == nil) or (len > (pos + __lua_lib_luautf8_Utf8.len(self)))) then 558 len = __lua_lib_luautf8_Utf8.len(self); 559 else 560 if (len < 0) then 561 len = __lua_lib_luautf8_Utf8.len(self) + len; 562 end; 563 end; 564 if (pos < 0) then 565 pos = __lua_lib_luautf8_Utf8.len(self) + pos; 566 end; 567 if (pos < 0) then 568 pos = 0; 569 end; 570 do return __lua_lib_luautf8_Utf8.sub(self, pos + 1, pos + len) end 571 end 572 573 Std.new = {} 574 Std.string = function(s) 575 do return __lua_Boot.__string_rec(s) end; 576 end 577 Std.int = function(x) 578 if (not Math.isFinite(x) or Math.isNaN(x)) then 579 do return 0 end; 580 else 581 do return _hx_bit_clamp(x) end; 582 end; 583 end 584 585 __haxe_Log.new = {} 586 __haxe_Log.formatOutput = function(v,infos) 587 local str = Std.string(v); 588 if (infos == nil) then 589 do return str end; 590 end; 591 local pstr = Std.string(Std.string(infos.fileName) .. Std.string(":")) .. Std.string(infos.lineNumber); 592 if (infos.customParams ~= nil) then 593 local _g = 0; 594 local _g1 = infos.customParams; 595 while (_g < _g1.length) do 596 local v1 = _g1[_g]; 597 _g = _g + 1; 598 str = Std.string(str) .. Std.string((Std.string(", ") .. Std.string(Std.string(v1)))); 599 end; 600 end; 601 do return Std.string(Std.string(pstr) .. Std.string(": ")) .. Std.string(str) end; 602 end 603 __haxe_Log.trace = function(v,infos) 604 local str = __haxe_Log.formatOutput(v, infos); 605 _hx_print(str); 606 end 607 608 __lua_Boot.new = {} 609 __lua_Boot.isArray = function(o) 610 if (_G.type(o) == "table") then 611 if ((o.__enum__ == nil) and (_G.getmetatable(o) ~= nil)) then 612 do return _G.getmetatable(o).__index == Array.prototype end; 613 else 614 do return false end; 615 end; 616 else 617 do return false end; 618 end; 619 end 620 __lua_Boot.printEnum = function(o,s) 621 if (o.length == 2) then 622 do return o[0] end; 623 else 624 local str = Std.string(Std.string(o[0])) .. Std.string("("); 625 s = Std.string(s) .. Std.string("\t"); 626 local _g = 2; 627 local _g1 = o.length; 628 while (_g < _g1) do 629 _g = _g + 1; 630 local i = _g - 1; 631 if (i ~= 2) then 632 str = Std.string(str) .. Std.string((Std.string(",") .. Std.string(__lua_Boot.__string_rec(o[i], s)))); 633 else 634 str = Std.string(str) .. Std.string(__lua_Boot.__string_rec(o[i], s)); 635 end; 636 end; 637 do return Std.string(str) .. Std.string(")") end; 638 end; 639 end 640 __lua_Boot.printClassRec = function(c,result,s) 641 if (result == nil) then 642 result = ""; 643 end; 644 local f = __lua_Boot.__string_rec; 645 for k,v in pairs(c) do if result ~= '' then result = result .. ', ' end result = result .. k .. ':' .. f(v, s.. ' ') end; 646 do return result end; 647 end 648 __lua_Boot.__string_rec = function(o,s) 649 if (s == nil) then 650 s = ""; 651 end; 652 if (__lua_lib_luautf8_Utf8.len(s) >= 5) then 653 do return "<...>" end; 654 end; 655 local _g = type(o); 656 if (_g) == "boolean" then 657 do return tostring(o) end; 658 elseif (_g) == "function" then 659 do return "<function>" end; 660 elseif (_g) == "nil" then 661 do return "null" end; 662 elseif (_g) == "number" then 663 if (o == _G.math.huge) then 664 do return "Infinity" end; 665 else 666 if (o == -_G.math.huge) then 667 do return "-Infinity" end; 668 else 669 if (o == 0) then 670 do return "0" end; 671 else 672 if (o ~= o) then 673 do return "NaN" end; 674 else 675 do return tostring(o) end; 676 end; 677 end; 678 end; 679 end; 680 elseif (_g) == "string" then 681 do return o end; 682 elseif (_g) == "table" then 683 if (o.__enum__ ~= nil) then 684 do return __lua_Boot.printEnum(o, s) end; 685 else 686 if ((_hx_wrap_if_string_field(o,'toString') ~= nil) and not __lua_Boot.isArray(o)) then 687 do return _hx_wrap_if_string_field(o,'toString')(o) end; 688 else 689 if (__lua_Boot.isArray(o)) then 690 local o2 = o; 691 if (__lua_lib_luautf8_Utf8.len(s) > 5) then 692 do return "[...]" end; 693 else 694 local _g1 = _hx_tab_array({}, 0); 695 local _g11 = 0; 696 while (_g11 < o2.length) do 697 local i = o2[_g11]; 698 _g11 = _g11 + 1; 699 _g1:push(__lua_Boot.__string_rec(i, Std.string(s) .. Std.string(1))); 700 end; 701 do return Std.string(Std.string("[") .. Std.string(_g1:join(","))) .. Std.string("]") end; 702 end; 703 else 704 if (o.__class__ ~= nil) then 705 do return Std.string(Std.string("{") .. Std.string(__lua_Boot.printClassRec(o, "", Std.string(s) .. Std.string("\t")))) .. Std.string("}") end; 706 else 707 local fields = __lua_Boot.fieldIterator(o); 708 local buffer = ({}); 709 local first = true; 710 _G.table.insert(buffer, "{ "); 711 local f = fields; 712 while (f:hasNext()) do 713 local f1 = f:next(); 714 if (first) then 715 first = false; 716 else 717 _G.table.insert(buffer, ", "); 718 end; 719 _G.table.insert(buffer, Std.string(Std.string(Std.string("") .. Std.string(Std.string(f1))) .. Std.string(" : ")) .. Std.string(__lua_Boot.__string_rec(o[f1], Std.string(s) .. Std.string("\t")))); 720 end; 721 _G.table.insert(buffer, " }"); 722 do return _G.table.concat(buffer, "") end; 723 end; 724 end; 725 end; 726 end; 727 elseif (_g) == "thread" then 728 do return "<thread>" end; 729 elseif (_g) == "userdata" then 730 local mt = _G.getmetatable(o); 731 if ((mt ~= nil) and (mt.__tostring ~= nil)) then 732 do return _G.tostring(o) end; 733 else 734 do return "<userdata>" end; 735 end;else 736 _G.error("Unknown Lua type",0); end; 737 end 738 __lua_Boot.fieldIterator = function(o) 739 if (_G.type(o) ~= "table") then 740 do return _hx_o({__fields__={next=true,hasNext=true},next=function(self) 741 do return nil end; 742 end,hasNext=function(self) 743 do return false end; 744 end}) end; 745 end; 746 local tbl = (function() 747 local _hx_1 748 if (o.__fields__ ~= nil) then 749 _hx_1 = o.__fields__; else 750 _hx_1 = o; end 751 return _hx_1 752 end )(); 753 local cur = _G.pairs(tbl); 754 local next_valid = function(tbl1,val) 755 while (__lua_Boot.hiddenFields[val] ~= nil) do 756 val = cur(tbl1, val); 757 end; 758 do return val end; 759 end; 760 local cur_val = next_valid(tbl, cur(tbl, nil)); 761 do return _hx_o({__fields__={next=true,hasNext=true},next=function(self) 762 local ret = cur_val; 763 cur_val = next_valid(tbl, cur(tbl, cur_val)); 764 do return ret end; 765 end,hasNext=function(self) 766 do return cur_val ~= nil end; 767 end}) end; 768 end 769 _hx_bit_clamp = function(v) 770 if v <= 2147483647 and v >= -2147483648 then 771 if v > 0 then return _G.math.floor(v) 772 else return _G.math.ceil(v) 773 end 774 end 775 if v > 2251798999999999 then v = v*2 end; 776 if (v ~= v or math.abs(v) == _G.math.huge) then return nil end 777 return _hx_bit.band(v, 2147483647 ) - math.abs(_hx_bit.band(v, 2147483648)) 778 end 779 780 -- require this for lua 5.1 781 pcall(require, 'bit') 782 if bit then 783 _hx_bit = bit 784 else 785 local _hx_bit_raw = _G.require('bit32') 786 _hx_bit = setmetatable({}, { __index = _hx_bit_raw }); 787 -- lua 5.2 weirdness 788 _hx_bit.bnot = function(...) return _hx_bit_clamp(_hx_bit_raw.bnot(...)) end; 789 _hx_bit.bxor = function(...) return _hx_bit_clamp(_hx_bit_raw.bxor(...)) end; 790 end 791 792 _hx_array_mt.__index = Array.prototype 793 794 local _hx_static_init = function() 795 __lua_Boot.hiddenFields = {__id__=true, hx__closures=true, super=true, prototype=true, __fields__=true, __ifields__=true, __class__=true, __properties__=true} 796 797 798 end 799 800 _hx_print = print or (function() end) 801 802 _hx_wrap_if_string_field = function(o, fld) 803 if _G.type(o) == 'string' then 804 if fld == 'length' then 805 return _G.string.len(o) 806 else 807 return String.prototype[fld] 808 end 809 else 810 return o[fld] 811 end 812 end 813 814 _hx_static_init(); 815 Main.main() 816