diff options
Diffstat (limited to 'opcode.c')
| -rw-r--r-- | opcode.c | 46 |
1 files changed, 26 insertions, 20 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 3.65 1996/03/21 18:55:02 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.66 1996/03/22 19:12:15 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| @@ -717,27 +717,31 @@ void *lua_getuserdata (lua_Object object) | |||
| 717 | } | 717 | } |
| 718 | 718 | ||
| 719 | 719 | ||
| 720 | lua_Object lua_getlocked (int ref) | 720 | lua_Object lua_getref (lua_Reference ref) |
| 721 | { | 721 | { |
| 722 | adjustC(0); | 722 | Object *o = luaI_getref(ref); |
| 723 | *top = *luaI_getlocked(ref); | 723 | if (o == NULL) |
| 724 | incr_top; | 724 | return LUA_NOOBJECT; |
| 725 | CBase++; /* incorporate object in the stack */ | 725 | adjustC(0); |
| 726 | return Ref(top-1); | 726 | luaI_pushobject(o); |
| 727 | CBase++; /* incorporate object in the stack */ | ||
| 728 | return Ref(top-1); | ||
| 727 | } | 729 | } |
| 728 | 730 | ||
| 729 | 731 | ||
| 730 | void lua_pushlocked (int ref) | 732 | void lua_pushref (lua_Reference ref) |
| 731 | { | 733 | { |
| 732 | *top = *luaI_getlocked(ref); | 734 | Object *o = luaI_getref(ref); |
| 733 | incr_top; | 735 | if (o == NULL) |
| 736 | lua_error("access to invalid (possibly garbage collected) reference"); | ||
| 737 | luaI_pushobject(o); | ||
| 734 | } | 738 | } |
| 735 | 739 | ||
| 736 | 740 | ||
| 737 | int lua_lock (void) | 741 | lua_Reference lua_ref (int lock) |
| 738 | { | 742 | { |
| 739 | adjustC(1); | 743 | adjustC(1); |
| 740 | return luaI_lock(--top); | 744 | return luaI_ref(--top, lock); |
| 741 | } | 745 | } |
| 742 | 746 | ||
| 743 | 747 | ||
| @@ -812,27 +816,29 @@ void lua_pushcfunction (lua_CFunction fn) | |||
| 812 | */ | 816 | */ |
| 813 | void lua_pushusertag (void *u, int tag) | 817 | void lua_pushusertag (void *u, int tag) |
| 814 | { | 818 | { |
| 815 | if (tag < LUA_T_USERDATA) return; | 819 | if (tag < LUA_T_USERDATA) |
| 820 | lua_error("invalid tag in `lua_pushusertag'"); | ||
| 816 | tag(top) = tag; uvalue(top) = u; | 821 | tag(top) = tag; uvalue(top) = u; |
| 817 | incr_top; | 822 | incr_top; |
| 818 | } | 823 | } |
| 819 | 824 | ||
| 820 | /* | 825 | /* |
| 821 | ** Push a lua_Object to stack. | 826 | ** Push an object on the stack. |
| 822 | */ | 827 | */ |
| 823 | void lua_pushobject (lua_Object o) | 828 | void luaI_pushobject (Object *o) |
| 824 | { | 829 | { |
| 825 | *top = *Address(o); | 830 | *top = *o; |
| 826 | incr_top; | 831 | incr_top; |
| 827 | } | 832 | } |
| 828 | 833 | ||
| 829 | /* | 834 | /* |
| 830 | ** Push an object on the stack. | 835 | ** Push a lua_Object on stack. |
| 831 | */ | 836 | */ |
| 832 | void luaI_pushobject (Object *o) | 837 | void lua_pushobject (lua_Object o) |
| 833 | { | 838 | { |
| 834 | *top = *o; | 839 | if (o == LUA_NOOBJECT) |
| 835 | incr_top; | 840 | lua_error("attempt to push a NOOBJECT"); |
| 841 | luaI_pushobject(Address(o)); | ||
| 836 | } | 842 | } |
| 837 | 843 | ||
| 838 | int lua_type (lua_Object o) | 844 | int lua_type (lua_Object o) |
