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-20 14:05:05
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1490 Modified Files: main.c Log Message: No need to display date of compilation. Index: main.c =================================================================== RCS file: /cvsroot/agd/server/src/main.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- main.c 8 Jun 2004 20:44:53 -0000 1.20 +++ main.c 20 Jun 2004 14:04:56 -0000 1.21 @@ -86,10 +86,11 @@ void print_version(void) { - printf("%s on %s, compiled on %s %s\n", PACKAGE_STRING, PLATFORM, __TIME__, __DATE__); + printf("%s on %s", PACKAGE_STRING, PLATFORM); #ifdef __GNUC__ - printf("gcc %s\n", __VERSION__); + printf(", gcc %s", __VERSION__); #endif + putchar('\n'); #ifdef ARCH_README printf("Your computer architecture is not fully supported. " |
From: Peep P. <so...@us...> - 2004-06-20 14:04:53
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1220 Modified Files: lang.y Log Message: Some hacks on expr_list and defining variables. Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- lang.y 14 Jun 2004 20:56:38 -0000 1.22 +++ lang.y 20 Jun 2004 14:04:45 -0000 1.23 @@ -1,4 +1,6 @@ %{ +/* local_vars and global_vars still need some work, + especially in not allowing 'void'. */ #include <stdlib.h> #include "config.h" @@ -126,21 +128,9 @@ def: fundef - | vardef + | global_var ; -vardef: - optional_type global_vars ';' - { - global_type = 0; - if($1 == T_VOID) { - comp_error("invalid type"); - } else if(!$1) { - comp_error("missing type"); - } - } - ; - fundef: optional_type L_IDENTIFIER { @@ -318,12 +308,15 @@ } | L_OPEN_ARRAY expr_list L_CLOSE_ARRAY { - $$.side_effect = $2.side_effect; + /* Ugh, an array constant has no side effect, but + still pushes something on the stack. Let's + set side effect always on, for now. */ + $$.side_effect = /*$2.side_effect*/ 1; + $$.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]);*/ + add_two_tokens($2.type, $2.lval); /* Abusing lval as length. */ } ; @@ -503,43 +496,37 @@ /* empty */ { $$.type = $$.side_effect = 0; -/* init_array(&$$.arr); - array_push(&$$.arr, (void *) 0);*/ + /* Ok, we're seriously abusing + a variable here - it's used in length + context - .lval shows how many members + are in the list. */ + $$.lval = 0; } | expr_list2 - { + { $$.type = $1.type; $$.side_effect = $1.side_effect; -/* init_array(&$$.arr); - array_concat(&$$.arr, &$1.arr);*/ - } - ; + $$.lval = $1.lval; /* Same abuse here. */ + } + ; expr_list2: expr - { - $$.type = $1.type; -/* $$.side_effect = $1.side_effect; - init_array(&$$.arr); - array_concat(&$$.arr, &$1.arr); - array_push(&$$.arr, (void *) 1);*/ - } - | expr ',' expr_list2 - { - $$.side_effect = $1.side_effect || $3.side_effect; + { + $$.type = $1.type; + $$.lval = 1; /* And here. */ + } + | expr ',' expr_list2 + { + $$.side_effect = $1.side_effect || $3.side_effect; if($1.type != $3.type) { comp_error("all elements in array constant must be of same type"); /*$$.type = T_MIXED;*/ } $$.type = $1.type; -/* init_array(&$$.arr); - array_concat(&$$.arr, &$1.arr); - $3.arr.length--; - array_concat(&$$.arr, &$3.arr); - array_push(&$$.arr, $3.arr.data[$3.arr.length] + 1); - $3.arr.data = realloc($3.arr.data, sizeof(void *) * $3.arr.length);*/ - } - ; + $$.lval = $3.lval + 1; /* And here. */ + } + ; block_or_semi: block { $$ = 1; } @@ -708,10 +695,27 @@ $$ = $1; } ; - + +local_var: + type local_vars + { + global_type = 0; + if(!$1) { + comp_error("missing type"); + } else if($1 == T_VOID) { + comp_error("invalid type"); + } + } + ; + local_vars: lvar_def - | local_vars ',' lvar_def + | local_vars ',' optional_type lvar_def + { + if($3 == T_VOID) { + comp_error("invalid type"); + } + } ; lvar_def: @@ -735,10 +739,29 @@ } } ; - + +global_var: + optional_type global_vars ';' + { + if(!$1) { + comp_error("missing type"); + } + if($1 == T_VOID) { + comp_error("invalid type"); + } + + global_type = 0; + } + ; + global_vars: gvar_def - | global_vars ',' gvar_def + | global_vars ',' optional_type gvar_def + { + if($3 == T_VOID) { + comp_error("invalid type"); + } + } ; gvar_def: @@ -783,18 +806,6 @@ } ; -local_var: - type local_vars - { - global_type = 0; - if(!$1) { - comp_error("missing type"); - } else if($1 == T_VOID) { - comp_error("invalid type"); - } - } - ; - optional_expr: /* empty */ { memset(&$$, 0, sizeof($$)); } |
From: Peep P. <so...@us...> - 2004-06-20 14:04:17
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv812 Modified Files: interpret.h Log Message: Added runtime_dyn. Index: interpret.h =================================================================== RCS file: /cvsroot/agd/server/src/interpret.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- interpret.h 12 Jun 2004 16:46:33 -0000 1.15 +++ interpret.h 20 Jun 2004 14:04:08 -0000 1.16 @@ -2,11 +2,14 @@ #define _INTERPRET_H variable_t *apply(object_t *ob, char *fun, char *argfmt, ...); -void runtime(char *s, int free_str); +void _runtime(char *s, int free_str); #define pop_stack() sp--; free_var(sp) #define pop_locals() while(sp > fp) { sp--; free_var(sp); } +#define runtime(msg) _runtime(msg, 0) +#define runtime_dyn(msg) _runtime(msg, 1) + typedef struct { variable_t *sp, *fp; int num_arg; |
From: Peep P. <so...@us...> - 2004-06-20 14:04:02
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv587 Modified Files: interpret.c Log Message: Lots of fixes. Notably: runtime for dynamically allocated memory is now called runtime_dyn; F_INDEX_LVALUE works with any operator; changed some macros into functions; F_SLICE works quite okay now; F_CALL_OTHER doesn't fail if called with no arguments Index: interpret.c =================================================================== RCS file: /cvsroot/agd/server/src/interpret.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- interpret.c 14 Jun 2004 20:55:42 -0000 1.24 +++ interpret.c 20 Jun 2004 14:03:53 -0000 1.25 @@ -38,9 +38,9 @@ control_stack_t *csp = control_stack; #define CHECK_CSP() if(csp >= control_stack + CONTROL_STACK_SIZE) \ - runtime("control stack overflow (too deep recursion)", 0); + runtime("control stack overflow (too deep recursion)"); #define CHECK_SP() if(sp >= value_stack + VALUE_STACK_SIZE) \ - runtime("value stack overflow", 0); + runtime("value stack overflow"); extern void (**dfptr)(void); @@ -67,7 +67,7 @@ /* Need the F_NEWLINE operation for this. */ /* 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) +void _runtime(char *s, int free_str) { char *buf; @@ -91,7 +91,7 @@ /* stack_trace();*/ out: - if(csp > &control_stack[0]) { + while(csp > &control_stack[0]) { pop_locals(); pop_control_stack(1); } @@ -254,7 +254,7 @@ { csp--; if(csp < control_stack) { - runtime("control stack underflow", 0); + runtime("control stack underflow"); } fp = csp->fp; @@ -271,15 +271,44 @@ } /* Used by F_JUMP and F_JUMP_IF_FALSE to check if they jumped too far. */ -#define CHECK_OVERRUN() if(cp >= code + codelen) {\ - debug("interpret", "Ran over end of array: returning\n"); return; } +#define CHECK_OVERRUN() do { if(cp >= code + codelen) {\ + debug("interpret", "Ran over end of array: returning\n"); return; \ + } } while(0) -#define GET_ARGS() arg[0] = sp[-1].u.i; pop_stack(); arg[1] = sp[-1].u.i; pop_stack(); +#define GET_ARGS() \ + arg[1] = sp[-1].u.i; pop_stack(); \ + arg[0] = sp[-1].u.i; pop_stack() -#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)+1 || arg[1] < 0 || arg[1] > arg[0]) runtime("substring out of range", 0); \ +void setup_frame(void) +{ + push_control_stack(); + csp->num_arg = *cp; + fp = sp - csp->num_arg; +} -#define SETUP_FRAME() push_control_stack(); csp->num_arg = *cp; fp = sp - csp->num_arg; +void index_check(int *arg, char *str) +{ + if(!str) + runtime("taking element of null string"); + if(arg[0] < 0 || arg[0] > strlen(str)) + runtime("index out of range"); +} + +variable_t *take_slice(int *arg) +{ + variable_t *v; + GET_ARGS(); + + v = sp[-1].u.v; + if(!v->u.s) + runtime("taking substring of null string"); + if(arg[0] > arg[1]) + runtime("first index is bigger than second index"); + if(arg[0] < 0 || arg[1] > strlen(v->u.s)) { + runtime("substring out of range"); + } + return v; +} void eval_instruction(void) { @@ -305,9 +334,7 @@ if(*cp == -1) tmps = NULL; else - tmps = this_ob->prog->str_tbl[*cp]; - if(tmps) - tmps = stringdup(tmps); + tmps = stringdup(this_ob->prog->str_tbl[*cp]); push_string(tmps, ST_MALLOC); break; case F_PUSH_VOID: @@ -377,8 +404,8 @@ } break; case F_SUB: - GET_ARGS() - push_int(arg[1] - arg[0]); + GET_ARGS(); + push_int(arg[0] - arg[1]); break; case F_SUB_EQ: if(sp[-2].type == T_CHAR_PTR) { @@ -392,8 +419,8 @@ push_int(tmpi); break; case F_MUL: - GET_ARGS() - push_int(arg[1] * arg[0]); + GET_ARGS(); + push_int(arg[0] * arg[1]); break; case F_MUL_EQ: if(sp[-2].type == T_CHAR_PTR) { @@ -407,14 +434,14 @@ push_int(tmpi); break; case F_DIV: - GET_ARGS() - if(!arg[0]) - runtime("division by zero", 0); - push_int(arg[1] / arg[0]); + GET_ARGS(); + if(!arg[1]) + runtime("division by zero"); + push_int(arg[0] / arg[1]); break; case F_DIV_EQ: if(!sp[-1].u.i) - runtime("division by zero", 0); + runtime("division by zero"); if(sp[-2].type == T_CHAR_PTR) { tmpi = sp[-2].u.s[0] / sp[-1].u.i; @@ -427,14 +454,14 @@ push_int(tmpi); break; case F_MOD: - GET_ARGS() - if(!arg[0]) - runtime("divison by zero", 0); - push_int(arg[1] % arg[0]); + GET_ARGS(); + if(!arg[1]) + runtime("divison by zero"); + push_int(arg[0] % arg[1]); break; case F_MOD_EQ: if(!sp[-1].u.i) - runtime("divison by zero", 0); + runtime("divison by zero"); if(sp[-2].type == T_CHAR_PTR) { tmpi = sp[-2].u.s[0] % sp[-1].u.i; } else { @@ -504,62 +531,43 @@ if(tmpvp->type & T_ARRAY) { if(!tmpvp->u.a) { - runtime("taking element of null array", 0); + runtime("taking element of null array"); } if(arg[0] < 0 || arg[0] >= tmpvp->u.a->length) { - runtime("index out of range", 0); + runtime("index out of range"); } tmpvp = tmpvp->u.a->data[arg[0]]; push_var(tmpvp); } else { - if(!tmpvp->u.s) { - runtime("taking element of null string", 0); - } - if(arg[0] < 0 || arg[0] > strlen(tmpvp->u.s)+1) { - runtime("index out of range", 0); - } + index_check(arg, tmpvp->u.s); arg[1] = tmpvp->u.s[arg[0]]; push_int(arg[1]); } break; case F_INDEX_LVALUE: - /* A bit hacky. */ arg[0] = sp[-1].u.i; pop_stack(); tmpvp = sp[-1].u.v; pop_stack(); - - tmps = tmpvp->u.s; - if(!tmps) { - runtime("taking element of null string", 0); - } - if(arg[0] < 0 || arg[0] > strlen(tmps)+1) { - runtime("index out of range", 0); - } + index_check(arg, tmpvp->u.s); sp->type = T_CHAR_PTR; - sp->u.s = tmps + arg[0]; + sp->u.s = tmpvp->u.s + arg[0]; sp++; CHECK_SP() -/* do_assign(sp, &sp[-1]); - sp->u.s += arg[0]; - pop_stack(); - push_var(sp+1); - push_lvalue(sp-1);*/ break; case F_SLICE: - TAKE_SLICE() - tmps = xmalloc(arg[0] - arg[1] + 1); - for(tmpi=0;tmpi<arg[0];tmpi++) - tmps[tmpi] = sp[-1].u.s[tmpi+arg[1]]; - tmps[tmpi] = '\0'; + tmpvp = take_slice(arg); + tmps = xmalloc(arg[1] - arg[0] + 2); + for(tmpi=arg[0];tmpi<=arg[1];tmpi++) + tmps[tmpi-arg[0]] = tmpvp->u.s[tmpi]; + tmps[arg[1] - arg[0] + 1] = '\0'; pop_stack(); push_string(tmps, ST_MALLOC); break; case F_SLICE_LVALUE: - TAKE_SLICE() - tmpvp = sp[-1].u.v; - tmps = tmpvp->u.s + arg[0]; /* begin */ + tmpvp = take_slice(arg); + tmps = tmpvp->u.s + arg[1]; /* begin */ tmpi = tmpvp->string_type; pop_stack(); push_string(tmps, tmpi); @@ -574,12 +582,12 @@ cp++; } free_var(sp); - CHECK_OVERRUN() + CHECK_OVERRUN(); break; case F_JUMP: tmpi = cp[1]; cp += tmpi; - CHECK_OVERRUN() + CHECK_OVERRUN(); break; case F_NEG: sp--; @@ -610,32 +618,32 @@ push_int(!tmpi); break; case F_GT: - GET_ARGS() - push_int(arg[1] > arg[0] ? 1 : 0); + GET_ARGS(); + push_int(arg[0] > arg[1] ? 1 : 0); break; case F_LT: - GET_ARGS() - push_int(arg[1] < arg[0] ? 1 : 0); + GET_ARGS(); + push_int(arg[0] < arg[1] ? 1 : 0); break; case F_GE: - GET_ARGS() - push_int(arg[1] >= arg[0] ? 1 : 0); + GET_ARGS(); + push_int(arg[0] >= arg[1] ? 1 : 0); break; case F_LE: - GET_ARGS() - push_int(arg[1] <= arg[0] ? 1 : 0); + GET_ARGS(); + push_int(arg[0] <= arg[1] ? 1 : 0); break; case F_CALL_LFUN: tmpi = *++cp; cp++; - SETUP_FRAME(); + setup_frame(); call_function(this_ob, tmpi); goto again; break; case F_CALL_DFUN: tmpi = *++cp; cp++; - SETUP_FRAME(); + setup_frame(); dfptr[tmpi](); pop_control_stack(0); break; @@ -643,7 +651,8 @@ cp++; tmps = this_ob->prog->str_tbl[*cp]; cp++; - sp -= *cp + 1; + arg[0] = *cp; /* num_arg */ + sp -= arg[0] + 1; if(sp->type == T_OBJECT) { tmpv.u.ob = sp->u.ob; /* A little hack so we don't need an object_t variable in this scope. @@ -656,15 +665,17 @@ } if(!tmpv.u.ob) { - runtime("call_other on null object", 0); + runtime("call_other on null object"); } tmpi = get_fun_index(tmpv.u.ob, tmps); if(tmpi == -1) - runtime("function doesn't exist", 0); - SETUP_FRAME(); + runtime("function doesn't exist"); + setup_frame(); fp = sp + 1; - sp = fp + 1; + sp = fp; + if(arg[0]) + sp++; call_function(tmpv.u.ob, tmpi); goto again; break; @@ -678,7 +689,7 @@ pop_control_stack(0); break; default: - printf("Unknown instruction %d\n", *cp); + printf("Unknown instruction %d\n", *cp); /* runtime here? */ break; } #ifdef DEBUG @@ -712,7 +723,7 @@ if(!f) { char *buf = xmalloc(512); sprintf(buf, "function %d doesn't exist in object \"%s\"", index, ob->name); - runtime(buf, 1); + runtime_dyn(buf); } csp->line = f->lineno; |
From: Peep P. <so...@us...> - 2004-06-20 14:02:06
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31851 Modified Files: debug.c Log Message: F_PUSH_ARRAy's type is shown using type2str Index: debug.c =================================================================== RCS file: /cvsroot/agd/server/src/debug.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- debug.c 14 Jun 2004 20:54:13 -0000 1.17 +++ debug.c 20 Jun 2004 14:01:57 -0000 1.18 @@ -235,7 +235,7 @@ break; case F_PUSH_ARRAY: num = code[++i]; - printf("type %d ", num); + printf("%s ", type2str(num)); num = code[++i]; printf("%d", num); break; |
From: Peep P. <so...@us...> - 2004-06-20 14:01:52
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31656 Modified Files: compile.c Log Message: F_PUSH_ARRAY in add_variable uses the correct type now Index: compile.c =================================================================== RCS file: /cvsroot/agd/server/src/compile.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- compile.c 14 Jun 2004 20:53:49 -0000 1.26 +++ compile.c 20 Jun 2004 14:01:42 -0000 1.27 @@ -474,13 +474,20 @@ v->type = lpc_type; init_var(v); } else /* LVAR */{ + int lpc_type2 = lpc_type & ~T_ARRAY; if(lpc_type & T_ARRAY) { add_token(F_PUSH_ARRAY); - add_two_tokens(T_VOID, 0); - } else switch(lpc_type & ~T_ARRAY) { - case T_INT: add_two_tokens(F_PUSH_INT, 0); break; - case T_STRING: add_two_tokens(F_PUSH_STRING, -1); break; - case T_OBJECT: add_token(F_PUSH_NULL_OBJECT); break; + add_two_tokens(lpc_type2, 0); + } else switch(lpc_type2) { + case T_INT: + add_two_tokens(F_PUSH_INT, 0); + break; + case T_STRING: + add_two_tokens(F_PUSH_STRING, -1); + break; + case T_OBJECT: + add_token(F_PUSH_NULL_OBJECT); + break; } } |
From: Peep P. <so...@us...> - 2004-06-14 20:58:41
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23601 Modified Files: object.c Log Message: Removed commented code and xfree; before apply create is called, this_player is set to 0. Index: object.c =================================================================== RCS file: /cvsroot/agd/server/src/object.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- object.c 12 Jun 2004 20:12:24 -0000 1.16 +++ object.c 14 Jun 2004 20:58:32 -0000 1.17 @@ -31,19 +31,9 @@ function_t *f = p; if(f->args) - xfree(f->args); + free(f->args); -#if 0 - for(i=0;i<f->code.length;i++) { - if((int) f->code.data[i] == F_PUSH_STRING) { - i++; - if(f->code.data[i]) - xfree(f->code.data[i]); - } - } -#endif - - xfree(f->code); + free(f->code); } void destruct(object_t *ob) @@ -87,15 +77,16 @@ free_var(&ob->globals[i]); } if(ob->globals) - xfree(ob->globals); - -/* free_array(&ob->globals, (void (*)(void*)) free_var); */ /* WTF? */ - + free(ob->globals); + if(ob->name) { - xfree(ob->name); + free(ob->name); } - xfree(ob); + if(this_ob == ob) + this_ob = NULL; + + free(ob); } void ref_ob(object_t *ob, variable_t *v) @@ -130,26 +121,21 @@ 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->num_str;i++) { + free(p->str_tbl[i]); + } + free(p->str_tbl); for(i=0;i<p->numfunc;i++) { free_fun(p->functions[i]); - xfree(p->fun_table[i]); + free(p->fun_table[i]); } if(p->numfunc) { - xfree(p->functions); - xfree(p->fun_table); + free(p->functions); + free(p->fun_table); } -/* Again: WTF? */ -/* - free_array(&p->functions, free_fun); - free_array(&p->fun_table, NULL); -*/ - - xfree(p); + free(p); *prog = NULL; } } @@ -181,6 +167,7 @@ object_t *ob, *saved_this_ob, *saved_prev_ob; + player_t *saved_tp; if(!legal_path(path)) { printf("load_object(): illegal path name \"%s\"!\n", path); @@ -205,6 +192,9 @@ unref_prog(&ob->prog); /* new_prog is already referenced by compile_prog() */ ob->prog = new_prog; + + saved_tp = this_player; + this_player = NULL; apply(ob, "create", NULL); goto out; } @@ -213,21 +203,25 @@ /* path = remove_extension(path); ? */ ob = xmalloc(sizeof(object_t)); memset(ob, 0, sizeof(object_t)); - ob->name = path; + ob->name = stringdup(path); this_ob = ob; ob->prog = compile_prog(path); if(!ob->prog) { - xfree(ob); + free(ob); ob = NULL; goto out; } list_push(&all_objects, ob); + + saved_tp = this_player; + this_player = NULL; apply(ob, "create", NULL); out: + this_player = saved_tp; this_ob = saved_this_ob; previous_ob = saved_prev_ob; return ob; |
From: Peep P. <so...@us...> - 2004-06-14 20:58:02
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22971 Modified Files: lpc.h Log Message: Added T_CHAR_PTR, for use by F_INDEX_LVALUE. Index: lpc.h =================================================================== RCS file: /cvsroot/agd/server/src/lpc.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- lpc.h 8 Jun 2004 20:44:53 -0000 1.10 +++ lpc.h 14 Jun 2004 20:57:52 -0000 1.11 @@ -12,10 +12,16 @@ #define T_VOID 0x03 #define T_OBJECT 0x04 #define T_MIXED 0x05 -#define T_LVALUE 0x10 /* Used by interpret.c. I'd rather not have it here, - but as it also needs an union member, it would be - too cluttered otherwise. */ -#define T_ARRAY 0x80 /* Indicates an array datatype. */ + +/* Used by interpret.c. I'd rather not have it here, + but as it also needs an union member, it would be + too cluttered otherwise. */ +#define T_LVALUE 0x10 + +/* Used by F_INDEX_LVALUE. */ +#define T_CHAR_PTR 0x20 + +#define T_ARRAY 0x80 /* string_types */ #define ST_MALLOC 1 |
From: Peep P. <so...@us...> - 2004-06-14 20:57:33
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22682 Modified Files: list.c Log Message: A little change in list_push. Index: list.c =================================================================== RCS file: /cvsroot/agd/server/src/list.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- list.c 8 Jun 2004 20:44:53 -0000 1.8 +++ list.c 14 Jun 2004 20:57:24 -0000 1.9 @@ -2,13 +2,6 @@ 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" @@ -16,22 +9,16 @@ void list_push(list_t *l, void *data) { - list_t *p; + list_t *p = l; - p = l; - while(p->next != p && p->next) { - if(!p->data) { /* reuse the slot */ - p->data = data; - return; - } - p = p->next; - } - if(!p->data) { - /* reusable slot */ p->data = data; } else { - /* didn't find a reusable slot */ + while(1) { + if(!p->next) + break; + p = p->next; + } p->next = xmalloc(sizeof(list_t)); p = p->next; p->data = data; @@ -49,12 +36,18 @@ while(1) { if(p->data == data) { if(!prev) { - l = p->next; + if(p->next) { + list_t temp; + temp = *p->next; + *p = temp; + } else { + p->data = NULL; + } } else { prev->next = p->next; } /* if(p != saved_l) - xfree(p);*/ /* Never free the root element. */ + free(p);*/ /* Never free the root element. */ return; } prev = p; |
From: Peep P. <so...@us...> - 2004-06-14 20:57:05
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22357 Modified Files: lex.l Log Message: __VERSION__ and __ARCH__ now do stringdup. Index: lex.l =================================================================== RCS file: /cvsroot/agd/server/src/lex.l,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- lex.l 8 Jun 2004 20:44:53 -0000 1.16 +++ lex.l 14 Jun 2004 20:56:56 -0000 1.17 @@ -72,7 +72,7 @@ *string_buf_ptr = '\0'; yylval.str = stringdup(string_buf); BEGIN(INITIAL); - RET(s, string_buf, L_STRING); + RET(s, yylval.str, L_STRING); } [ ] STRING_PUTWHITESPACE(1); \t STRING_PUTWHITESPACE(8); @@ -186,11 +186,11 @@ /* fake preprocessor macros */ "__VERSION__" { - yylval.str = PACKAGE_VERSION; + yylval.str = stringdup(PACKAGE_VERSION); RET(s, "__VERSION__", L_STRING); } "__ARCH__" { - yylval.str = PLATFORM; + yylval.str = stringdup(PLATFORM); RET(s, "__ARCH__", L_STRING); } |
From: Peep P. <so...@us...> - 2004-06-14 20:56:49
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22107 Modified Files: lang.y Log Message: Fixed F_INDEX and F_INDEX_LVALUE; removed xfree; removed commented code Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- lang.y 12 Jun 2004 20:51:40 -0000 1.21 +++ lang.y 14 Jun 2004 20:56:38 -0000 1.22 @@ -41,6 +41,7 @@ void do_inc_expr(expr_t *result, expr_t *expr, int op); int add_string_to_table(char *s); +void make_lvalue(int index); %} @@ -108,7 +109,8 @@ %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> constant +%type <expr> expr_open_bracket index_expr %type <expr> fun_call call_other %type <i> block_or_semi @@ -153,7 +155,7 @@ sprintf(buf, "warning: return type defaults to %s", type2str(DEFAULT_FUNCTION_TYPE)); display_error(buf); compile_warnings++; - xfree(buf); + free(buf); } $<id>$ = idp = find_id($2); @@ -186,7 +188,7 @@ char *buf = xmalloc(strlen($2) + 42 /* ;) */); sprintf(buf, "definition doesn't match declaration for %s", $2); comp_error(buf); - xfree(buf); + free(buf); } idp->type = ID_FUN; @@ -224,7 +226,7 @@ char *buf = xmalloc(strlen($2) + 64); sprintf(buf, "warning: repeated prototype for %s; using existing prototype", $2); display_error(buf); - xfree(buf); + free(buf); compile_warnings++; } else { add_function(idp, $<i>7/*, NULL*/); @@ -465,22 +467,30 @@ } ; +expr_open_bracket: + expr '[' + { + $$ = $1; + make_lvalue(curr_fun->codelen - 2); + } + ; + index_expr: /* XXX - first expr must be indexable */ - expr '[' expr ']' + expr_open_bracket expr ']' { - $$.side_effect = $1.side_effect || $3.side_effect; + $$.side_effect = $1.side_effect || $2.side_effect; $$.direct_type = 0; $$.lval = 1; - if($3.type != T_INT && $3.type != T_ANY) { + if($2.type != T_INT && $2.type != T_ANY) { comp_error("index must be integer"); } $$.type = T_INT; add_token(F_INDEX); } - | expr '[' expr L_RANGE expr ']' + | expr_open_bracket expr L_RANGE expr ']' { - $$.side_effect = $1.side_effect || $3.side_effect || $5.side_effect; + $$.side_effect = $1.side_effect || $2.side_effect || $4.side_effect; $$.direct_type = 0; $$.lval = 1; $$.type = T_STRING; @@ -587,8 +597,8 @@ buf = xmalloc(strlen($1) + 25); sprintf(buf, "undeclared identifier '%s'", $1); comp_error(buf); - xfree(buf); - xfree($1); /* WATCH OUT */ + free(buf); + free($1); /* WATCH OUT */ } } ; @@ -620,14 +630,7 @@ statements: /* empty */ - {/* $$ = num_locals_pushed = malloc(sizeof(int)); - *num_locals_pushed = 0; - printf("empty statements. num_locals_pushed: %p (value = %d)\n", num_locals_pushed, *num_locals_pushed);*/ - } - | statements { -/* $$ = $1; - printf("statements and another statement reached. num_locals_pushed: %p (value=%d); $$: %p\n", num_locals_pushed, *num_locals_pushed, $$);*/ - } statement + | statements statement ; arguments: @@ -681,7 +684,7 @@ } $$ = $1; - xfree($2); + free($2); } ; @@ -696,7 +699,7 @@ buf = xmalloc(strlen($1) + 51); sprintf(buf, "warning: declaration of %s shadows function argument", $1); display_error(buf); - xfree(buf); + free(buf); compile_warnings++; } else if(id->type == ID_DFUN) { redeclaration_error(id, ID_LVAR); @@ -769,6 +772,9 @@ string_con2: L_STRING + { + $$ = $1; + } | string_con2 L_STRING { $$ = xmalloc(strlen($1) + strlen($2) + 1); @@ -850,15 +856,6 @@ { 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)); - array_concat(&$$, &$6.arr); - array_push(&$$, (void *) F_JMPF); - array_push(&$$, (void *) ($3.length + 3)); - array_concat(&$$, &$3); - array_push(&$$, (void *) F_JMP); - array_push(&$$, (void *) -($3.length + $6.arr.length + 3));*/ break_allowed = continue_allowed = 0; } @@ -895,15 +892,6 @@ } */ -/* 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; -*/ } ; @@ -973,21 +961,7 @@ } } - init_array(&$$); - / * first expr. * / - array_concat(&$$, &$3.arr); - / * condition expr. * / - array_concat(&$$, &$5.arr); - array_push(&$$, (void *) F_JMPF); - array_push(&$$, (void *) ($7.arr.length + $10.length + 3)); - - / * Third expression - after every loop. * / - array_concat(&$$, &$7.arr); - / * Statements. * / - array_concat(&$$, &$10); - array_push(&$$, (void *) F_JMP); - array_push(&$$, (void *) -($10.length + $7.arr.length + + $5.arr.length + 3));*/ - break_allowed = continue_allowed = 0; + break_allowed = continue_allowed = 0;*/ } ; @@ -1038,12 +1012,12 @@ buf = xmalloc(strlen($1->name) + 23); sprintf(buf, "too many arguments to %s", $1->name); comp_error(buf); - xfree(buf); + free(buf); } 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); + free(buf); } else { for(i=0;i<$1->num_arg;i++) { if($1->args[i] != T_ANY && $3.data[i] != T_ANY @@ -1056,7 +1030,7 @@ sprintf(buf, "argument %d type mismatch for %s - expected %s, got %s", i+1, $1->name, ts1, ts2); comp_error(buf); - xfree(buf); + free(buf); break; } } @@ -1122,7 +1096,7 @@ void make_lvalue(int index) { int replace; - + /* Turn it into a lvalue. */ switch(curr_fun->code[index]) { case F_PUSH_LVAR: @@ -1131,11 +1105,19 @@ 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; + default: + index++; + switch(curr_fun->code[index]) { + case F_INDEX: + replace = F_INDEX_LVALUE; + break; + case F_SLICE: + replace = F_SLICE_LVALUE; + comp_error("assigning to slices not implemented"); + break; + default: + return; + } break; } curr_fun->code[index] = replace; |
From: Peep P. <so...@us...> - 2004-06-14 20:55:52
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21421 Modified Files: interpret.c Log Message: F_INDEX and F_INDEX_LVALUE work, and with all operators; removed xfree Index: interpret.c =================================================================== RCS file: /cvsroot/agd/server/src/interpret.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- interpret.c 12 Jun 2004 20:51:40 -0000 1.23 +++ interpret.c 14 Jun 2004 20:55:42 -0000 1.24 @@ -83,10 +83,10 @@ do_write(buf); net_disconnect(this_player); } - xfree(buf); + free(buf); if(free_str) - xfree(s); + free(s); /* stack_trace();*/ @@ -277,7 +277,7 @@ #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", 0); \ - if(arg[1] >= strlen(sp[-1].u.s) || arg[1] < 0 || arg[1] > arg[0]) runtime("substring out of range", 0); \ + if(arg[1] >= strlen(sp[-1].u.s)+1 || 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; @@ -302,8 +302,13 @@ break; case F_PUSH_STRING: cp++; - tmps = this_ob->prog->str_tbl[*cp]; - push_string(tmps, ST_STATIC); + if(*cp == -1) + tmps = NULL; + else + tmps = this_ob->prog->str_tbl[*cp]; + if(tmps) + tmps = stringdup(tmps); + push_string(tmps, ST_MALLOC); break; case F_PUSH_VOID: push_void(); @@ -358,20 +363,31 @@ 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); + if(sp[-2].type == T_CHAR_PTR) { + tmpvp = sp-2; + tmpvp->u.s[0] += sp[-1].u.i; + pop_stack(); pop_stack(); + push_int(*tmpvp->u.s); + } else { + 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; + if(sp[-2].type == T_CHAR_PTR) { + tmpi = sp[-2].u.s[0] - sp[-1].u.i; + } else { + 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; @@ -380,9 +396,13 @@ 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; + if(sp[-2].type == T_CHAR_PTR) { + tmpi = sp[-2].u.s[0] * sp[-1].u.i; + } else { + 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; @@ -393,11 +413,16 @@ 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; + + if(sp[-2].type == T_CHAR_PTR) { + tmpi = sp[-2].u.s[0] / sp[-1].u.i; + } else { + 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; @@ -408,62 +433,92 @@ 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; + if(sp[-2].type == T_CHAR_PTR) { + tmpi = sp[-2].u.s[0] % sp[-1].u.i; + } else { + 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_ASSIGN: - do_assign(sp[-2].u.v, sp-1); + if(sp[-2].type == T_CHAR_PTR) { + /* Work of F_INDEX_LVALUE. */ + *sp[-2].u.s = sp[-1].u.i; + } else { + do_assign(sp[-2].u.v, sp-1); + } do_assign(&tmpv, sp-1); pop_stack(); pop_stack(); push_var(&tmpv); break; case F_POSTINC: - tmpvp = sp[-1].u.v; - tmpi = tmpvp->u.i++; + if(sp[-1].type == T_CHAR_PTR) { + tmpi = *sp[-1].u.s; + ++*sp[-1].u.s; + } else { + tmpvp = sp[-1].u.v; + tmpi = tmpvp->u.i++; + } pop_stack(); push_int(tmpi); break; case F_PREINC: - tmpvp = sp[-1].u.v; - tmpi = ++tmpvp->u.i; + if(sp[-1].type == T_CHAR_PTR) { + tmpi = ++*sp[-1].u.s; + } else { + tmpvp = sp[-1].u.v; + tmpi = ++tmpvp->u.i; + } pop_stack(); push_int(tmpi); break; case F_POSTDEC: - tmpvp = sp[-1].u.v; - tmpi = tmpvp->u.i--; + if(sp[-1].type == T_CHAR_PTR) { + tmpi = *sp[-1].u.s; + --*sp[-1].u.s; + } else { + tmpvp = sp[-1].u.v; + tmpi = tmpvp->u.i--; + } push_int(tmpi); break; case F_PREDEC: - tmpvp = sp[-1].u.v; - tmpi = --tmpvp->u.i; + if(sp[-1].type == T_CHAR_PTR) { + tmpi = --*sp[-2].u.s; + } else { + tmpvp = sp[-1].u.v; + tmpi = --tmpvp->u.i; + } push_int(tmpi); break; case F_INDEX: arg[0] = sp[-1].u.i; pop_stack(); + tmpvp = sp[-1].u.v; + pop_stack(); - if(sp[-1].type & T_ARRAY) { - if(!sp[-1].u.a) { + if(tmpvp->type & T_ARRAY) { + if(!tmpvp->u.a) { runtime("taking element of null array", 0); } - if(arg[0] >= sp[-1].u.a->length || arg[0] < 0) { + if(arg[0] < 0 || arg[0] >= tmpvp->u.a->length) { runtime("index out of range", 0); } - tmpvp = sp[-1].u.a->data[arg[0]]; - pop_stack(); + tmpvp = tmpvp->u.a->data[arg[0]]; push_var(tmpvp); } else { - if(!sp[-1].u.s) { + if(!tmpvp->u.s) { runtime("taking element of null string", 0); } - arg[1] = sp[-1].u.s[arg[0]]; - pop_stack(); + if(arg[0] < 0 || arg[0] > strlen(tmpvp->u.s)+1) { + runtime("index out of range", 0); + } + arg[1] = tmpvp->u.s[arg[0]]; push_int(arg[1]); } break; @@ -471,14 +526,26 @@ /* A bit hacky. */ arg[0] = sp[-1].u.i; pop_stack(); - if(!sp[-1].u.s) { + tmpvp = sp[-1].u.v; + pop_stack(); + + tmps = tmpvp->u.s; + if(!tmps) { runtime("taking element of null string", 0); } - do_assign(sp, &sp[-1]); + if(arg[0] < 0 || arg[0] > strlen(tmps)+1) { + runtime("index out of range", 0); + } + + sp->type = T_CHAR_PTR; + sp->u.s = tmps + arg[0]; + sp++; + CHECK_SP() +/* do_assign(sp, &sp[-1]); sp->u.s += arg[0]; pop_stack(); push_var(sp+1); - push_lvalue(sp-1); + push_lvalue(sp-1);*/ break; case F_SLICE: TAKE_SLICE() @@ -598,7 +665,6 @@ SETUP_FRAME(); fp = sp + 1; sp = fp + 1; - show_stack(); call_function(tmpv.u.ob, tmpi); goto again; break; |
From: Peep P. <so...@us...> - 2004-06-14 20:54:48
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20519 Modified Files: dfuns.c Log Message: input_to checks for this_player. Index: dfuns.c =================================================================== RCS file: /cvsroot/agd/server/src/dfuns.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- dfuns.c 12 Jun 2004 16:47:06 -0000 1.21 +++ dfuns.c 14 Jun 2004 20:54:30 -0000 1.22 @@ -89,8 +89,15 @@ void df_input_to(void) { - this_player->input_to = fp->u.s; - this_player->input_to_called = 0; + if(this_player) { + this_player->input_to = stringdup(fp->u.s); + this_player->input_to_called = 0; + } +#ifdef DEBUG + else { + debug("input_to", "input_to() called on non-interactive object\n"); + } +#endif pop_stack(); push_void(); } @@ -217,7 +224,7 @@ { char *ret; if(fp->u.ob && fp->u.ob->name) - ret = fp->u.ob->name; + ret = stringdup(fp->u.ob->name); else ret = "<NULL>"; pop_stack(); |
From: Peep P. <so...@us...> - 2004-06-14 20:54:22
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20284 Modified Files: debug.c Log Message: Changed display of F_PUSH_STRING: index -1 means push NULL string. Index: debug.c =================================================================== RCS file: /cvsroot/agd/server/src/debug.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- debug.c 12 Jun 2004 20:18:00 -0000 1.16 +++ debug.c 14 Jun 2004 20:54:13 -0000 1.17 @@ -225,9 +225,13 @@ break; case F_PUSH_STRING: i++; - printf("%d (", code[i]); - puts_nonl(prog->str_tbl[code[i]]); - putchar(')'); + if(code[i] == -1) { + printf("NULL"); + } else { + printf("%d (", code[i]); + puts_nonl(prog->str_tbl[code[i]]); + putchar(')'); + } break; case F_PUSH_ARRAY: num = code[++i]; |
From: Peep P. <so...@us...> - 2004-06-14 20:53:59
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19970 Modified Files: compile.c Log Message: Removed commented and unused code; removed xfree. Index: compile.c =================================================================== RCS file: /cvsroot/agd/server/src/compile.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- compile.c 12 Jun 2004 20:06:08 -0000 1.25 +++ compile.c 14 Jun 2004 20:53:49 -0000 1.26 @@ -23,14 +23,6 @@ int compile_errors, compile_warnings; -#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, @@ -57,59 +49,6 @@ return h; } -#if 0 -/* define_id functions. */ -def_id_t *define_id(char *name, int type, int lpc_type, int *args, int numarg) -{ - def_id_t *idp; - - idp = xmalloc(sizeof(def_id_t)); - if(type == ID_DFUN) { - num_global_ids++; - global_ids = xrealloc(global_ids, num_global_ids * sizeof(def_id_t*)); - global_ids[num_global_ids - 1] = idp; - } else { - num_local_ids++; - local_ids = xrealloc(local_ids, num_local_ids * sizeof(def_id_t*)); - local_ids[num_local_ids - 1] = idp; - } - - idp->name = stringdup(name); - idp->type = type; - idp->lpc_type = lpc_type; - idp->args = args; - idp->numarg = numarg; - idp->base_scope = scope_level; - switch(type) { - case ID_ARG: - case ID_LVAR: - idp->index = numlvars; - numlvars++; - break; - case ID_GVAR: - idp->index = numgvars; - numgvars++; - break; - case ID_FUN_PROT: - case ID_FUN: - idp->index = numlfuns; - numlfuns++; - break; - case ID_DFUN: - idp->index = numdfuns; - numdfuns++; - break; - } - -#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; -} -#endif - int assign_index(int type) { switch(type) { @@ -173,7 +112,7 @@ } buf = strcat(buf, buf2); comp_error(buf); - xfree(buf); + free(buf); } int redeclaration_allowed(def_id_t *target, int type) @@ -186,6 +125,7 @@ return 1; } + def_id_t *define_id(char *name, int type, int lpc_type, int *args, int num_arg) { unsigned hash; @@ -210,8 +150,10 @@ redeclaration_error(target, type); return; } - - printf("hash collision! \"%s\" && \"%s\" == %d!\n", name, target->name, hash); + +#ifdef DEBUG + debug("define_id", "hash collision! \"%s\" && \"%s\" == %d!\n", name, target->name, hash); +#endif temp = *elem; @@ -263,47 +205,18 @@ 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; - int i; - - /* First search in local_ids. */ - for(i=0;i<num_local_ids;i++) { - idp = local_ids[i]; - if(idp->base_scope == -1) { - continue; - } - if(!strcmp(name, idp->name)) - return idp; - } + /* First look in global table. */ + idp = find_elem(gid_tbl, GLOBAL_HASH_SIZE, hash); + if(idp) + return idp; - /* Then global_ids. */ - for(i=0;i<num_global_ids;i++) { - idp = global_ids[i]; - if(idp->base_scope == -1) { - continue; - } - if(!strcmp(name, idp->name)) - return idp; - } return NULL; } -#endif #if 0 void pop_scope() @@ -333,9 +246,9 @@ break; } - xfree(id->name); + free(id->name); if(id->args) - xfree(id->args); + free(id->args); } } } @@ -351,10 +264,10 @@ idp = tbl[i].data; if(idp->base_scope > scope_level) { unassign_index(idp->type); - xfree(idp->name); + free(idp->name); if(idp->args) - xfree(idp->args); - xfree(idp); + free(idp->args); + free(idp); if(tbl[i].next) { list_t *temp; @@ -510,13 +423,16 @@ function_t *f; f = this_prog->functions[idp->index]; f->type = idp->lpc_type; - f->args = idp->args; f->num_arg = idp->num_arg; + f->args = xmalloc(sizeof(int) * f->num_arg); + memcpy(f->args, idp->args, f->num_arg); f->lineno = lineno; } else { curr_fun_check(); curr_fun->type = idp->lpc_type; - curr_fun->args = idp->args; + curr_fun->num_arg = idp->num_arg; + curr_fun->args = xmalloc(sizeof(int) * curr_fun->num_arg); + memcpy(curr_fun->args, idp->args, curr_fun->num_arg); curr_fun->lineno = lineno; this_prog->numfunc++; @@ -556,13 +472,14 @@ v = &this_ob->globals[this_ob->numglobals-1]; v->name = name; v->type = lpc_type; + init_var(v); } else /* LVAR */{ - if(type & T_ARRAY) { + if(lpc_type & T_ARRAY) { add_token(F_PUSH_ARRAY); add_two_tokens(T_VOID, 0); - } else switch(type & ~T_ARRAY) { + } else switch(lpc_type & ~T_ARRAY) { case T_INT: add_two_tokens(F_PUSH_INT, 0); break; - case T_STRING: add_two_tokens(F_PUSH_STRING, 0); break; + case T_STRING: add_two_tokens(F_PUSH_STRING, -1); break; case T_OBJECT: add_token(F_PUSH_NULL_OBJECT); break; } } @@ -625,7 +542,7 @@ sprintf(buf, "function %s has been called, " "but not defined", id->name); comp_error(buf); - xfree(buf); + free(buf); return 1; } @@ -693,13 +610,13 @@ compile_warnings == 1 ? "": "s"); } printf(" - failed\n"); - xfree(this_prog); + free(this_prog); prog = NULL; goto out; } if(check_fun_definitions()) { - xfree(this_prog); + free(this_prog); prog = NULL; goto out; } @@ -729,7 +646,7 @@ out: this_prog = NULL; this_file = NULL; - xfree(real_path); + free(real_path); start_with_newline = 0; return prog; } |
From: Peep P. <so...@us...> - 2004-06-14 20:48:18
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15271 Modified Files: vars.c sys.h sys.c net.c array.c Log Message: Removed xfree. Index: sys.h =================================================================== RCS file: /cvsroot/agd/server/src/sys.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- sys.h 8 Jun 2004 20:44:53 -0000 1.10 +++ sys.h 14 Jun 2004 20:48:08 -0000 1.11 @@ -4,12 +4,6 @@ /* memory allocation */ void *xmalloc(size_t bytes); void *xrealloc(void *ptr, size_t bytes); -#ifdef DEBUG -void xfree(void *p); -#else -#define xfree free -#endif - /* configuration */ typedef struct { Index: net.c =================================================================== RCS file: /cvsroot/agd/server/src/net.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- net.c 12 Jun 2004 20:09:13 -0000 1.17 +++ net.c 14 Jun 2004 20:48:08 -0000 1.18 @@ -112,7 +112,7 @@ if(!login_ob->u.ob) { fprintf(stderr, "Warning: master::connect() didn't return an object.\n"); do_write("Oops, glitch in world fabric - you didn't get a login object.\n"); - xfree(player_ob); + free(player_ob); net_disconnect(p); return; } @@ -124,9 +124,9 @@ 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); + debug("net_accept", "player object was changed to %p (%s); freeing player_ob %p (%s)\n", p->ob, p->ob->name, player_ob, player_ob->name); /* player_ob is not needed anymore if we get this far. */ - xfree(player_ob); + free(player_ob); } void net_disconnect(player_t *p) @@ -163,6 +163,7 @@ char *c; if(!p->input_to) { + debug("net", "player %p (with iaob %s) doesn't have input_to set\n", p->ob? p->ob->name :NULL, p); goto out; } Index: sys.c =================================================================== RCS file: /cvsroot/agd/server/src/sys.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- sys.c 8 Jun 2004 20:44:53 -0000 1.15 +++ sys.c 14 Jun 2004 20:48:08 -0000 1.16 @@ -116,19 +116,6 @@ return p; } -#ifdef DEBUG - /* Quite useless. */ -void xfree(void *p) -{ - if(!p) { - fprintf(stderr, "free() called on a nullpointer!\n"); - return; - } - - free(p); -} -#endif - int legal_path(char *fn) { char *p; Index: array.c =================================================================== RCS file: /cvsroot/agd/server/src/array.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- array.c 8 Jun 2004 20:23:06 -0000 1.14 +++ array.c 14 Jun 2004 20:48:08 -0000 1.15 @@ -27,11 +27,11 @@ { int i; if(!freefun) - freefun = (void(*)(variable_t*))xfree; /* free_var? */ + freefun = (void(*)(variable_t*))free; /* free_var? */ for(i=0;i<a->length;i++) freefun(a->data[i]); if(a->length) - xfree(a->data); + free(a->data); init_array(a); } Index: vars.c =================================================================== RCS file: /cvsroot/agd/server/src/vars.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- vars.c 8 Jun 2004 20:44:53 -0000 1.14 +++ vars.c 14 Jun 2004 20:48:08 -0000 1.15 @@ -16,8 +16,9 @@ unref_ob(v->u.ob, v); break; case T_STRING: - if(v->string_type != ST_STATIC) - xfree(v->u.s); + if(v->string_type != ST_STATIC) { + free(v->u.s); + } break; } } @@ -138,7 +139,7 @@ buf = xmalloc(256); sprintf(buf, "%d", v1->u.i); buf2 = xmalloc(strlen(v2->u.s) + strlen(buf) + 1); - xfree(buf); + free(buf); sprintf(buf2, "%d%s", v1->u.i, v2->u.s); ret->type = T_STRING; ret->u.s = buf2; @@ -168,7 +169,7 @@ buf = xmalloc(256); sprintf(buf, "%d", v2->u.i); buf2 = xmalloc(strlen(v1->u.s) + strlen(buf) + 1); - xfree(buf); + free(buf); sprintf(buf2, "%s%d", v1->u.s, v2->u.i); ret->type = T_STRING; ret->u.s = buf2; @@ -206,7 +207,7 @@ printf("add_vars(): type %d vs %d; type %d is unknown\n", v1->type, v2->type, v1->type); break; } - xfree(ret); + free(ret); return NULL; } #if 0 |
From: Peep P. <so...@us...> - 2004-06-12 20:51:49
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8452 Modified Files: interpret.c lang.y Log Message: Fixed call_other. Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- lang.y 12 Jun 2004 20:08:46 -0000 1.20 +++ lang.y 12 Jun 2004 20:51:40 -0000 1.21 @@ -1090,6 +1090,10 @@ index = add_string_to_table($3); add_token(F_CALL_OTHER); add_two_tokens(index, $5.len); + /* We can't remove the object from the stack + since it's before the arguments - that's + why this pop is necessary. */ + add_token(F_POP); } ; Index: interpret.c =================================================================== RCS file: /cvsroot/agd/server/src/interpret.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- interpret.c 12 Jun 2004 20:06:55 -0000 1.22 +++ interpret.c 12 Jun 2004 20:51:40 -0000 1.23 @@ -575,9 +575,7 @@ case F_CALL_OTHER: cp++; tmps = this_ob->prog->str_tbl[*cp]; - printf("cp: %d; tmps: %s\n", *cp, tmps); cp++; - printf("numarg: %d\n", *cp); sp -= *cp + 1; if(sp->type == T_OBJECT) { tmpv.u.ob = sp->u.ob; /* A little hack so we don't @@ -595,10 +593,12 @@ } tmpi = get_fun_index(tmpv.u.ob, tmps); - free_var(sp); if(tmpi == -1) runtime("function doesn't exist", 0); SETUP_FRAME(); + fp = sp + 1; + sp = fp + 1; + show_stack(); call_function(tmpv.u.ob, tmpi); goto again; break; |
From: Peep P. <so...@us...> - 2004-06-12 20:18:09
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5282 Modified Files: debug.c Log Message: Really, really fixed displaying of call_other num_arg. Index: debug.c =================================================================== RCS file: /cvsroot/agd/server/src/debug.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- debug.c 12 Jun 2004 20:06:29 -0000 1.15 +++ debug.c 12 Jun 2004 20:18:00 -0000 1.16 @@ -250,7 +250,7 @@ printf("fun %d (", code[i]); puts_nonl(prog->str_tbl[code[i]]); num = code[++i]; - printf(") num_arg: %d", s, num); + printf(") num_arg: %d", num); break; case F_PUSH_LVAR: case F_PUSH_LVAR_LVALUE: |
From: Peep P. <so...@us...> - 2004-06-12 20:15:06
|
Update of /cvsroot/agd/server/lib/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2000 Modified Files: master.c Log Message: Doesn't store banner in global variable anymore. Index: master.c =================================================================== RCS file: /cvsroot/agd/server/lib/sys/master.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- master.c 7 Jun 2004 15:54:56 -0000 1.14 +++ master.c 12 Jun 2004 20:14:57 -0000 1.15 @@ -1,6 +1,5 @@ -string banner; int biggest; - + int crash(int signal) { if(signal == 11) { shout("Driver shutting down - " @@ -16,9 +15,9 @@ } void write_version() { - string b; - b = read_file("/doc/login/" + random(biggest)); - write(b + banner); + write(read_file("/doc/login/" + random(biggest))); + write("\n\t" + __VERSION__ + " / " + __ARCH__ + "\n" + + "\thttp://agd.sf.net\n\tag...@li...\n"); } object connect() { @@ -29,11 +28,8 @@ } void create(void) { - int *a; +// int *a; /* a = ({ 1, 2, 3 }); write("a[0]: " + a[0] + "\n");*/ - - banner = "\n\t" + __VERSION__ + " / " + __ARCH__ + "\n" - + "\thttp://agd.sf.net\n\tag...@li...\n"; biggest = atoi(read_file("/doc/login/biggest")); } |
From: Peep P. <so...@us...> - 2004-06-12 20:13:21
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32118 Modified Files: TODO ChangeLog Log Message: Self-documenting changes. Index: TODO =================================================================== RCS file: /cvsroot/agd/server/TODO,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- TODO 12 Jun 2004 16:48:28 -0000 1.21 +++ TODO 12 Jun 2004 20:13:12 -0000 1.22 @@ -2,17 +2,16 @@ '!' means first-priority, '?' means trivial and not really important. - ! new interpreter! - Interpreter. - - runtime() for dfuns (doesn't display line numbers) + - F_PUSH_NUM_INT <constant> <number> + - F_POP_N <number> - pops <number> elements off the stack + - 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 - 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 Index: ChangeLog =================================================================== RCS file: /cvsroot/agd/server/ChangeLog,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- ChangeLog 8 Jun 2004 20:50:40 -0000 1.19 +++ ChangeLog 12 Jun 2004 20:13:12 -0000 1.20 @@ -1,5 +1,10 @@ 0.0.3: ---------------------------------------------------------------------------- +2004-06-12 + * lang.y: lvalues work again + * lang.y: removed the hacky rules to have statements without semicolons; + do_while now uses expr instead of statement, so do..while without a + semicolon is still possible 2004-06-08 * compile.c: redeclaration is now more sane. Also fixed crasher in redeclaration_error() - didn't allocate enough space for strcat() |
From: Peep P. <so...@us...> - 2004-06-12 20:12:35
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31200 Modified Files: object.c Log Message: Added brackets, trivial. Index: object.c =================================================================== RCS file: /cvsroot/agd/server/src/object.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- object.c 8 Jun 2004 20:44:53 -0000 1.15 +++ object.c 12 Jun 2004 20:12:24 -0000 1.16 @@ -91,8 +91,9 @@ /* free_array(&ob->globals, (void (*)(void*)) free_var); */ /* WTF? */ - if(ob->name) + if(ob->name) { xfree(ob->name); + } xfree(ob); } |
From: Peep P. <so...@us...> - 2004-06-12 20:09:21
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28089 Modified Files: net.c Log Message: Remove destructed object from to_be_dested list after destructing. Index: net.c =================================================================== RCS file: /cvsroot/agd/server/src/net.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- net.c 8 Jun 2004 20:44:53 -0000 1.16 +++ net.c 12 Jun 2004 20:09:13 -0000 1.17 @@ -16,7 +16,7 @@ #include "net.h" #include "interpret.h" -#define LOOP_PLAYERS() for(l=&players;l->next;l=l->next) { player_t *pl = l->data; +#define LOOP_PLAYERS() for(l=&players;l&&(l->data||l->next);l=l->next) { player_t *pl = l->data; list_t players; @@ -100,7 +100,8 @@ this_player = p; player_ob = xmalloc(sizeof(object_t)); player_ob->iaob = p; - player_ob->name = "NONE"; /* So find_object() won't barf. */ + /* So find_object() won't barf. Have to copy because it will be freed. */ + player_ob->name = stringdup("LOGIN"); player_ob->prog = NULL; this_ob = p->ob = player_ob; @@ -221,8 +222,16 @@ for(p = &to_be_dested; p; p=p->next) { object_t *ob = p->data; - if(ob->flags & O_DESTRUCTED) + if(ob->flags & O_DESTRUCTED) { + if(p->next) { + list_t temp = *p->next; + *p = temp; + } else { + p->data = NULL; + } + actual_destruct(ob); + } } } |
From: Peep P. <so...@us...> - 2004-06-12 20:08:55
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27569 Modified Files: lang.y Log Message: Now pops locals after leaving a block. Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- lang.y 12 Jun 2004 16:44:22 -0000 1.19 +++ lang.y 12 Jun 2004 20:08:46 -0000 1.20 @@ -1,6 +1,5 @@ %{ -/* TODO: pop locals after returning from block */ #include <stdlib.h> #include "config.h" #include "compile_options.h" @@ -30,6 +29,9 @@ continue_allowed, is_new_declaration; +static int num_locals_pushed, + dont_add_pop; + extern int scope_level; extern program_t *this_prog; extern function_t *curr_fun; @@ -102,7 +104,7 @@ %type <str> var_def %type <arr> call_args call_arg_list -%type <expr> expr/* expr1 expr2 lvalue*/ +%type <expr> expr %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 @@ -177,7 +179,9 @@ block_or_semi { if($8) { + int dont_warn = 0; def_id_t *idp = $<id>3; + if(idp->lpc_type != $1/* || compare_args(idp->args, &$5) FIXME!*/) { char *buf = xmalloc(strlen($2) + 42 /* ;) */); sprintf(buf, "definition doesn't match declaration for %s", $2); @@ -185,10 +189,9 @@ xfree(buf); } idp->type = ID_FUN; - /* 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) { + switch(curr_fun_type) { case T_INT: add_two_tokens(F_PUSH_INT, 0); break; @@ -200,16 +203,19 @@ break; case T_VOID: add_token(F_PUSH_VOID); + dont_warn = 1; + break; default: - warn = 0; + printf("curr_fun_type unknown! (%d)\n", curr_fun_type); break; } + add_token(F_RETURN); - if(warn) { + if(!dont_warn) { comp_warning("control reaches end of non-void function"); } } - + add_function(idp, $<i>3/*, &$8*/); curr_fun_type = 0; } else { @@ -483,43 +489,6 @@ } ; -/* -lvalue: - expr2 '[' expr ']' - { - if($3.type != T_INT && $3.type != T_ANY) { - comp_error("index must be integer"); - } - $$.type = T_INT; - add_token(F_INDEX); - } - | expr2 '[' expr L_RANGE expr ']' - { - $$.type = T_STRING; - add_token(F_SLICE); - } - | defined_name - { - $$.side_effect = $$.direct_type = 0; - $$.type = 0; - - if($1) { - if($1->type == ID_GVAR) - add_token(F_PUSH_GVAR_LVALUE); - else if($1->type == ID_LVAR || $1->type == ID_ARG) - add_token(F_PUSH_LVAR_LVALUE); - else { - comp_error("variable expected"); - } - - add_token($1->index); - $$.type = $1->lpc_type; - } - } - | error ';' { comp_error("invalid lvalue"); } - ; -*/ - expr_list: /* empty */ { @@ -571,10 +540,23 @@ '{' { scope_level++; - /*new_block_level();*/ + $<i>$ = num_locals_pushed; + num_locals_pushed = 0; } statements '}' { + int i; + int num; + /* Don't want F_POP after F_RETURN. */ + if(!dont_add_pop) { + num = $<i>2 + num_locals_pushed; + num_locals_pushed = 0; + for(i=0;i<num;i++) + add_token(F_POP); + } else { + dont_add_pop = 0; + num_locals_pushed = 0; + } pop_scope(); } ; @@ -614,21 +596,17 @@ statement: block | stmt_no_semi ';' - | stmt_no_semi_at_all - ; - -stmt_no_semi_at_all: - if + | if | while | for ; - + stmt_no_semi: return | do_while | break | continue - | local_var {/* num_locals++;*/ } + | local_var | expr { if($1.side_effect) { @@ -640,22 +618,27 @@ | /* 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 + {/* $$ = num_locals_pushed = malloc(sizeof(int)); + *num_locals_pushed = 0; + printf("empty statements. num_locals_pushed: %p (value = %d)\n", num_locals_pushed, *num_locals_pushed);*/ + } + | statements { +/* $$ = $1; + printf("statements and another statement reached. num_locals_pushed: %p (value=%d); $$: %p\n", num_locals_pushed, *num_locals_pushed, $$);*/ + } statement ; arguments: /* empty */ - { $$.len = 0; } + { + $$.data = NULL; + $$.len = 0; + } | L_DATA_TYPE { + $$.data = NULL; $$.len = 0; if($1 != T_VOID) { comp_error("syntax error"); @@ -730,12 +713,16 @@ lvar_def: var_def - { add_variable($1, global_type, ID_LVAR); } + { + add_variable($1, global_type, ID_LVAR); + num_locals_pushed++; + } | var_def '=' { def_id_t *idp; idp = add_variable($1, global_type, ID_LVAR); add_two_tokens(F_PUSH_LVAR_LVALUE, idp->index); + num_locals_pushed++; } expr { @@ -822,6 +809,8 @@ if(!$2.type) add_token(F_PUSH_VOID); add_token(F_RETURN); + + dont_add_pop = 1; } ; @@ -831,7 +820,7 @@ add_two_tokens(F_JUMP_IF_FALSE, 0); $<i>$ = curr_fun->codelen - 1; } - stmt_no_semi_or_block + statement { add_two_tokens(F_JUMP, 0); curr_fun->code[$<i>5] = curr_fun->codelen - $<i>5; @@ -848,16 +837,16 @@ else: /* empty */ - | L_ELSE stmt_no_semi_or_block + | L_ELSE statement ; do_while: 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 ')' + { + break_allowed = continue_allowed = /*1*/ 0; /* For now. */ + $<i>$ = curr_fun ? curr_fun->codelen : 0; + } + expr L_WHILE '(' expr ')' { add_two_tokens(F_JUMP_IF_FALSE, 3); add_two_tokens(F_JUMP, $<i>2 - curr_fun->codelen - 1); @@ -919,13 +908,13 @@ ; for: - L_FOR '(' expr ';' + L_FOR '(' optional_expr ';' { if($3.side_effect) add_token(F_POP); $<i>$ = curr_fun->codelen; } - expr + optional_expr { if($6.side_effect) add_token(F_POP); @@ -937,7 +926,7 @@ $<ptr>$ = curr_fun; curr_fun = NULL; } - expr + optional_expr { if($10.side_effect) add_token(F_POP); |
From: Peep P. <so...@us...> - 2004-06-12 20:07:04
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25937 Modified Files: interpret.c Log Message: Added codelen to csp. Index: interpret.c =================================================================== RCS file: /cvsroot/agd/server/src/interpret.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- interpret.c 12 Jun 2004 16:46:33 -0000 1.21 +++ interpret.c 12 Jun 2004 20:06:55 -0000 1.22 @@ -245,6 +245,7 @@ csp->sp = sp; csp->cp = cp; csp->code = code; + csp->codelen = codelen; csp++; CHECK_CSP() } @@ -261,6 +262,7 @@ sp = csp->sp; cp = csp->cp; code = csp->code; + codelen = csp->codelen; previous_ob = csp->previous_ob; this_ob = csp->this_ob; @@ -268,7 +270,7 @@ this_player = /*this_ob->iaob*/ csp->this_player; } -/* Used by F_JMP and F_JMPF to check if they jumped too far. */ +/* Used by F_JUMP and F_JUMP_IF_FALSE to check if they jumped too far. */ #define CHECK_OVERRUN() if(cp >= code + codelen) {\ debug("interpret", "Ran over end of array: returning\n"); return; } @@ -573,8 +575,10 @@ case F_CALL_OTHER: cp++; tmps = this_ob->prog->str_tbl[*cp]; + printf("cp: %d; tmps: %s\n", *cp, tmps); cp++; - sp--; + printf("numarg: %d\n", *cp); + sp -= *cp + 1; if(sp->type == T_OBJECT) { tmpv.u.ob = sp->u.ob; /* A little hack so we don't need an object_t variable in this scope. |
From: Peep P. <so...@us...> - 2004-06-12 20:06:37
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25531 Modified Files: debug.c Log Message: Fixed showing call_other num_args Index: debug.c =================================================================== RCS file: /cvsroot/agd/server/src/debug.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- debug.c 12 Jun 2004 16:47:41 -0000 1.14 +++ debug.c 12 Jun 2004 20:06:29 -0000 1.15 @@ -249,6 +249,7 @@ i++; printf("fun %d (", code[i]); puts_nonl(prog->str_tbl[code[i]]); + num = code[++i]; printf(") num_arg: %d", s, num); break; case F_PUSH_LVAR: |