diff options
| author | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1994-08-05 16:31:09 -0300 |
|---|---|---|
| committer | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1994-08-05 16:31:09 -0300 |
| commit | 41fd23287aae60354c264be8f1807bccd937fbf1 (patch) | |
| tree | 58670393eeb575ee622ca52dbde7b65f7ce3098f /opcode.c | |
| parent | be7aa3854be4c8d9203637955a064439f240951f (diff) | |
| download | lua-41fd23287aae60354c264be8f1807bccd937fbf1.tar.gz lua-41fd23287aae60354c264be8f1807bccd937fbf1.tar.bz2 lua-41fd23287aae60354c264be8f1807bccd937fbf1.zip | |
Implementacao da definicao e chamada de METODOS.
Diffstat (limited to 'opcode.c')
| -rw-r--r-- | opcode.c | 17 |
1 files changed, 13 insertions, 4 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_opcode="$Id: opcode.c,v 2.2 1994/07/19 21:27:18 celes Exp celes $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 2.3 1994/08/03 14:15:46 celes Exp celes $"; |
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
| @@ -211,6 +211,14 @@ int lua_execute (Byte *pc) | |||
| 211 | tag(top) = T_STRING; svalue(top++) = lua_constant[code.w]; | 211 | tag(top) = T_STRING; svalue(top++) = lua_constant[code.w]; |
| 212 | } | 212 | } |
| 213 | break; | 213 | break; |
| 214 | |||
| 215 | case PUSHFUNCTION: | ||
| 216 | { | ||
| 217 | CodeCode code; | ||
| 218 | get_code(code,pc); | ||
| 219 | tag(top) = T_FUNCTION; bvalue(top++) = code.b; | ||
| 220 | } | ||
| 221 | break; | ||
| 214 | 222 | ||
| 215 | case PUSHLOCAL0: case PUSHLOCAL1: case PUSHLOCAL2: | 223 | case PUSHLOCAL0: case PUSHLOCAL1: case PUSHLOCAL2: |
| 216 | case PUSHLOCAL3: case PUSHLOCAL4: case PUSHLOCAL5: | 224 | case PUSHLOCAL3: case PUSHLOCAL4: case PUSHLOCAL5: |
| @@ -235,7 +243,7 @@ int lua_execute (Byte *pc) | |||
| 235 | return 1; | 243 | return 1; |
| 236 | } | 244 | } |
| 237 | { | 245 | { |
| 238 | Object *h = lua_hashdefine (avalue(top-1), top); | 246 | Object *h = lua_hashget (avalue(top-1), top); |
| 239 | if (h == NULL) return 1; | 247 | if (h == NULL) return 1; |
| 240 | *(top-1) = *h; | 248 | *(top-1) = *h; |
| 241 | } | 249 | } |
| @@ -773,7 +781,7 @@ Object *lua_getfield (Object *object, char *field) | |||
| 773 | Object ref; | 781 | Object ref; |
| 774 | tag(&ref) = T_STRING; | 782 | tag(&ref) = T_STRING; |
| 775 | svalue(&ref) = lua_createstring(field); | 783 | svalue(&ref) = lua_createstring(field); |
| 776 | return (lua_hashdefine(avalue(object), &ref)); | 784 | return (lua_hashget(avalue(object), &ref)); |
| 777 | } | 785 | } |
| 778 | } | 786 | } |
| 779 | 787 | ||
| @@ -791,7 +799,7 @@ Object *lua_getindexed (Object *object, float index) | |||
| 791 | Object ref; | 799 | Object ref; |
| 792 | tag(&ref) = T_NUMBER; | 800 | tag(&ref) = T_NUMBER; |
| 793 | nvalue(&ref) = index; | 801 | nvalue(&ref) = index; |
| 794 | return (lua_hashdefine(avalue(object), &ref)); | 802 | return (lua_hashget(avalue(object), &ref)); |
| 795 | } | 803 | } |
| 796 | } | 804 | } |
| 797 | 805 | ||
| @@ -1025,6 +1033,7 @@ void lua_print (void) | |||
| 1025 | { | 1033 | { |
| 1026 | if (lua_isnumber(obj)) printf("%g\n",lua_getnumber (obj)); | 1034 | if (lua_isnumber(obj)) printf("%g\n",lua_getnumber (obj)); |
| 1027 | else if (lua_isstring(obj)) printf("%s\n",lua_getstring (obj)); | 1035 | else if (lua_isstring(obj)) printf("%s\n",lua_getstring (obj)); |
| 1036 | else if (lua_isfunction(obj)) printf("function: %p\n",bvalue(obj)); | ||
| 1028 | else if (lua_iscfunction(obj)) printf("cfunction: %p\n",lua_getcfunction (obj)); | 1037 | else if (lua_iscfunction(obj)) printf("cfunction: %p\n",lua_getcfunction (obj)); |
| 1029 | else if (lua_isuserdata(obj)) printf("userdata: %p\n",lua_getuserdata (obj)); | 1038 | else if (lua_isuserdata(obj)) printf("userdata: %p\n",lua_getuserdata (obj)); |
| 1030 | else if (lua_istable(obj)) printf("table: %p\n",obj); | 1039 | else if (lua_istable(obj)) printf("table: %p\n",obj); |
