new operations POWOP (power) and PUSHMARKMET (for marking method calls).

remove of operation PUSHOBJECT.
This commit is contained in:
Waldemar Celes 1994-10-17 17:00:40 -02:00
parent fca10c6733
commit ad07c0f638
2 changed files with 25 additions and 6 deletions

View File

@ -3,11 +3,12 @@
** TecCGraf - PUC-Rio ** TecCGraf - PUC-Rio
*/ */
char *rcs_opcode="$Id: opcode.c,v 2.8 1994/09/27 21:43:30 celes Exp celes $"; char *rcs_opcode="$Id: opcode.c,v 2.9 1994/10/11 14:38:17 celes Exp $";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h>
#ifdef __GNUC__ #ifdef __GNUC__
#include <floatingpoint.h> #include <floatingpoint.h>
#endif #endif
@ -245,8 +246,14 @@ int lua_execute (Byte *pc)
break; break;
case PUSHMARK: tag(top++) = T_MARK; break; case PUSHMARK: tag(top++) = T_MARK; break;
case PUSHMARKMET:
case PUSHOBJECT: *top = *(top-3); top++; break; {
Object receiver = *(top-2);
if (lua_pushsubscript() == 1) return 1;
tag(top++) = T_MARK;
*(top++) = receiver;
break;
}
case STORELOCAL0: case STORELOCAL1: case STORELOCAL2: case STORELOCAL0: case STORELOCAL1: case STORELOCAL2:
case STORELOCAL3: case STORELOCAL4: case STORELOCAL5: case STORELOCAL3: case STORELOCAL4: case STORELOCAL5:
@ -457,6 +464,17 @@ int lua_execute (Byte *pc)
} }
break; break;
case POWOP:
{
Object *l = top-2;
Object *r = top-1;
if (tonumber(r) || tonumber(l))
return 1;
nvalue(l) = pow(nvalue(l), nvalue(r));
--top;
}
break;
case CONCOP: case CONCOP:
{ {
Object *l = top-2; Object *l = top-2;
@ -819,7 +837,7 @@ Object *lua_getfield (Object *object, char *field)
{ {
Object ref; Object ref;
tag(&ref) = T_STRING; tag(&ref) = T_STRING;
svalue(&ref) = lua_createstring(field); svalue(&ref) = lua_constant[lua_findconstant(field)];
return (lua_hashget(avalue(object), &ref)); return (lua_hashget(avalue(object), &ref));
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
** TeCGraf - PUC-Rio ** TeCGraf - PUC-Rio
** $Id: opcode.h,v 2.2 1994/07/19 21:27:18 celes Exp celes $ ** $Id: opcode.h,v 2.3 1994/08/05 19:31:09 celes Exp celes $
*/ */
#ifndef opcode_h #ifndef opcode_h
@ -55,7 +55,7 @@ typedef enum
PUSHGLOBAL, PUSHGLOBAL,
PUSHINDEXED, PUSHINDEXED,
PUSHMARK, PUSHMARK,
PUSHOBJECT, PUSHMARKMET,
STORELOCAL0, STORELOCAL1, STORELOCAL2, STORELOCAL3, STORELOCAL4, STORELOCAL0, STORELOCAL1, STORELOCAL2, STORELOCAL3, STORELOCAL4,
STORELOCAL5, STORELOCAL6, STORELOCAL7, STORELOCAL8, STORELOCAL9, STORELOCAL5, STORELOCAL6, STORELOCAL7, STORELOCAL8, STORELOCAL9,
STORELOCAL, STORELOCAL,
@ -74,6 +74,7 @@ typedef enum
SUBOP, SUBOP,
MULTOP, MULTOP,
DIVOP, DIVOP,
POWOP,
CONCOP, CONCOP,
MINUSOP, MINUSOP,
NOTOP, NOTOP,