aboutsummaryrefslogtreecommitdiff
path: root/opcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-02-20 12:51:14 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-02-20 12:51:14 -0300
commit6769f3481701a17d15d513c5b875999d38d81877 (patch)
treeaedeeba87f17a4633750f5d9fdd5d7d001326293 /opcode.c
parent0b110f7922b2e5c066f3b10f50e4d1079ccd7f93 (diff)
downloadlua-6769f3481701a17d15d513c5b875999d38d81877.tar.gz
lua-6769f3481701a17d15d513c5b875999d38d81877.tar.bz2
lua-6769f3481701a17d15d513c5b875999d38d81877.zip
lua_Type is private (preparation for tags)
Diffstat (limited to 'opcode.c')
-rw-r--r--opcode.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/opcode.c b/opcode.c
index 281cf1bb..c089dccb 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_opcode="$Id: opcode.c,v 3.79 1997/01/31 14:27:11 roberto Exp roberto $"; 6char *rcs_opcode="$Id: opcode.c,v 3.80 1997/02/11 11:35:05 roberto Exp roberto $";
7 7
8#include <setjmp.h> 8#include <setjmp.h>
9#include <stdio.h> 9#include <stdio.h>
@@ -671,20 +671,41 @@ lua_Object lua_getparam (int number)
671 return CLS_current.base-CLS_current.num+number; 671 return CLS_current.base-CLS_current.num+number;
672} 672}
673 673
674int lua_isnumber (lua_Object object) 674int lua_isnil (lua_Object o)
675{ 675{
676 return (object != LUA_NOOBJECT) && (tonumber(Address(object)) == 0); 676 return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_NIL);
677} 677}
678 678
679int lua_isstring (lua_Object object) 679int lua_istable (lua_Object o)
680{ 680{
681 int t = lua_type(object); 681 return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_ARRAY);
682}
683
684int lua_isuserdata (lua_Object o)
685{
686 return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_USERDATA);
687}
688
689int lua_iscfunction (lua_Object o)
690{
691 int t = lua_type(o);
692 return (t == LUA_T_CMARK) || (t == LUA_T_CFUNCTION);
693}
694
695int lua_isnumber (lua_Object o)
696{
697 return (o!= LUA_NOOBJECT) && (tonumber(Address(o)) == 0);
698}
699
700int lua_isstring (lua_Object o)
701{
702 int t = lua_type(o);
682 return (t == LUA_T_STRING) || (t == LUA_T_NUMBER); 703 return (t == LUA_T_STRING) || (t == LUA_T_NUMBER);
683} 704}
684 705
685int lua_isfunction (lua_Object object) 706int lua_isfunction (lua_Object o)
686{ 707{
687 int t = lua_type(object); 708 int t = lua_type(o);
688 return (t == LUA_T_FUNCTION) || (t == LUA_T_CFUNCTION) || 709 return (t == LUA_T_FUNCTION) || (t == LUA_T_CFUNCTION) ||
689 (t == LUA_T_MARK) || (t == LUA_T_CMARK); 710 (t == LUA_T_MARK) || (t == LUA_T_CMARK);
690} 711}
@@ -734,14 +755,6 @@ lua_CFunction lua_getcfunction (lua_Object object)
734 else return (fvalue(Address(object))); 755 else return (fvalue(Address(object)));
735} 756}
736 757
737/*
738** Given an object handle, return its user data. On error, return NULL.
739*/
740void *lua_getuserdata (lua_Object object)
741{
742 return *(void **)lua_getbinarydata(object);
743}
744
745 758
746lua_Object lua_getref (int ref) 759lua_Object lua_getref (int ref)
747{ 760{
@@ -888,7 +901,7 @@ int lua_type (lua_Object o)
888 lua_Type t = tag(Address(o)); 901 lua_Type t = tag(Address(o));
889 if (t == LUA_T_USERDATA) 902 if (t == LUA_T_USERDATA)
890 return (Address(o))->value.ts->tag; 903 return (Address(o))->value.ts->tag;
891 else return tag(Address(o)); 904 else return t;
892 } 905 }
893} 906}
894 907