Advertisement
PXshadow

Untitled

Dec 12th, 2019
862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.33 KB | None | 0 0
  1. -- Generated by Haxe 4.0.0-rc.5+4a745347f
  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. local Main = _hx_e()
  54. local Math = _hx_e()
  55. local Program = _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 = function()
  386. local self = _hx_new(Main.prototype)
  387. Main.super(self)
  388. return self
  389. end
  390. Main.super = function(self)
  391. self.program = Program.new();
  392. if (self.program:fuelLevel() < 80) then
  393. self.program:exit("Need 80 fuel to start");
  394. end;
  395. self.program:dig(1, 40);
  396. if (self.program:fuelLevel() < 80) then
  397. self.program:dig(-1, 40);
  398. self.program:exit("Need more fuel!");
  399. end;
  400. while (self.program:fuelLevel() > 80) do
  401. self:circle();
  402. self.program:dig(1, 1);
  403. end;
  404. end
  405. Main.main = function()
  406. Main.new();
  407. end
  408. Main.prototype = _hx_a();
  409. Main.prototype.circle = function(self)
  410. self.program:dig(1, 10);
  411. self.program:turn();
  412. self.program:dig(1, 10);
  413. self.program:turn();
  414. self.program:dig(1, 10);
  415. self.program:turn();
  416. self.program:dig(1, 10);
  417. self.program:turn();
  418. end
  419.  
  420. Math.new = {}
  421. Math.isNaN = function(f)
  422. do return f ~= f end;
  423. end
  424. Math.isFinite = function(f)
  425. if (f > -_G.math.huge) then
  426. do return f < _G.math.huge end;
  427. else
  428. do return false end;
  429. end;
  430. end
  431. Math.min = function(a,b)
  432. if (Math.isNaN(a) or Math.isNaN(b)) then
  433. do return (0/0) end;
  434. else
  435. do return _G.math.min(a, b) end;
  436. end;
  437. end
  438.  
  439. Program.new = function()
  440. local self = _hx_new(Program.prototype)
  441. Program.super(self)
  442. return self
  443. end
  444. Program.super = function(self)
  445. self.z = 0;
  446. self.y = 0;
  447. self.x = 0;
  448. end
  449. Program.prototype = _hx_a();
  450. Program.prototype.fuelLevel = function(self)
  451. self:fuel();
  452. local level = turtle.getFuelLevel();
  453. __haxe_Log.trace(Std.string("fuel level: ") .. Std.string(level), _hx_o({__fields__={fileName=true,lineNumber=true,className=true,methodName=true},fileName="src/Program.hx",lineNumber=32,className="Program",methodName="fuelLevel"}));
  454. do return level end
  455. end
  456. Program.prototype.fuel = function(self,max)
  457. if (max == nil) then
  458. max = 280;
  459. end;
  460. self:select(0);
  461. turtle.refuel();
  462. self:select(1);
  463. turtle.refuel();
  464. self:select(2);
  465. turtle.refuel();
  466. self:select(3);
  467. turtle.refuel();
  468. self:select(4);
  469. turtle.refuel();
  470. self:select(5);
  471. turtle.refuel();
  472. self:select(6);
  473. turtle.refuel();
  474. self:select(7);
  475. turtle.refuel();
  476. self:select(8);
  477. turtle.refuel();
  478. self:select(9);
  479. turtle.refuel();
  480. self:select(10);
  481. turtle.refuel();
  482. self:select(11);
  483. turtle.refuel();
  484. self:select(12);
  485. turtle.refuel();
  486. self:select(13);
  487. turtle.refuel();
  488. self:select(14);
  489. turtle.refuel();
  490. self:select(15);
  491. turtle.refuel();
  492. do return self end
  493. end
  494. Program.prototype.select = function(self,index)
  495. turtle.select(index + 1);
  496. do return self end
  497. end
  498. Program.prototype.dig = function(self,dir,amount)
  499. if (amount == nil) then
  500. amount = 1;
  501. end;
  502. if (dir == nil) then
  503. dir = 0;
  504. end;
  505. local dir1 = dir;
  506. if (dir1) == -1 then
  507. local _g = 0;
  508. local _g1 = amount;
  509. while (_g < _g1) do
  510. _g = _g + 1;
  511. local i = _g - 1;
  512. turtle.digUp();
  513. turtle.up();
  514. end;
  515. elseif (dir1) == 0 then
  516. local _g2 = 0;
  517. local _g11 = amount;
  518. while (_g2 < _g11) do
  519. _g2 = _g2 + 1;
  520. local i1 = _g2 - 1;
  521. turtle.dig();
  522. if (turtle.forward()) then
  523. local tmp = self;
  524. tmp.x = tmp.x + (function()
  525. local _hx_1
  526. if (dir > 1) then
  527. _hx_1 = 0; else
  528. _hx_1 = dir; end
  529. return _hx_1
  530. end )();
  531. local tmp1 = self;
  532. tmp1.z = tmp1.z + (function()
  533. local _hx_2
  534. if (dir <= 1) then
  535. _hx_2 = 0; else
  536. _hx_2 = dir - 1; end
  537. return _hx_2
  538. end )();
  539. end;
  540. end;
  541. elseif (dir1) == 1 then
  542. local _g3 = 0;
  543. local _g12 = amount;
  544. while (_g3 < _g12) do
  545. _g3 = _g3 + 1;
  546. local i2 = _g3 - 1;
  547. turtle.digDown();
  548. if (turtle.down()) then
  549. self.y = self.y - 1;
  550. end;
  551. end; end;
  552. end
  553. Program.prototype.turn = function(self,dir)
  554. if (dir == nil) then
  555. dir = 1;
  556. end;
  557. if (dir == 1) then
  558. _hx_box_mr(_hx_table.pack(turtle.turnRight()), {"successful", "error"});
  559. else
  560. _hx_box_mr(_hx_table.pack(turtle.turnLeft()), {"successful", "error"});
  561. end;
  562. end
  563. Program.prototype.exit = function(self,string)
  564. __haxe_Log.trace(string, _hx_o({__fields__={fileName=true,lineNumber=true,className=true,methodName=true},fileName="src/Program.hx",lineNumber=101,className="Program",methodName="exit"}));
  565. _G.os.exit(0);
  566. end
  567.  
  568. String.new = function(string)
  569. local self = _hx_new(String.prototype)
  570. String.super(self,string)
  571. self = string
  572. return self
  573. end
  574. String.super = function(self,string)
  575. end
  576. String.__index = function(s,k)
  577. if (k == "length") then
  578. do return _G.string.len(s) end;
  579. else
  580. local o = String.prototype;
  581. local field = k;
  582. if ((function()
  583. local _hx_1
  584. if ((_G.type(o) == "string") and ((String.prototype[field] ~= nil) or (field == "length"))) then
  585. _hx_1 = true; elseif (o.__fields__ ~= nil) then
  586. _hx_1 = o.__fields__[field] ~= nil; else
  587. _hx_1 = o[field] ~= nil; end
  588. return _hx_1
  589. end )()) then
  590. do return String.prototype[k] end;
  591. else
  592. if (String.__oldindex ~= nil) then
  593. if (_G.type(String.__oldindex) == "function") then
  594. do return String.__oldindex(s, k) end;
  595. else
  596. if (_G.type(String.__oldindex) == "table") then
  597. do return String.__oldindex[k] end;
  598. end;
  599. end;
  600. do return nil end;
  601. else
  602. do return nil end;
  603. end;
  604. end;
  605. end;
  606. end
  607. String.fromCharCode = function(code)
  608. do return _G.string.char(code) end;
  609. end
  610. String.prototype = _hx_a();
  611. String.prototype.toUpperCase = function(self)
  612. do return _G.string.upper(self) end
  613. end
  614. String.prototype.toLowerCase = function(self)
  615. do return _G.string.lower(self) end
  616. end
  617. String.prototype.indexOf = function(self,str,startIndex)
  618. if (startIndex == nil) then
  619. startIndex = 1;
  620. else
  621. startIndex = startIndex + 1;
  622. end;
  623. local r = _G.string.find(self, str, startIndex, true);
  624. if ((r ~= nil) and (r > 0)) then
  625. do return r - 1 end;
  626. else
  627. do return -1 end;
  628. end;
  629. end
  630. String.prototype.lastIndexOf = function(self,str,startIndex)
  631. local i = 0;
  632. local ret = -1;
  633. if (startIndex == nil) then
  634. startIndex = #self;
  635. end;
  636. while (true) do
  637. local startIndex1 = ret + 1;
  638. if (startIndex1 == nil) then
  639. startIndex1 = 1;
  640. else
  641. startIndex1 = startIndex1 + 1;
  642. end;
  643. local r = _G.string.find(self, str, startIndex1, true);
  644. local p = (function()
  645. local _hx_1
  646. if ((r ~= nil) and (r > 0)) then
  647. _hx_1 = r - 1; else
  648. _hx_1 = -1; end
  649. return _hx_1
  650. end )();
  651. if ((p == -1) or (p > startIndex)) then
  652. break;
  653. end;
  654. ret = p;
  655. end;
  656. do return ret end
  657. end
  658. String.prototype.split = function(self,delimiter)
  659. local idx = 1;
  660. local ret = _hx_tab_array({}, 0);
  661. local delim_offset = (function()
  662. local _hx_1
  663. if (#delimiter > 0) then
  664. _hx_1 = #delimiter; else
  665. _hx_1 = 1; end
  666. return _hx_1
  667. end )();
  668. while (idx ~= nil) do
  669. local newidx = 0;
  670. if (#delimiter > 0) then
  671. newidx = _G.string.find(self, delimiter, idx, true);
  672. else
  673. if (idx >= #self) then
  674. newidx = nil;
  675. else
  676. newidx = idx + 1;
  677. end;
  678. end;
  679. if (newidx ~= nil) then
  680. local match = _G.string.sub(self, idx, newidx - 1);
  681. ret:push(match);
  682. idx = newidx + #delimiter;
  683. else
  684. ret:push(_G.string.sub(self, idx, #self));
  685. idx = nil;
  686. end;
  687. end;
  688. do return ret end
  689. end
  690. String.prototype.toString = function(self)
  691. do return self end
  692. end
  693. String.prototype.substring = function(self,startIndex,endIndex)
  694. if (endIndex == nil) then
  695. endIndex = #self;
  696. end;
  697. if (endIndex < 0) then
  698. endIndex = 0;
  699. end;
  700. if (startIndex < 0) then
  701. startIndex = 0;
  702. end;
  703. if (endIndex < startIndex) then
  704. do return _G.string.sub(self, endIndex + 1, startIndex) end;
  705. else
  706. do return _G.string.sub(self, startIndex + 1, endIndex) end;
  707. end;
  708. end
  709. String.prototype.charAt = function(self,index)
  710. do return _G.string.sub(self, index + 1, index + 1) end
  711. end
  712. String.prototype.charCodeAt = function(self,index)
  713. do return _G.string.byte(self, index + 1) end
  714. end
  715. String.prototype.substr = function(self,pos,len)
  716. if ((len == nil) or (len > (pos + #self))) then
  717. len = #self;
  718. else
  719. if (len < 0) then
  720. len = #self + len;
  721. end;
  722. end;
  723. if (pos < 0) then
  724. pos = #self + pos;
  725. end;
  726. if (pos < 0) then
  727. pos = 0;
  728. end;
  729. do return _G.string.sub(self, pos + 1, pos + len) end
  730. end
  731.  
  732. Std.new = {}
  733. Std.string = function(s)
  734. do return __lua_Boot.__string_rec(s) end;
  735. end
  736. Std.int = function(x)
  737. if (not Math.isFinite(x) or Math.isNaN(x)) then
  738. do return 0 end;
  739. else
  740. if (x < __lua_Boot.Min_Int32) then
  741. do return __lua_Boot.Min_Int32 end;
  742. else
  743. if (x > __lua_Boot.Max_Int32) then
  744. do return __lua_Boot.Max_Int32 end;
  745. else
  746. do return _G.math.floor(x) end;
  747. end;
  748. end;
  749. end;
  750. end
  751.  
  752. __haxe_Log.new = {}
  753. __haxe_Log.formatOutput = function(v,infos)
  754. local str = Std.string(v);
  755. if (infos == nil) then
  756. do return str end;
  757. end;
  758. local pstr = Std.string(Std.string(infos.fileName) .. Std.string(":")) .. Std.string(infos.lineNumber);
  759. if (infos.customParams ~= nil) then
  760. local _g = 0;
  761. local _g1 = infos.customParams;
  762. while (_g < _g1.length) do
  763. local v1 = _g1[_g];
  764. _g = _g + 1;
  765. str = Std.string(str) .. Std.string((Std.string(", ") .. Std.string(Std.string(v1))));
  766. end;
  767. end;
  768. do return Std.string(Std.string(pstr) .. Std.string(": ")) .. Std.string(str) end;
  769. end
  770. __haxe_Log.trace = function(v,infos)
  771. local str = __haxe_Log.formatOutput(v, infos);
  772. _hx_print(str);
  773. end
  774.  
  775. __lua_Boot.new = {}
  776. __lua_Boot.isArray = function(o)
  777. if (_G.type(o) == "table") then
  778. if ((o.__enum__ == nil) and (_G.getmetatable(o) ~= nil)) then
  779. do return _G.getmetatable(o).__index == Array.prototype end;
  780. else
  781. do return false end;
  782. end;
  783. else
  784. do return false end;
  785. end;
  786. end
  787. __lua_Boot.printEnum = function(o,s)
  788. if (o.length == 2) then
  789. do return o[0] end;
  790. else
  791. local str = Std.string(Std.string(o[0])) .. Std.string("(");
  792. s = Std.string(s) .. Std.string("\t");
  793. local _g = 2;
  794. local _g1 = o.length;
  795. while (_g < _g1) do
  796. _g = _g + 1;
  797. local i = _g - 1;
  798. if (i ~= 2) then
  799. str = Std.string(str) .. Std.string((Std.string(",") .. Std.string(__lua_Boot.__string_rec(o[i], s))));
  800. else
  801. str = Std.string(str) .. Std.string(__lua_Boot.__string_rec(o[i], s));
  802. end;
  803. end;
  804. do return Std.string(str) .. Std.string(")") end;
  805. end;
  806. end
  807. __lua_Boot.printClassRec = function(c,result,s)
  808. if (result == nil) then
  809. result = "";
  810. end;
  811. local f = __lua_Boot.__string_rec;
  812. for k,v in pairs(c) do if result ~= '' then result = result .. ', ' end result = result .. k .. ':' .. f(v, s.. ' ') end;
  813. do return result end;
  814. end
  815. __lua_Boot.__string_rec = function(o,s)
  816. if (s == nil) then
  817. s = "";
  818. end;
  819. if (#s >= 5) then
  820. do return "<...>" end;
  821. end;
  822. local _g = type(o);
  823. if (_g) == "boolean" then
  824. do return tostring(o) end;
  825. elseif (_g) == "function" then
  826. do return "<function>" end;
  827. elseif (_g) == "nil" then
  828. do return "null" end;
  829. elseif (_g) == "number" then
  830. if (o == _G.math.huge) then
  831. do return "Infinity" end;
  832. else
  833. if (o == -_G.math.huge) then
  834. do return "-Infinity" end;
  835. else
  836. if (o == 0) then
  837. do return "0" end;
  838. else
  839. if (o ~= o) then
  840. do return "NaN" end;
  841. else
  842. do return tostring(o) end;
  843. end;
  844. end;
  845. end;
  846. end;
  847. elseif (_g) == "string" then
  848. do return o end;
  849. elseif (_g) == "table" then
  850. if (o.__enum__ ~= nil) then
  851. do return __lua_Boot.printEnum(o, s) end;
  852. else
  853. if ((_hx_wrap_if_string_field(o,'toString') ~= nil) and not __lua_Boot.isArray(o)) then
  854. do return _hx_wrap_if_string_field(o,'toString')(o) end;
  855. else
  856. if (__lua_Boot.isArray(o)) then
  857. local o2 = o;
  858. if (#s > 5) then
  859. do return "[...]" end;
  860. else
  861. local _g1 = _hx_tab_array({}, 0);
  862. local _g11 = 0;
  863. while (_g11 < o2.length) do
  864. local i = o2[_g11];
  865. _g11 = _g11 + 1;
  866. _g1:push(__lua_Boot.__string_rec(i, Std.string(s) .. Std.string(1)));
  867. end;
  868. do return Std.string(Std.string("[") .. Std.string(_g1:join(","))) .. Std.string("]") end;
  869. end;
  870. else
  871. if (o.__class__ ~= nil) then
  872. do return Std.string(Std.string("{") .. Std.string(__lua_Boot.printClassRec(o, "", Std.string(s) .. Std.string("\t")))) .. Std.string("}") end;
  873. else
  874. local fields = __lua_Boot.fieldIterator(o);
  875. local buffer = ({});
  876. local first = true;
  877. _G.table.insert(buffer, "{ ");
  878. local f = fields;
  879. while (f:hasNext()) do
  880. local f1 = f:next();
  881. if (first) then
  882. first = false;
  883. else
  884. _G.table.insert(buffer, ", ");
  885. end;
  886. _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"))));
  887. end;
  888. _G.table.insert(buffer, " }");
  889. do return _G.table.concat(buffer, "") end;
  890. end;
  891. end;
  892. end;
  893. end;
  894. elseif (_g) == "thread" then
  895. do return "<thread>" end;
  896. elseif (_g) == "userdata" then
  897. local mt = _G.getmetatable(o);
  898. if ((mt ~= nil) and (mt.__tostring ~= nil)) then
  899. do return _G.tostring(o) end;
  900. else
  901. do return "<userdata>" end;
  902. end;else
  903. _G.error("Unknown Lua type",0); end;
  904. end
  905. __lua_Boot.fieldIterator = function(o)
  906. if (_G.type(o) ~= "table") then
  907. do return _hx_o({__fields__={next=true,hasNext=true},next=function(self)
  908. do return nil end;
  909. end,hasNext=function(self)
  910. do return false end;
  911. end}) end;
  912. end;
  913. local tbl = (function()
  914. local _hx_1
  915. if (o.__fields__ ~= nil) then
  916. _hx_1 = o.__fields__; else
  917. _hx_1 = o; end
  918. return _hx_1
  919. end )();
  920. local cur = _G.pairs(tbl);
  921. local next_valid = function(tbl1,val)
  922. while (__lua_Boot.hiddenFields[val] ~= nil) do
  923. val = cur(tbl1, val);
  924. end;
  925. do return val end;
  926. end;
  927. local cur_val = next_valid(tbl, cur(tbl, nil));
  928. do return _hx_o({__fields__={next=true,hasNext=true},next=function(self)
  929. local ret = cur_val;
  930. cur_val = next_valid(tbl, cur(tbl, cur_val));
  931. do return ret end;
  932. end,hasNext=function(self)
  933. do return cur_val ~= nil end;
  934. end}) end;
  935. end
  936. _hx_array_mt.__index = Array.prototype
  937.  
  938. local _hx_static_init = function()
  939. __lua_Boot.Max_Int32 = 2147483647;
  940.  
  941. __lua_Boot.Min_Int32 = -2147483648;
  942.  
  943. __lua_Boot.hiddenFields = {__id__=true, hx__closures=true, super=true, prototype=true, __fields__=true, __ifields__=true, __class__=true, __properties__=true}
  944.  
  945.  
  946. end
  947.  
  948. _hx_print = print or (function() end)
  949.  
  950. _hx_box_mr = function(x,nt)
  951. res = _hx_o({__fields__={}})
  952. for i,v in ipairs(nt) do
  953. res[v] = x[i]
  954. end
  955. return res
  956. end
  957.  
  958. _hx_table = {}
  959. _hx_table.pack = _G.table.pack or function(...)
  960. return {...}
  961. end
  962. _hx_table.unpack = _G.table.unpack or _G.unpack
  963. _hx_table.maxn = _G.table.maxn or function(t)
  964. local maxn=0;
  965. for i in pairs(t) do
  966. maxn=type(i)=='number'and i>maxn and i or maxn
  967. end
  968. return maxn
  969. end;
  970.  
  971. _hx_wrap_if_string_field = function(o, fld)
  972. if _G.type(o) == 'string' then
  973. if fld == 'length' then
  974. return _G.string.len(o)
  975. else
  976. return String.prototype[fld]
  977. end
  978. else
  979. return o[fld]
  980. end
  981. end
  982.  
  983. _hx_static_init();
  984. Main.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement