diff options
Diffstat (limited to 'opcode.c')
| -rw-r--r-- | opcode.c | 28 |
1 files changed, 26 insertions, 2 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.1 1994/04/20 22:07:57 celes Exp celes $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 2.2 1994/07/19 21:27:18 celes Exp celes $"; |
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
| @@ -26,7 +26,7 @@ char *rcs_opcode="$Id: opcode.c,v 2.1 1994/04/20 22:07:57 celes Exp celes $"; | |||
| 26 | 26 | ||
| 27 | #define STACK_BUFFER (STACKGAP+128) | 27 | #define STACK_BUFFER (STACKGAP+128) |
| 28 | 28 | ||
| 29 | static Word maxstack; | 29 | static Long maxstack; |
| 30 | static Object *stack=NULL; | 30 | static Object *stack=NULL; |
| 31 | static Object *top, *base; | 31 | static Object *top, *base; |
| 32 | 32 | ||
| @@ -684,6 +684,22 @@ int lua_call (char *functionname, int nparam) | |||
| 684 | } | 684 | } |
| 685 | 685 | ||
| 686 | /* | 686 | /* |
| 687 | ** Execute the given lua function. Return 0 on success or 1 on error. | ||
| 688 | */ | ||
| 689 | int lua_callfunction (Object *function, int nparam) | ||
| 690 | { | ||
| 691 | static Byte startcode[] = {CALLFUNC, HALT}; | ||
| 692 | int i; | ||
| 693 | if (tag(function) != T_FUNCTION) return 1; | ||
| 694 | for (i=1; i<=nparam; i++) | ||
| 695 | *(top-i+2) = *(top-i); | ||
| 696 | top += 2; | ||
| 697 | tag(top-nparam-1) = T_MARK; | ||
| 698 | *(top-nparam-2) = *function; | ||
| 699 | return (lua_execute (startcode)); | ||
| 700 | } | ||
| 701 | |||
| 702 | /* | ||
| 687 | ** Get a parameter, returning the object handle or NULL on error. | 703 | ** Get a parameter, returning the object handle or NULL on error. |
| 688 | ** 'number' must be 1 to get the first parameter. | 704 | ** 'number' must be 1 to get the first parameter. |
| 689 | */ | 705 | */ |
| @@ -954,6 +970,14 @@ int lua_istable (Object *object) | |||
| 954 | } | 970 | } |
| 955 | 971 | ||
| 956 | /* | 972 | /* |
| 973 | ** Given an object handle, return if it is a lua function. | ||
| 974 | */ | ||
| 975 | int lua_isfunction (Object *object) | ||
| 976 | { | ||
| 977 | return (object != NULL && tag(object) == T_FUNCTION); | ||
| 978 | } | ||
| 979 | |||
| 980 | /* | ||
| 957 | ** Given an object handle, return if it is a cfunction one. | 981 | ** Given an object handle, return if it is a cfunction one. |
| 958 | */ | 982 | */ |
| 959 | int lua_iscfunction (Object *object) | 983 | int lua_iscfunction (Object *object) |
