You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(180) |
Apr
(20) |
May
|
Jun
(91) |
Jul
(78) |
Aug
(18) |
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Peep P. <so...@us...> - 2004-06-12 20:06:16
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25182 Modified Files: compile.c Log Message: Identifiers from a previous compile are now freed. Index: compile.c =================================================================== RCS file: /cvsroot/agd/server/src/compile.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- compile.c 12 Jun 2004 16:48:00 -0000 1.24 +++ compile.c 12 Jun 2004 20:06:08 -0000 1.25 @@ -233,6 +233,11 @@ idp->base_scope = scope_level; idp->index = assign_index(idp->type); +#ifdef DEBUG + debug("define_id", "%s [hash %u] base_scope %d index %d\n", + idp->name, strhash(idp->name), idp->base_scope, idp->index); +#endif + return idp; } @@ -369,8 +374,8 @@ { scope_level--; +/* clean_ids(gid_tbl, GLOBAL_HASH_SIZE);*/ /* Uhh.. globals don't get *ever* out of scope. */ /* Ok, this is as ugly as it gets.. find another way. */ - clean_ids(gid_tbl, GLOBAL_HASH_SIZE); clean_ids(lid_tbl, LOCAL_HASH_SIZE); } @@ -498,6 +503,8 @@ void add_function(def_id_t *idp, int lineno) { + lineno = 0; /* XXX */ + if(idp->index < this_prog->numfunc) { /* Adding a definition for a prototype. */ function_t *f; @@ -517,7 +524,7 @@ this_prog->functions[this_prog->numfunc-1] = curr_fun; this_prog->fun_table = xrealloc(this_prog->fun_table, this_prog->numfunc * sizeof(char *)); - this_prog->fun_table[this_prog->numfunc-1] = idp->name; + this_prog->fun_table[this_prog->numfunc-1] = stringdup(idp->name); /* Name gets freed later. (by clean_ids()) */ curr_fun = NULL; } @@ -589,6 +596,8 @@ void parse_init(void) { + scope_level = 1; /* So globals are at level 1, and can be cleaned with + scope_level == 0. */ compile_errors = 0; this_ob->numglobals = 0; @@ -634,6 +643,7 @@ { char *real_path; program_t *prog; + int ret; #ifdef DEBUG struct timeval tm, tm2; @@ -670,7 +680,11 @@ } #endif - if(yyparse() > 0 || compile_errors) { + ret = yyparse(); + + pop_scope(); /* Go to scope level 0 and free all identifiers. */ + + if(ret > 0 || compile_errors) { if(compile_errors) { printf("%d error%s", compile_errors, compile_errors == 1 ? "" : "s"); |
From: Peep P. <so...@us...> - 2004-06-12 20:05:39
|
Update of /cvsroot/agd/server/lib/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24687 Modified Files: player.c Log Message: Uses __VERSION__ instead of version(). Index: player.c =================================================================== RCS file: /cvsroot/agd/server/lib/sys/player.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- player.c 7 Jun 2004 15:54:56 -0000 1.14 +++ player.c 12 Jun 2004 20:05:31 -0000 1.15 @@ -94,7 +94,7 @@ " has quit the game\n"); destruct(this_object()); } else if(s == "uptime") { - write("AGD " + version() + " has been running for " + ctime(uptime()) + ".\n"); + write("AGD " + __VERSION__ + " has been running for " + ctime(uptime()) + ".\n"); } else if(s == "version") { "/sys/master"->write_version(); } else if(s == "help") { |
From: Peep P. <so...@us...> - 2004-06-12 16:49:30
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8338 Modified Files: instr.h Log Message: Removed F_MAKE_LVALUE. Index: instr.h =================================================================== RCS file: /cvsroot/agd/server/src/instr.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- instr.h 8 Jun 2004 20:38:38 -0000 1.2 +++ instr.h 12 Jun 2004 16:49:22 -0000 1.3 @@ -10,8 +10,6 @@ #define F_PUSH_VOID 6 /* For 'return;' */ #define F_PUSH_ARRAY 7 -#define F_MAKE_LVALUE 8 - #define F_POP 10 /* Pops a variable off the stack. */ #define F_PUSH_LVAR 11 /* Pushes local variable <n> on stack. */ #define F_PUSH_LVAR_LVALUE 12 /* Pushes T_LVALUE to local var <n> */ |
From: Peep P. <so...@us...> - 2004-06-12 16:48:40
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7223 Modified Files: TODO Log Message: runtime can free allocated memory Index: TODO =================================================================== RCS file: /cvsroot/agd/server/TODO,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- TODO 8 Jun 2004 20:50:40 -0000 1.20 +++ TODO 12 Jun 2004 16:48:28 -0000 1.21 @@ -3,6 +3,9 @@ '?' means trivial and not really important. ! new interpreter! + - Interpreter. + - runtime() for dfuns (doesn't display line numbers) + - display stack trace (with line numbers and functions) when getting a runtime error lang.y: ! pop locals after leaving block @@ -41,12 +44,6 @@ - allow both .c and .lpc for file extensions (/usr/bin/file could recognize LPC, and editors can turn on syntax highlighting automatically) - Runtime token positions (with the F_NEWLINE operator). - - Interpreter. - - three versions of runtime() - - for dfuns (doesn't display line numbers) - - for dynamically allocated strings (automatically frees the string after runtiming) - - normal runtime - - display stack trace (with line numbers and functions) when getting a runtime error - keep interactive objects in a separate linked list, and make shout act on that list - LPC: ! arrays (T_ARRAY) |
From: Peep P. <so...@us...> - 2004-06-12 16:48:08
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6610 Modified Files: compile.c Log Message: curr_fun_check() uses memset to clear the new function Index: compile.c =================================================================== RCS file: /cvsroot/agd/server/src/compile.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- compile.c 8 Jun 2004 20:24:10 -0000 1.23 +++ compile.c 12 Jun 2004 16:48:00 -0000 1.24 @@ -490,8 +490,9 @@ { if(!curr_fun) { curr_fun = xmalloc(sizeof(function_t)); - curr_fun->codelen = 0; - curr_fun->code = NULL; + memset(curr_fun, 0, sizeof *curr_fun); /* XXX */ +/* curr_fun->codelen = 0; + curr_fun->code = NULL;*/ } } |
From: Peep P. <so...@us...> - 2004-06-12 16:47:49
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6228 Modified Files: debug.c Log Message: Slight fix for displaying lvalue infinite loops. Index: debug.c =================================================================== RCS file: /cvsroot/agd/server/src/debug.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- debug.c 8 Jun 2004 20:30:40 -0000 1.13 +++ debug.c 12 Jun 2004 16:47:41 -0000 1.14 @@ -51,7 +51,7 @@ #define NAME() if(v->name) printf("%s", v->name); void print_var(variable_t *v, int values) { - int lval_lvl; + static int lval_nested; if(!v) { printf("<NULL>"); @@ -87,12 +87,13 @@ case T_LVALUE: NAME(); printf("=<"); - lval_lvl++; - if(lval_lvl == 2) + if(lval_nested) printf("infinite loop"); - else + else { + lval_nested = 1; print_var(v->u.v, 1); - lval_lvl--; + } + lval_nested = 0; printf(">"); break; @@ -111,7 +112,6 @@ case F_PUSH_VOID: return "F_PUSH_VOID"; case F_PUSH_NULL_OBJECT: return "F_PUSH_NULL_OBJECT"; case F_PUSH_ARRAY: return "F_PUSH_ARRAY"; - case F_MAKE_LVALUE: return "F_MAKE_LVALUE"; case F_PUSH_LVAR: return "F_PUSH_LVAR"; case F_PUSH_LVAR_LVALUE: return "F_PUSH_LVAR_LVALUE"; case F_PUSH_GVAR: return "F_PUSH_GVAR"; |
From: Peep P. <so...@us...> - 2004-06-12 16:47:15
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5457 Modified Files: dfuns.c Log Message: runtime now can free dynamically allocated memory Index: dfuns.c =================================================================== RCS file: /cvsroot/agd/server/src/dfuns.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- dfuns.c 8 Jun 2004 20:37:35 -0000 1.20 +++ dfuns.c 12 Jun 2004 16:47:06 -0000 1.21 @@ -337,10 +337,9 @@ path = absolute_path(fp->u.s); f = fopen(path, "r"); if(!f) { - /* I'd rather use a dynamically allocated buffer - * and also show the filename, but runtime() does - * longjmp(), and memory will be lost. */ - runtime("can't open file for reading!"); + char *buf = xmalloc(strlen(path) + 50); + sprintf(buf, "can't open '%s' for reading!", path); + runtime(buf, 1); } file_str = NULL; @@ -361,7 +360,7 @@ /* Misc. */ void df_throw(void) { - runtime(fp->u.s); + runtime(fp->u.s, 0); pop_stack(); push_void(); } |
From: Peep P. <so...@us...> - 2004-06-12 16:46:53
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4994 Modified Files: lang.h Log Message: Regenerated. Index: lang.h =================================================================== RCS file: /cvsroot/agd/server/src/lang.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- lang.h 8 Jun 2004 20:20:48 -0000 1.10 +++ lang.h 12 Jun 2004 16:46:45 -0000 1.11 @@ -108,7 +108,7 @@ #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 52 "lang.y" +#line 51 "lang.y" typedef union YYSTYPE { char *str; int i; |
From: Peep P. <so...@us...> - 2004-06-12 16:46:42
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4700 Modified Files: interpret.c interpret.h Log Message: Interpreter now works again; runtime can free its argument; added *_EQ operators Index: interpret.c =================================================================== RCS file: /cvsroot/agd/server/src/interpret.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- interpret.c 8 Jun 2004 20:40:54 -0000 1.20 +++ interpret.c 12 Jun 2004 16:46:33 -0000 1.21 @@ -1,7 +1,6 @@ #include <stdlib.h> #include <setjmp.h> #include <stdarg.h> -/*#include "vars.h"*/ /*#include "config.h"*/ #include "compile_options.h" @@ -12,6 +11,8 @@ #include "object.h" #include "net.h" #include "interpret.h" +#include "instr.h" +#include "vars.h" extern player_t *this_player; extern object_t *this_ob, *previous_ob; @@ -28,35 +29,28 @@ 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 = value_stack; /* Frame pointer - where locals begin on the stack */ int *cp; /* Code pointer into code->data */ -/*array_t *code;*/ +int *code, codelen; 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)"); + runtime("control stack overflow (too deep recursion)", 0); #define CHECK_SP() if(sp >= value_stack + VALUE_STACK_SIZE) \ - runtime("value stack overflow"); + runtime("value stack overflow", 0); 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); +void call_function(object_t *ob, int index); extern char *opc_name(int i); +#if 0 + void stack_trace(void) { int i, len; @@ -68,9 +62,12 @@ p->this_ob?p->this_ob->name:"unknown", p->fun, p->line); } } +#endif /* Need the F_NEWLINE operation for this. */ -void runtime(char *s) +/* free_str: whether to free the string passed to it before + * doing longjmp() or not - for dynamically allocated strings */ +void runtime(char *s, int free_str) { char *buf; @@ -88,6 +85,9 @@ } xfree(buf); + if(free_str) + xfree(s); + /* stack_trace();*/ out: @@ -201,7 +201,7 @@ int len; len = max(sp-&value_stack[0], fp-&value_stack[0]); printf("sp: %d; fp: %d; cp: %d; csp: %d\n", sp ? sp - &value_stack[0] : 0, - fp ? fp - &value_stack[0] : 0, cp ? cp - (int *)code->data : 0, + fp ? fp - &value_stack[0] : 0, cp ? cp - code : 0, csp ? csp - &control_stack[0] : 0); printf("Value stack: |"); for(i=0;i<=len;i++) { @@ -224,7 +224,7 @@ for(i=0;i<=csp-&control_stack[0];i++) { printf("%d | cp: %d; fp: %d; sp: %d fun:%d line:%d |\n", i, control_stack[i].cp ? control_stack[i].cp - - (control_stack[i].code ? (int *) control_stack[i].code->data : 0) : 0, + (control_stack[i].code ? control_stack[i].code : 0) : 0, control_stack[i].fp ? control_stack[i].fp - &value_stack[0] : 0, control_stack[i].sp ? control_stack[i].sp - &value_stack[0] : 0, control_stack[i].fun, control_stack[i].line); @@ -235,7 +235,6 @@ #define show_stack() #endif - void push_control_stack(void) { csp->previous_ob = previous_ob; @@ -254,7 +253,7 @@ { csp--; if(csp < control_stack) { - runtime("control stack underflow"); + runtime("control stack underflow", 0); } fp = csp->fp; @@ -269,15 +268,14 @@ 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) {\ +#define CHECK_OVERRUN() if(cp >= code + codelen) {\ debug("interpret", "Ran over end of array: returning\n"); return; } #define GET_ARGS() arg[0] = sp[-1].u.i; pop_stack(); arg[1] = sp[-1].u.i; pop_stack(); -#define TAKE_SLICE() GET_ARGS() if(!sp[-1].u.s) runtime("taking substring of null string"); \ - if(arg[1] >= strlen(sp[-1].u.s) || arg[1] < 0 || arg[1] > arg[0]) runtime("substring out of range"); \ +#define TAKE_SLICE() GET_ARGS() if(!sp[-1].u.s) runtime("taking substring of null string", 0); \ + if(arg[1] >= strlen(sp[-1].u.s) || arg[1] < 0 || arg[1] > arg[0]) runtime("substring out of range", 0); \ #define SETUP_FRAME() push_control_stack(); csp->num_arg = *cp; fp = sp - csp->num_arg; @@ -293,7 +291,7 @@ again: #ifdef DEBUG if(!dont_debug_interpreter) - debug("interpret", "Executing %s at %d\n", opc_name(*cp), cp - (int *)code->data); + debug("interpret", "Executing %s at %d\n", opc_name(*cp), cp - code); #endif switch(*cp) { case F_PUSH_INT: @@ -302,7 +300,7 @@ break; case F_PUSH_STRING: cp++; - tmps = this_prog->str_tbl[*cp]; + tmps = this_ob->prog->str_tbl[*cp]; push_string(tmps, ST_STATIC); break; case F_PUSH_VOID: @@ -313,13 +311,13 @@ break; case F_PUSH_ARRAY: { - array_t *a = type_xmalloc(array_t); + array_t *a = xmalloc(sizeof(array_t)); arg[0] = *++cp; arg[1] = *++cp; a->length = arg[1]; a->data = calloc(arg[1], sizeof(variable_t*)); for(tmpi=0;tmpi<arg[1];tmpi++) { - do_assign(&a->data[tmpi], --sp); + do_assign(a->data[tmpi], --sp); /* Note that we're not freeing the arguments, * as they go into the array. */ } @@ -346,33 +344,76 @@ break; case F_PUSH_GVAR: cp++; - push_var(this_ob->variables.data[*cp]); + push_var(&this_ob->globals[*cp]); break; case F_PUSH_GVAR_LVALUE: cp++; - push_lvalue(this_ob->variables.data[*cp]); + push_lvalue(&this_ob->globals[*cp]); break; case F_ADD: tmpvp = add_vars(sp-2, sp-1); pop_stack(); pop_stack(); push_var(tmpvp); break; + case F_ADD_EQ: + tmpv = *sp[-2].u.v; + tmpvp = add_vars(&tmpv, sp-1); + do_assign(sp[-2].u.v, tmpvp); + pop_stack(); pop_stack(); + push_var(tmpvp); + break; case F_SUB: GET_ARGS() push_int(arg[1] - arg[0]); break; + case F_SUB_EQ: + tmpv = *sp[-2].u.v; + tmpi = tmpv.u.i - sp[-1].u.i; + sp[-2].u.v->u.i = tmpi; + pop_stack(); pop_stack(); + push_int(tmpi); + break; case F_MUL: GET_ARGS() push_int(arg[1] * arg[0]); break; + case F_MUL_EQ: + tmpv = *sp[-2].u.v; + tmpi = tmpv.u.i * sp[-1].u.i; + sp[-2].u.v->u.i = tmpi; + pop_stack(); pop_stack(); + push_int(tmpi); + break; case F_DIV: GET_ARGS() + if(!arg[0]) + runtime("division by zero", 0); push_int(arg[1] / arg[0]); break; + case F_DIV_EQ: + tmpv = *sp[-2].u.v; + if(!sp[-1].u.i) + runtime("division by zero", 0); + tmpi = tmpv.u.i / sp[-1].u.i; + sp[-2].u.v->u.i = tmpi; + pop_stack(); pop_stack(); + push_int(tmpi); + break; case F_MOD: GET_ARGS() + if(!arg[0]) + runtime("divison by zero", 0); push_int(arg[1] % arg[0]); break; + case F_MOD_EQ: + tmpv = *sp[-2].u.v; + if(!sp[-1].u.i) + runtime("divison by zero", 0); + tmpi = tmpv.u.i % sp[-1].u.i; + sp[-2].u.v->u.i = tmpi; + pop_stack(); pop_stack(); + push_int(tmpi); + break; case F_ASSIGN: do_assign(sp[-2].u.v, sp-1); do_assign(&tmpv, sp-1); @@ -407,17 +448,17 @@ if(sp[-1].type & T_ARRAY) { if(!sp[-1].u.a) { - runtime("taking element of null array"); + runtime("taking element of null array", 0); } if(arg[0] >= sp[-1].u.a->length || arg[0] < 0) { - runtime("index out of range"); + runtime("index out of range", 0); } tmpvp = sp[-1].u.a->data[arg[0]]; pop_stack(); push_var(tmpvp); } else { if(!sp[-1].u.s) { - runtime("taking element of null string"); + runtime("taking element of null string", 0); } arg[1] = sp[-1].u.s[arg[0]]; pop_stack(); @@ -429,7 +470,7 @@ arg[0] = sp[-1].u.i; pop_stack(); if(!sp[-1].u.s) { - runtime("taking element of null string"); + runtime("taking element of null string", 0); } do_assign(sp, &sp[-1]); sp->u.s += arg[0]; @@ -455,7 +496,7 @@ push_string(tmps, tmpi); push_lvalue(sp-1); break; - case F_JMPF: + case F_JUMP_IF_FALSE: sp--; if(!test_var(sp)) { tmpi = cp[1]; @@ -466,7 +507,7 @@ free_var(sp); CHECK_OVERRUN() break; - case F_JMP: + case F_JUMP: tmpi = cp[1]; cp += tmpi; CHECK_OVERRUN() @@ -530,8 +571,9 @@ pop_control_stack(0); break; case F_CALL_OTHER: - tmps = (char *) *++cp; - ++cp; + cp++; + tmps = this_ob->prog->str_tbl[*cp]; + cp++; sp--; if(sp->type == T_OBJECT) { tmpv.u.ob = sp->u.ob; /* A little hack so we don't @@ -545,13 +587,13 @@ } if(!tmpv.u.ob) { - runtime("call_other on null object"); + runtime("call_other on null object", 0); } tmpi = get_fun_index(tmpv.u.ob, tmps); free_var(sp); if(tmpi == -1) - runtime("function doesn't exist"); + runtime("function doesn't exist", 0); SETUP_FRAME(); call_function(tmpv.u.ob, tmpi); goto again; @@ -596,22 +638,20 @@ void call_function(object_t *ob, int index) { int i, j; - function_t *f; - f = ob->prog->functions.data[index]; + function_t *f = ob->prog->functions[index]; if(!f) { - char buf[512]; /* Can't use dynamic memory - because of runtime()'s longjmp() */ + char *buf = xmalloc(512); sprintf(buf, "function %d doesn't exist in object \"%s\"", index, ob->name); - runtime(buf); + runtime(buf, 1); } csp->line = f->lineno; csp->fun = index; - i = f->args.length - csp->num_arg; + i = f->num_arg - csp->num_arg; if(i > 0) { for(j=0;j<i;j++) { - switch((*(variable_t*)f->args.data[j]).type) { + switch(f->args[j]) { case T_INT: push_int(0); break; @@ -633,10 +673,10 @@ if(this_ob->iaob) this_player = this_ob->iaob; - cp = (int *) &f->code.data[0]; - code = &f->code; + cp = f->code; + code = f->code; + codelen = f->codelen; } -#endif #if 0 void init_interpreter(void) @@ -649,7 +689,6 @@ } #endif -#endif int get_fun_index(object_t *ob, char *fun_name) { int i; @@ -689,7 +728,6 @@ gettimeofday(&tm, NULL); #endif -#if 0 push_control_stack(); va_start(va, argfmt); @@ -719,13 +757,11 @@ } 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,7 +774,6 @@ call_function(ob, index); eval_instruction(); -#endif #ifdef DEBUG gettimeofday(&tm2, NULL); Index: interpret.h =================================================================== RCS file: /cvsroot/agd/server/src/interpret.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- interpret.h 7 Jun 2004 15:41:13 -0000 1.14 +++ interpret.h 12 Jun 2004 16:46:33 -0000 1.15 @@ -2,7 +2,7 @@ #define _INTERPRET_H variable_t *apply(object_t *ob, char *fun, char *argfmt, ...); -void runtime(char *s); +void runtime(char *s, int free_str); #define pop_stack() sp--; free_var(sp) #define pop_locals() while(sp > fp) { sp--; free_var(sp); } @@ -12,7 +12,7 @@ int num_arg; int *cp; - int **code; + int *code; int codelen; int fun, line; |
From: Peep P. <so...@us...> - 2004-06-12 16:44:31
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2679 Modified Files: lang.y Log Message: lvalues work. Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- lang.y 8 Jun 2004 20:41:49 -0000 1.18 +++ lang.y 12 Jun 2004 16:44:22 -0000 1.19 @@ -29,13 +29,12 @@ break_allowed, continue_allowed, is_new_declaration; -/*typedef struct arr_t arr_t;*/ extern int scope_level; extern program_t *this_prog; extern function_t *curr_fun; -void do_assign_expr(expr_t *result, expr_t *left, int type2, int op); +void do_assign_expr(expr_t *result, expr_t *left, int type2, int op, int index); void do_expr(expr_t *result, expr_t *op1, expr_t *op2, int operator); void do_inc_expr(expr_t *result, expr_t *expr, int op); @@ -321,20 +320,27 @@ ; assign_expr: - expr '=' { add_token(F_MAKE_LVALUE); } - expr { do_assign_expr(&$$, &$1, $4.type, F_ASSIGN); } - | expr L_PLUS_EQ { add_token(F_MAKE_LVALUE); } - expr { do_assign_expr(&$$, &$1, $4.type, F_ADD_EQ); } - | expr L_MINUS_EQ { add_token(F_MAKE_LVALUE); } - expr { do_assign_expr(&$$, &$1, $4.type, F_SUB_EQ); } - | expr L_MUL_EQ { add_token(F_MAKE_LVALUE); } - expr { do_assign_expr(&$$, &$1, $4.type, F_MUL_EQ); } - | expr L_DIV_EQ { add_token(F_MAKE_LVALUE); } - expr { do_assign_expr(&$$, &$1, $4.type, F_DIV_EQ); } - | expr L_MOD_EQ { add_token(F_MAKE_LVALUE); } - expr { do_assign_expr(&$$, &$1, $4.type, F_MOD_EQ); } - | expr L_POW_EQ { add_token(F_MAKE_LVALUE); } - expr { do_assign_expr(&$$, &$1, $4.type, F_POW_EQ); } + expr '=' { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_ASSIGN, $<i>3); } + | expr L_PLUS_EQ { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_ADD_EQ, $<i>3); } + | expr L_MINUS_EQ { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_SUB_EQ, $<i>3); } + | expr L_MUL_EQ { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_MUL_EQ, $<i>3); } + | expr L_DIV_EQ { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_DIV_EQ, $<i>3); } + | expr L_MOD_EQ { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_MOD_EQ, $<i>3); } + | expr L_POW_EQ { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_POW_EQ, $<i>3); } + ; + +inc_expr: + expr L_INC { do_inc_expr(&$$, &$1, F_POSTINC); } + | L_INC expr { do_inc_expr(&$$, &$2, F_PREINC); } + | expr L_DEC { do_inc_expr(&$$, &$1, F_POSTDEC); } + | L_DEC expr { do_inc_expr(&$$, &$2, F_PREDEC); } ; arith_expr: @@ -359,29 +365,6 @@ | expr L_EQ expr { do_expr(&$$, &$1, &$3, F_EQ); } ; -inc_expr: - expr L_INC - { - add_token(F_MAKE_LVALUE); - do_inc_expr(&$$, &$1, F_POSTINC); - } - | L_INC expr - { - add_token(F_MAKE_LVALUE); - do_inc_expr(&$$, &$2, F_PREINC); - } - | expr L_DEC - { - add_token(F_MAKE_LVALUE); - do_inc_expr(&$$, &$1, F_POSTDEC); - } - | L_DEC expr - { - add_token(F_MAKE_LVALUE); - do_inc_expr(&$$, &$2, F_PREDEC); - } - ; - neg_expr: '-' expr %prec L_NEG { @@ -1143,8 +1126,32 @@ ; %% -void do_assign_expr(expr_t *result, expr_t *left, int type2, int op) +void make_lvalue(int index) +{ + int replace; + + /* Turn it into a lvalue. */ + switch(curr_fun->code[index]) { + case F_PUSH_LVAR: + replace = F_PUSH_LVAR_LVALUE; + break; + case F_PUSH_GVAR: + replace = F_PUSH_GVAR_LVALUE; + break; + case F_INDEX: + replace = F_INDEX_LVALUE; + break; + case F_SLICE: + replace = F_SLICE_LVALUE; + break; + } + curr_fun->code[index] = replace; +} + +void do_assign_expr(expr_t *result, expr_t *left, int type2, int op, int index) { + make_lvalue(index); + if(!left->lval) { comp_error("invalid lvalue"); } @@ -1172,6 +1179,8 @@ void do_inc_expr(expr_t *result, expr_t *expr, int op) { + make_lvalue(curr_fun->codelen - 2); + if(!expr->lval) { comp_error("invalid lvalue"); } |
From: Peep P. <so...@us...> - 2004-06-08 20:51:46
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16908 Modified Files: ChangeLog TODO Log Message: Updates. Index: TODO =================================================================== RCS file: /cvsroot/agd/server/TODO,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- TODO 7 Jun 2004 15:50:19 -0000 1.19 +++ TODO 8 Jun 2004 20:50:40 -0000 1.20 @@ -2,36 +2,41 @@ '!' means first-priority, '?' means trivial and not really important. - - dfparse.y: remove argument variants. Use combinations of mixed type and function overloading - - dfparse.y and dfdecl.in: remove all the c-name stuff, it's always "df_" + name - ? remove all the typedefs for the structs etc? Currently it's bad style. + ! new interpreter! + + lang.y: + ! pop locals after leaving block + - do int i while(1); should either not be allowed + syntactically or should pop after it pushes + ! break, continue + ! remove all the shift/reduce conflicts + - compile.c::compile_prog() should show global vars - debug.c::print_code() should show functions' arguments - ! new interpreter! + - Do something about compile.c::pop_scope() - it's slow. + + - New configuration parser. + - Change 'errorlog' to just 'log', or change debug() to be an error + logging facility, or remove the option completely. + - Default error level option. + - For lib: option - if it doesn't end in /, add it. + + - Build system. + * make maintainer-clean + should also remove src/dfparse.output and src/lang.output + shouldn't delete src/dfparse.h and src/lang.h + ? optimize string tables - remove repetitions - ! lang.y: while, for, break, continue - fix lvalues - test operators: - && || ?: - documentation: * Small textbook about AGD's dialect of LPC * Short text describing main differences between LPC and C * Short text describing AGD and it's purposes, mainly for people coming from the AGI community. - - syntax highlighting scripts for AGD's LPC (vim, emacs) - - the famous host lookup daemon, so gethostbyaddr() won't block. Or maybe a separate thread with libpthread? - - New configuration parser. - - Change 'errorlog' to just 'log', or change debug() to be an error - logging facility, or remove the option completely. - - Default error level option. - - For lib: option - if it doesn't end in /, add it. - - Hash tables (mappings) for define_id in compile.c and the function lookup - table (prog->nametable), for O(1) instead of O(n) lookup. - allow both .c and .lpc for file extensions (/usr/bin/file could recognize LPC, and editors can turn on syntax highlighting automatically) @@ -43,10 +48,6 @@ - normal runtime - display stack trace (with line numbers and functions) when getting a runtime error - keep interactive objects in a separate linked list, and make shout act on that list - - Build system. - * make maintainer-clean - should also remove src/dfparse.output and src/lang.output - shouldn't delete src/dfparse.h and src/lang.h - LPC: ! arrays (T_ARRAY) - foreach(), switch() @@ -99,7 +100,9 @@ - binary: \0bnnnnnnnn - multiline strings -? better logging system + ? Better function lookup table (prog->nametable)? O(1) would be nice. + + ? better logging system - print time using strftime() - log using lib's facilities (master::log()?) - different prefixes have different debuglevels Index: ChangeLog =================================================================== RCS file: /cvsroot/agd/server/ChangeLog,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- ChangeLog 7 Jun 2004 15:50:19 -0000 1.18 +++ ChangeLog 8 Jun 2004 20:50:40 -0000 1.19 @@ -1,5 +1,23 @@ 0.0.3: ---------------------------------------------------------------------------- +2004-06-08 + * compile.c: redeclaration is now more sane. Also fixed crasher in + redeclaration_error() - didn't allocate enough space for strcat() + * compile.c: new define_id system uses hash tables + * object.h,compile.c,debug.c: function_t's code array is now short int, + not long. + * lang.y: call_other now uses index into string table as the function + name + * dfuns.c: changed dfuns_init() to use new structure of dfdecl.h + * dfparse.y: raised version to 0.09, see ChangeLog in src/dfparse.y + * lang.y: statements like 'do write("\n") while(1);' now work (i.e. a + single statement outside a block) + * lang.y: fixed while(), do..while(), for(), lvalues + * compile.c: readded checking of complying return type - functions like + "int foo() { }" now push an empty value on the stack. + * lang.y: fixed &&, || and ?: operators + * compile.c: when an identifier goes out of scope, the corresponding + counter is now decreased. This fixes indexes of defined id's. 2004-06-04 * dfdecl.in,dfuns.c: throw() dfun * various: removed references to type_xmalloc, was a silly thing |
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15712 Modified Files: array.h lex.l list.c list.h lpc.h main.c net.c net.h object.c object.h sys.c sys.h vars.c Log Message: Cleanups. Index: net.h =================================================================== RCS file: /cvsroot/agd/server/src/net.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- net.h 1 Apr 2004 19:10:53 -0000 1.11 +++ net.h 8 Jun 2004 20:44:53 -0000 1.12 @@ -24,11 +24,10 @@ int socket; struct sockaddr_in addr; char recvbuf[NET_RECEIVEBUF]; -/* enum { DISCONNECTED = -1, DEFAULT, CONNECTED } state;*/ time_t last_active; } player_connection_t; -typedef struct player_t { +typedef struct player { player_connection_t conn; object_t *ob; @@ -36,8 +35,6 @@ int input_to_called; } player_t; -/*void net_accept(player_t *p);*/ - void net_loop(void); void net_listen(unsigned short port); void net_send(char *buf, int siz, player_t *p); Index: sys.c =================================================================== RCS file: /cvsroot/agd/server/src/sys.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- sys.c 7 Jun 2004 15:45:51 -0000 1.14 +++ sys.c 8 Jun 2004 20:44:53 -0000 1.15 @@ -17,13 +17,10 @@ #endif #include <dirent.h> -#include "sys.h" #include "compile_options.h" +#include "sys.h" config_t conf; -/* -static mstats_t mstats; -*/ #define CONFCHECK(x, y) if((x) == 0) { \ fprintf(stderr, "\""y": \" directive not found in config file.\n"); \ @@ -44,9 +41,6 @@ fprintf(stderr, "Can't open configuration file! (%s)\n", strerror(errno)); exit(5); } -/* - conf.exit_stats = 0; -*/ while(fscanf(f, "%s ", buf) != EOF) { line++; @@ -71,12 +65,7 @@ conf.error_log = stringdup(buf); continue; } -/* - if(strncmp(buf, "exitstats:", 11) == 0) { - fscanf(f, "%d\n", &conf.exit_stats); - continue; - } -*/ + if(strncmp(buf, "master:", 8) == 0) { fscanf(f, "%s\n", buf); conf.master = stringdup(buf); @@ -101,64 +90,16 @@ CONFCHECK(conf.master, "master"); } -#if 0 -char *bytes_string(int bytes) -{ - static char buf[256]; - int scale = 0; - float result = bytes; - - char c = 0; - int prec = 3; - - for(scale = 0; scale < 2; scale++) { - if(result >= 1024.0) { - result /= 1024.0; - } else break; - } - - if(result != 1.0) c = 's'; - if(floor(result) == result) prec = 0; - - switch(scale) { - case 0: sprintf(buf, "%d byte%c", bytes, c); break; - case 1: sprintf(buf, "%.*f kilobyte%c", prec, result, c); break; - case 2: sprintf(buf, "%.*f megabyte%c", prec, result, c); break; - } - - return buf; -} - -void mstats_summary(void) -{ - int avg; - - printf("Memory allocation statistics:\n"); - printf("----------------------------------------------------------\n"); - printf(" Total malloc() calls: %d\n", mstats.alloc); - printf(" Total free() calls: %d (%d on nullpointers)\n", mstats.free, mstats.free_on_null); - printf(" Total bytes allocated: %s\n", bytes_string(mstats.total_alloced)); - if(mstats.alloc != 0) - avg = mstats.total_alloced / mstats.alloc; - else - avg = 0; - printf(" Average bytes per call: %s\n", bytes_string(avg)); - printf("----------------------------------------------------------\n"); -} -#endif - void *xmalloc(size_t bytes) { void *p; p = malloc(bytes); -/* mstats.alloc++;*/ if(!p) { fprintf(stderr, "Out of memory!\n"); exit(1); /* Or crash()? */ } -/* mstats.total_alloced += bytes;*/ return p; } @@ -176,19 +117,16 @@ } #ifdef DEBUG + /* Quite useless. */ void xfree(void *p) { -/* mstats.free++;*/ if(!p) { fprintf(stderr, "free() called on a nullpointer!\n"); -/* mstats.free_on_null++;*/ return; } free(p); } -#else -#define xfree(p) free(p) #endif int legal_path(char *fn) @@ -229,4 +167,3 @@ s = strcat(s, path); return s; } - Index: array.h =================================================================== RCS file: /cvsroot/agd/server/src/array.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- array.h 7 Jun 2004 15:35:52 -0000 1.7 +++ array.h 8 Jun 2004 20:44:53 -0000 1.8 @@ -1,7 +1,7 @@ #ifndef _ARRAY_H #define _ARRAY_H -typedef struct array_t { +typedef struct array { int length; int ref; variable_t **data; Index: list.c =================================================================== RCS file: /cvsroot/agd/server/src/list.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- list.c 7 Jun 2004 15:42:56 -0000 1.7 +++ list.c 8 Jun 2004 20:44:53 -0000 1.8 @@ -2,6 +2,13 @@ list.c - a generic linked list data structure Based on (the old) array.c -solicit 06.12.03 + + XXX - this could be a lot faster if we wouldn't + start from the beginning of the chain to + find an empty slot or then push it into the end, + but just set new element as root, and former + root as ->next in chain - i.e. reverse the order. + Look into it. */ #include <stdio.h> #include "sys.h" Index: sys.h =================================================================== RCS file: /cvsroot/agd/server/src/sys.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- sys.h 7 Jun 2004 15:45:51 -0000 1.9 +++ sys.h 8 Jun 2004 20:44:53 -0000 1.10 @@ -2,28 +2,18 @@ #define _SYS_H /* memory allocation */ -/*#define type_xmalloc(type) (type *) xmalloc(sizeof(type))*/ void *xmalloc(size_t bytes); void *xrealloc(void *ptr, size_t bytes); +#ifdef DEBUG void xfree(void *p); - -#if 0 -/* memory stats */ -void mstats_summary(void); - -typedef struct { - int alloc; - int free, free_on_null; - int total_alloced; -} mstats_t; +#else +#define xfree free #endif + /* configuration */ typedef struct { int port, heartbeat; -/* - int exit_stats; -*/ char *lib_root, *error_log; char *master; int debuglevel; Index: net.c =================================================================== RCS file: /cvsroot/agd/server/src/net.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- net.c 7 Jun 2004 15:44:17 -0000 1.15 +++ net.c 8 Jun 2004 20:44:53 -0000 1.16 @@ -7,8 +7,9 @@ #include <string.h> #include <errno.h> -#include "sys.h" +#include "config.h" #include "compile_options.h" +#include "sys.h" #include "list.h" #include "lpc.h" #include "object.h" @@ -26,7 +27,7 @@ static int greatest_sockfd, listenfd; static fd_set readfds, writefds; -void do_write(char *s); +extern void do_write(char *s); void net_listen(unsigned short port) { @@ -99,7 +100,7 @@ this_player = p; player_ob = xmalloc(sizeof(object_t)); player_ob->iaob = p; - player_ob->name = NULL; + player_ob->name = "NONE"; /* So find_object() won't barf. */ player_ob->prog = NULL; this_ob = p->ob = player_ob; @@ -115,12 +116,11 @@ return; } - p->ob = login_ob->u.ob; - this_ob = p->ob /*login_ob->u.ob*/; + this_ob = p->ob = login_ob->u.ob; p->ob->iaob = p; apply(login_ob->u.ob, "logon", NULL); - if(this_player == p && p->ob == player_ob) + if(this_player == p && p->ob == player_ob) /* wasn't changed. */ return; debug("net_accept", "player object was changed to %p; freeing player_ob %p\n", p->ob, player_ob); @@ -203,7 +203,6 @@ /* the login object will have to restore this object's iaob */ pl->ob->iaob = NULL; } -/* pl->conn.state = DISCONNECTED;*/ break; default: net_read(pl); @@ -220,7 +219,7 @@ if(!to_be_dested.data) return; - for(p = /*&all_objects*/ &to_be_dested; p; p=p->next) { + for(p = &to_be_dested; p; p=p->next) { object_t *ob = p->data; if(ob->flags & O_DESTRUCTED) actual_destruct(ob); @@ -241,7 +240,7 @@ FD_SET(listenfd, &readfds); LOOP_PLAYERS() - if(/*pl->conn.state != DISCONNECTED*/pl->ob) { + if(pl->ob) { FD_SET(pl->conn.socket, &readfds); /*FD_SET(pl->conn.socket, &writefds);*/ } Index: list.h =================================================================== RCS file: /cvsroot/agd/server/src/list.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- list.h 1 Feb 2004 13:12:30 -0000 1.4 +++ list.h 8 Jun 2004 20:44:53 -0000 1.5 @@ -1,9 +1,9 @@ #ifndef _LIST_H #define _LIST_H -typedef struct list_s { +typedef struct list { void *data; - struct list_s *next; + struct list *next; } list_t; void list_push(list_t *l, void *data); Index: object.c =================================================================== RCS file: /cvsroot/agd/server/src/object.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- object.c 7 Jun 2004 15:45:02 -0000 1.14 +++ object.c 8 Jun 2004 20:44:53 -0000 1.15 @@ -2,10 +2,10 @@ #include "config.h" */ #include <stdlib.h> -/*#include "arch.h"*/ -#include "sys.h" #include "compile_options.h" +#include "sys.h" +/*#include "arch.h"*/ #include "list.h" #include "lpc.h" #include "object.h" @@ -13,7 +13,7 @@ #include "vars.h" list_t all_objects, - to_be_dested; /* Objects which have the destructed flag + to_be_dested; /* Objects which have the destructed flag set, but are still in memory. This is so that destruct_all() in net.c has less objects to traverse. */ @@ -23,7 +23,7 @@ player_t *this_player; object_t *this_ob, *previous_ob; -program_t *compile_prog(char *path); +extern program_t *compile_prog(char *path); void free_fun(void *p) { @@ -77,11 +77,20 @@ void actual_destruct(object_t *ob) { + int i; + /* list_remove(&all_objects, ob);*/ unref_prog(&ob->prog); - free_array(&ob->globals, (void (*)(void*))free_var); + for(i=0;i<ob->numglobals;i++) { + free_var(&ob->globals[i]); + } + if(ob->globals) + xfree(ob->globals); + +/* free_array(&ob->globals, (void (*)(void*)) free_var); */ /* WTF? */ + if(ob->name) xfree(ob->name); @@ -116,14 +125,29 @@ return; p->ref--; + if(p->ref < 0) + printf("p[%p]->ref < 0!\n", p); if(p->ref <= 0) { int i; for(i=0;i<p->num_str;i++) xfree(p->str_tbl[i]); xfree(p->str_tbl); + for(i=0;i<p->numfunc;i++) { + free_fun(p->functions[i]); + xfree(p->fun_table[i]); + } + if(p->numfunc) { + xfree(p->functions); + xfree(p->fun_table); + } + +/* Again: WTF? */ +/* free_array(&p->functions, free_fun); free_array(&p->fun_table, NULL); +*/ + xfree(p); *prog = NULL; } @@ -138,10 +162,12 @@ for(p = &all_objects; p; p = p->next) { object_t *ob = p->data; - /* I'd rather not have the check for ob->name here. - * It's only here because of net.c, which creates a temporary - * ob with NULL name. */ - if(ob->name && strcmp(path, ob->name) == 0) { +#ifdef DEBUG + if(!ob->name) { + printf("Warning! Object[%p] doesn't have a name!\n", ob); + } else +#endif + if(strcmp(path, ob->name) == 0) { return ob; } } Index: lpc.h =================================================================== RCS file: /cvsroot/agd/server/src/lpc.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- lpc.h 7 Jun 2004 15:43:11 -0000 1.9 +++ lpc.h 8 Jun 2004 20:44:53 -0000 1.10 @@ -21,7 +21,7 @@ #define ST_MALLOC 1 #define ST_STATIC 2 -typedef struct variable_t { +typedef struct variable { unsigned char type; char *name; char string_type; @@ -32,9 +32,9 @@ unsigned char c; #endif char *s; - struct array_t *a; - struct object_t *ob; - struct variable_t *v; /* T_LVALUE */ + struct array *a; + struct object *ob; + struct variable *v; /* T_LVALUE */ } u; } variable_t; Index: lex.l =================================================================== RCS file: /cvsroot/agd/server/src/lex.l,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- lex.l 7 Jun 2004 15:42:38 -0000 1.15 +++ lex.l 8 Jun 2004 20:44:53 -0000 1.16 @@ -21,12 +21,11 @@ #ifdef DEBUG #define RET(type, value, tok) \ - pos += yyleng; \ if(conf.debuglevel > 3) \ printf("yylex(): %"#type"\n", value); \ return tok #else -#define RET(type, value, tok) pos += yyleng; return tok +#define RET(type, value, tok) return tok #endif #define NEWLINE() pos = 1; line++ @@ -246,7 +245,7 @@ yylval.str = str; RET(s, str, L_IDENTIFIER); } -" " pos++; +" " /*pos++;*/ \t pos += 8; \r { if(!warned_newlines) { Index: object.h =================================================================== RCS file: /cvsroot/agd/server/src/object.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- object.h 7 Jun 2004 15:45:20 -0000 1.9 +++ object.h 8 Jun 2004 20:44:53 -0000 1.10 @@ -5,9 +5,9 @@ int type; int *args; - int numarg; + int num_arg; - long int *code; + int *code; int codelen; unsigned int lineno; @@ -16,7 +16,7 @@ typedef struct { function_t **functions; /* This shouldn't be an array to pointers. */ int numfunc; - char **fun_table; /* This should be a hash table. */ + char **fun_table; /* This could be a hash table. */ int num_str; char **str_tbl; @@ -24,7 +24,7 @@ int ref; } program_t; -typedef struct object_t { +typedef struct object { char *name; program_t *prog; @@ -35,11 +35,11 @@ list_t refs; int flags; - struct object_t *environment, *parent; - struct object_t **inv; + struct object *environment, *parent; + struct object **inv; /* The interactive player associated with this object. */ - struct player_t *iaob; + struct player *iaob; } object_t; #define O_DESTRUCTED 0x1 Index: main.c =================================================================== RCS file: /cvsroot/agd/server/src/main.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- main.c 7 Jun 2004 15:43:32 -0000 1.19 +++ main.c 8 Jun 2004 20:44:53 -0000 1.20 @@ -181,7 +181,7 @@ parse_config(conf_file); check_logfile(); dfuns_init(); - init_interpreter(); +/* init_interpreter();*/ master = load_object(conf.master); if(!master) @@ -189,7 +189,7 @@ master->numref++; net_listen(conf.port); - + time(&startup_time); printf("Started at %s", ctime(&startup_time)); srand(startup_time); Index: vars.c =================================================================== RCS file: /cvsroot/agd/server/src/vars.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- vars.c 7 Jun 2004 15:46:15 -0000 1.13 +++ vars.c 8 Jun 2004 20:44:53 -0000 1.14 @@ -135,9 +135,9 @@ ret->u.i = v1->u.i + v2->u.i; return ret; case T_STRING: - buf = xmalloc(256); /* legit */ + buf = xmalloc(256); sprintf(buf, "%d", v1->u.i); - buf2 = xmalloc(strlen(v2->u.s) + strlen(buf) + 1); /* legit */ + buf2 = xmalloc(strlen(v2->u.s) + strlen(buf) + 1); xfree(buf); sprintf(buf2, "%d%s", v1->u.i, v2->u.s); ret->type = T_STRING; @@ -157,7 +157,7 @@ } else if(!v2->u.s) buf = stringdup(v1->u.s); else { - buf = xmalloc(strlen(v1->u.s) + strlen(v2->u.s) + 1); /* legit */ + buf = xmalloc(strlen(v1->u.s) + strlen(v2->u.s) + 1); sprintf(buf, "%s%s", v1->u.s, v2->u.s); } ret->type = T_STRING; @@ -165,9 +165,9 @@ ret->string_type = ST_MALLOC; return ret; case T_INT: - buf = xmalloc(256); /* legit */ + buf = xmalloc(256); sprintf(buf, "%d", v2->u.i); - buf2 = xmalloc(strlen(v1->u.s) + strlen(buf) + 1); /* legit */ + buf2 = xmalloc(strlen(v1->u.s) + strlen(buf) + 1); xfree(buf); sprintf(buf2, "%s%d", v1->u.s, v2->u.i); ret->type = T_STRING; @@ -177,7 +177,7 @@ case T_OBJECT: /* check for v2->u.ob */ ret->type = T_STRING; - ret->u.s = xmalloc(strlen(v1->u.s) + strlen(v2->u.ob->name) + 1); /* legit */ + ret->u.s = xmalloc(strlen(v1->u.s) + strlen(v2->u.ob->name) + 1); sprintf(ret->u.s, "%s%s", v1->u.s, v2->u.ob->name); ret->string_type = ST_MALLOC; return ret; @@ -193,7 +193,7 @@ ret->u.s = "<NULL>"; ret->string_type = ST_STATIC; } else { - ret->u.s = xmalloc(strlen(v1->u.ob->name) + strlen(v2->u.s) + 1); /* legit */ + ret->u.s = xmalloc(strlen(v1->u.ob->name) + strlen(v2->u.s) + 1); sprintf(ret->u.s, "%s%s", v1->u.ob->name, v2->u.s); ret->string_type = ST_MALLOC; } @@ -276,4 +276,3 @@ return "unknown"; } } - |
From: Peep P. <so...@us...> - 2004-06-08 20:43:09
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15127 Modified Files: lang.y Log Message: Rearranged stuff; made for, while, do..while work; fixed lvalues Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- lang.y 7 Jun 2004 15:54:05 -0000 1.17 +++ lang.y 8 Jun 2004 20:41:49 -0000 1.18 @@ -29,15 +29,15 @@ break_allowed, continue_allowed, is_new_declaration; -typedef struct arr_t arr_t; +/*typedef struct arr_t arr_t;*/ extern int scope_level; extern program_t *this_prog; extern function_t *curr_fun; -void do_assign_expr(expr_t *result, int type1, int type2, int op); +void do_assign_expr(expr_t *result, expr_t *left, int type2, int op); void do_expr(expr_t *result, expr_t *op1, expr_t *op2, int operator); -void do_inc_expr(expr_t *result, int type, int op); +void do_inc_expr(expr_t *result, expr_t *expr, int op); int add_string_to_table(char *s); @@ -53,12 +53,13 @@ char *str; int i; char c; /* used by lex.l */ - struct arr_t { - int length; + struct arr { + int len; int *data; } arr; expr_t expr; def_id_t *id; + void *ptr; /* for() uses this. */ } %token L_IF L_ELSE L_DO L_WHILE L_FOR @@ -102,9 +103,11 @@ %type <str> var_def %type <arr> call_args call_arg_list -%type <expr> expr expr1 expr2 lvalue +%type <expr> expr/* expr1 expr2 lvalue*/ %type <expr> optional_expr expr_list expr_list2 %type <expr> assign_expr arith_expr compare_expr inc_expr +%type <expr> neg_expr not_expr and_expr or_expr trinary_expr +%type <expr> constant index_expr %type <expr> fun_call call_other %type <i> block_or_semi @@ -168,7 +171,7 @@ '(' arguments ')' { $<id>3->args = $5.data; - $<id>3->numarg = $5.length; + $<id>3->num_arg = $5.len; $<i>$ = yylloc.first_line; } @@ -183,8 +186,8 @@ xfree(buf); } idp->type = ID_FUN; -#if 0 - if($8.data[$8.length-1] != F_RETURN) { + /* curr_fun can be zero if add_token() wasn't called for this function */ + if(!curr_fun || curr_fun->code[curr_fun->codelen-1] != F_RETURN) { int warn = 1; switch($1) { case T_INT: @@ -207,7 +210,7 @@ comp_warning("control reaches end of non-void function"); } } -#endif + add_function(idp, $<i>3/*, &$8*/); curr_fun_type = 0; } else { @@ -227,92 +230,20 @@ ; expr: - expr1 - | expr2; - -expr1: assign_expr | arith_expr | compare_expr | inc_expr - | '-' expr %prec L_NEG - { - $$.side_effect = 0; - $$.direct_type = 0; - $$.type = $2.type; - check_operand(F_NEG, $2.type, 0); - add_token(F_NEG); - } - | '!' expr - { - $$.side_effect = $$.direct_type = 0; - $$.type = T_INT; - check_operand(F_NOT, $2.type, 0); - add_token(F_NOT); - } - | expr L_AND - { - add_two_tokens(F_JUMP_IF_FALSE, 0); - $<i>$ = curr_fun->codelen - 1; /* save length */ - } - expr - { - $$.direct_type = 0; - $$.side_effect = $1.side_effect || $4.side_effect; - $$.type = T_INT; - check_operand(F_AND, $1.type, $4.type); - - curr_fun->code[$<i>3] = $<i>3 + 9; /* Jump past $4. */ - add_two_tokens(F_JUMP_IF_FALSE, 6); - add_two_tokens(F_PUSH_INT, 1); - add_two_tokens(F_JUMP, 3); - add_two_tokens(F_PUSH_INT, 0); - } - | expr L_OR - { - add_two_tokens(F_JUMP_IF_FALSE, 3); - add_two_tokens(F_JUMP, 0); - $<i>$ = curr_fun->codelen - 1; /* Save length. */ - } - expr - { - check_operand(F_OR, $1.type, $4.type); - $$.direct_type = 0; - $$.side_effect = $1.side_effect || $4.side_effect; - $$.type = T_INT; - - curr_fun->code[$<i>3] = $<i>3 + 7; - add_two_tokens(F_JUMP_IF_FALSE, 5); - add_two_tokens(F_PUSH_INT, 1); - add_two_tokens(F_JUMP, 3); - add_two_tokens(F_PUSH_INT, 0); - } - | expr '?' - { - add_two_tokens(F_JUMP_IF_FALSE, 0); - $<i>$ = curr_fun->codelen - 1; -/* ray_push(&$$.arr, (void *) $3.arr.length + 3);*/ - } - expr ':' - { - add_two_tokens(F_JUMP, 0); - $<i>$ = curr_fun->codelen - 1; -/*array_push(&$$.arr, (void *) F_JMP); - array_push(&$$.arr, (void *) $5.arr.length + 1);*/ - } - expr - { - $$.side_effect = $4.side_effect || $7.side_effect; - $$.direct_type = 0; - $$.type = $4.type; - - curr_fun->code[$<i>3] = $<i>6 + 1; - curr_fun->code[$<i>6] = curr_fun->codelen - 1; - - if($4.type != $7.type) { - comp_error("type mismatch"); - } - } + | neg_expr + | not_expr + | and_expr + | or_expr + | trinary_expr + | constant + | '(' expr ')' { $$ = $2; } + | call_other + | fun_call + | index_expr /* | '(' type ')' expr %prec L_TYPECAST { $$.side_effect = $4.side_effect; @@ -334,22 +265,23 @@ init_array(&$$.arr); array_concat(&$$.arr, &$4.arr); }*/ - | L_INTEGER + ; + +constant: + L_INTEGER { $$.side_effect = 0; $$.direct_type = 1; - if($1) - $$.type = T_INT; - else - $$.type = T_ANY; + $$.lval = 0; + +/* $$.type = $1 ? T_INT : T_ANY;*/ + $$.type = T_INT; add_two_tokens(F_PUSH_INT, $1); } - ; - -expr2: - defined_name + | defined_name { $$.side_effect = $$.direct_type = 0; + $$.lval = 1; $$.type = 0; if($1) { @@ -365,15 +297,13 @@ $$.type = $1->lpc_type; } } - | '(' expr ')' { $$ = $2; } - | call_other - | fun_call | string { int index; $$.side_effect = 0; $$.direct_type = 1; + $$.lval = 0; $$.type = T_STRING; index = add_string_to_table($1); @@ -382,21 +312,29 @@ | L_OPEN_ARRAY expr_list L_CLOSE_ARRAY { $$.side_effect = $2.side_effect; + $$.lval = 0; $$.type = $2.type | T_ARRAY; /* $2.arr.length--;*/ add_token(F_PUSH_ARRAY); /* add_two_tokens($2.type, $2.arr.data[$2.arr.length]);*/ } ; - + assign_expr: - lvalue '=' expr { do_assign_expr(&$$, $1.type, $3.type, F_ASSIGN); } - | lvalue L_PLUS_EQ expr { do_assign_expr(&$$, $1.type, $3.type, F_ADD_EQ); } - | lvalue L_MINUS_EQ expr { do_assign_expr(&$$, $1.type, $3.type, F_SUB_EQ); } - | lvalue L_MUL_EQ expr { do_assign_expr(&$$, $1.type, $3.type, F_MUL_EQ); } - | lvalue L_DIV_EQ expr { do_assign_expr(&$$, $1.type, $3.type, F_DIV_EQ); } - | lvalue L_MOD_EQ expr { do_assign_expr(&$$, $1.type, $3.type, F_MOD_EQ); } - | lvalue L_POW_EQ expr { do_assign_expr(&$$, $1.type, $3.type, F_POW_EQ); } + expr '=' { add_token(F_MAKE_LVALUE); } + expr { do_assign_expr(&$$, &$1, $4.type, F_ASSIGN); } + | expr L_PLUS_EQ { add_token(F_MAKE_LVALUE); } + expr { do_assign_expr(&$$, &$1, $4.type, F_ADD_EQ); } + | expr L_MINUS_EQ { add_token(F_MAKE_LVALUE); } + expr { do_assign_expr(&$$, &$1, $4.type, F_SUB_EQ); } + | expr L_MUL_EQ { add_token(F_MAKE_LVALUE); } + expr { do_assign_expr(&$$, &$1, $4.type, F_MUL_EQ); } + | expr L_DIV_EQ { add_token(F_MAKE_LVALUE); } + expr { do_assign_expr(&$$, &$1, $4.type, F_DIV_EQ); } + | expr L_MOD_EQ { add_token(F_MAKE_LVALUE); } + expr { do_assign_expr(&$$, &$1, $4.type, F_MOD_EQ); } + | expr L_POW_EQ { add_token(F_MAKE_LVALUE); } + expr { do_assign_expr(&$$, &$1, $4.type, F_POW_EQ); } ; arith_expr: @@ -406,28 +344,163 @@ if($1.type == T_STRING || $3.type == T_STRING) $$.type = T_STRING; } - | expr '-' expr { do_expr(&$$, &$1, &$3, F_SUB); } - | expr '*' expr { do_expr(&$$, &$1, &$3, F_MUL); } - | expr '/' expr { do_expr(&$$, &$1, &$3, F_DIV); } - | expr '%' expr { do_expr(&$$, &$1, &$3, F_MOD); } - | expr L_POW expr { do_expr(&$$, &$1, &$3, F_POW); } + | expr '-' expr { do_expr(&$$, &$1, &$3, F_SUB); } + | expr '*' expr { do_expr(&$$, &$1, &$3, F_MUL); } + | expr '/' expr { do_expr(&$$, &$1, &$3, F_DIV); } + | expr '%' expr { do_expr(&$$, &$1, &$3, F_MOD); } + | expr L_POW expr { do_expr(&$$, &$1, &$3, F_POW); } compare_expr: - expr '>' expr { do_expr(&$$, &$1, &$3, F_GT); } - | expr L_GE expr { do_expr(&$$, &$1, &$3, F_GE); } - | expr '<' expr { do_expr(&$$, &$1, &$3, F_LT); } - | expr L_LE expr { do_expr(&$$, &$1, &$3, F_LE); } - | expr L_NE expr { do_expr(&$$, &$1, &$3, F_NE); } - | expr L_EQ expr { do_expr(&$$, &$1, &$3, F_EQ); } + expr '>' expr { do_expr(&$$, &$1, &$3, F_GT); } + | expr L_GE expr { do_expr(&$$, &$1, &$3, F_GE); } + | expr '<' expr { do_expr(&$$, &$1, &$3, F_LT); } + | expr L_LE expr { do_expr(&$$, &$1, &$3, F_LE); } + | expr L_NE expr { do_expr(&$$, &$1, &$3, F_NE); } + | expr L_EQ expr { do_expr(&$$, &$1, &$3, F_EQ); } ; inc_expr: - lvalue L_INC { do_inc_expr(&$$, $1.type, F_POSTINC); } - | L_INC lvalue { do_inc_expr(&$$, $2.type, F_PREINC); } - | lvalue L_DEC { do_inc_expr(&$$, $1.type, F_POSTDEC); } - | L_DEC lvalue { do_inc_expr(&$$, $2.type, F_PREDEC); } + expr L_INC + { + add_token(F_MAKE_LVALUE); + do_inc_expr(&$$, &$1, F_POSTINC); + } + | L_INC expr + { + add_token(F_MAKE_LVALUE); + do_inc_expr(&$$, &$2, F_PREINC); + } + | expr L_DEC + { + add_token(F_MAKE_LVALUE); + do_inc_expr(&$$, &$1, F_POSTDEC); + } + | L_DEC expr + { + add_token(F_MAKE_LVALUE); + do_inc_expr(&$$, &$2, F_PREDEC); + } + ; + +neg_expr: + '-' expr %prec L_NEG + { + $$.side_effect = $$.direct_type = 0; + $$.lval = 0; + $$.type = $2.type; + check_operand(F_NEG, $2.type, 0); + add_token(F_NEG); + } + ; + +not_expr: + '!' expr + { + $$.side_effect = $$.direct_type = 0; + $$.lval = 0; + $$.type = T_INT; + check_operand(F_NOT, $2.type, 0); + add_token(F_NOT); + } + ; + +and_expr: + expr L_AND + { + add_two_tokens(F_JUMP_IF_FALSE, 0); + $<i>$ = curr_fun->codelen - 1; /* save length */ + } + expr + { + $$.direct_type = 0; + $$.side_effect = $1.side_effect || $4.side_effect; + $$.lval = 0; + $$.type = T_INT; + check_operand(F_AND, $1.type, $4.type); + + curr_fun->code[$<i>3] = curr_fun->codelen - $<i>3 + 6; /* Jump past $4. */ + add_two_tokens(F_JUMP_IF_FALSE, 5); + add_two_tokens(F_PUSH_INT, 1); + add_two_tokens(F_JUMP, 3); + add_two_tokens(F_PUSH_INT, 0); + } + ; + +or_expr: + expr L_OR + { + add_two_tokens(F_JUMP_IF_FALSE, 3); + add_two_tokens(F_JUMP, 0); + $<i>$ = curr_fun->codelen - 1; /* Save length. */ + } + expr + { + check_operand(F_OR, $1.type, $4.type); + $$.direct_type = 0; + $$.side_effect = $1.side_effect || $4.side_effect; + $$.lval = 0; + $$.type = T_INT; + + curr_fun->code[$<i>3] = curr_fun->codelen - $<i>3 + 2; + add_two_tokens(F_JUMP_IF_FALSE, 5); + add_two_tokens(F_PUSH_INT, 1); + add_two_tokens(F_JUMP, 3); + add_two_tokens(F_PUSH_INT, 0); + } + ; + +trinary_expr: + expr '?' + { + add_two_tokens(F_JUMP_IF_FALSE, 0); + $<i>$ = curr_fun->codelen - 1; + } + expr ':' + { + add_two_tokens(F_JUMP, 0); + $<i>$ = curr_fun->codelen - 1; + } + expr + { + $$.side_effect = $4.side_effect || $7.side_effect; + $$.lval = 0; + $$.direct_type = 0; + $$.type = $4.type; + + curr_fun->code[$<i>3] = curr_fun->codelen - $<i>3 - 2; + curr_fun->code[$<i>6] = curr_fun->codelen - $<i>6; + + if($4.type != $7.type) { + comp_error("type mismatch"); + } + } + ; + +index_expr: /* XXX - first expr must be indexable */ + expr '[' expr ']' + { + $$.side_effect = $1.side_effect || $3.side_effect; + $$.direct_type = 0; + $$.lval = 1; + + if($3.type != T_INT && $3.type != T_ANY) { + comp_error("index must be integer"); + } + $$.type = T_INT; + add_token(F_INDEX); + } + | expr '[' expr L_RANGE expr ']' + { + $$.side_effect = $1.side_effect || $3.side_effect || $5.side_effect; + $$.direct_type = 0; + $$.lval = 1; + $$.type = T_STRING; + + add_token(F_SLICE); + } ; +/* lvalue: expr2 '[' expr ']' { @@ -462,6 +535,7 @@ } | error ';' { comp_error("invalid lvalue"); } ; +*/ expr_list: /* empty */ @@ -511,8 +585,15 @@ ; block: - '{' { scope_level++; /*new_block_level();*/ } statements '}' - { pop_scope(); } + '{' + { + scope_level++; + /*new_block_level();*/ + } + statements '}' + { + pop_scope(); + } ; optional_star: @@ -525,7 +606,12 @@ | type ; -type: L_DATA_TYPE optional_star { $$ = $1|$2; global_type = $$; } ; +type: L_DATA_TYPE optional_star + { + $$ = $1|$2; + global_type = $$; + } + ; defined_name: L_IDENTIFIER @@ -544,15 +630,23 @@ statement: block - | return - | if - | do_while + | stmt_no_semi ';' + | stmt_no_semi_at_all + ; + +stmt_no_semi_at_all: + if | while | for + ; + +stmt_no_semi: + return + | do_while | break | continue | local_var {/* num_locals++;*/ } - | expr ';' + | expr { if($1.side_effect) { add_token(F_POP); @@ -560,19 +654,26 @@ comp_warning("statement with no effect"); } } - | ';' + | /* empty, for a single ';'-statement to work */ ; +stmt_no_semi_or_block: + stmt_no_semi + | block + | stmt_no_semi_at_all + ; + statements: /* empty */ | statements statement ; arguments: - /* empty */ { $$.length = 0; } + /* empty */ + { $$.len = 0; } | L_DATA_TYPE { - $$.length = 0; + $$.len = 0; if($1 != T_VOID) { comp_error("syntax error"); } @@ -583,16 +684,16 @@ argument_list: fun_arg { - $$.length = 1; + $$.len = 1; $$.data = malloc(sizeof(int)); $$.data[0] = $1; } | argument_list ',' fun_arg { $$ = $1; - $$.length++; - $$.data = realloc($$.data, $$.length * sizeof(int)); - $$.data[$$.length-1] = $3; + $$.len++; + $$.data = realloc($$.data, $$.len * sizeof(int)); + $$.data[$$.len-1] = $3; } ; @@ -645,7 +746,8 @@ ; lvar_def: - var_def { add_variable($1, global_type, ID_LVAR); } + var_def + { add_variable($1, global_type, ID_LVAR); } | var_def '=' { def_id_t *idp; @@ -667,7 +769,8 @@ ; gvar_def: - var_def { add_variable($1, global_type, ID_GVAR); } + var_def + { add_variable($1, global_type, ID_GVAR); } | var_def '=' { def_id_t *idp; @@ -705,7 +808,7 @@ ; local_var: - type local_vars ';' + type local_vars { global_type = 0; if(!$1) { @@ -717,12 +820,13 @@ ; optional_expr: - /* empty */ { memset(&$$, 0, sizeof($$)); } + /* empty */ + { memset(&$$, 0, sizeof($$)); } | expr ; return: - L_RETURN optional_expr ';' + L_RETURN optional_expr { if(curr_fun_type == T_VOID) { if($2.type) { @@ -744,7 +848,7 @@ add_two_tokens(F_JUMP_IF_FALSE, 0); $<i>$ = curr_fun->codelen - 1; } - statement + stmt_no_semi_or_block { add_two_tokens(F_JUMP, 0); curr_fun->code[$<i>5] = curr_fun->codelen - $<i>5; @@ -761,13 +865,19 @@ else: /* empty */ - | L_ELSE statement + | L_ELSE stmt_no_semi_or_block ; do_while: - L_DO { break_allowed = continue_allowed = 1; } - statement L_WHILE '(' expr ')' + L_DO + { + break_allowed = continue_allowed = /*1*/ 0; /* For now. */ + $<i>$ = curr_fun ? curr_fun->codelen : 0; + } + stmt_no_semi_or_block L_WHILE '(' expr ')' { + add_two_tokens(F_JUMP_IF_FALSE, 3); + add_two_tokens(F_JUMP, $<i>2 - curr_fun->codelen - 1); /* init_array(&$$); array_push(&$$, (void *) F_JMP); array_push(&$$, (void *) ($6.arr.length + 3)); @@ -783,11 +893,21 @@ while: L_WHILE { - break_allowed = continue_allowed = 1; + break_allowed = continue_allowed = /*1*/ 0; /* For now. */ + $<i>$ = curr_fun ? curr_fun->codelen : 0; } - '(' expr ')' statement + '(' expr + { + add_two_tokens(F_JUMP_IF_FALSE, 0); + $<i>$ = curr_fun->codelen - 1; + } + ')' statement { -/* int i; + add_two_tokens(F_JUMP, $<i>2 - curr_fun->codelen - 1); + curr_fun->code[$<i>5] = curr_fun->codelen - $<i>5; + +/* + int i; for(i=0;i<$6.length;i++) { if((int)$6.data[i] == F_BREAK_MAGIC1 && (int)$6.data[i+1] == F_BREAK_MAGIC2) { @@ -801,25 +921,70 @@ $6.data[i] = (void *) -(i + $4.arr.length + 2); } } - - init_array(&$$); +*/ + +/* init_array(&$$); array_concat(&$$, &$4.arr); array_push(&$$, (void *) F_JMPF); array_push(&$$, (void *) ($6.length + 3)); array_concat(&$$, &$6); array_push(&$$, (void *) F_JMP); array_push(&$$, (void *) -($6.length + $4.arr.length + 3)); - break_allowed = continue_allowed = 0;*/ + break_allowed = continue_allowed = 0; +*/ } ; for: - L_FOR '(' expr ';' expr ';' expr ')' - { - break_allowed = continue_allowed = 1; - } + L_FOR '(' expr ';' + { + if($3.side_effect) + add_token(F_POP); + $<i>$ = curr_fun->codelen; + } + expr + { + if($6.side_effect) + add_token(F_POP); + add_two_tokens(F_JUMP_IF_FALSE, 0); + $<i>$ = curr_fun->codelen - 1; + } + ';' + { + $<ptr>$ = curr_fun; + curr_fun = NULL; + } + expr + { + if($10.side_effect) + add_token(F_POP); + + /* Now we have a new curr_fun. */ + $<ptr>$ = (void *) curr_fun; + curr_fun = $<ptr>9; + } + ')' + { break_allowed = continue_allowed = /*1*/ 0; /* For now. */ } statement - { + { + /* Statements are pushed, concatenate the expr3 tokens. */ + int i; + int old_len; + function_t *expr3 = $<ptr>11; + + old_len = curr_fun->codelen; + curr_fun->codelen += expr3->codelen; + curr_fun->code = xrealloc(curr_fun->code, curr_fun->codelen * sizeof(int)); + + for(i=old_len;i<curr_fun->codelen;i++) { + curr_fun->code[i] = expr3->code[i-old_len]; + } + + free_fun(expr3); + + add_two_tokens(F_JUMP, $<i>5 - curr_fun->codelen - 1); + + curr_fun->code[$<i>7] = curr_fun->codelen - $<i>7; /* int i; for(i=0;i<$10.length;i++) { @@ -855,7 +1020,7 @@ ; break: - L_BREAK ';' + L_BREAK { /* $$.length = 2; $$.data = malloc(sizeof(int *) * 2); @@ -869,7 +1034,7 @@ ; continue: - L_CONTINUE ';' + L_CONTINUE { /* $$.length = 2; $$.data = malloc(sizeof(int *) * 2); @@ -887,6 +1052,7 @@ { int i; char *buf; + def_id_t *idp; $$.side_effect = 1; $$.direct_type = 0; @@ -896,18 +1062,18 @@ $$.type = $1->lpc_type; - if($3.length > $1->numarg) { + if($3.len > $1->num_arg) { buf = xmalloc(strlen($1->name) + 23); sprintf(buf, "too many arguments to %s", $1->name); comp_error(buf); xfree(buf); - } else if($3.length < $1->numarg) { + } else if($3.len < $1->num_arg) { buf = xmalloc(strlen($1->name) + 22); sprintf(buf, "too few arguments to %s", $1->name); comp_error(buf); xfree(buf); } else { - for(i=0;i<$1->numarg;i++) { + for(i=0;i<$1->num_arg;i++) { if($1->args[i] != T_ANY && $3.data[i] != T_ANY && $1->args[i] != $3.data[i]) { char *ts1, *ts2; @@ -931,14 +1097,14 @@ add_token(F_CALL_DFUN); } else /* ID_FUN */ add_token(F_CALL_LFUN); - add_two_tokens($1->index, $3.length); + add_two_tokens($1->index, $3.len); } ; call_other: expr L_ARROW L_IDENTIFIER '(' call_args ')' { - int i; + int index; $$.side_effect = 1; $$.direct_type = 0; @@ -949,42 +1115,49 @@ comp_error("not an object to '->'"); } + index = add_string_to_table($3); add_token(F_CALL_OTHER); - add_two_tokens((long int)$3 /*XXX*/, $5.length); + add_two_tokens(index, $5.len); } ; call_args: - /* empty */ { $$.length = 0; } + /* empty */ { $$.len = 0; } | call_arg_list ; call_arg_list: expr { - $$.length = 1; + $$.len = 1; $$.data = malloc(sizeof(int)); $$.data[0] = $1.type; } | call_arg_list ',' expr { $$ = $1; - $$.length++; - $$.data = realloc($$.data, $$.length * sizeof(int)); - $$.data[$$.length-1] = $3.type; + $$.len++; + $$.data = realloc($$.data, $$.len * sizeof(int)); + $$.data[$$.len-1] = $3.type; } ; %% -void do_assign_expr(expr_t *result, int type1, int type2, int op) +void do_assign_expr(expr_t *result, expr_t *left, int type2, int op) { + if(!left->lval) { + comp_error("invalid lvalue"); + } + result->side_effect = 1; - result->type = type1; + result->type = left->type; result->direct_type = 0; - if(type1 && type2 && type1 != type2) { + result->lval = 0; + + if(left->type && type2 && left->type != type2) { comp_error("type mismatch"); } - check_operand(op, type1, type2); + check_operand(op, left->type, type2); add_token(op); } @@ -997,12 +1170,17 @@ add_token(operator); } -void do_inc_expr(expr_t *result, int type, int op) +void do_inc_expr(expr_t *result, expr_t *expr, int op) { + if(!expr->lval) { + comp_error("invalid lvalue"); + } + result->side_effect = 1; result->direct_type = 0; - result->type = type; - check_operand(op, type, 0); + result->lval = 0; + result->type = expr->type; + check_operand(op, expr->type, 0); add_token(op); } |
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 |
From: Peep P. <so...@us...> - 2004-06-08 20:39:53
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14645 Modified Files: instr.h Log Message: F_MAKE_LVALUE Index: instr.h =================================================================== RCS file: /cvsroot/agd/server/src/instr.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- instr.h 7 Jun 2004 15:41:33 -0000 1.1 +++ instr.h 8 Jun 2004 20:38:38 -0000 1.2 @@ -10,6 +10,8 @@ #define F_PUSH_VOID 6 /* For 'return;' */ #define F_PUSH_ARRAY 7 +#define F_MAKE_LVALUE 8 + #define F_POP 10 /* Pops a variable off the stack. */ #define F_PUSH_LVAR 11 /* Pushes local variable <n> on stack. */ #define F_PUSH_LVAR_LVALUE 12 /* Pushes T_LVALUE to local var <n> */ |
From: Peep P. <so...@us...> - 2004-06-08 20:38:31
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14485 Modified Files: dfuns.c Log Message: Removed argument variants. Index: dfuns.c =================================================================== RCS file: /cvsroot/agd/server/src/dfuns.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- dfuns.c 7 Jun 2004 15:40:52 -0000 1.19 +++ dfuns.c 8 Jun 2004 20:37:35 -0000 1.20 @@ -20,21 +20,27 @@ extern list_t all_objects; extern time_t startup_time; /* for uptime() */ -void (**dfptr)(void); +void (**dfptr)(void); /* Array for dfun function pointers. */ void dfuns_init(void) { - int i, j, k; + int i, j/*, k*/; int *args; - int numarg; + int num_arg; #include "dfdecl.h" - dfptr = xmalloc(sizeof(void(*)(void)) * NUM_DF); + dfptr = xmalloc(sizeof(void (*) (void)) * NUM_DF); for(i=0;i<NUM_DF;i++) { dfptr[i] = decl[i].fun; - numarg = 0; - args = NULL; + + num_arg = decl[i].num_arg; + args = xmalloc(sizeof(int) * num_arg); + + for(j=0;j<num_arg;j++) { + args[j] = decl[i].args[j]; + } +#if 0 for(j=0;j<decl[i].arglen;j++) { if(j == 0) j = 1; @@ -49,7 +55,8 @@ } } } - define_id(decl[i].name, ID_DFUN, decl[i].ret, args, numarg); +#endif + define_id(decl[i].name, ID_DFUN, decl[i].ret, args, num_arg); } } @@ -128,18 +135,6 @@ push_void(); } -#if 0 -void df_platform(void) -{ - push_string(PLATFORM, ST_STATIC); -} - -void df_version(void) -{ - push_string(PACKAGE_VERSION, ST_STATIC); -} -#endif - void df_destruct(void) { destruct(fp->u.ob); |
From: Peep P. <so...@us...> - 2004-06-08 20:37:34
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14296 Modified Files: dfparse.y Log Message: Removed argument variants. Index: dfparse.y =================================================================== RCS file: /cvsroot/agd/server/src/dfparse.y,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- dfparse.y 7 Jun 2004 15:40:03 -0000 1.9 +++ dfparse.y 8 Jun 2004 20:36:41 -0000 1.10 @@ -1,7 +1,14 @@ /* - parser for dfdecl + parser for dfdecl.in + + NOTE: Maybe we could put the prototypes in dfuns.h or in dfuns.c? Changelog: + 0.09: + * Not using argument variants any more. + * Prints out return type as a string. + * General cleanup, less memory use and less grammar rules. + * Doesn't cast function pointers. Saves space. 0.08: * Not using array_{push,concat} etc anymore. No changes in output. 0.07: @@ -33,29 +40,35 @@ #include "sys.h" /* xmalloc */ #include "lpc.h" -#define DFVERSION "0.08" +#define DFVERSION "0.09" #define DFDECL_T "typedef struct {\n\tint ret;\n\tchar *name;\n\tvoid (*fun)(void);\n\t"\ - "int arglen;\n\tint args[%d];\n} dfdecl_t;\n" + "int num_arg;\n\tint args[%d];\n} dfdecl_t;\n" + typedef struct { int ret; char *name; - int arglen; + int num_arg; int *args; } dfdecl_t; dfdecl_t *dfdecl; + static int numdecl, failed; -static int maxarglen; +static int greatest_num_arg; extern FILE *yyin; +typedef struct arr arr_t; %} +/* Force yacc to define yylloc. */ +%locations + %union { char *s; int i; - struct arr_t { - int length; - long int *data; + struct arr { + int len; + int *data; } a; } @@ -63,9 +76,7 @@ %token <i> L_DATA_TYPE %type <i> type -%type <a> arguments argument -%type <a> another_argument another_type -%type <a> argument_and_another type_and_another +%type <a> arguments argument_and_another %% @@ -77,15 +88,22 @@ dfdecl: type L_IDENTIFIER '(' arguments ')' { - int i, j, index; +/* int i, j, index;*/ dfdecl_t decl; - int find_linear_len(struct arr_t *a); +/* int find_linear_len(struct arr_t *a);*/ - @1; /* To force bison to define yylloc. */ - decl.ret = $1; decl.name = $2; + decl.num_arg = $4.len; + if(decl.num_arg > greatest_num_arg) + greatest_num_arg = decl.num_arg; + if(decl.num_arg) + decl.args = $4.data; + + dfdecl = xrealloc(dfdecl, sizeof(dfdecl_t) * ++numdecl); + dfdecl[numdecl-1] = decl; +/* decl.arglen = find_linear_len(&$4); if(decl.arglen > maxarglen) maxarglen = decl.arglen; @@ -93,33 +111,40 @@ decl.args = xmalloc(sizeof(int) * decl.arglen); for(index=i=0;i<$4.length;i++) { struct arr_t *var = (struct arr_t *) $4.data[i]; - foo(); decl.args[index++] = var->length; for(j=0;j<var->length;j++) decl.args[index++] = (int) var->data[j]; } dfdecl = xrealloc(dfdecl, sizeof(dfdecl_t) * ++numdecl); dfdecl[numdecl-1] = decl; +*/ + } ; -type: L_DATA_TYPE /* optional_star */; - +type: + L_DATA_TYPE /* optional_star */ + ; + arguments: - /* empty */ { $$.length = 0; } + /* empty */ { $$.len = 0; } | argument_and_another ; -argument: type_and_another; - -another_argument: - /* empty */ { $$.length = 0; } - | ',' argument_and_another { $$ = $2; } - ; - argument_and_another: - argument another_argument + type + { + $$.len = 1; + $$.data = xmalloc(sizeof(arr_t)); + $$.data[0] = $1; + } + | argument_and_another ',' type { + $$ = $1; + $$.len++; + $$.data = xrealloc($$.data, $$.len * sizeof(arr_t)); + $$.data[$$.len-1] = $3; +/* int i, foo; foo = $1.length ? 1 : 0; @@ -135,30 +160,7 @@ for(i=foo;i<$$.length;i++) { $$.data[i] = $2.data[i-foo]; } - } - ; - -another_type: - /* empty */ { $$.length = 0; } - | '|' type_and_another { $$ = $2; } - ; - -type_and_another: - type another_type - { - int i, foo; - - foo = $1 != T_VOID ? 1 : 0; - $$.length = $2.length + foo; - $$.data = xmalloc(sizeof(int) * $$.length); - - if($1 != T_VOID) { - $$.data[0] = $1; - } - - for(i=foo;i<$$.length;i++) { - $$.data[i] = $2.data[i-foo]; - } +*/ } ; @@ -172,6 +174,7 @@ return 0; } +#if 0 int find_linear_len(struct arr_t *a) { int len; @@ -182,18 +185,55 @@ } return len; } +#endif + +void write_type(int t) +{ + /* Just for readability. */ + switch(t) { + case T_INT: + printf("T_INT"); + break; + case T_STRING: + printf("T_STRING"); + break; + case T_OBJECT: + printf("T_OBJECT"); + break; + case T_VOID: + printf("T_VOID"); + break; + default: + printf("%d", t); + break; + } +} void print_declarations(void) { - int i, j, k; + int i, j/*, k*/; printf("dfdecl_t decl[] = {\n"); for(i=0;i<numdecl;i++) { - printf("\t/* %d */ { %d, \"%s\", (void (*)(void))df_%s, ", - i, dfdecl[i].ret, dfdecl[i].name, dfdecl[i].name); + printf("\t/* %d */ { ", i); + write_type(dfdecl[i].ret); + printf(", \"%s\", df_%s, ", + dfdecl[i].name, dfdecl[i].name); - printf("%d, {", dfdecl[i].arglen); - for(j=0;j<dfdecl[i].arglen;j++) { + printf("%d", dfdecl[i].num_arg); + if(dfdecl[i].num_arg) + printf(", {"); + for(j=0;j<dfdecl[i].num_arg;j++) { + putchar(' '); + + write_type(dfdecl[i].args[j]); + + if(j+1 < dfdecl[i].num_arg) + putchar(','); + else + putchar(' '); + +#if 0 int len = dfdecl[i].args[j]; printf(" %d,", len); for(k=j+1;k-j<=len;k++) { @@ -212,11 +252,14 @@ putchar(' '); } j += len; +#endif } - if(!j) - printf("0"); - printf("} }"); +/* if(!j) + printf("0");*/ + if(j) + putchar('}'); + printf(" }"); if(i+1 < numdecl) putchar(','); putchar('\n'); @@ -259,7 +302,8 @@ printf("/* dfdecl.h: dfun declarations\n generated by dfparse %s on %s */\n", DFVERSION, timestr); printf("#define NUM_DF %d\n", numdecl); - printf(DFDECL_T, maxarglen); + + printf(DFDECL_T, greatest_num_arg); print_prototypes(); print_declarations(); @@ -267,5 +311,3 @@ return 0; } -foo() { -} |
From: Peep P. <so...@us...> - 2004-06-08 20:35:07
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13835 Modified Files: dflex.l Log Message: Changes in indentation. Index: dflex.l =================================================================== RCS file: /cvsroot/agd/server/src/dflex.l,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- dflex.l 7 Jun 2004 15:39:39 -0000 1.3 +++ dflex.l 8 Jun 2004 20:33:45 -0000 1.4 @@ -18,38 +18,38 @@ \n pos = 0; line++; BEGIN(INITIAL); } /* everything else */ -void { - yylval.i = T_VOID; - pos += 4; - return L_DATA_TYPE; - } -int { - yylval.i = T_INT; - pos += 3; - return L_DATA_TYPE; - } -string { - yylval.i = T_STRING; - pos += 6; - return L_DATA_TYPE; - } -mixed { - yylval.i = T_MIXED; - pos += 5; - return L_DATA_TYPE; - } -object { - yylval.i = T_OBJECT; - pos += 6; - return L_DATA_TYPE; - } -{IDENTIFIER} { - char *s = (char *) stringdup(yytext); - yylval.s = s; - pos += strlen(s); - return L_IDENTIFIER; - } -[ \t] pos++; /* ignore whitespace */ +void { + yylval.i = T_VOID; + pos += 4; + return L_DATA_TYPE; +} +int { + yylval.i = T_INT; + pos += 3; + return L_DATA_TYPE; +} +string { + yylval.i = T_STRING; + pos += 6; + return L_DATA_TYPE; +} +mixed { + yylval.i = T_MIXED; + pos += 5; + return L_DATA_TYPE; +} +object { + yylval.i = T_OBJECT; + pos += 6; + return L_DATA_TYPE; +} +{IDENTIFIER} { + char *s = stringdup(yytext); + yylval.s = s; + pos += strlen(s); + return L_IDENTIFIER; +} + +[ \t] pos++; /* ignore whitespace */ . pos++; return *yytext; \n line++; pos = 0; - |
From: Peep P. <so...@us...> - 2004-06-08 20:32:06
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13516 Modified Files: dfdecl.in Log Message: Removed the c-name stuff. Index: dfdecl.in =================================================================== RCS file: /cvsroot/agd/server/src/dfdecl.in,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- dfdecl.in 7 Jun 2004 15:39:16 -0000 1.12 +++ dfdecl.in 8 Jun 2004 20:31:29 -0000 1.13 @@ -1,18 +1,13 @@ -# driver function declarations +# Driver function declarations # -# syntax: -# return-type dfun-name(type|type2|typeN|*, type|type2|typeN|*, ...) optional-c-name +# Syntax: +# return-type dfun-name(type1, type2, typeN) # # dfun-name is the name as known by the LPC parser -# c-name is the name of the dfun in dfuns.c. if c-name isn't supplied, it will be dfun-name with -# a prefix (if it has arguments, the prefix is "df_", if it doesn't, the prefix is "do_") -# For example, "int foo(void)" would have it's c-name set to 'do_foo', since it doesn't have -# arguments; while "int foo(string)"'s c-name would be "df_foo". (df_ is a dfun hook, do_ -# is the dfun definition itself) - -# if dfun doesn't return anything, return-type should be `void'. -# -# type is one of string, int, object +# Possible types are string, int, object - both for return-type +# and argument types. +# +# return-type can also be 'void' if it doesn't return anything. # Expect lots of nasty error messages if you mess up here. |
From: Peep P. <so...@us...> - 2004-06-08 20:31:01
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13249 Modified Files: debug.c Log Message: F_MAKE_LVALUE, code array now int instead of long int, call_other takes index into string table Index: debug.c =================================================================== RCS file: /cvsroot/agd/server/src/debug.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- debug.c 7 Jun 2004 15:38:46 -0000 1.12 +++ debug.c 8 Jun 2004 20:30:40 -0000 1.13 @@ -111,6 +111,7 @@ case F_PUSH_VOID: return "F_PUSH_VOID"; case F_PUSH_NULL_OBJECT: return "F_PUSH_NULL_OBJECT"; case F_PUSH_ARRAY: return "F_PUSH_ARRAY"; + case F_MAKE_LVALUE: return "F_MAKE_LVALUE"; case F_PUSH_LVAR: return "F_PUSH_LVAR"; case F_PUSH_LVAR_LVALUE: return "F_PUSH_LVAR_LVALUE"; case F_PUSH_GVAR: return "F_PUSH_GVAR"; @@ -205,23 +206,19 @@ void print_instr(program_t *prog, function_t *f) { int i; - long int *code; + int *code; int codelen; codelen = f->codelen; code = f->code; for(i = 0; i < codelen; i++) { - printf("@[%d]: %d/%s ", i, code[i], opc_name(code[i])); + printf("[%d]: %d/%s ", i, code[i], opc_name(code[i])); switch(code[i]) { int index, num; char *s; - /* case F_PUSH: - print_var(a->data[++*i], 1); - printf("\n"); - break;*/ case F_PUSH_INT: num = code[++i]; printf("%d", num); @@ -231,8 +228,6 @@ printf("%d (", code[i]); puts_nonl(prog->str_tbl[code[i]]); putchar(')'); -/* s = (char *) code[++i]; - printf("\"%s\"", s);*/ break; case F_PUSH_ARRAY: num = code[++i]; @@ -251,9 +246,10 @@ printf("index %d num_arg: %d", index, num); break; case F_CALL_OTHER: - s = (char *) code[++i]; - num = code[++i]; - printf("fun \"%s\" num_arg: %d", s, num); + i++; + printf("fun %d (", code[i]); + puts_nonl(prog->str_tbl[code[i]]); + printf(") num_arg: %d", s, num); break; case F_PUSH_LVAR: case F_PUSH_LVAR_LVALUE: |
From: Peep P. <so...@us...> - 2004-06-08 20:25:32
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11784 Modified Files: compile.c compile.h compile_options.h Log Message: define_id now uses hash tables for identifiers Index: compile.h =================================================================== RCS file: /cvsroot/agd/server/src/compile.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- compile.h 7 Jun 2004 15:37:55 -0000 1.13 +++ compile.h 8 Jun 2004 20:24:10 -0000 1.14 @@ -11,30 +11,33 @@ typedef struct { char *name; + unsigned hashed_name; + int base_scope; /* The scope level at which this id was defined */ int index; int type; int lpc_type; /* The datatype of the id. Return type for functions. */ int has_been_called; - int *args; /*For ID_FUN_PROT and ID_FUN*/ - int numarg; + int *args; /* For ID_FUN_PROT and ID_FUN. */ + int num_arg; } def_id_t; -def_id_t *define_id(char *name, int type, int lpc_type, int *args, int numarg); +def_id_t *define_id(char *name, int type, int lpc_type, int *args, int num_arg); def_id_t *find_id(char *name); typedef struct { int side_effect; int type, direct_type; + int lval; /* If it can be used in lvalue context */ } expr_t; int check_operand(int operator, int opr1, int opr2); -int get_fun_index(object_t *ob, char *fun); -void add_function(def_id_t *idp, int lineno/*, int **code, int codelen*/); -void add_token(long int t); -void add_two_tokens(long int t1, long int t2); +/*int get_fun_index(object_t *ob, char *fun);*/ +void add_function(def_id_t *idp, int lineno); +void add_token(int t); +void add_two_tokens(int t1, int t2); def_id_t *add_variable(char *name, int lpc_type, int type); void redeclaration_error(def_id_t *id, int new_type); Index: compile_options.h =================================================================== RCS file: /cvsroot/agd/server/src/compile_options.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- compile_options.h 7 Jun 2004 15:38:15 -0000 1.14 +++ compile_options.h 8 Jun 2004 20:24:11 -0000 1.15 @@ -35,18 +35,26 @@ long will be cut off in the end. */ #define NET_RECEIVEBUF 512 -/* Define this if you want to enable debugging for the driver. */ +/* Define this if you want to enable debugging for the driver. + There is no reason to disable debugging at this point - bugs lurk + at every corner. */ #define DEBUG /* The type a function has if one isn't specified (e.g. create() { } ) - * Must be one of T_VOID, T_STRING, T_OBJECT or T_INT. */ + Must be one of T_VOID, T_STRING, T_OBJECT or T_INT. */ #define DEFAULT_FUNCTION_TYPE T_VOID /* Define this if you want to allow root to run AGD, - * BUT ONLY IF YOU REALLY KNOW WHAT YOU ARE DOING! - * AGD is probably not very secure at this point. - * I will not take responsibility for anything that happens - * because of this. */ + BUT ONLY IF YOU REALLY KNOW WHAT YOU ARE DOING! + AGD is probably not very secure at this point. + I will not take responsibility for anything that happens + because of this. */ #undef ALLOW_ROOT +/* Size of global identifiers hash table. Should experiment with it. */ +#define GLOBAL_HASH_SIZE 1024 + +/* Size of local identifiers hash table. Should experiment with it. */ +#define LOCAL_HASH_SIZE 10000 + #endif Index: compile.c =================================================================== RCS file: /cvsroot/agd/server/src/compile.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- compile.c 7 Jun 2004 15:37:55 -0000 1.22 +++ compile.c 8 Jun 2004 20:24:10 -0000 1.23 @@ -23,15 +23,21 @@ int compile_errors, compile_warnings; -/* For define_id. */ -int scope_level; -int numlvars, numgvars, - numdfuns, numlfuns; +#if 0 /* These are arrays to pointers. realloc might * move the memory segments, and we have * pointers to this memory - that would get corrupted. */ def_id_t **local_ids, **global_ids; int num_local_ids, num_global_ids; +#endif + +/* For define_id. */ +int scope_level; +int numlvars, numgvars, + numdfuns, numlfuns; + +list_t gid_tbl[GLOBAL_HASH_SIZE]; /* Hash table for global identifiers. */ +list_t lid_tbl[LOCAL_HASH_SIZE]; /* Hash table for local identifiers. */ #if YYDEBUG extern int yydebug; @@ -41,6 +47,17 @@ extern FILE *yyin; +unsigned strhash(char *s) +{ + int h = *s; + if(!h) + return 0; + for(s++;*s;s++) + h = (h<<5)-h+*s; + return h; +} + +#if 0 /* define_id functions. */ def_id_t *define_id(char *name, int type, int lpc_type, int *args, int numarg) { @@ -85,12 +102,176 @@ } #ifdef DEBUG - debug("define_id", "%s base_scope %d index %d\n", idp->name, idp->base_scope, idp->index); + debug("define_id", "%s [hash %u] base_scope %d index %d\n", + idp->name, strhash(idp->name), idp->base_scope, idp->index); +#endif + + return idp; +} #endif +int assign_index(int type) +{ + switch(type) { + case ID_ARG: + case ID_LVAR: + return numlvars++; + case ID_GVAR: + return numgvars++; + case ID_FUN_PROT: + case ID_FUN: + return numlfuns++; + case ID_DFUN: + return numdfuns++; + default: + printf("assign_index(): invalid def_id_t type %d\n", type); + break; + } +} + +void unassign_index(int type) +{ + switch(type) { + case ID_ARG: + case ID_LVAR: + numlvars--; + break; + case ID_GVAR: + numgvars--; + break; + case ID_FUN_PROT: + case ID_FUN: + numlfuns--; + break; + case ID_DFUN: + numdfuns--; + break; + } +} + +void redeclaration_error(def_id_t *id, int new_type) +{ + char *buf, *buf2; + buf = xmalloc(strlen(id->name) + 100); + sprintf(buf, "%s redeclared as ", id->name); + switch(new_type) { + case ID_ARG: + buf2 = "function argument"; + break; + case ID_FUN: + buf2 = "local function"; + break; + case ID_LVAR: + buf2 = "local variable"; + break; + case ID_GVAR: + buf2 = "global variable"; + break; + default: + buf2 = "idontknowwhat!"; + break; + } + buf = strcat(buf, buf2); + comp_error(buf); + xfree(buf); +} + +int redeclaration_allowed(def_id_t *target, int type) +{ + if(target->base_scope >= scope_level) + return 0; + + if(target->type == ID_FUN_PROT || target->type == ID_DFUN) + return 0; + + return 1; +} +def_id_t *define_id(char *name, int type, int lpc_type, int *args, int num_arg) +{ + unsigned hash; + list_t *elem; + def_id_t *idp; + + idp = xmalloc(sizeof(def_id_t)); + + hash = strhash(name); + + if(type == ID_DFUN) + elem = &gid_tbl[hash % GLOBAL_HASH_SIZE]; + else + elem = &lid_tbl[hash % LOCAL_HASH_SIZE]; + + if(elem->data) { + def_id_t *target; + list_t temp, *new_list; + + target = elem->data; + if(!redeclaration_allowed(target, type)) { + redeclaration_error(target, type); + return; + } + + printf("hash collision! \"%s\" && \"%s\" == %d!\n", name, target->name, hash); + + temp = *elem; + + new_list = xmalloc(sizeof(list_t)); + new_list->data = temp.data; + new_list->next = temp.next; + elem->data = idp; + elem->next = new_list; + } else { + elem->data = idp; + } + + idp->hashed_name = hash; + idp->name = stringdup(name); + idp->type = type; + idp->lpc_type = lpc_type; + idp->args = args; + idp->num_arg = num_arg; + idp->base_scope = scope_level; + idp->index = assign_index(idp->type); + return idp; } +static def_id_t *find_elem(list_t *tbl, unsigned tbl_size, unsigned hash) { + list_t *list; + def_id_t *idp; + + list = &tbl[hash % tbl_size]; + if(list->data) { + list_t *p; + for(p=list; p; p=p->next) { + idp = p->data; + if(idp->hashed_name == hash) + return idp; + } + } + + return NULL; +} + +def_id_t *find_id(char *name) +{ + def_id_t *idp; + unsigned hash = strhash(name); + + /* First look in global table. */ + idp = find_elem(gid_tbl, GLOBAL_HASH_SIZE, hash); + if(idp) + return idp; + + /* Now look in local table. */ + idp = find_elem(lid_tbl, LOCAL_HASH_SIZE, hash); + if(idp) + return idp; + + return NULL; +} + +#if 0 def_id_t *find_id(char *name) { def_id_t *idp; @@ -117,7 +298,9 @@ } return NULL; } +#endif +#if 0 void pop_scope() { int i; @@ -128,12 +311,68 @@ /* if(id->type == ID_LVAR || id->type == ID_ARG) { } else if(id->type == ID_GVAR) { }*/ id->base_scope = -1; /* Temporary hack until identifiers use hash tables. */ + switch(id->type) { + case ID_ARG: + case ID_LVAR: + numlvars--; + break; + case ID_GVAR: + numgvars--; + break; + case ID_FUN_PROT: + case ID_FUN: + numlfuns--; + break; + case ID_DFUN: + numdfuns--; + break; + } + xfree(id->name); if(id->args) xfree(id->args); } } } +#endif + +void clean_ids(list_t *tbl, unsigned tbl_size) +{ + def_id_t *idp; + int i; + + for(i=0;i<tbl_size;i++) { + if(tbl[i].data) { + idp = tbl[i].data; + if(idp->base_scope > scope_level) { + unassign_index(idp->type); + xfree(idp->name); + if(idp->args) + xfree(idp->args); + xfree(idp); + + if(tbl[i].next) { + list_t *temp; + temp = tbl[i].next; + tbl[i] = *temp; + i--; /* Look over this chain again. */ + } else { + tbl[i].data = NULL; + } + } + } + } + +} + +void pop_scope() +{ + scope_level--; + + /* Ok, this is as ugly as it gets.. find another way. */ + clean_ids(gid_tbl, GLOBAL_HASH_SIZE); + clean_ids(lid_tbl, LOCAL_HASH_SIZE); +} /* Operator argument checking functions and definitions. */ typedef struct { @@ -256,7 +495,7 @@ } } -void add_function(def_id_t *idp, int lineno/*, long int *code, int codelen*/) +void add_function(def_id_t *idp, int lineno) { if(idp->index < this_prog->numfunc) { /* Adding a definition for a prototype. */ @@ -264,15 +503,12 @@ f = this_prog->functions[idp->index]; f->type = idp->lpc_type; f->args = idp->args; - f->numarg = idp->numarg; -/* f->code = code; - f->codelen = codelen;*/ + f->num_arg = idp->num_arg; f->lineno = lineno; } else { curr_fun_check(); curr_fun->type = idp->lpc_type; curr_fun->args = idp->args; -/* curr_fun->code = code;*/ curr_fun->lineno = lineno; this_prog->numfunc++; @@ -286,20 +522,20 @@ } } -void add_token(long int t) +void add_token(int t) { - curr_fun_check(); - curr_fun->codelen++; - curr_fun->code = xrealloc(curr_fun->code, sizeof(long int) * curr_fun->codelen); - curr_fun->code[curr_fun->codelen-1] = t; + curr_fun_check(); + curr_fun->codelen++; + curr_fun->code = xrealloc(curr_fun->code, sizeof(int) * curr_fun->codelen); + curr_fun->code[curr_fun->codelen-1] = t; } -void add_two_tokens(long int t1, long int t2) +void add_two_tokens(int t1, int t2) { - curr_fun_check(); - curr_fun->code = xrealloc(curr_fun->code, sizeof(long int) * (curr_fun->codelen+2)); - curr_fun->code[curr_fun->codelen++] = t1; - curr_fun->code[curr_fun->codelen++] = t2; + curr_fun_check(); + curr_fun->code = xrealloc(curr_fun->code, sizeof(int) * (curr_fun->codelen+2)); + curr_fun->code[curr_fun->codelen++] = t1; + curr_fun->code[curr_fun->codelen++] = t2; } def_id_t *add_variable(char *name, int lpc_type, int type) @@ -326,33 +562,6 @@ return define_id(name, type, lpc_type, NULL, 0); } -void redeclaration_error(def_id_t *id, int new_type) -{ - char *buf, *buf2; - buf = xmalloc(strlen(id->name) + 16); - sprintf(buf, "%s redeclared as ", id->name); - switch(new_type) { - case ID_ARG: - buf2 = "function argument"; - break; - case ID_FUN: - buf2 = "local function"; - break; - case ID_LVAR: - buf2 = "local variable"; - break; - case ID_GVAR: - buf2 = "global variable"; - break; - default: - buf2 = "idontknowwhat!"; - break; - } - buf = strcat(buf, buf2); - comp_error(buf); - xfree(buf); -} - /* This does the actual formatting. */ void display_error(char *s) { @@ -385,7 +594,7 @@ numlvars = numgvars = 0; numdfuns = numlfuns = 0; - num_local_ids = 0; +/* num_local_ids = 0;*/ yylloc.first_line = yylloc.first_column = 1; yyreset(); @@ -397,16 +606,24 @@ int check_fun_definitions(void) { int i; - for(i=0;i<num_local_ids;i++) { - def_id_t *id = local_ids[i]; - if(id->type == ID_FUN_PROT && id->has_been_called) { - char *buf; - buf = xmalloc(strlen(id->name) + 43); - sprintf(buf, "function %s has been called, " - "but not defined", id->name); - comp_error(buf); - xfree(buf); - return 1; + for(i=0;i<LOCAL_HASH_SIZE;i++) { + if(lid_tbl[i].data) { + def_id_t *id = lid_tbl[i].data; + if(id->type == ID_FUN_PROT && id->has_been_called) { + char *buf; + buf = xmalloc(strlen(id->name) + 43); + sprintf(buf, "function %s has been called, " + "but not defined", id->name); + comp_error(buf); + xfree(buf); + return 1; + } + + if(lid_tbl[i].next) { + list_t *tmp = lid_tbl[i].next; + lid_tbl[i] = *tmp; + i--; /* Check this list_t again. */ + } } } return 0; @@ -440,7 +657,7 @@ } prog = xmalloc(sizeof(program_t)); - memset(prog, 0, sizeof(program_t)); + memset(prog, 0, sizeof *prog); this_prog = prog; parse_init(); |
From: Peep P. <so...@us...> - 2004-06-08 20:24:52
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11595 Modified Files: array.c Log Message: Small change in indentation. Index: array.c =================================================================== RCS file: /cvsroot/agd/server/src/array.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- array.c 7 Jun 2004 15:35:52 -0000 1.13 +++ array.c 8 Jun 2004 20:23:06 -0000 1.14 @@ -128,8 +128,9 @@ void unref_array(array_t *a) { - a->ref--; - if(a->ref <= 0) { - free_array(a, NULL); - } + a->ref--; + if(a->ref < 0) + printf("Warning: array[%p] ref < 0\n", a); + if(a->ref <= 0) + free_array(a, NULL); } |
From: Peep P. <so...@us...> - 2004-06-08 20:23:59
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11239/src Modified Files: Makefile.am Log Message: Cleaned a little. Index: Makefile.am =================================================================== RCS file: /cvsroot/agd/server/src/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Makefile.am 7 Jun 2004 15:34:54 -0000 1.10 +++ Makefile.am 8 Jun 2004 20:21:38 -0000 1.11 @@ -12,7 +12,8 @@ noinst_PROGRAMS = dfparse dfparse_SOURCES = dfparse.y dflex.l -dfparse_LDADD = sys.o array.o log.o @LEXLIB@ +dfparse_LDADD = sys.o @LEXLIB@ +# array.o log.o dflex.c: dfparse.c @@ -24,7 +25,7 @@ bin_PROGRAMS = agd agd_SOURCES = arch.h array.c array.h compile.c compile.h compile_options.h \ debug.c debug.h dfdecl.h dfuns.c dfuns.h interpret.c interpret.h lex.l lex.h \ -list.c list.h log.c lpc.h lpc_incl.h lang.y main.c net.c net.h std.h \ +list.c list.h log.c lpc.h lpc_incl.h lang.y main.c net.c net.h std.h \ sys.c sys.h vars.c vars.h dfdecl.in dfdecl.h object.c object.h agd_LDADD = @LEXLIB@ |
From: Peep P. <so...@us...> - 2004-06-08 20:22:09
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11022 Modified Files: configure Makefile.in Log Message: Regenerated. Index: Makefile.in =================================================================== RCS file: /cvsroot/agd/server/Makefile.in,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.in 12 Mar 2004 14:43:27 -0000 1.3 +++ Makefile.in 8 Jun 2004 20:20:48 -0000 1.4 @@ -503,6 +503,7 @@ install-data-local: cp -r lib $(pkgdatadir) cp -r doc $(pkgdatadir) +# touch $(pkgdatadir)/debug.log uninstall-local: rm -rf $(pkgdatadir)/doc Index: configure =================================================================== RCS file: /cvsroot/agd/server/configure,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- configure 7 Jun 2004 15:51:29 -0000 1.8 +++ configure 8 Jun 2004 20:20:47 -0000 1.9 @@ -3,7 +3,7 @@ # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for AGD 0.0.3. # -# Report bugs to <so...@es...>. +# Report bugs to <pe...@li...>. # # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation @@ -272,7 +272,7 @@ PACKAGE_TARNAME='agd' PACKAGE_VERSION='0.0.3' PACKAGE_STRING='AGD 0.0.3' -PACKAGE_BUGREPORT='so...@es...' +PACKAGE_BUGREPORT='pe...@li...' ac_unique_file="src/dfparse.y" ac_default_prefix=/usr @@ -872,7 +872,7 @@ Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to <so...@es...>. +Report bugs to <pe...@li...>. _ACEOF fi @@ -4116,9 +4116,9 @@ echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to so...@es... ## -## --------------------------------- ## +## ---------------------------- ## +## Report this to pe...@li... ## +## ---------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -4266,9 +4266,9 @@ echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to so...@es... ## -## --------------------------------- ## +## ---------------------------- ## +## Report this to pe...@li... ## +## ---------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 |
From: Peep P. <so...@us...> - 2004-06-08 20:22:02
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11022/src Modified Files: Makefile.in dfparse.h lang.h Log Message: Regenerated. Index: lang.h =================================================================== RCS file: /cvsroot/agd/server/src/lang.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- lang.h 7 Jun 2004 15:51:29 -0000 1.9 +++ lang.h 8 Jun 2004 20:20:48 -0000 1.10 @@ -113,15 +113,16 @@ char *str; int i; char c; /* used by lex.l */ - struct arr_t { - int length; + struct arr { + int len; int *data; } arr; expr_t expr; def_id_t *id; + void *ptr; /* for() uses this. */ } YYSTYPE; /* Line 1240 of yacc.c. */ -#line 125 "lang.h" +#line 126 "lang.h" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 Index: Makefile.in =================================================================== RCS file: /cvsroot/agd/server/src/Makefile.in,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Makefile.in 7 Jun 2004 15:51:29 -0000 1.12 +++ Makefile.in 8 Jun 2004 20:20:48 -0000 1.13 @@ -120,14 +120,14 @@ noinst_PROGRAMS = dfparse dfparse_SOURCES = dfparse.y dflex.l -dfparse_LDADD = sys.o array.o log.o @LEXLIB@ +dfparse_LDADD = sys.o @LEXLIB@ BUILT_SOURCES = dfdecl.h bin_PROGRAMS = agd agd_SOURCES = arch.h array.c array.h compile.c compile.h compile_options.h \ debug.c debug.h dfdecl.h dfuns.c dfuns.h interpret.c interpret.h lex.l lex.h \ -list.c list.h log.c lpc.h lpc_incl.h lang.y main.c net.c net.h std.h \ +list.c list.h log.c lpc.h lpc_incl.h lang.y main.c net.c net.h std.h \ sys.c sys.h vars.c vars.h dfdecl.in dfdecl.h object.c object.h agd_LDADD = @LEXLIB@ @@ -149,7 +149,7 @@ agd_LDFLAGS = am_dfparse_OBJECTS = dfparse.$(OBJEXT) dflex.$(OBJEXT) dfparse_OBJECTS = $(am_dfparse_OBJECTS) -dfparse_DEPENDENCIES = sys.o array.o log.o +dfparse_DEPENDENCIES = sys.o dfparse_LDFLAGS = DEFAULT_INCLUDES = -I. -I$(srcdir) -I. @@ -492,6 +492,7 @@ uninstall-am uninstall-binPROGRAMS uninstall-dist_pkgdataDATA \ uninstall-info-am +# array.o log.o dflex.c: dfparse.c Index: dfparse.h =================================================================== RCS file: /cvsroot/agd/server/src/dfparse.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- dfparse.h 7 Jun 2004 15:51:29 -0000 1.6 +++ dfparse.h 8 Jun 2004 20:20:48 -0000 1.7 @@ -40,13 +40,13 @@ #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 53 "dfparse.y" +#line 66 "dfparse.y" typedef union YYSTYPE { char *s; int i; - struct arr_t { - int length; - long int *data; + struct arr { + int len; + int *data; } a; } YYSTYPE; /* Line 1240 of yacc.c. */ |