aboutsummaryrefslogtreecommitdiff
path: root/games/minimal/mods/default/textures/default_grass.png
blob: 3610bb2bc54cc561abd9d59f2ee78c9ea9d1a5a0 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 08 06 00 00 00 1f f3 ff .PNG........IHDR................
0020 61 00 00 00 01 73 52 47 42 00 ae ce 1c e9 00 00 00 06 62 4b 47 44 00 ff 00 ff 00 ff a0 bd a7 93 a....sRGB.........bKGD..........
0040 00 00 00 09 70 48 59 73 00 00 0b 13 00 00 0b 13 01 00 9a 9c 18 00 00 00 07 74 49 4d 45 07 db 04 ....pHYs.................tIME...
0060 1c 15 25 34 88 c8 4d 62 00 00 02 ea 49 44 41 54 38 cb 25 c8 5b 6e e3 54 00 80 e1 df f6 f1 dd 49 ..%4..Mb....IDAT8.%.[n.T.......I
0080 1c c7 71 68 a0 1d da 19 69 ca 03 12 48 6c 80 15 b0 10 36 81 c4 ee e0 15 69 40 45 33 e9 35 6d 12 ..qh....i...Hl....6.....i@E3.5m.
00a0 db 71 e2 1c db f1 e5 f0 c0 f7 f8 69 bf fe fe a3 0a 46 3e 6e 68 d1 2b 8d 72 27 71 6c 13 59 35 bc .q.........i.....F>nh.+.r'ql.Y5.
00c0 bf 5d d2 36 3d ae 66 53 0e 03 db f4 8d b1 e7 b0 8c bf 61 9b 3e f3 fc 90 a1 cf 2e 47 f4 fa 00 c2 .].6=.fS..........a.>......G....
00e0 62 31 4e f0 b1 b8 fe 7a 82 6b 09 d6 eb 94 e6 d0 b1 5d 17 e4 db 23 52 76 d8 be 49 2a 9f d8 1f 2b b1N....z.k.......]...#Rv..I*...+
0100 34 11 a2 47 f3 19 c2 d4 28 d3 16 c7 b0 b9 fe f8 8e 4a 76 f4 aa c7 30 6c 56 ab 8c f9 c5 04 37 e8 4..G....(........Jv...0lV.....7.
0120 38 64 35 87 7d cd 38 8c 08 93 84 51 e4 21 da 12 74 4b 47 b4 27 5a 95 33 b6 6c 56 f9 09 25 74 5c 8d5.}.8....Q.!..tKG.'Z.3.lV..%t\
0140 cd 60 36 72 d9 64 25 ba 2f 78 7f 3b a6 ef 21 cb 4a b6 0f 35 52 9e d1 df b2 17 f6 59 c9 a0 69 54 .`6r.d%./x.;..!.J..5R......Y..iT
0160 6d cb fa 75 cf 59 b5 58 ae cf db ab e4 e6 36 c1 0a ce bc 6d 0e 08 c3 a4 92 67 22 df c6 33 1a ae m..u.Y.X......6....m.....g"..3..
0180 3f 4e 10 eb 4d cd d4 73 a0 83 a7 87 3d e5 a9 67 3e 9f 60 2b 87 9b 1f e6 60 f6 a8 c6 a0 ef 7b f2 ?N..M..s....=..g>.`+....`.....{.
01a0 43 8d 25 a0 2a 6c 76 87 81 5c e5 88 45 e4 b1 88 c6 bc 3c 16 58 8e c1 3c f4 d9 ac 0b c2 f0 c4 e3 C.%.*lv..\..E.....<.X..<........
01c0 ea 80 36 55 a8 a1 23 99 ba 28 0b 8c 5e 91 d6 07 6e ae ae 18 2c d0 2b 59 93 95 25 c9 32 61 34 32 ..6U..#..(..^...n...,.+Y..%.2a42
01e0 69 d4 91 f1 54 a3 e9 7b e2 f1 15 a2 0b 90 45 cf 22 0c 99 8e 26 ec 76 67 3e fd f5 c4 ea 65 45 d9 i...T..{......E."...&.vg>....eE.
0200 e4 e8 c7 ac a3 91 03 4d 53 31 d4 20 06 81 d0 3d 54 ab 71 77 77 47 5d e4 2c 93 80 e4 ab 25 f7 ff .......MS1.....=T.qwwG].,....%..
0220 a4 f8 ae 46 1c 07 f8 53 13 db 13 08 a1 19 08 c7 63 68 27 0c 6a 8f 33 12 ac d7 15 e1 c8 c2 9f da ...F...S........ch'.j.3.........
0240 08 47 92 ef 6b aa ea 91 d9 85 89 1f 3a 28 bd a2 3a 77 18 a6 8b f8 fe a7 98 fb 95 64 53 1e b9 fc .G..k.......:(..:w.........dS...
0260 36 64 ec fb 8c 47 2e 9d 3a a1 61 b0 fa 24 69 35 45 d3 4b a2 85 4b af 9f 91 45 43 94 44 d0 9f 10 6d...G..:.a..$i5E.K..K...EC.D...
0280 a7 5a 12 4d 4c 82 58 60 59 30 34 1a bb a2 a0 ec 4a 1c d7 44 f7 74 2e e3 80 46 69 38 96 47 5e e4 .Z.ML.X`Y04.....J..D.t...Fi8.G^.
02a0 7c b8 89 51 b6 c1 c3 fd 16 7d f3 dc 10 4f 47 c4 93 09 c5 ae e4 35 dd d2 0d 67 6a 09 9e 15 70 fd |..Q.....}...OG......5...gj...p.
02c0 6e 8e ec 5b aa 73 87 69 9a 74 67 c1 22 59 b2 fa 7b 87 6f 2b 74 55 0b a2 e8 ff 70 74 98 ce 46 54 n..[.s.i.tg."Y..{.o+tU....pt..FT
02e0 85 c1 cc b3 e8 8e 8a 20 48 38 e4 36 9b ac e6 8f 3f bf 20 0f 1d ff 7e 7e 61 76 61 32 bf 9c 61 fc ........H8.6....?.....~~ava2..a.
0300 fc cb d5 6f b2 e9 10 4e 8b 61 98 04 81 45 18 5b 58 b6 a0 da 43 a7 5a 1c 02 5c d7 83 b6 a2 1e 1a ...o...N.a...E.[X...C.Z..\......
0320 76 d9 09 dd 32 10 96 86 78 dd 9e b8 7f 3e 91 2c 3d e2 c4 26 dd 48 9a b2 c6 72 4d c6 93 29 9a 21 v...2...x....>.,=..&.H...rM..).!
0340 79 49 37 60 98 7c f8 6e ce e7 2f 29 e1 d4 c5 b3 7d 76 af 29 ff 01 f9 39 74 df 68 95 78 27 00 00 yI7`.|.n../)....}v.)...9t.h.x'..
0360 00 00 49 45 4e 44 ae 42 60 82 ..IEND.B`.
' href='#n209'>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
/*
** $Id: lcode.c,v 2.25.1.5 2011/01/31 14:53:16 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/


#include <stdlib.h>

#define lcode_c
#define LUA_CORE

#include "lua.h"

#include "lcode.h"
#include "ldebug.h"
#include "ldo.h"
#include "lgc.h"
#include "llex.h"
#include "lmem.h"
#include "lobject.h"
#include "lopcodes.h"
#include "lparser.h"
#include "ltable.h"


#define hasjumps(e)	((e)->t != (e)->f)


static int isnumeral(expdesc *e) {
  return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
}


void luaK_nil (FuncState *fs, int from, int n) {
  Instruction *previous;
  if (fs->pc > fs->lasttarget) {  /* no jumps to current position? */
    if (fs->pc == 0) {  /* function start? */
      if (from >= fs->nactvar)
        return;  /* positions are already clean */
    }
    else {
      previous = &fs->f->code[fs->pc-1];
      if (GET_OPCODE(*previous) == OP_LOADNIL) {
        int pfrom = GETARG_A(*previous);
        int pto = GETARG_B(*previous);
        if (pfrom <= from && from <= pto+1) {  /* can connect both? */
          if (from+n-1 > pto)
            SETARG_B(*previous, from+n-1);
          return;
        }
      }
    }
  }
  luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0);  /* else no optimization */
}


int luaK_jump (FuncState *fs) {
  int jpc = fs->jpc;  /* save list of jumps to here */
  int j;
  fs->jpc = NO_JUMP;
  j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
  luaK_concat(fs, &j, jpc);  /* keep them on hold */
  return j;
}


void luaK_ret (FuncState *fs, int first, int nret) {
  luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
}


static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
  luaK_codeABC(fs, op, A, B, C);
  return luaK_jump(fs);
}


static void fixjump (FuncState *fs, int pc, int dest) {
  Instruction *jmp = &fs->f->code[pc];
  int offset = dest-(pc+1);
  lua_assert(dest != NO_JUMP);
  if (abs(offset) > MAXARG_sBx)
    luaX_syntaxerror(fs->ls, "control structure too long");
  SETARG_sBx(*jmp, offset);
}


/*
** returns current `pc' and marks it as a jump target (to avoid wrong
** optimizations with consecutive instructions not in the same basic block).
*/
int luaK_getlabel (FuncState *fs) {
  fs->lasttarget = fs->pc;
  return fs->pc;
}


