aboutsummaryrefslogtreecommitdiff
path: root/opcode.c
diff options
context:
space:
mode:
authorWaldemar Celes <celes@tecgraf.puc-rio.br>1994-08-03 11:15:46 -0300
committerWaldemar Celes <celes@tecgraf.puc-rio.br>1994-08-03 11:15:46 -0300
commitb1e9b37883ebc3f9926f6693350a73d6cbb94b6e (patch)
tree600f3e33d0dd976b0c2d6c86489f22ebcd129301 /opcode.c
parent467288e5b35d6f264bdded9b4d09dbaa0597f967 (diff)
downloadlua-b1e9b37883ebc3f9926f6693350a73d6cbb94b6e.tar.gz
lua-b1e9b37883ebc3f9926f6693350a73d6cbb94b6e.tar.bz2
lua-b1e9b37883ebc3f9926f6693350a73d6cbb94b6e.zip
Implementacao de funcoes para tratar Lua function em C e
correcoes de bugs nas tabelas dinamicas.
Diffstat (limited to 'opcode.c')
-rw-r--r--opcode.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/opcode.c b/opcode.c
index 2309bed1..b2f5cb41 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 2.1 1994/04/20 22:07:57 celes Exp celes $"; 6char *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
29static Word maxstack; 29static Long maxstack;
30static Object *stack=NULL; 30static Object *stack=NULL;
31static Object *top, *base; 31static 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*/
689int 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*/
975int 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*/
959int lua_iscfunction (Object *object) 983int lua_iscfunction (Object *object)