From: Peep P. <so...@us...> - 2004-06-08 20:42:17
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15010 Modified Files: interpret.c Log Message: Another temporary stub. Index: interpret.c =================================================================== RCS file: /cvsroot/agd/server/src/interpret.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- interpret.c 7 Jun 2004 15:54:34 -0000 1.19 +++ interpret.c 8 Jun 2004 20:40:54 -0000 1.20 @@ -1,37 +1,17 @@ -#include "compile_options.h" -#include "lpc.h" -#include "list.h" -#include "object.h" - -#include "net.h" -#include "interpret.h" -variable_t *sp, *fp; -control_stack_t control_stack[CONTROL_STACK_SIZE]; -control_stack_t *csp = control_stack; - - -void push_int(int i) { } -void push_void() { } -void push_string(char *s, int i) { } -void push_object(object_t *i) { } -void pop_control_stack(int i) { } -void push_control_stack() { } -void runtime(char *s) { } -variable_t* apply(object_t *ob, char *s, char *fmt, ...) { } -void init_interpreter() { } -int dont_debug_interpreter; -#if 0 #include <stdlib.h> -#include <stdarg.h> #include <setjmp.h> +#include <stdarg.h> +/*#include "vars.h"*/ + +/*#include "config.h"*/ #include "compile_options.h" #include "sys.h" -/*#include "array.h"*/ #include "lpc.h" +#include "array.h" +#include "list.h" #include "object.h" #include "net.h" #include "interpret.h" -#include "vars.h" extern player_t *this_player; extern object_t *this_ob, *previous_ob; @@ -43,18 +23,27 @@ int dont_debug_interpreter; #endif +/* Let's try to hold sp, fp, cp, codelen and code in csp */ /* This is the stack containing all local variables, function arguments and function return values. */ variable_t value_stack[VALUE_STACK_SIZE]; variable_t *sp = value_stack, /* Stack pointer after the last element pushed. */ - *fp; /* Frame pointer - where locals begin on the stack */ + *fp; /* Frame pointer - where locals begin on the stack */ -int *cp; /* Code pointer into code->data */ -array_t *code; +int *cp; /* Code pointer into code->data */ +/*array_t *code;*/ control_stack_t control_stack[CONTROL_STACK_SIZE]; control_stack_t *csp = control_stack; +void push_void() { } +void push_string(char *s, int x) { } +void push_object(object_t *ob) { } +void pop_control_stack(int x) { } +void push_int(int i) { } +void runtime(char *s) { } +void push_control_stack() { } + #define CHECK_CSP() if(csp >= control_stack + CONTROL_STACK_SIZE) \ runtime("control stack overflow (too deep recursion)"); #define CHECK_SP() if(sp >= value_stack + VALUE_STACK_SIZE) \ @@ -62,10 +51,11 @@ extern void (**dfptr)(void); +#if 0 void call_function(object_t *ob, int index); void do_assign(variable_t *lval, variable_t *rval); void pop_control_stack(int pop_sp); -char *opc_name(int i); +extern char *opc_name(int i); void stack_trace(void) { @@ -108,17 +98,6 @@ longjmp(error_context, 1); } -int get_fun_index(object_t *ob, char *fun) -{ - int i; - array_t *tbl = &ob->prog->fun_table; - for(i=0;i<tbl->length;i++) { - if(!strcmp(tbl->data[i], fun)) - return i; - } - return -1; -} - void push_object(object_t *ob) { sp->type = T_OBJECT; @@ -256,6 +235,7 @@ #define show_stack() #endif + void push_control_stack(void) { csp->previous_ob = previous_ob; @@ -289,6 +269,7 @@ this_player = /*this_ob->iaob*/ csp->this_player; } +#if 0 /* Used by F_JMP and F_JMPF to check if they jumped too far. */ #define CHECK_OVERRUN() if((int *) cp >= (int *) code->data + code->length) {\ debug("interpret", "Ran over end of array: returning\n"); return; } @@ -655,7 +636,9 @@ cp = (int *) &f->code.data[0]; code = &f->code; } +#endif +#if 0 void init_interpreter(void) { fp = sp = &value_stack[0]; @@ -664,6 +647,18 @@ csp->sp = sp; cp = 0; } +#endif + +#endif +int get_fun_index(object_t *ob, char *fun_name) +{ + int i; + for(i=0;i < ob->prog->numfunc;i++) { + if(strcmp(ob->prog->fun_table[i], fun_name) == 0) + return i; + } + return -1; +} /* apply(): This is what the driver uses to call functions in LPC objects formerly call_function() @@ -674,12 +669,14 @@ o - object_t*, i - int, s - char*. For example, apply(ob, "fun", "isos", 5, "abc", &object, string); */ + variable_t *apply(object_t *ob, char *fun, char *argfmt, ...) { int index; va_list va; char *p; int i, j; + #ifdef DEBUG struct timeval tm, tm2; #endif @@ -692,6 +689,7 @@ gettimeofday(&tm, NULL); #endif +#if 0 push_control_stack(); va_start(va, argfmt); @@ -721,11 +719,13 @@ } va_end(va); - +#endif + #ifdef DEBUG debug("lpc", "apply \"%s\" on \"%s\"\n", fun, ob->name); #endif +#if 0 if(!have_error_context) { if(setjmp(error_context)) { /* setjmp() returned a value, @@ -738,6 +738,7 @@ call_function(ob, index); eval_instruction(); +#endif #ifdef DEBUG gettimeofday(&tm2, NULL); @@ -747,4 +748,3 @@ have_error_context = 0; return fp; } -#endif |