Overview
Comment: | Implement more of pattern matching. (It is only partially tested so far. Also, only (P) and (,P) are implemented, and so far not (=P) and (P*) and (,P*) and (=P*).) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
de3822f0fe82c68f3d567dbacbeae273 |
User & Date: | user on 2021-04-18 03:04:14 |
Other Links: | manifest | tags |
Context
2021-04-18
| ||
09:10 | Correct a mistake in the Coloc instruction. check-in: 1948866d52 user: user tags: trunk | |
03:04 | Implement more of pattern matching. (It is only partially tested so far. Also, only (P) and (,P) are implemented, and so far not (=P) and (P*) and (,P*) and (=P*).) check-in: de3822f0fe user: user tags: trunk | |
2021-04-17
| ||
05:53 | Check for unterminated flow control structures check-in: 288e31e44b user: user tags: trunk | |
Changes
Modified class.c from [5e7918c55b] to [f6d1b8ebcb].
︙ | ︙ | |||
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 | labelptr=0; } static int parse_pattern(int cla,int ptr,Hash*hash) { Class*cl=classes[cla]; Uint8 depth=0; Uint16 nest[32]; int x,y; for(;;) { nxttok(); if(Tokenf(TF_MACRO)) ParseError("Unexpected macro\n"); if(Tokenf(TF_DIR)) { cl->codes[ptr++]=tokenv&15; } else if(Tokenf(TF_NAME)) { switch(tokenv) { case OP_ADD: case OP_CLIMB: case OP_EIGHT: case OP_FOUR: case OP_HEIGHT: case OP_LOC: case OP_MARK: case OP_SUB: case OP_DIR: case OP_DIR_C: case OP_DIR_E: case OP_DIR_EC: case 0x0200 ... 0x02FF: // message case 0x4000 ... 0x7FFF: // class case 0xC000 ... 0xFFFF: // message cl->codes[ptr++]=tokenv; break; case OP_BEGIN: case OP_IF: if(depth==31) ParseError("Too much pattern nesting\n"); | > > > | > > | > | | > | 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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 | labelptr=0; } static int parse_pattern(int cla,int ptr,Hash*hash) { Class*cl=classes[cla]; Uint8 depth=0; Uint16 nest[32]; Uint16 nest0[32]; int x,y; for(;;) { nxttok(); if(Tokenf(TF_MACRO)) ParseError("Unexpected macro\n"); if(Tokenf(TF_DIR)) { cl->codes[ptr++]=tokenv&15; } else if(Tokenf(TF_NAME)) { switch(tokenv) { case OP_ADD: case OP_CLIMB: case OP_EIGHT: case OP_FOUR: case OP_HEIGHT: case OP_LOC: case OP_MARK: case OP_SUB: case OP_DIR: case OP_DIR_C: case OP_DIR_E: case OP_DIR_EC: case OP_OBJTOPAT: case OP_OBJBOTTOMAT: case OP_CUT: case OP_MUL: case OP_OBJABOVE: case OP_OBJBELOW: case OP_TRACE: case 0x0200 ... 0x02FF: // message case 0x4000 ... 0x7FFF: // class case 0xC000 ... 0xFFFF: // message cl->codes[ptr++]=tokenv; break; case OP_BEGIN: case OP_IF: if(depth==31) ParseError("Too much pattern nesting\n"); nest0[depth]=nest[depth]=ptr; cl->codes[ptr++]=tokenv; cl->codes[ptr++]=0; depth++; break; case OP_ELSE: if(!depth) ParseError("Premature end of subpattern\n"); cl->codes[nest[depth-1]+1]=ptr; cl->codes[ptr++]=OP_ELSE; cl->codes[ptr++]=cl->codes[nest[depth-1]]; cl->codes[nest[depth-1]]=OP_IF; cl->codes[ptr++]=0; break; case OP_THEN: if(!depth) ParseError("Premature end of subpattern\n"); cl->codes[nest[--depth]+1]=ptr; cl->codes[ptr++]=OP_THEN; break; case OP_AGAIN: if(!depth) ParseError("Premature end of subpattern\n"); cl->codes[ptr++]=OP_AGAIN; cl->codes[ptr++]=nest0[depth-1]; cl->codes[nest[--depth]+1]=ptr; cl->codes[ptr++]=OP_THEN; break; case OP_USERFLAG: x=look_hash(glohash,HASH_SIZE,0x1000,0x10FF,0,"user flags"); if(!x) ParseError("User flag ^%s not defined\n",tokenstr); if(Tokenf(TF_COMMA)) x+=0x100; if(Tokenf(TF_EQUAL)) ParseError("Improper token in pattern\n"); cl->codes[ptr++]=x; |
︙ | ︙ |
Modified class.doc from [1027896695] to [5e94c88c88].
︙ | ︙ | |||
2073 2074 2075 2076 2077 2078 2079 | this case, a warp occurs. The movement is restarted, using the specified object as the origin of the movement, and that object's direction as the direction of movement. === Pattern matching === | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 | this case, a warp occurs. The movement is restarted, using the specified object as the origin of the movement, and that object's direction as the direction of movement. === Pattern matching === Where an instruction is expected, you can have pattern matching. This can be (P <pattern...>) or (,P <pattern...>) where the first one uses the current location, and the second kind uses the position and direction of the specified object as the matching. It pushes the found object to the stack, or pushes zero if the pattern does not match. <class> Match an object of the specified class. <dir> Move in the specified direction. (This does not move any objects; it only moves the cursor for pattern matching.) The direction can be relative to the current direction (initially the Dir variable of the origin object) or absolute. <message> Send the message to all objects at the current location. From is the position from which pattern matching started. Arg1 is the direction. Arg2 is the currently matched object (which may be zero). If the return value is zero, it continues normally; if one, the match fails; if two, it continues without sending more messages at this location; if an object, sets the matched object and current location. <userflag> Match an object with the specified flag. ,<userflag> Fail if there are any objects having the specified flag here. + Push the matched object to the stack. - Push zero to the stack. * Update the current choice point with the location and direction. _ Push a mark to the stack. again End a block with begin or if, allowing it to occur more than once; it is repeated until it no longer matches. If the first word is begin, then it must match at least once; if it is if, then it can match zero or more times. The match is greedy; it will match as much as possible. begin Begin a block. Climb Fail the match if the origin object cannot climb here. (Climb <number>) Fail the match if the height here is greater than this number. cut Discards the most recent choice point. else Delimits alternatives within a block. Four Try four directions (E, N, W, and S). Eight Try all eight directions. Height Fail the match if the origin object can climb here. (Height <number>) Fail the match if the height here isn't greater than this number. if Begin a block that can optionally match. ObjAbove Match the object above the currently matched object. ObjBelow Match the object below the currently matched object. ObjBottomAt Match the object at the bottom of this location. ObjTopAt Match the object at the top of this location. then Ends a block started with begin or if. Trace Used for debugging. === Compatibility === Compatible objects have the following differences from the default: * VisualOnly implies Stealthy. |
︙ | ︙ |
Modified exec.c from [866b9c6f26] to [7d927372dc].
︙ | ︙ | |||
1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 | static int colocation(Uint32 a,Uint32 b) { if(a==VOIDLINK || b==VOIDLINK) return 0; if((objects[a]->oflags|objects[b]->oflags)&OF_DESTROYED) return 0; if((objects[a]->oflags^objects[b]->oflags)&OF_BIZARRO) return 0; return (objects[a]->x==objects[b]->x && objects[a]->y==objects[b]->y); } // Here is where the execution of a Free Hero Mesh bytecode subroutine is executed. #define NoIgnore() do{ changed=1; }while(0) #define GetVariableOf(a,b) (i=v_object(Pop()),i==VOIDLINK?NVALUE(0):b(objects[i]->a)) #define GetVariableOrAttributeOf(a,b) (t2=Pop(),t2.t==TY_CLASS?NVALUE(classes[t2.u]->a):(i=v_object(t2),i==VOIDLINK?NVALUE(0):b(objects[i]->a))) #define Numeric(a) do{ if((a).t!=TY_NUMBER) Throw("Type mismatch"); }while(0) #define DivideBy(a) do{ Numeric(a); if(!(a).u) Throw("Division by zero"); }while(0) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 | static int colocation(Uint32 a,Uint32 b) { if(a==VOIDLINK || b==VOIDLINK) return 0; if((objects[a]->oflags|objects[b]->oflags)&OF_DESTROYED) return 0; if((objects[a]->oflags^objects[b]->oflags)&OF_BIZARRO) return 0; return (objects[a]->x==objects[b]->x && objects[a]->y==objects[b]->y); } static Uint32 pat_find_at(int xy,Uint32 m4,Uint32 m5,Uint32 m6,Uint32 m7,Uint8 cl) { Uint8 n=playfield[xy]; Object*o; while(n!=VOIDLINK) { o=objects[n]; if(!(o->oflags&(OF_DESTROYED|OF_VISUALONLY))) { if(o->misc4.t==TY_SOUND || o->misc4.t==TY_USOUND) Throw("Cannot convert sound to type"); if(o->misc5.t==TY_SOUND || o->misc5.t==TY_USOUND) Throw("Cannot convert sound to type"); if(o->misc6.t==TY_SOUND || o->misc6.t==TY_USOUND) Throw("Cannot convert sound to type"); if(o->misc7.t==TY_SOUND || o->misc7.t==TY_USOUND) Throw("Cannot convert sound to type"); if(o->misc4.t==TY_NUMBER && (o->misc4.u&m4)) return n; if(o->misc5.t==TY_NUMBER && (o->misc5.u&m5)) return n; if(o->misc6.t==TY_NUMBER && (o->misc6.u&m6)) return n; if(o->misc7.t==TY_NUMBER && (o->misc7.u&m7)) return n; if(classes[o->class]->collisionLayers&cl) return n; } n=o->up; } return VOIDLINK; } typedef struct { Uint16 ptr,depth; Uint8 x,y,dir,t; } ChoicePoint; #define MAXCHOICE 80 static Uint32 v_pattern(Uint16*code,int ptr,Uint32 obj,char all) { Uint8 x=objects[obj]->x; Uint8 y=objects[obj]->y; Uint8 d=objects[obj]->dir; Uint32 n=VOIDLINK; Uint32 m; Uint16 g; Value v; static ChoicePoint cp[MAXCHOICE]; Uint8 cpi=0; cp->depth=vstackptr; again: switch(code[ptr++]) { case 0 ... 7: n=VOIDLINK; x+=x_delta[code[ptr-1]]; y+=y_delta[code[ptr-1]]; if(x<1 || x>pfwidth || y<1 || y>pfheight) goto fail; break; case 8 ... 15: n=VOIDLINK; x+=x_delta[(code[ptr-1]+objects[obj]->dir)&7]; y+=y_delta[(code[ptr-1]+objects[obj]->dir)&7]; if(x<1 || x>pfwidth || y<1 || y>pfheight) goto fail; break; case 0x0200 ... 0x02FF: g=code[ptr-1]&255; goto message; case 0x1000 ... 0x10FF: g=code[ptr-1]&255; if(g<0x20) n=pat_find_at(x+y*64-65,1UL<<(g&31),0,0,0,0); else if(g<0x40) n=pat_find_at(x+y*64-65,0,1UL<<(g&31),0,0,0); else if(g<0x60) n=pat_find_at(x+y*64-65,0,0,1UL<<(g&31),0,0); else if(g<0x80) n=pat_find_at(x+y*64-65,0,0,0,1UL<<(g&31),0); else n=pat_find_at(x+y*64-65,0,0,0,0,1U<<(g&7)); if(n==VOIDLINK) goto fail; break; case 0x4000 ... 0x7FFF: n=obj_class_at(code[ptr-1]&0x3FFF,x,y); if(n==VOIDLINK) goto fail; break; case 0xC000 ... 0xFFFF: g=(code[ptr-1]&0x3FFF)+256; message: m=playfield[x+y*64-65]; while(m!=VOIDLINK) { v=send_message(obj,m,g,NVALUE(d),OVALUE(n),NVALUE(0)); if(v.t==TY_NUMBER) { if(v.u==1) goto fail; else if(v.u==2) break; else if(v.u) Throw("Invalid return value from message in pattern matching"); } else if(v.t>TY_MAXTYPE) { n=v_object(v); x=objects[n]->x; y=objects[n]->y; } else { Throw("Type mismatch"); } m=objects[m]->up; } break; case OP_ADD: if(vstackptr>=VSTACKSIZE-1) Throw("Stack overflow"); m=(n==VOIDLINK?obj_bottom_at(x,y):n); Push(OVALUE(m)); break; case OP_AGAIN: if(cp[cpi].ptr!=ptr+1) { if(cpi>=MAXCHOICE-1) Throw("Choice overflow"); cpi++; cp[cpi].ptr=ptr+1; } cp[cpi].x=x; cp[cpi].y=y; cp[cpi].dir=d; cp[cpi].depth=vstackptr; ptr=code[ptr]+2; break; case OP_BEGIN: ptr++; break; case OP_CLIMB: if(playfield[x+y*64-65]==VOIDLINK || height_at(x,y)>objects[obj]->climb) goto fail; break; case OP_CLIMB_C: g=code[ptr++]; if(playfield[x+y*64-65]==VOIDLINK || height_at(x,y)>g) goto fail; break; case OP_CUT: if(cpi) cpi--; break; case OP_DIR: d=objects[obj]->dir; break; case OP_DIR_C: if(n==VOIDLINK) Throw("No object specified in pattern"); d=objects[n]->dir; break; case OP_DIR_E: changed=1; objects[obj]->dir=d; break; case OP_DIR_EC: if(n==VOIDLINK) Throw("No object specified in pattern"); changed=1; objects[n]->dir=d; break; case OP_EIGHT: if(cpi>=MAXCHOICE-8) Throw("Choice overflow"); d=0; cpi+=7; cp[cpi].x=x; cp[cpi].y=y; cp[cpi].depth=vstackptr; cp[cpi].ptr=ptr; cp[cpi-1]=cp[cpi-2]=cp[cpi-3]=cp[cpi-4]=cp[cpi-5]=cp[cpi-6]=cp[cpi]; cp[cpi].dir=1; cp[cpi-1].dir=2; cp[cpi-2].dir=3; cp[cpi-3].dir=4; cp[cpi-4].dir=5; cp[cpi-5].dir=6; cp[cpi-6].dir=7; break; case OP_ELSE: ptr--; while(code[ptr]==OP_ELSE) ptr=code[ptr+2]; break; case OP_FOUR: if(cpi>=MAXCHOICE-4) Throw("Choice overflow"); d=0; cpi+=3; cp[cpi].x=x; cp[cpi].y=y; cp[cpi].depth=vstackptr; cp[cpi].ptr=ptr; cp[cpi-1]=cp[cpi-2]=cp[cpi]; cp[cpi].dir=2; cp[cpi-1].dir=4; cp[cpi-2].dir=6; break; case OP_HEIGHT: if(playfield[x+y*64-65]==VOIDLINK || height_at(x,y)<=objects[obj]->climb) goto fail; break; case OP_HEIGHT_C: g=code[ptr++]; if(playfield[x+y*64-65]==VOIDLINK || height_at(x,y)<=g) goto fail; break; case OP_IF: if(cpi>=MAXCHOICE-1) Throw("Pattern stack overflow"); cpi++; cp[cpi].x=x; cp[cpi].y=y; cp[cpi].dir=d; cp[cpi].depth=vstackptr; cp[cpi].ptr=code[ptr++]; break; case OP_LOC: if(vstackptr>=VSTACKSIZE-2) Throw("Stack overflow"); Push(NVALUE(x)); Push(NVALUE(y)); break; case OP_MARK: if(vstackptr>=VSTACKSIZE-1) Throw("Stack overflow"); Push(UVALUE(0,TY_MARK)); break; case OP_MUL: cp[cpi].x=x; cp[cpi].y=y; cp[cpi].dir=d; break; case OP_OBJABOVE: if(n==VOIDLINK) Throw("No object specified in pattern"); n=obj_above(n); break; case OP_OBJBELOW: if(n==VOIDLINK) Throw("No object specified in pattern"); n=obj_below(n); break; case OP_OBJBOTTOMAT: n=obj_bottom_at(x,y); break; case OP_OBJTOPAT: n=obj_top_at(x,y); break; case OP_RET: return n==VOIDLINK?obj_bottom_at(x,y):n; case OP_SUB: if(vstackptr>=VSTACKSIZE-1) Throw("Stack overflow"); Push(NVALUE(0)); break; case OP_THEN: // This opcode does nothing break; case OP_TRACE: if(main_options['t']) { printf("ptr=%d cpi=%d x=%d y=%d dir=%d obj=%lu ",ptr,cpi,x,y,d,(long)n); printf("[ptr=%d x=%d y=%d dir=%d]\n",cp[cpi].ptr,cp[cpi].x,cp[cpi].y,cp[cpi].dir); } break; default: Throw("Unimplemented opcode in pattern"); } goto again; fail: if(vstackptr<cp->depth) Throw("Stack underflow in pattern matching"); vstackptr=cp[cpi].depth; if(!cpi) return VOIDLINK; x=cp[cpi].x; y=cp[cpi].y; d=cp[cpi].dir; ptr=cp[cpi].ptr; n=VOIDLINK; cpi--; goto again; } // Here is where the execution of a Free Hero Mesh bytecode subroutine is executed. #define NoIgnore() do{ changed=1; }while(0) #define GetVariableOf(a,b) (i=v_object(Pop()),i==VOIDLINK?NVALUE(0):b(objects[i]->a)) #define GetVariableOrAttributeOf(a,b) (t2=Pop(),t2.t==TY_CLASS?NVALUE(classes[t2.u]->a):(i=v_object(t2),i==VOIDLINK?NVALUE(0):b(objects[i]->a))) #define Numeric(a) do{ if((a).t!=TY_NUMBER) Throw("Type mismatch"); }while(0) #define DivideBy(a) do{ Numeric(a); if(!(a).u) Throw("Division by zero"); }while(0) |
︙ | ︙ | |||
1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 | case OP_OBJCLASSAT: StackReq(3,1); t3=Pop(); t2=Pop(); t1=Pop(); Push(v_obj_class_at(t1,t2,t3)); break; case OP_OBJDIR: StackReq(1,1); t2=Pop(); Numeric(t2); i=obj_dir(obj,t2.u); Push(OVALUE(i)); break; case OP_OBJDIR_C: StackReq(2,1); t2=Pop(); Numeric(t2); i=obj_dir(v_object(Pop()),t2.u); Push(OVALUE(i)); break; case OP_OBJLAYERAT: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); i=obj_layer_at(t1.u,t2.u,t3.u); Push(OVALUE(i)); break; case OP_OBJMOVINGTO: StackReq(2,0); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); v_obj_moving_to(t1.u,t2.u); break; case OP_OBJTOPAT: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); i=obj_top_at(t1.u,t2.u); Push(OVALUE(i)); break; case OP_OVER: StackReq(2,3); t2=Pop(); t1=Pop(); Push(t1); Push(t2); Push(t1); break; case OP_PICK: StackReq(0,1); t1=Pop(); Numeric(t1); if(t1.u>=vstackptr) Throw("Stack index out of range"); t1=vstack[vstackptr-t1.u-1]; Push(t1); break; case OP_PLAYER: StackReq(0,1); if(classes[o->class]->cflags&CF_PLAYER) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_PLAYER_C: StackReq(1,1); GetClassFlagOf(CF_PLAYER); break; case OP_PLUSMOVE: StackReq(1,1); t1=Pop(); Numeric(t1); i=defer_move(obj,t1.u,1); Push(NVALUE(i)); break; case OP_PLUSMOVE_C: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); i=defer_move(i,t1.u,1); Push(NVALUE(i)); break; case OP_PLUSMOVE_D: StackReq(1,0); t1=Pop(); Numeric(t1); defer_move(obj,t1.u,1); break; case OP_PLUSMOVE_CD: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); defer_move(i,t1.u,1); break; | > > | 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 | case OP_OBJCLASSAT: StackReq(3,1); t3=Pop(); t2=Pop(); t1=Pop(); Push(v_obj_class_at(t1,t2,t3)); break; case OP_OBJDIR: StackReq(1,1); t2=Pop(); Numeric(t2); i=obj_dir(obj,t2.u); Push(OVALUE(i)); break; case OP_OBJDIR_C: StackReq(2,1); t2=Pop(); Numeric(t2); i=obj_dir(v_object(Pop()),t2.u); Push(OVALUE(i)); break; case OP_OBJLAYERAT: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); i=obj_layer_at(t1.u,t2.u,t3.u); Push(OVALUE(i)); break; case OP_OBJMOVINGTO: StackReq(2,0); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); v_obj_moving_to(t1.u,t2.u); break; case OP_OBJTOPAT: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); i=obj_top_at(t1.u,t2.u); Push(OVALUE(i)); break; case OP_OVER: StackReq(2,3); t2=Pop(); t1=Pop(); Push(t1); Push(t2); Push(t1); break; case OP_PATTERN: StackReq(0,1); i=code[ptr++]; j=v_pattern(code,ptr,obj,0); ptr=i; Push(OVALUE(j)); break; case OP_PATTERN_C: StackReq(1,1); i=code[ptr++]; j=v_object(Pop()); if(j!=VOIDLINK) j=v_pattern(code,ptr,j,0); ptr=i; Push(OVALUE(j)); break; case OP_PICK: StackReq(0,1); t1=Pop(); Numeric(t1); if(t1.u>=vstackptr) Throw("Stack index out of range"); t1=vstack[vstackptr-t1.u-1]; Push(t1); break; case OP_PLAYER: StackReq(0,1); if(classes[o->class]->cflags&CF_PLAYER) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_PLAYER_C: StackReq(1,1); GetClassFlagOf(CF_PLAYER); break; case OP_PLUSMOVE: StackReq(1,1); t1=Pop(); Numeric(t1); i=defer_move(obj,t1.u,1); Push(NVALUE(i)); break; case OP_PLUSMOVE_C: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); i=defer_move(i,t1.u,1); Push(NVALUE(i)); break; case OP_PLUSMOVE_D: StackReq(1,0); t1=Pop(); Numeric(t1); defer_move(obj,t1.u,1); break; case OP_PLUSMOVE_CD: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); defer_move(i,t1.u,1); break; |
︙ | ︙ |
Modified instruc from [aef07dfcc7] to [43ddd4ce2c].
︙ | ︙ | |||
281 282 283 284 285 286 287 288 289 290 291 292 293 294 | ArrayCell ; Pattern matching -,=Pattern "P" -,=PatternS "P*" -Four -Eight ; Specials *Function *Local *Label *String *Int16 | > | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | ArrayCell ; Pattern matching -,=Pattern "P" -,=PatternS "P*" -Four -Eight -cut ; Specials *Function *Local *Label *String *Int16 |
︙ | ︙ |
Modified instruc.h from [b4a8f7dc1b] to [e4917d9dd6].
︙ | ︙ | |||
413 414 415 416 417 418 419 | #define OP_PATTERN_EC 39118 #define OP_PATTERNS 32975 #define OP_PATTERNS_C 35023 #define OP_PATTERNS_E 37071 #define OP_PATTERNS_EC 39119 #define OP_FOUR 32976 #define OP_EIGHT 32977 | > | | | | | | | | | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | #define OP_PATTERN_EC 39118 #define OP_PATTERNS 32975 #define OP_PATTERNS_C 35023 #define OP_PATTERNS_E 37071 #define OP_PATTERNS_EC 39119 #define OP_FOUR 32976 #define OP_EIGHT 32977 #define OP_CUT 32978 #define OP_FUNCTION 32979 #define OP_LOCAL 32980 #define OP_LABEL 32981 #define OP_STRING 32982 #define OP_INT16 32983 #define OP_INT32 32984 #define OP_DISPATCH 32985 #define OP_USERFLAG 32986 #ifdef HEROMESH_CLASS static const Op_Names op_names[]={ {"*",8486937}, {"+",8421399}, {"+Move",10584230}, {"-",8421400}, {"-Move",10584231}, |
︙ | ︙ | |||
695 696 697 698 699 700 701 702 703 704 705 706 707 708 | {"bit8",8423400}, {"bit9",8423401}, {"bnot",8421412}, {"bor",8421410}, {"bxor",8421411}, {"c?",8421427}, {"chain",8421520}, {"cz?",8421428}, {"dup",8421377}, {"el",8683532}, {"else",8683530}, {"eq",8421418}, {"eq2",8421419}, {"flip",8421576}, | > | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | {"bit8",8423400}, {"bit9",8423401}, {"bnot",8421412}, {"bor",8421410}, {"bxor",8421411}, {"c?",8421427}, {"chain",8421520}, {"cut",8683730}, {"cz?",8421428}, {"dup",8421377}, {"el",8683532}, {"else",8683530}, {"eq",8421418}, {"eq2",8421419}, {"flip",8421576}, |
︙ | ︙ | |||
742 743 744 745 746 747 748 | {"swap",8421378}, {"then",8683531}, {"tmark",8421572}, {"tuck",8421380}, {"until",8683535}, {"while",8683536}, }; | | | 744 745 746 747 748 749 750 751 752 | {"swap",8421378}, {"then",8683531}, {"tmark",8421572}, {"tuck",8421380}, {"until",8683535}, {"while",8683536}, }; #define N_OP_NAMES 319 #endif |