diff options
-rw-r--r-- | opcode.c | 26 | ||||
-rw-r--r-- | opcode.h | 5 |
2 files changed, 25 insertions, 6 deletions
@@ -3,11 +3,12 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 2.8 1994/09/27 21:43:30 celes Exp celes $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 2.9 1994/10/11 14:38:17 celes Exp $"; |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | #include <string.h> | 10 | #include <string.h> |
11 | #include <math.h> | ||
11 | #ifdef __GNUC__ | 12 | #ifdef __GNUC__ |
12 | #include <floatingpoint.h> | 13 | #include <floatingpoint.h> |
13 | #endif | 14 | #endif |
@@ -245,8 +246,14 @@ int lua_execute (Byte *pc) | |||
245 | break; | 246 | break; |
246 | 247 | ||
247 | case PUSHMARK: tag(top++) = T_MARK; break; | 248 | case PUSHMARK: tag(top++) = T_MARK; break; |
248 | 249 | case PUSHMARKMET: | |
249 | case PUSHOBJECT: *top = *(top-3); top++; break; | 250 | { |
251 | Object receiver = *(top-2); | ||
252 | if (lua_pushsubscript() == 1) return 1; | ||
253 | tag(top++) = T_MARK; | ||
254 | *(top++) = receiver; | ||
255 | break; | ||
256 | } | ||
250 | 257 | ||
251 | case STORELOCAL0: case STORELOCAL1: case STORELOCAL2: | 258 | case STORELOCAL0: case STORELOCAL1: case STORELOCAL2: |
252 | case STORELOCAL3: case STORELOCAL4: case STORELOCAL5: | 259 | case STORELOCAL3: case STORELOCAL4: case STORELOCAL5: |
@@ -457,6 +464,17 @@ int lua_execute (Byte *pc) | |||
457 | } | 464 | } |
458 | break; | 465 | break; |
459 | 466 | ||
467 | case POWOP: | ||
468 | { | ||
469 | Object *l = top-2; | ||
470 | Object *r = top-1; | ||
471 | if (tonumber(r) || tonumber(l)) | ||
472 | return 1; | ||
473 | nvalue(l) = pow(nvalue(l), nvalue(r)); | ||
474 | --top; | ||
475 | } | ||
476 | break; | ||
477 | |||
460 | case CONCOP: | 478 | case CONCOP: |
461 | { | 479 | { |
462 | Object *l = top-2; | 480 | Object *l = top-2; |
@@ -819,7 +837,7 @@ Object *lua_getfield (Object *object, char *field) | |||
819 | { | 837 | { |
820 | Object ref; | 838 | Object ref; |
821 | tag(&ref) = T_STRING; | 839 | tag(&ref) = T_STRING; |
822 | svalue(&ref) = lua_createstring(field); | 840 | svalue(&ref) = lua_constant[lua_findconstant(field)]; |
823 | return (lua_hashget(avalue(object), &ref)); | 841 | return (lua_hashget(avalue(object), &ref)); |
824 | } | 842 | } |
825 | } | 843 | } |
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | ** TeCGraf - PUC-Rio | 2 | ** TeCGraf - PUC-Rio |
3 | ** $Id: opcode.h,v 2.2 1994/07/19 21:27:18 celes Exp celes $ | 3 | ** $Id: opcode.h,v 2.3 1994/08/05 19:31:09 celes Exp celes $ |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef opcode_h | 6 | #ifndef opcode_h |
@@ -55,7 +55,7 @@ typedef enum | |||
55 | PUSHGLOBAL, | 55 | PUSHGLOBAL, |
56 | PUSHINDEXED, | 56 | PUSHINDEXED, |
57 | PUSHMARK, | 57 | PUSHMARK, |
58 | PUSHOBJECT, | 58 | PUSHMARKMET, |
59 | STORELOCAL0, STORELOCAL1, STORELOCAL2, STORELOCAL3, STORELOCAL4, | 59 | STORELOCAL0, STORELOCAL1, STORELOCAL2, STORELOCAL3, STORELOCAL4, |
60 | STORELOCAL5, STORELOCAL6, STORELOCAL7, STORELOCAL8, STORELOCAL9, | 60 | STORELOCAL5, STORELOCAL6, STORELOCAL7, STORELOCAL8, STORELOCAL9, |
61 | STORELOCAL, | 61 | STORELOCAL, |
@@ -74,6 +74,7 @@ typedef enum | |||
74 | SUBOP, | 74 | SUBOP, |
75 | MULTOP, | 75 | MULTOP, |
76 | DIVOP, | 76 | DIVOP, |
77 | POWOP, | ||
77 | CONCOP, | 78 | CONCOP, |
78 | MINUSOP, | 79 | MINUSOP, |
79 | NOTOP, | 80 | NOTOP, |