diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-04-22 15:00:37 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-04-22 15:00:37 -0300 |
commit | 0ef5cf22891c9d34a88ccc5d89eb0ed82b004471 (patch) | |
tree | 1a095acefa978d5a41f32ff7d0fef58a642aa66c /opcode.c | |
parent | fed9408ab51a4be5ff84450ad47d1e0cdaed97bc (diff) | |
download | lua-0ef5cf22891c9d34a88ccc5d89eb0ed82b004471.tar.gz lua-0ef5cf22891c9d34a88ccc5d89eb0ed82b004471.tar.bz2 lua-0ef5cf22891c9d34a88ccc5d89eb0ed82b004471.zip |
lock mechanism seperseded by the REFERENCE mechanism.
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) |