static int getjump (FuncState *fs, int pc) {
  int offset = GETARG_sBx(fs->f->code[pc]);
  if (offset == NO_JUMP)  /* point to itself represents end of list */
    return NO_JUMP;  /* end of list */
  else
    return (pc+1)+offset;  /* turn offset into absolute position */
}


static Instruction *getjumpcontrol (FuncState *fs, int pc) {
  Instruction *pi = &fs->f->code[pc];
  if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
    return pi-1;
  else
    return pi;
}


/*
** check whether list has any jump that do not produce a value
** (or produce an inverted value)
*/
static int need_value (FuncState *fs, int list) {
  for (; list != NO_JUMP; list = getjump(fs, list)) {
    Instruction i = *getjumpcontrol(fs, list);
    if (GET_OPCODE(i) != OP_TESTSET) return 1;
  }
  return 0;  /* not found */
}


static int patchtestreg (FuncState *fs, int node, int reg) {
  Instruction *i = getjumpcontrol(fs, node);
  if (GET_OPCODE(*i) != OP_TESTSET)
    return 0;  /* cannot patch other instructions */
  if (reg != NO_REG && reg != GETARG_B(*i))
    SETARG_A(*i, reg);
  else  /* no register to put value or register already has the value */
    *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));

  return 1;
}


