diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-03-19 19:28:37 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-03-19 19:28:37 -0300 |
| commit | 85b76bcc01141a118a22203798b7206d943ac072 (patch) | |
| tree | c4e5500728adaae5fc2cc023860957986deae490 | |
| parent | a275d9a25b161af426696d7b73d46f91150309c9 (diff) | |
| download | lua-85b76bcc01141a118a22203798b7206d943ac072.tar.gz lua-85b76bcc01141a118a22203798b7206d943ac072.tar.bz2 lua-85b76bcc01141a118a22203798b7206d943ac072.zip | |
functions "lua_is..." consider coercions.
small change when calling call hook.
| -rw-r--r-- | opcode.c | 30 |
1 files changed, 22 insertions, 8 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.60 1996/03/15 13:13:13 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.61 1996/03/19 16:50:24 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| @@ -259,13 +259,10 @@ static StkId callC (lua_CFunction func, StkId base) | |||
| 259 | /* incorporate parameters on the stack */ | 259 | /* incorporate parameters on the stack */ |
| 260 | CBase = base+CnResults; /* == top-stack */ | 260 | CBase = base+CnResults; /* == top-stack */ |
| 261 | if (call_hook) | 261 | if (call_hook) |
| 262 | { | 262 | callHook(base, LUA_T_CMARK, 0); |
| 263 | callHook (base, LUA_T_CMARK, 0); | 263 | (*func)(); |
| 264 | (*func)(); | 264 | if (call_hook) /* func may have changed call_hook */ |
| 265 | callHook (base, LUA_T_CMARK, 1); | 265 | callHook(base, LUA_T_CMARK, 1); |
| 266 | } | ||
| 267 | else | ||
| 268 | (*func)(); | ||
| 269 | firstResult = CBase; | 266 | firstResult = CBase; |
| 270 | CBase = oldBase; | 267 | CBase = oldBase; |
| 271 | CnResults = oldCnResults; | 268 | CnResults = oldCnResults; |
| @@ -673,6 +670,23 @@ lua_Object lua_getparam (int number) | |||
| 673 | return CBase-CnResults+number; | 670 | return CBase-CnResults+number; |
| 674 | } | 671 | } |
| 675 | 672 | ||
| 673 | int lua_isnumber (lua_Object object) | ||
| 674 | { | ||
| 675 | return (object != LUA_NOOBJECT) && (tonumber(Address(object)) == 0); | ||
| 676 | } | ||
| 677 | |||
| 678 | int lua_isstring (lua_Object object) | ||
| 679 | { | ||
| 680 | int t = lua_type(object); | ||
| 681 | return (t == LUA_T_STRING) || (t == LUA_T_NUMBER); | ||
| 682 | } | ||
| 683 | |||
| 684 | int lua_isfunction (lua_Object object) | ||
| 685 | { | ||
| 686 | int t = lua_type(object); | ||
| 687 | return (t == LUA_T_FUNCTION) || (t == LUA_T_CFUNCTION); | ||
| 688 | } | ||
| 689 | |||
| 676 | /* | 690 | /* |
| 677 | ** Given an object handle, return its number value. On error, return 0.0. | 691 | ** Given an object handle, return its number value. On error, return 0.0. |
| 678 | */ | 692 | */ |