static void removevalues (FuncState *fs, int list) {
  for (; list != NO_JUMP; list = getjump(fs, list))
      patchtestreg(fs, list, NO_REG);
}


static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
                          int dtarget) {
  while (list != NO_JUMP) {
    int next = getjump(fs, list);
    if (patchtestreg(fs, list, reg))
      fixjump(fs, list, vtarget);
    else
      fixjump(fs, list, dtarget);  /* jump to default target */
    list = next;
  }
}


static void dischargejpc (FuncState *fs) {
  patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
  fs->jpc = NO_JUMP;
}


void luaK_patchlist (FuncState *fs, int list, int target) {
  if (target == fs->pc)
    luaK_patchtohere(fs, list);
  else {
    lua_assert(target < fs->pc);
    patchlistaux(fs, list, target, NO_REG, target);
  }
}


void luaK_patchtohere (FuncState *fs, int list) {
  luaK_getlabel(fs);
  luaK_concat(fs, &fs->jpc, list);
}


void luaK_concat (FuncState *fs, int *l1, int l2) {
  if (l2 == NO_JUMP) return;
  else if (*l1 == NO_JUMP)
    *l1 = l2;
  else {
    int list = *l1;
    int next;
    while ((next = getjump(fs, list)) != NO_JUMP)  /* find last element */
      list = next;
    fixjump(fs, list, l2);
  }
}


void luaK_checkstack (FuncState *fs, int n) {
  int newstack = fs->freereg + n;
  if (newstack > fs->f->maxstacksize) {
    if (newstack >= MAXSTACK)
      luaX_syntaxerror(fs->ls, "function or expression too complex");
    fs->f->maxstacksize = cast_byte(newstack);
  }
}


void luaK_reserveregs (FuncState *fs, int n) {
  luaK_checkstack(fs, n);
  fs->freereg += n;
}


static void freereg (FuncState *fs, int reg) {
  if (!ISK(reg) && reg >= fs->nactvar) {
    fs->freereg--;
    lua_assert(reg == fs->freereg);
  }
}


static void freeexp (FuncState *fs, expdesc *e) {
  if (e->k == VNONRELOC)
    freereg(fs, e->u.s.info);
}


static int addk (FuncState *fs, TValue *k, TValue *v) {
  lua_State *L = fs->L;
  TValue *idx = luaH_set(L, fs->h, k);
  Proto *f = fs->f;
  int oldsize = f->sizek;
  if (ttisnumber(idx)) {
    lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
    return cast_int(nvalue(idx));
  }
  else {  /* constant not found; create a new entry */
    setnvalue(idx, cast_num(fs->nk));
    luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
                    MAXARG_Bx, "constant table overflow");
    while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
    setobj(L, &f->k[fs->nk], v);
    luaC_barrier(L, f, v);
    return fs->nk++;
  }
}


int luaK_stringK (FuncState *fs, TString *s) {
  TValue o;
  setsvalue(fs->L, &o, s);
  return addk(fs, &o, &o);
}


int luaK_numberK (FuncState *fs, lua_Number r) {
  TValue o;
  setnvalue(&o, r);
  return addk(fs, &o, &o);
}


static int boolK (FuncState *fs, int b) {
  TValue o;
  setbvalue(&o, b);
  return addk(fs, &o, &o);
}


static int nilK (FuncState *fs) {
  TValue k, v;
  setnilvalue(&v);
  /* cannot use nil as key; instead use table itself to represent nil */
  sethvalue(fs->L, &k, fs->h);
  return addk(fs, &k, &v);
}


void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
  if (e->k == VCALL) {  /* expression is an open function call? */
    SETARG_C(getcode(fs, e), nresults+1);
  }
  else if (e->k == VVARARG) {
    SETARG_B(getcode(fs, e), nresults+1);
    SETARG_A(getcode(fs, e), fs->freereg);
    luaK_reserveregs(fs, 1);
  }
}


void luaK_setoneret (FuncState *fs, expdesc *e) {
  if (e->k == VCALL) {  /* expression is an open function call? */
    e->k = VNONRELOC;
    e->u.s.info = GETARG_A(getcode(fs, e));
  }
  else if (e->k == VVARARG) {
    SETARG_B(getcode(fs, e), 2);
    e->k = VRELOCABLE;  /* can relocate its simple result */
  }
}


void luaK_dischargevars (FuncState *fs, expdesc *e) {
  switch (e->k) {
    case VLOCAL: {
      e->k = VNONRELOC;
      break;
    }
    case VUPVAL: {
      e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0);
      e->k = VRELOCABLE;
      break;
    }
    case VGLOBAL: {
      e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info);
      e->k = VRELOCABLE;
      break;
    }
    case VINDEXED: {
      freereg(fs, e->u.s.aux);
      freereg(fs, e->u.s.info);
      e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux);
      e->k = VRELOCABLE;
      break;
    }
    case VVARARG:
    case VCALL: {
      luaK_setoneret(fs, e);
      break;
    }
    default: break;  /* there is one value available (somewhere) */
  }
}


static int code_label (FuncState *fs, int A, int b, int jump) {
  luaK_getlabel(fs);  /* those instructions may be jump targets */
  return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
}


static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
  luaK_dischargevars(fs, e);
  switch (e->k) {
    case VNIL: {
      luaK_nil(fs, reg, 1);
      break;
    }
    case VFALSE:  case VTRUE: {
      luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0);
      break;
    }
    case VK: {
      luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info);
      break;
    }
    case VKNUM: {
      luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
      break;
    }
    case VRELOCABLE: {
      Instruction *pc = &getcode(fs, e);
      SETARG_A(*pc, reg);
      break;
    }
    case VNONRELOC: {
      if (reg != e->u.s.info)
        luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0);
      break;
    }
    default: {
      lua_assert(e->k == VVOID || e->k == VJMP);
      return;  /* nothing to do... */
    }
  }
  e->u.s.info = reg;
  e->k = VNONRELOC;
}


static void discharge2anyreg (FuncState *fs, expdesc *e) {