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-07-23 17:21:27
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16447 Modified Files: ChangeLog Ideas TODO Log Message: Chaaanges! Index: TODO =================================================================== RCS file: /cvsroot/agd/server/TODO,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- TODO 21 Jul 2004 12:13:09 -0000 1.24 +++ TODO 23 Jul 2004 17:21:18 -0000 1.25 @@ -12,52 +12,35 @@ while our offset is bigger than the element in line_numbers. If offset is smaller or equal, it means that it must be on the current index. - - profiling memory usage - find out if variables are really freed and if they're being overduplicated or something. - - everything to do with arrays, notably: - operators: & &= - call_other on an array - foreach() - - - dfuns + - dfuns: delete - member_array - explode, implode - save_object, restore_object - crypt - + member_array + explode, implode + save_object, restore_object + crypt - allow 'string foo; foo[0]="a";' - sprintf and printf - - Interpreter. ? F_PUSH_NUM_INT <constant> <number> - < runtime() for dfuns (doesn't display line numbers) - - lang.y: + - runtime() for dfuns (doesn't display line numbers) + - lang.y: ! break, continue ! fix L_SLICE_LVALUE - - < compile.c::compile_prog() should show global vars - < debug.c::print_code() should show functions' arguments - + - compile.c::compile_prog() should show global vars + - debug.c::print_code() should show functions' arguments - Do something about compile.c::pop_scope() - it's slow (well, algorithmically speaking, at least). - - - 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. - + - In config, 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 - - documentation: * Small textbook about AGD's dialect of LPC * Short text describing main differences between LPC and C @@ -66,67 +49,54 @@ - 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? - - - allow both .c and .lpc for file extensions (/usr/bin/file could recognize LPC, - and editors can turn on syntax highlighting automatically) - keep interactive objects in a separate linked list, and make shout act on that list -- LPC: - - switch() - - all of the operators (/doc/lpc/operators) - - ',' - this takes some serious grammar-hacking, because - comma as a function call argument is a separator for expressions. - - mixed type - - string slices - ! assigning to slices (F_SLICE_LVALUE etc.) - - Check if assigning too long a string. - * m.. - * ..n - * m..n,o..p - * !n - - inheritance + - switch() + - all of the operators (/doc/lpc/operators) + - ',' - this takes some serious grammar-hacking, because + comma as a function call argument is a separator for expressions. + - mixed type + - string slices + ! assigning to slices (F_SLICE_LVALUE etc.) + - Check if assigning too long a string. + - m.. + - ..n + - m..n,o..p + - !n + - m..<n + - inheritance - lexer: - - preprocessor (read flex(1)) - a {IDENTIFIER} rule first up in the rule list which goes through all of the macro - definitions and if anything is found, it opens up another buffer (pushes it on - flex's stack), containing the macro replacement, which will then get parsed again. - if no macros match, REJECT() is called and flex tries to match with next available rule - - #pragma - warnings - low-warnings - no-warnings - - #if - - defined() - - have_dfun() - - !, &&, || - - predefined names: - __HOST__ the return value of gethostname() - __AUTHORS__ - - character encoding inside strings: - - decimal: \nnn - - octal: \0nnn - - hexadecimal: \0xnn - - binary: \nnnnnnnnb - - multiline strings (like this: - string s = "@@@FOO - blah - blah - blah - FOO"; - Or however it's done elsewhere. - + - preprocessor (read flex(1)) + an {IDENTIFIER} rule first up in the rule list which goes through all of the macro + definitions and if anything is found, it opens up another buffer (pushes it on + flex's stack), containing the macro replacement, which will then get parsed again. + if no macros match, REJECT() is called and flex tries to match with next available rule + - #pragma + warnings, low-warnings, no-warnings + - #if + - defined() + - have_dfun() + - !, &&, || + - predefined names: + __HOST__ the return value of gethostname() + __AUTHORS__ + - character encoding inside strings: + - decimal: \nnn + - octal: \0nnn + - hexadecimal: \0xnn + - binary: \nnnnnnnnb + - multiline strings (like this: + string s = "@@@FOO + blah + blah + blah + FOO"; + Or however it's done elsewhere. ? 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 - - save to different files - warn about unused variables - initialization of global variables - dfun overrides, :: operator - - ? check for lib root and folder of debug log with access() and exit gracefully if it fails. - ? if we crash while running apply(master::crash), then we should rerun with debugging on + - check for lib root and folder of debug log with access() and exit gracefully if it fails. + - if we crash while running apply(master::crash), then we should rerun with debugging on ? IPv6 support? ? Some work could be done on i18n. For example, allow for multilingual yyerror-messages. Index: Ideas =================================================================== RCS file: /cvsroot/agd/server/Ideas,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Ideas 21 Jul 2004 12:13:09 -0000 1.10 +++ Ideas 23 Jul 2004 17:21:18 -0000 1.11 @@ -5,7 +5,7 @@ each time. Just player() and this() or self() should suffice. environment() -> env() etc, too. * superscope global variables. Maybe called world scope? - i.e. global foo; - then can be accessed from any object. + i.e. global int foo; - then can be accessed from any object. And this_object/this_player are driver-defined world globals. * default values for arguments int foo(int i, int j = 1); Index: ChangeLog =================================================================== RCS file: /cvsroot/agd/server/ChangeLog,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- ChangeLog 23 Jul 2004 14:25:10 -0000 1.23 +++ ChangeLog 23 Jul 2004 17:21:18 -0000 1.24 @@ -3,6 +3,10 @@ 2004-07-23 * dflex.l,lex.l,compile.c: added manual 'extern YYLTYPE yylloc' declarations, which seem to be necessary with older version of bison. + * instr.h,lex.l,lang.y,interpret.c: bitwise operators + * dfuns.c: dfun names were stored in *local* array, so the name needs + to be strdup'ed. + * main.c: implemented flag() 2004-06-23 * compile.c,lang.y,interpret.c,vars.c: + operator for arrays * compile.c: fixed adding definitions for prototypes - their code wasn't |
|
From: Peep P. <so...@us...> - 2004-07-23 17:21:27
|
Update of /cvsroot/agd/server/doc/lpc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16447/doc/lpc Modified Files: datatypes Log Message: Chaaanges! Index: datatypes =================================================================== RCS file: /cvsroot/agd/server/doc/lpc/datatypes,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- datatypes 20 Mar 2004 19:14:27 -0000 1.2 +++ datatypes 23 Jul 2004 17:21:18 -0000 1.3 @@ -3,11 +3,10 @@ string object void + type * (array type) These should be fully functional everywhere. -Valid, but not implemented types are mixed and type* -(array type). In fact, using arrays can cause severe bugs, -as they are not handled properly yet. +Valid, but not implemented is the mixed type. Data types that I will implement: mapping |
|
From: Peep P. <so...@us...> - 2004-07-23 17:20:38
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16296 Modified Files: Makefile.am Makefile.in Log Message: log.c removed Index: Makefile.in =================================================================== RCS file: /cvsroot/agd/server/src/Makefile.in,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- Makefile.in 8 Jun 2004 20:20:48 -0000 1.13 +++ Makefile.in 23 Jul 2004 17:20:29 -0000 1.14 @@ -126,8 +126,8 @@ 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 \ +debug.c debug.h dfdecl.h dfuns.c dfuns.h interpret.c interpret.h instr.h \ +lex.l lex.h list.c list.h 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@ @@ -142,8 +142,8 @@ am_agd_OBJECTS = array.$(OBJEXT) compile.$(OBJEXT) debug.$(OBJEXT) \ dfuns.$(OBJEXT) interpret.$(OBJEXT) lex.$(OBJEXT) \ - list.$(OBJEXT) log.$(OBJEXT) lang.$(OBJEXT) main.$(OBJEXT) \ - net.$(OBJEXT) sys.$(OBJEXT) vars.$(OBJEXT) object.$(OBJEXT) + list.$(OBJEXT) lang.$(OBJEXT) main.$(OBJEXT) net.$(OBJEXT) \ + sys.$(OBJEXT) vars.$(OBJEXT) object.$(OBJEXT) agd_OBJECTS = $(am_agd_OBJECTS) agd_DEPENDENCIES = agd_LDFLAGS = @@ -160,9 +160,9 @@ @AMDEP_TRUE@ ./$(DEPDIR)/dfparse.Po ./$(DEPDIR)/dfuns.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/interpret.Po ./$(DEPDIR)/lang.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/lex.Po ./$(DEPDIR)/list.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/log.Po ./$(DEPDIR)/main.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/net.Po ./$(DEPDIR)/object.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/sys.Po ./$(DEPDIR)/vars.Po +@AMDEP_TRUE@ ./$(DEPDIR)/main.Po ./$(DEPDIR)/net.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/object.Po ./$(DEPDIR)/sys.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/vars.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) @@ -254,7 +254,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lang.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object.Po@am__quote@ @@ -492,7 +491,7 @@ uninstall-am uninstall-binPROGRAMS uninstall-dist_pkgdataDATA \ uninstall-info-am -# array.o log.o +# array.o dflex.c: dfparse.c Index: Makefile.am =================================================================== RCS file: /cvsroot/agd/server/src/Makefile.am,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Makefile.am 8 Jun 2004 20:21:38 -0000 1.11 +++ Makefile.am 23 Jul 2004 17:20:29 -0000 1.12 @@ -13,7 +13,7 @@ noinst_PROGRAMS = dfparse dfparse_SOURCES = dfparse.y dflex.l dfparse_LDADD = sys.o @LEXLIB@ -# array.o log.o +# array.o dflex.c: dfparse.c @@ -24,8 +24,8 @@ 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 \ +debug.c debug.h dfdecl.h dfuns.c dfuns.h interpret.c interpret.h instr.h \ +lex.l lex.h list.c list.h 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-07-23 17:20:17
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16113 Modified Files: array.c Log Message: dummy intersect_arrays Index: array.c =================================================================== RCS file: /cvsroot/agd/server/src/array.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- array.c 21 Jul 2004 12:10:17 -0000 1.16 +++ array.c 23 Jul 2004 17:19:58 -0000 1.17 @@ -165,3 +165,7 @@ return ret; } + +array_t *intersect_arrays(array_t *a1, array_t *a2) { + return a1; +} |
|
From: Peep P. <so...@us...> - 2004-07-23 17:19:59
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16075 Modified Files: array.h Log Message: intersect_arrays; removed commented prototypes Index: array.h =================================================================== RCS file: /cvsroot/agd/server/src/array.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- array.h 21 Jul 2004 12:10:17 -0000 1.9 +++ array.h 23 Jul 2004 17:19:48 -0000 1.10 @@ -8,15 +8,9 @@ } array_t; void init_array(array_t *a); -/*void array_push(array_t *a, variable_t *data);*/ void free_array(array_t *a, void (*freefun)(variable_t)); #define ref_array(a) a->ref++ -/* -void array_insert(array_t *a, void *data, int index); -void array_remove(array_t *a, int index); -array_t *copy_array(array_t *a, void *(*copyfun)(void *)); -array_t *array_concat(array_t *a1, array_t *a2);*/ array_t *sub_arrays(array_t *a1, array_t *a2); - +array_t *intersect_arrays(array_t *a1, array_t *a2); #endif |
|
From: Peep P. <so...@us...> - 2004-07-23 17:19:37
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16012 Modified Files: compile.c Log Message: stringdup renamed to xstrdup; bitwise operators Index: compile.c =================================================================== RCS file: /cvsroot/agd/server/src/compile.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- compile.c 23 Jul 2004 14:24:55 -0000 1.29 +++ compile.c 23 Jul 2004 17:19:27 -0000 1.30 @@ -333,6 +333,20 @@ {"%=", 2, 1, TYPE_INT}, {"**", 2, 1, TYPE_INT}, {"**=", 2, 1, TYPE_INT}, + + {"&", 2, 1, TYPE_INT|TYPE_ARRAY}, + {"&=", 2, 1, TYPE_INT|TYPE_ARRAY}, + {"|", 2, 1, TYPE_INT}, + {"|=", 2, 1, TYPE_INT}, + {"~", 2, 1, TYPE_INT}, + {"~=", 2, 1, TYPE_INT}, + {"^", 2, 1, TYPE_INT}, + {"^=", 2, 1, TYPE_INT}, + {">>", 2, 1, TYPE_INT}, + {">>=", 2, 1, TYPE_INT}, + {"<<", 2, 1, TYPE_INT}, + {"<<=", 2, 1, TYPE_INT}, + {"!", 1, 0, TYPE_ALL}, {"==", 2, 1, TYPE_ALL}, {"!=", 2, 1, TYPE_ALL}, @@ -459,7 +473,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] = stringdup(idp->name); /* Name gets freed later. (by clean_ids()) */ + this_prog->fun_table[this_prog->numfunc-1] = xstrdup(idp->name); /* Name gets freed later. (by clean_ids()) */ curr_fun = NULL; } @@ -489,7 +503,7 @@ this_ob->numglobals++; this_ob->globals = xrealloc(this_ob->globals, this_ob->numglobals * sizeof(variable_t)); v = &this_ob->globals[this_ob->numglobals-1]; - v->name = stringdup(name); /* Going to be stored. */ + v->name = xstrdup(name); /* Going to be stored. */ v->type = lpc_type; init_var(v); } else /* LVAR */{ |
|
From: Peep P. <so...@us...> - 2004-07-23 17:19:15
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15898 Modified Files: dflex.l Log Message: stringdup renamed to xstrdup Index: dflex.l =================================================================== RCS file: /cvsroot/agd/server/src/dflex.l,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- dflex.l 23 Jul 2004 14:23:20 -0000 1.5 +++ dflex.l 23 Jul 2004 17:19:05 -0000 1.6 @@ -45,7 +45,7 @@ return L_DATA_TYPE; } {IDENTIFIER} { - char *s = stringdup(yytext); + char *s = xstrdup(yytext); yylval.s = s; pos += strlen(s); return L_IDENTIFIER; |
|
From: Peep P. <so...@us...> - 2004-07-23 17:18:44
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15769 Modified Files: dfuns.c Log Message: dfun name as passed to define_id is dup'ed (it's in a local array) stringdup renamed to xstrdup Index: dfuns.c =================================================================== RCS file: /cvsroot/agd/server/src/dfuns.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- dfuns.c 21 Jul 2004 12:07:13 -0000 1.24 +++ dfuns.c 23 Jul 2004 17:18:35 -0000 1.25 @@ -42,23 +42,7 @@ 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; - /*if(!j)j++;*/ /* Feels like a hack. Any better ways? */ - - /* FIXME - implement variants in define_name */ - for(k=0;k<decl[i].args[j];k++,j++) { - if(k == 0) { /* remove this line if variants are implemented */ - numarg++; - args = xrealloc(args, sizeof(int) * numarg); - args[numarg-1] = decl[i].args[j+k]; - } - } - } -#endif - define_id(decl[i].name, ID_DFUN, decl[i].ret, args, num_arg); + define_id(xstrdup(decl[i].name), ID_DFUN, decl[i].ret, args, num_arg); } } @@ -95,12 +79,13 @@ void df_input_to(void) { if(this_player) { - this_player->input_to = stringdup(fp->u.s); + this_player->input_to = xstrdup(fp->u.s); this_player->input_to_called = 0; } #ifdef DEBUG else { - debug("input_to", "input_to() called on non-interactive object\n"); + if(conf.debuglevel) + printf("[input_to] input_to() called on non-interactive object\n"); } #endif pop_stack(); @@ -229,7 +214,7 @@ { char *ret; if(fp->u.ob && fp->u.ob->name) - ret = stringdup(fp->u.ob->name); + ret = xstrdup(fp->u.ob->name); else ret = "<NULL>"; pop_stack(); @@ -333,7 +318,7 @@ void df_capitalize(void) { char *s; - s = stringdup(fp->u.s); + s = xstrdup(fp->u.s); s[0] = toupper(s[0]); pop_stack(); push_string(s, ST_MALLOC); |
|
From: Peep P. <so...@us...> - 2004-07-23 17:17:16
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15530 Modified Files: interpret.c Log Message: Renamed stringdup to xstrdup; removed log.c and debug(); bitwise operators; pop excessive function arguments off the stack Index: interpret.c =================================================================== RCS file: /cvsroot/agd/server/src/interpret.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- interpret.c 21 Jul 2004 12:05:59 -0000 1.26 +++ interpret.c 23 Jul 2004 17:17:01 -0000 1.27 @@ -19,10 +19,6 @@ jmp_buf error_context; int have_error_context; -#ifdef DEBUG -int dont_debug_interpreter; -#endif - /* This is the stack containing all local variables, function arguments and function return values. */ variable_t value_stack[VALUE_STACK_SIZE]; @@ -95,7 +91,6 @@ printf(buf); if(this_player) { do_write(buf); -/* net_disconnect(this_player);*/ } free(buf); @@ -190,7 +185,7 @@ case T_STRING: lval->string_type = rval->string_type; if(rval->string_type != ST_STATIC && rval->u.s) { - lval->u.s = stringdup(rval->u.s); + lval->u.s = xstrdup(rval->u.s); } else { lval->u.s = rval->u.s; } @@ -277,6 +272,7 @@ csp->cp = cp; csp->code = code; csp->codelen = codelen; + csp->num_arg = 0; } void pop_control_stack(int pop_sp) @@ -300,9 +296,7 @@ } /* Used by F_JUMP and F_JUMP_IF_FALSE to check if they jumped too far. */ -#define CHECK_OVERRUN() do { if(cp >= code + codelen) {\ - debug("interpret", "Ran over end of array: returning\n"); return; \ - } } while(0) +#define CHECK_OVERRUN() do { if(cp >= code + codelen) { return; } } while(0) #define GET_ARGS() \ arg[1] = sp[-1].u.i; pop_stack(); \ @@ -358,7 +352,7 @@ saved_csp = csp - 1; again: #ifdef DEBUG - if(!dont_debug_interpreter && conf.debuglevel > 0) + if(conf.debuglevel > 0) printf("[interpret] executing %s at %d\n", opc_name(*cp), cp - code); #endif switch(*cp) { @@ -371,7 +365,7 @@ if(*cp == -1) tmps = NULL; else - tmps = stringdup(this_ob->prog->str_tbl[*cp]); + tmps = xstrdup(this_ob->prog->str_tbl[*cp]); push_string(tmps, ST_MALLOC); break; case F_PUSH_VOID: @@ -465,8 +459,6 @@ tmpvp = sub_vars(sp-2, sp-1); pop_stack(); pop_stack(); push_var(tmpvp); -/* GET_ARGS(); - push_int(arg[0] - arg[1]);*/ break; case F_SUB_EQ: if(sp[-2].type == T_CHAR_PTR) { @@ -540,6 +532,90 @@ pop_stack(); pop_stack(); push_int(tmpi); break; + case F_POW: + GET_ARGS(); + push_int(to_power(arg[0], arg[1])); + break; + case F_POW_EQ: + tmpv = *sp[-2].u.v; + tmpi = to_power(tmpv.u.i, sp[-1].u.i); + sp[-2].u.v->u.i = tmpi; + pop_stack(); pop_stack(); + push_int(tmpi); + break; + case F_BAND: + tmpvp = band_vars(sp-2, sp-1); + pop_stack(); pop_stack(); + push_var(tmpvp); + break; + case F_BAND_EQ: + tmpv = *sp[-2].u.v; + if(tmpv.type & T_ARRAY) { + tmpvp = band_vars(&tmpv, sp-1); + do_assign(sp[-2].u.v, tmpvp); + pop_stack(); pop_stack(); + push_var(tmpvp); + } else { + 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_BOR: + tmpi = sp[-2].u.i | sp[-1].u.i; + pop_stack(); pop_stack(); + push_int(tmpi); + break; + case F_BOR_EQ: + tmpvp = sp[-2].u.v; + tmpi = tmpvp->u.i | sp[-1].u.i; + tmpvp->u.i = tmpi; + pop_stack(); pop_stack(); + push_int(tmpi); + break; + case F_BNOT: + tmpi = sp[-1].u.i; + pop_stack(); + push_int(~tmpi); + break; + /* case F_BNOT_EQ: */ + case F_BXOR: + tmpi = sp[-2].u.i ^ sp[-1].u.i; + pop_stack(); pop_stack(); + push_int(tmpi); + break; + case F_BXOR_EQ: + tmpvp = sp[-2].u.v; + tmpi = tmpvp->u.i ^ sp[-1].u.i; + tmpvp->u.i = tmpi; + pop_stack(); pop_stack(); + push_int(tmpi); + break; + case F_BSL: + tmpi = sp[-2].u.i << sp[-1].u.i; + pop_stack(); pop_stack(); + push_int(tmpi); + break; + case F_BSL_EQ: + tmpvp = sp[-2].u.v; + tmpi = tmpvp->u.i << sp[-1].u.i; + tmpvp->u.i = tmpi; + pop_stack(); pop_stack(); + push_int(tmpi); + break; + case F_BSR: + tmpi = sp[-2].u.i >> sp[-1].u.i; + pop_stack(); pop_stack(); + push_int(tmpi); + break; + case F_BSR_EQ: + tmpvp = sp[-2].u.v; + tmpi = tmpvp->u.i >> sp[-1].u.i; + tmpvp->u.i = tmpi; + pop_stack(); pop_stack(); + push_int(tmpi); + break; case F_ASSIGN: if(sp[-2].type == T_CHAR_PTR) { /* Work of F_INDEX_LVALUE. */ @@ -680,9 +756,8 @@ } break; case F_NOT: - sp--; - tmpi = test_var(sp); - free_var(sp); + tmpi = test_var(sp-1); + pop_stack(); push_int(!tmpi); break; case F_GT: @@ -763,7 +838,7 @@ } #ifdef DEBUG - if(conf.debuglevel > 2 && !dont_debug_interpreter) + if(conf.debuglevel > 2) show_stack(); #endif @@ -785,7 +860,7 @@ void call_function(object_t *ob, int index) { - int i, j; + int i; function_t *f = ob->prog->functions[index]; if(!f) { char *buf = xmalloc(512); @@ -793,11 +868,12 @@ runtime_dyn(buf); } -/* csp->line = f->lineno;*/ csp->fun = index; i = f->num_arg - csp->num_arg; if(i > 0) { + /* Not enough arguments. */ + int j; for(j=0;j<i;j++) { switch(f->args[j]) { case T_INT: @@ -811,11 +887,14 @@ break; } } + } else if(i < 0) { + /* Too much arguments. */ + int j; + for(j=i;j<0;j++) { + pop_stack(); + } } -#ifdef DEBUG - debug("interpret", "call_function %d on %s\n", index, ob->name); -#endif previous_ob = this_ob; this_ob = ob; if(this_ob->iaob) @@ -886,7 +965,7 @@ case 's': /* We duplicate the string, so we can be sure it's not static and can free() it. */ - push_string(stringdup(va_arg(va, char*)), ST_MALLOC); + push_string(xstrdup(va_arg(va, char*)), ST_MALLOC); csp->num_arg++; break; default: |
|
From: Peep P. <so...@us...> - 2004-07-23 17:08:31
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14240 Modified Files: lex.l Log Message: renamed stringdup to xstrdup; bitwise operators Index: lex.l =================================================================== RCS file: /cvsroot/agd/server/src/lex.l,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- lex.l 23 Jul 2004 14:23:20 -0000 1.18 +++ lex.l 23 Jul 2004 17:08:21 -0000 1.19 @@ -71,7 +71,7 @@ \\ pos++; BEGIN(in_string_backslash); \" { *string_buf_ptr = '\0'; - yylval.str = stringdup(string_buf); + yylval.str = xstrdup(string_buf); BEGIN(INITIAL); RET(s, yylval.str, L_STRING); } @@ -187,11 +187,11 @@ /* fake preprocessor macros */ "__VERSION__" { - yylval.str = stringdup(PACKAGE_VERSION); + yylval.str = xstrdup(PACKAGE_VERSION); RET(s, "__VERSION__", L_STRING); } "__ARCH__" { - yylval.str = stringdup(PLATFORM); + yylval.str = xstrdup(PLATFORM); RET(s, "__ARCH__", L_STRING); } @@ -214,6 +214,14 @@ "%=" RET(s, "%=", L_MOD_EQ); ".." RET(s, "..", L_RANGE); +"^=" RET(s, "^=", L_BXOR_EQ); +"|=" RET(s, "|=", L_BOR_EQ); +"&=" RET(s, "&=", L_BAND_EQ); +"<<" RET(s, "<<", L_BSL); +"<<=" RET(s, "<<=", L_BSL_EQ); +">>" RET(s, ">>", L_BSR); +">>=" RET(s, ">>=", L_BSR_EQ); + "({" RET(s, "({", L_OPEN_ARRAY); "([" RET(s, "([", L_OPEN_MAPPING); "(:" RET(s, "(:", L_OPEN_FUNP); @@ -242,7 +250,7 @@ mixed yylval.i = T_MIXED; RET(s, "mixed", L_DATA_TYPE); object yylval.i = T_OBJECT; RET(s, "object", L_DATA_TYPE); {IDENTIFIER} { - char *str = stringdup(yytext); + char *str = xstrdup(yytext); yylval.str = str; RET(s, str, L_IDENTIFIER); } |
|
From: Peep P. <so...@us...> - 2004-07-23 17:08:14
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14169 Modified Files: main.c Log Message: master flag() apply; general cleanup Index: main.c =================================================================== RCS file: /cvsroot/agd/server/src/main.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- main.c 21 Jul 2004 11:57:22 -0000 1.22 +++ main.c 23 Jul 2004 17:07:59 -0000 1.23 @@ -34,27 +34,47 @@ extern object_t *master; static char *conf_file; time_t startup_time; -extern variable_t *fp, *sp; -void crash(int sig, char *reason, int retval) +void sighandler(int num) +{ + switch(num) { + case SIGINT: + crash(SIGINT, "Interrupted", 4); + break; + case SIGSEGV: + crash(SIGSEGV, "Segmentation fault", 4); + break; + case SIGPIPE: + crash(SIGPIPE, "Broken pipe", 4); + break; + } +} + +void catch_signals() +{ + signal(SIGINT, sighandler); + signal(SIGSEGV, sighandler); + signal(SIGPIPE, sighandler); +} + +void stop_signals() { -#ifdef DEBUG - extern int dont_debug_interpreter; -#endif - - fprintf(stderr, "Crashing: %s\n", reason); signal(SIGINT, SIG_IGN); signal(SIGSEGV, SIG_IGN); signal(SIGPIPE, SIG_IGN); -#ifdef DEBUG - /* We generally do not want to debug the crash function. Causes unnecessary spam. */ - dont_debug_interpreter = 0; -#endif +} + +void crash(int sig, char *reason, int retval) +{ + extern variable_t *fp, *sp; + + fprintf(stderr, "Crashing: %s\n", reason); + stop_signals(); if(master) { int ret; fp = sp; - ret = apply(master, "crash", "i", sig); + ret = apply(master, "crash", "is", sig, reason); if(!ret) fprintf(stderr, "master::crash() failed.\n"); else @@ -63,32 +83,14 @@ exit(retval); } -/* system (maybe virtual?) header <signal.h> for crash() to identify signals - by name, not number. */ -void sighandler(int num) -{ - switch(num) { - case SIGINT: - crash(SIGINT, "Interrupted", 4); - break; - case SIGSEGV: - crash(SIGSEGV, "Segmentation fault", 4); - break; - case SIGPIPE: - crash(SIGPIPE, "Broken pipe", 4); - break; - } -} - void usage(char *s) { - printf("Usage: %s [options] [configuration file]\n", s); - printf("\tOptions:\n\ - \t\t-d:\n\ - \t\t Increase debug level\n\ - \t\t-?\n\ - \t\t-v:\n\ - \t\t Show version and quit\n"); + printf("Usage: %s [options] <configuration file>\n", s); + printf("Options:\n" + "\t-d: Increase debug level\n" + "\t-f<text>: pass flag to master object\n" + "\t-? or -h: Show this text\n" + "\t-v: Show version and quit\n"); exit(5); } @@ -97,12 +99,31 @@ printf("%s for %s starting at %s", PACKAGE_STRING, PLATFORM, ctime(&startup_time)); #ifdef ARCH_README printf("Your computer architecture is not fully supported. " - "Please read README.ARCH in the source directory.\n"); + "Please read README.ARCH in the source directory.\n"); #endif } -#define JUMPTONEXT() if(argv[i][j+1] == '=') { i++; if(i < argc) goto next_i; else return; } +void do_flag(char *s) +{ + static char **flags; + static int numflags; + if(!s) { + /* apply them. */ + int i; + for(i=0;i<numflags;i++) { + apply(master, "flag", "s", flags[i]); + } + free(flags); + } else { + /* add one. */ + numflags++; + flags = xrealloc(flags, sizeof(char *) * numflags); + flags[numflags-1] = s; + } +} + +#define NEXTARG() { i++; if(i<argc) goto next_i; else return; } void parse_args(int argc, char **argv) { int i, j; @@ -126,7 +147,8 @@ #ifdef DEBUG if(argv[i][j+1] == '=') { conf.debuglevel = atoi(argv[i]+j+2); - JUMPTONEXT() + if(argv[i][j+1] == '=') + NEXTARG() } else { conf.debuglevel++; } @@ -134,10 +156,23 @@ if(conf.debuglevel >= 0) { printf("-d only works if the driver is compiled with debugging on.\n"); conf.debuglevel = -1; - JUMPTONEXT() + if(argv[i][j+1] == '=') + NEXTARG() } #endif break; + case 'f': + if(argv[i][j+1]) { + do_flag(&argv[i][j+1]); + NEXTARG() + } else if(argv[i+1]) { + do_flag(argv[i+1]); + NEXTARG() + } else { + printf("-f needs an argument\n"); + exit(5); + } + break; default: printf("invalid argument '%c'\n", argv[i][j]); usage(argv[0]); @@ -181,20 +216,18 @@ } setvbuf(stdout, NULL, _IONBF, 0); - signal(SIGINT, sighandler); - signal(SIGSEGV, sighandler); - signal(SIGPIPE, sighandler); + catch_signals(); parse_config(conf_file); - check_logfile(); dfuns_init(); -/* init_interpreter();*/ master = load_object(conf.master); if(!master) crash(0, "Master object doesn't load", 3); /* master->numref++; Is this really necessary? */ + do_flag(NULL); /* Apply flags. */ + net_listen(conf.port); printf("Accepting connections on port %d.\n", conf.port); |
|
From: Peep P. <so...@us...> - 2004-07-23 17:06:53
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13914 Modified Files: object.c net.c Log Message: Removed debug(); renamed stringdup to xstrdup Index: object.c =================================================================== RCS file: /cvsroot/agd/server/src/object.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- object.c 21 Jul 2004 11:55:39 -0000 1.18 +++ object.c 23 Jul 2004 17:06:43 -0000 1.19 @@ -57,9 +57,6 @@ list_remove(&all_objects, ob); list_push(&to_be_dested, ob); -#ifdef DEBUG - debug("dfun", "destructed \"%s\"\n", ob->name); -#endif } void actual_destruct(object_t *ob) @@ -204,7 +201,7 @@ /* path = remove_extension(path); ? */ ob = xmalloc(sizeof(object_t)); memset(ob, 0, sizeof(object_t)); - ob->name = stringdup(path); + ob->name = xstrdup(path); this_ob = ob; @@ -240,9 +237,6 @@ return NULL; } -#ifdef DEBUG - debug("dfun", "cloning object %s\n", path); -#endif /* ref_ob(base_ob, NULL);*/ new_ob = xmalloc(sizeof(object_t)); @@ -260,7 +254,7 @@ variable_t *v = &new_ob->globals[i]; *v = base_ob->globals[i]; if(v->name) - v->name = stringdup(v->name); + v->name = xstrdup(v->name); } apply(new_ob, "create", NULL); Index: net.c =================================================================== RCS file: /cvsroot/agd/server/src/net.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- net.c 21 Jul 2004 11:56:28 -0000 1.19 +++ net.c 23 Jul 2004 17:06:43 -0000 1.20 @@ -101,7 +101,7 @@ player_ob = xmalloc(sizeof(object_t)); player_ob->iaob = p; /* So find_object() won't barf. Have to copy because it will be freed. */ - player_ob->name = stringdup("LOGIN"); + player_ob->name = xstrdup("LOGIN"); player_ob->prog = NULL; this_ob = p->ob = player_ob; @@ -124,7 +124,6 @@ if(this_player == p && p->ob == player_ob) /* wasn't changed. */ return; - 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. */ free(player_ob); } @@ -163,7 +162,10 @@ 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); +#ifdef DEBUG + if(conf.debuglevel) + printf("[net] player %p (with iaob %s) doesn't have input_to set\n", p->ob? p->ob->name :NULL, p); +#endif goto out; } |
|
From: Peep P. <so...@us...> - 2004-07-23 17:05:48
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13694 Modified Files: sys.c sys.h Log Message: Cleaned up; removed log.c [and debug()]; to_power(); renamed stringdup to xstrdup Index: sys.h =================================================================== RCS file: /cvsroot/agd/server/src/sys.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- sys.h 14 Jun 2004 20:48:08 -0000 1.11 +++ sys.h 23 Jul 2004 17:05:40 -0000 1.12 @@ -4,28 +4,24 @@ /* memory allocation */ void *xmalloc(size_t bytes); void *xrealloc(void *ptr, size_t bytes); +char *xstrdup(char *s); /* configuration */ typedef struct { int port, heartbeat; - char *lib_root, *error_log; + char *lib_root; char *master; int debuglevel; } config_t; - extern config_t conf; -int legal_path(char *fn); - -char *stringdup(char *s); - #define max(i, j) i > j ? i : j +int to_power(int base, int pow); +int legal_path(char *fn); char *add_extension(char *str); char *absolute_path(char *path); -/* Defined in log.c */ -int check_logfile(void); -void debug(char *prefix, char *fmt, ...); +void crash(int sig, char *reason, int retval); #endif Index: sys.c =================================================================== RCS file: /cvsroot/agd/server/src/sys.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- sys.c 23 Jul 2004 14:22:43 -0000 1.18 +++ sys.c 23 Jul 2004 17:05:40 -0000 1.19 @@ -57,19 +57,13 @@ if(strncmp(buf, "lib:", 4) == 0) { fscanf(f, "%s\n", buf); - conf.lib_root = stringdup(buf); - continue; - } - - if(strncmp(buf, "errorlog:", 10) == 0) { - fscanf(f, "%s\n", buf); - conf.error_log = stringdup(buf); + conf.lib_root = xstrdup(buf); continue; } if(strncmp(buf, "master:", 8) == 0) { fscanf(f, "%s\n", buf); - conf.master = stringdup(buf); + conf.master = xstrdup(buf); continue; } @@ -87,7 +81,6 @@ CONFCHECK(conf.port, "port"); CONFCHECK(conf.heartbeat, "heartbeat"); CONFCHECK(conf.lib_root, "lib"); -/* CONFCHECK(conf.error_log, "errorlog");*/ CONFCHECK(conf.master, "master"); } @@ -125,7 +118,7 @@ } /* strdup() isn't ANSI, so we need this replacement. */ -char *stringdup(char *s) +char *xstrdup(char *s) { char *p = xmalloc(strlen(s) + 1); strcpy(p, s); @@ -140,7 +133,7 @@ p = str + len - 5; if(strcmp(p, ".lpc") == 0) - return stringdup(buf); + return xstrdup(buf); buf = xmalloc(len + 5); sprintf(buf, "%s.lpc", str); @@ -155,3 +148,22 @@ s = strcat(s, path); return s; } + +int to_power(int base, int pow) +{ + int i, ret; + if(base == 0) + return 0; + if(pow == 0) + return 1; + if(pow == 1) + return base; + if(base == 2) + return 2 << pow - 1; + + ret = base; + for(i=0;i<pow-1;i++) { + ret *= base; + } + return ret; +} |
|
From: Peep P. <so...@us...> - 2004-07-23 17:05:02
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13508 Modified Files: vars.c Log Message: Bitwise operators; renamed stringdup to xstrdup Index: vars.c =================================================================== RCS file: /cvsroot/agd/server/src/vars.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- vars.c 21 Jul 2004 11:54:01 -0000 1.16 +++ vars.c 23 Jul 2004 17:04:36 -0000 1.17 @@ -184,9 +184,9 @@ if(!v2->u.s) buf = NULL; else - buf = stringdup(v2->u.s); + buf = xstrdup(v2->u.s); } else if(!v2->u.s) - buf = stringdup(v1->u.s); + buf = xstrdup(v1->u.s); else { buf = xmalloc(strlen(v1->u.s) + strlen(v2->u.s) + 1); sprintf(buf, "%s%s", v1->u.s, v2->u.s); @@ -257,6 +257,20 @@ return ret; } +variable_t *band_vars(variable_t *var1, variable_t *var2) +{ + variable_t *ret; + ret = xmalloc(sizeof(variable_t)); + if(var1->type & T_ARRAY && var2->type & T_ARRAY) { + ret->type = var1->type; + ret->u.a = intersect_arrays(var1->u.a, var2->u.a); + } else { + ret->type = T_INT; + ret->u.i = var1->u.i & var2->u.i; + } + return ret; +} + char *type2str(int t) { if(t & T_ARRAY) { |
|
From: Peep P. <so...@us...> - 2004-07-23 17:04:06
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13410 Modified Files: vars.h lang.y lang.h instr.h Log Message: Bitwise operators. Index: lang.h =================================================================== RCS file: /cvsroot/agd/server/src/lang.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- lang.h 21 Jul 2004 12:13:09 -0000 1.12 +++ lang.h 23 Jul 2004 17:03:56 -0000 1.13 @@ -48,23 +48,30 @@ L_OPEN_FUNP = 274, L_CLOSE_FUNP = 275, L_RANGE = 276, - L_MINUS_EQ = 277, - L_PLUS_EQ = 278, - L_DIV_EQ = 279, - L_MOD_EQ = 280, - L_MUL_EQ = 281, - L_POW_EQ = 282, - L_AND = 283, - L_OR = 284, - L_NE = 285, - L_EQ = 286, - L_GE = 287, - L_LE = 288, - L_POW = 289, - L_ARROW = 290, - L_DEC = 291, - L_INC = 292, - L_NEG = 293 + L_BSR_EQ = 277, + L_BSL_EQ = 278, + L_BAND_EQ = 279, + L_BOR_EQ = 280, + L_BXOR_EQ = 281, + L_MINUS_EQ = 282, + L_PLUS_EQ = 283, + L_DIV_EQ = 284, + L_MOD_EQ = 285, + L_MUL_EQ = 286, + L_POW_EQ = 287, + L_AND = 288, + L_OR = 289, + L_NE = 290, + L_EQ = 291, + L_GE = 292, + L_LE = 293, + L_BSL = 294, + L_BSR = 295, + L_POW = 296, + L_ARROW = 297, + L_DEC = 298, + L_INC = 299, + L_NEG = 300 }; #endif #define L_IF 258 @@ -86,23 +93,30 @@ #define L_OPEN_FUNP 274 #define L_CLOSE_FUNP 275 #define L_RANGE 276 -#define L_MINUS_EQ 277 -#define L_PLUS_EQ 278 -#define L_DIV_EQ 279 -#define L_MOD_EQ 280 -#define L_MUL_EQ 281 -#define L_POW_EQ 282 -#define L_AND 283 -#define L_OR 284 -#define L_NE 285 -#define L_EQ 286 -#define L_GE 287 -#define L_LE 288 -#define L_POW 289 -#define L_ARROW 290 -#define L_DEC 291 -#define L_INC 292 -#define L_NEG 293 +#define L_BSR_EQ 277 +#define L_BSL_EQ 278 +#define L_BAND_EQ 279 +#define L_BOR_EQ 280 +#define L_BXOR_EQ 281 +#define L_MINUS_EQ 282 +#define L_PLUS_EQ 283 +#define L_DIV_EQ 284 +#define L_MOD_EQ 285 +#define L_MUL_EQ 286 +#define L_POW_EQ 287 +#define L_AND 288 +#define L_OR 289 +#define L_NE 290 +#define L_EQ 291 +#define L_GE 292 +#define L_LE 293 +#define L_BSL 294 +#define L_BSR 295 +#define L_POW 296 +#define L_ARROW 297 +#define L_DEC 298 +#define L_INC 299 +#define L_NEG 300 @@ -122,7 +136,7 @@ void *ptr; /* for() uses this. */ } YYSTYPE; /* Line 1240 of yacc.c. */ -#line 126 "lang.h" +#line 140 "lang.h" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- lang.y 23 Jul 2004 14:24:05 -0000 1.25 +++ lang.y 23 Jul 2004 17:03:56 -0000 1.26 @@ -81,23 +81,27 @@ %token L_OPEN_ARRAY L_CLOSE_ARRAY %token L_OPEN_FUNP L_CLOSE_FUNP - /* operators */ %nonassoc L_RANGE %right '=' +%left L_BXOR_EQ L_BOR_EQ L_BAND_EQ L_BSL_EQ L_BSR_EQ %left L_PLUS_EQ L_MINUS_EQ %left L_MUL_EQ L_MOD_EQ L_DIV_EQ %left L_POW_EQ %left L_OR L_AND +%left '|' +%left '^' +%left '&' %left L_EQ L_NE %left '?' %left '<' '>' L_LE L_GE +%left L_BSR L_BSL %left '+' '-' %left ':' %left '*' '/' '%' %left L_POW %left L_ARROW -%nonassoc L_NEG '!' L_INC L_DEC +%nonassoc L_NEG '!' L_INC L_DEC '~' %left '[' ']' %nonassoc '(' ')' @@ -338,6 +342,17 @@ 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); } + + | expr L_BXOR_EQ { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_BXOR_EQ, $<i>3); } + | expr L_BOR_EQ { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_BOR_EQ, $<i>3); } + | expr L_BAND_EQ { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_BAND_EQ, $<i>3); } + | expr L_BSL_EQ { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_BSL_EQ, $<i>3); } + | expr L_BSR_EQ { $<i>$ = curr_fun->codelen - 2; } + expr { do_assign_expr(&$$, &$1, $4.type, F_BSR_EQ, $<i>3); } ; inc_expr: @@ -359,6 +374,13 @@ | 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_BAND); } + | expr '|' expr { do_expr(&$$, &$1, &$3, F_BOR); } + | expr '~' expr { do_expr(&$$, &$1, &$3, F_BNOT); } + | expr '^' expr { do_expr(&$$, &$1, &$3, F_BXOR); } + | expr L_BSL expr { do_expr(&$$, &$1, &$3, F_BSL); } + | expr L_BSR expr { do_expr(&$$, &$1, &$3, F_BSR); } ; compare_expr: Index: vars.h =================================================================== RCS file: /cvsroot/agd/server/src/vars.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- vars.h 21 Jul 2004 11:54:01 -0000 1.9 +++ vars.h 23 Jul 2004 17:03:56 -0000 1.10 @@ -8,6 +8,7 @@ int compare_vars(variable_t *v1, variable_t *v2); variable_t *add_vars(variable_t *v1, variable_t *v2); variable_t *sub_vars(variable_t *v1, variable_t *v2); +variable_t *band_vars(variable_t *v1, variable_t *v2); char *type2str(int t); #endif Index: instr.h =================================================================== RCS file: /cvsroot/agd/server/src/instr.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- instr.h 21 Jul 2004 12:06:31 -0000 1.4 +++ instr.h 23 Jul 2004 17:03:56 -0000 1.5 @@ -24,37 +24,49 @@ #define F_CALL_OTHER 18 #define F_ASSIGN 19 /* Pops two variables off the stack, and assigns upper one's value to the lower one. (the lower one should be a T_LVALUE) */ -#define F_ADD 20 -#define F_ADD_EQ 21 -#define F_SUB 22 -#define F_SUB_EQ 23 -#define F_MUL 24 -#define F_MUL_EQ 25 -#define F_DIV 26 -#define F_DIV_EQ 27 -#define F_MOD 28 -#define F_MOD_EQ 29 -#define F_POW 30 -#define F_POW_EQ 31 -#define F_NOT 32 -#define F_EQ 33 -#define F_NE 34 -#define F_GT 35 -#define F_GE 36 -#define F_LT 37 -#define F_LE 38 -#define F_NEG 39 -#define F_AND 40 /* Have to keep these in because of check_operand() */ -#define F_OR 41 /* */ -#define F_POSTINC 42 -#define F_PREINC 43 -#define F_POSTDEC 44 -#define F_PREDEC 45 -#define F_INDEX 46 /* Single index into an array or string. */ -#define F_INDEX_LVALUE 47 -#define F_SLICE 48 -#define F_SLICE_LVALUE 49 -#define F_COMM 50 +#define F_ADD 20 /* + */ +#define F_ADD_EQ 21 /* += */ +#define F_SUB 22 /* - */ +#define F_SUB_EQ 23 /* -=*/ +#define F_MUL 24 /* * */ +#define F_MUL_EQ 25 /* *= */ +#define F_DIV 26 /* / */ +#define F_DIV_EQ 27 /* /= */ +#define F_MOD 28 /* % */ +#define F_MOD_EQ 29 /* %= */ +#define F_POW 30 /* ** */ +#define F_POW_EQ 31 /* **= */ -#define F_HIGHEST F_COMM +#define F_BAND 32 /* & */ +#define F_BAND_EQ 33 /* &= */ +#define F_BOR 34 /* | */ +#define F_BOR_EQ 35 /* |= */ +#define F_BNOT 36 /* ~ */ +#define F_BNOT_EQ 37 /* ~= */ +#define F_BXOR 38 /* ^ */ +#define F_BXOR_EQ 39 /* ^= */ +#define F_BSR 40 /* >> */ +#define F_BSR_EQ 41 /* >>= */ +#define F_BSL 42 /* << */ +#define F_BSL_EQ 43 /* <<= */ + +#define F_NOT 44 /* ! */ +#define F_EQ 45 /* == */ +#define F_NE 46 /* != */ +#define F_GT 47 /* > */ +#define F_GE 48 /* >= */ +#define F_LT 49 /* < */ +#define F_LE 50 /* <= */ +#define F_NEG 51 /* -expr */ +#define F_AND 52 /* && */ /* Have to keep these in because of check_operand() */ +#define F_OR 53 /* || */ /* ------------------------------------------------ */ +#define F_POSTINC 54 /* expr++*/ +#define F_PREINC 55 /* ++expr */ +#define F_POSTDEC 56 /* expr-- */ +#define F_PREDEC 57 /* --expr */ +#define F_INDEX 58 /* [expr] */ /* Single index into an array or string. */ +#define F_INDEX_LVALUE 59 +#define F_SLICE 60 /* [expr..expr] */ +#define F_SLICE_LVALUE 61 +#define F_COMM 62 /* , */ #endif |
|
From: Peep P. <so...@us...> - 2004-07-23 17:01:26
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13027 Removed Files: log.c Log Message: Removed; this was pointless anyway --- log.c DELETED --- |
|
From: Peep P. <so...@us...> - 2004-07-23 14:45:03
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23156 Modified Files: BUGS Log Message: Bugs keep on disappearing! Index: BUGS =================================================================== RCS file: /cvsroot/agd/server/BUGS,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- BUGS 23 Jul 2004 14:25:45 -0000 1.14 +++ BUGS 23 Jul 2004 14:44:54 -0000 1.15 @@ -1,5 +1,2 @@ Currently known bugs: - - crashes on Solaris/SPARC with a SIGSEGV somewhere - between lines 190 and 199 in net.c (don't have gdb - on that host). Could this be the wretched inet_ntoa() problem? - select() just blocks after a player receives a runtime error |
|
From: Peep P. <so...@us...> - 2004-07-23 14:25:54
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20278 Modified Files: BUGS Log Message: The 64-bit bug seems to be gone. Index: BUGS =================================================================== RCS file: /cvsroot/agd/server/BUGS,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- BUGS 21 Jul 2004 12:13:09 -0000 1.13 +++ BUGS 23 Jul 2004 14:25:45 -0000 1.14 @@ -2,6 +2,4 @@ - crashes on Solaris/SPARC with a SIGSEGV somewhere between lines 190 and 199 in net.c (don't have gdb on that host). Could this be the wretched inet_ntoa() problem? - - on 64-bit, the interpreter fails miserably - I think the code pointer (int *cp) is - incremented by 4 bytes, when it should be incremented by 8. - select() just blocks after a player receives a runtime error |
|
From: Peep P. <so...@us...> - 2004-07-23 14:25:19
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20173 Modified Files: ChangeLog Log Message: Manual yylloc declaration. Index: ChangeLog =================================================================== RCS file: /cvsroot/agd/server/ChangeLog,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- ChangeLog 21 Jul 2004 12:13:09 -0000 1.22 +++ ChangeLog 23 Jul 2004 14:25:10 -0000 1.23 @@ -1,5 +1,8 @@ 0.0.3: ---------------------------------------------------------------------------- +2004-07-23 + * dflex.l,lex.l,compile.c: added manual 'extern YYLTYPE yylloc' + declarations, which seem to be necessary with older version of bison. 2004-06-23 * compile.c,lang.y,interpret.c,vars.c: + operator for arrays * compile.c: fixed adding definitions for prototypes - their code wasn't |
|
From: Peep P. <so...@us...> - 2004-07-23 14:25:04
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20017 Modified Files: compile.c Log Message: string.h for strerror; manual yylloc declaration; set prog to NULL if file not found Index: compile.c =================================================================== RCS file: /cvsroot/agd/server/src/compile.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- compile.c 21 Jul 2004 12:09:47 -0000 1.28 +++ compile.c 23 Jul 2004 14:24:55 -0000 1.29 @@ -1,5 +1,6 @@ #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <errno.h> #include <sys/time.h> #include <time.h> @@ -15,6 +16,8 @@ #include "instr.h" #include "lang.h" +extern YYLTYPE yylloc; + extern object_t *this_ob; program_t *this_prog; @@ -603,7 +606,7 @@ yyin = fopen(real_path, "r"); if(!yyin) { printf("failed (can't open %s: %s)\n", real_path, strerror(errno)); - this_prog = 0; + prog = NULL; goto out; } @@ -633,13 +636,13 @@ compile_warnings == 1 ? "": "s"); } printf(" - failed\n"); - free(this_prog); + free(prog); prog = NULL; goto out; } if(check_fun_definitions()) { - free(this_prog); + free(prog); prog = NULL; goto out; } |
|
From: Peep P. <so...@us...> - 2004-07-23 14:24:27
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19897 Modified Files: lang.y Log Message: Missing semicolons Index: lang.y =================================================================== RCS file: /cvsroot/agd/server/src/lang.y,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- lang.y 21 Jul 2004 12:01:51 -0000 1.24 +++ lang.y 23 Jul 2004 14:24:05 -0000 1.25 @@ -359,6 +359,7 @@ | 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); } @@ -882,6 +883,7 @@ add_two_tokens(F_JUMP, $<i>2 - curr_fun->codelen - 1); break_allowed = continue_allowed = 0; } + ; while: L_WHILE |
|
From: Peep P. <so...@us...> - 2004-07-23 14:23:58
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19737 Modified Files: options Log Message: Removed uselessness. Index: options =================================================================== RCS file: /cvsroot/agd/server/src/options,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- options 1 Apr 2004 19:10:53 -0000 1.4 +++ options 23 Jul 2004 14:23:49 -0000 1.5 @@ -10,20 +10,6 @@ # Mudlib root folder. lib: /usr/share/agd/lib -# Log file for debugging information. -# Edit this if you want debugging information (not really necessary) -# The file needs to exist, as AGD doesn't have the privileges to -# create the file under /usr/share/agd. -#errorlog: /usr/share/agd/debug.log - -# Whether to show memory statistics when quitting or not. -exitstats: 0 - # Path to master object (relative to library root) master: /sys/master -# Options below this line are not yet implemented. - -# Default error level -#errorlevel: 1 - |
|
From: Peep P. <so...@us...> - 2004-07-23 14:23:29
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19612 Modified Files: lex.l dflex.l Log Message: Older versions of bison don't declare yylloc, have to do it manually Index: lex.l =================================================================== RCS file: /cvsroot/agd/server/src/lex.l,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- lex.l 14 Jun 2004 20:56:56 -0000 1.17 +++ lex.l 23 Jul 2004 14:23:20 -0000 1.18 @@ -12,6 +12,7 @@ #include "sys.h" /* conf_t */ #include "arch.h" +extern YYLTYPE yylloc; #define pos yylloc.first_column #define line yylloc.first_line Index: dflex.l =================================================================== RCS file: /cvsroot/agd/server/src/dflex.l,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- dflex.l 8 Jun 2004 20:33:45 -0000 1.4 +++ dflex.l 23 Jul 2004 14:23:20 -0000 1.5 @@ -4,6 +4,7 @@ #include "sys.h" #include "lpc.h" #include "dfparse.h" +extern YYLTYPE yylloc; #define pos yylloc.first_column #define line yylloc.first_line %} |
|
From: Peep P. <so...@us...> - 2004-07-23 14:22:52
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19398 Modified Files: sys.c dfparse.y Log Message: string.h is needed for strerror Index: sys.c =================================================================== RCS file: /cvsroot/agd/server/src/sys.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- sys.c 21 Jul 2004 11:55:06 -0000 1.17 +++ sys.c 23 Jul 2004 14:22:43 -0000 1.18 @@ -10,6 +10,7 @@ #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <errno.h> #include <math.h> #if HAVE_MACHINE_TYPES_H Index: dfparse.y =================================================================== RCS file: /cvsroot/agd/server/src/dfparse.y,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- dfparse.y 21 Jul 2004 12:08:17 -0000 1.11 +++ dfparse.y 23 Jul 2004 14:22:43 -0000 1.12 @@ -34,6 +34,7 @@ %{ #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <errno.h> #include <time.h> |
|
From: Peep P. <so...@us...> - 2004-07-21 12:13:23
|
Update of /cvsroot/agd/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11107 Modified Files: BUGS NEWS TODO ChangeLog Ideas Log Message: Bing, changes\! Index: NEWS =================================================================== RCS file: /cvsroot/agd/server/NEWS,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- NEWS 7 Jun 2004 15:50:19 -0000 1.12 +++ NEWS 21 Jul 2004 12:13:09 -0000 1.13 @@ -1,9 +1,10 @@ Changes in 0.0.3: + * Arrays! * Renamed interactivep() to interactive() * Locals can now be defined in the middle of code. * dfun platform() changed to a preprocessor macro __ARCH__, version() to __VERSION__. - * New dfuns: throw() + * New dfuns: throw(), users() Features in 0.0.2-3: * Real string ranges like string[0..4] Index: BUGS =================================================================== RCS file: /cvsroot/agd/server/BUGS,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- BUGS 7 Jun 2004 15:31:21 -0000 1.12 +++ BUGS 21 Jul 2004 12:13:09 -0000 1.13 @@ -1,9 +1,7 @@ Currently known bugs: - - src/options and src/compile_options.h don't honor $prefix. - Could use a shell script and sed to do substitutions. - But not that important, I guess. - crashes on Solaris/SPARC with a SIGSEGV somewhere between lines 190 and 199 in net.c (don't have gdb on that host). Could this be the wretched inet_ntoa() problem? - on 64-bit, the interpreter fails miserably - I think the code pointer (int *cp) is incremented by 4 bytes, when it should be incremented by 8. + - select() just blocks after a player receives a runtime error Index: TODO =================================================================== RCS file: /cvsroot/agd/server/TODO,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- TODO 20 Jun 2004 14:05:16 -0000 1.23 +++ TODO 21 Jul 2004 12:13:09 -0000 1.24 @@ -1,16 +1,40 @@ Not necessarily in order of importance. '!' means first-priority, -'?' means trivial and not really important. +'?' means trivial and/or not really important. '<' means low priority + - Runtime token positions (aka line number information). + How to do it. Just like in LPMUD. program_t->line_numbers is + an array with the same length as there are lines. Each + element contains the index into the code array at which + the line begins. To find a line number using cp: + get offset into code (cp - code), loop through line_numbers + while our offset is bigger than the element in line_numbers. + If offset is smaller or equal, it means that it must be on + the current index. + + - profiling memory usage - find out if variables are really freed and if they're + being overduplicated or something. + + - everything to do with arrays, notably: + - operators: + & &= + - call_other on an array + - foreach() + + - dfuns + delete + member_array + explode, implode + save_object, restore_object + crypt + - allow 'string foo; foo[0]="a";' - sprintf and printf - Interpreter. ? 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: ! break, continue @@ -45,16 +69,14 @@ - 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). - keep interactive objects in a separate linked list, and make shout act on that list - LPC: - ! arrays (T_ARRAY) - - foreach(), switch() + - switch() - all of the operators (/doc/lpc/operators) - ',' - this takes some serious grammar-hacking, because comma as a function call argument is a separator for expressions. - mixed type - - string slices (ranges) + - string slices ! assigning to slices (F_SLICE_LVALUE etc.) - Check if assigning too long a string. * m.. @@ -72,32 +94,25 @@ warnings low-warnings no-warnings - - #define name value - - #define name(x) value x - - #include, #ifdef, #else, #endif - #if - defined() - have_dfun() - !, &&, || - - #elsif - predefined names: - #define __AGD__ 1 - #define __VERSION__ PACKAGE_VERSION - Also possible: - #define __AGD_MAJOR__ 0 - #define __AGD_MINOR__ 0 - #define __AGD_SUBMINOR__ 2 - #define __AGD_PATCHLEVEL__ 3 - But these are quite pointless at this time. - #define __ARCH__ PLATFORM - #define __HOST__ the return value of gethostname() - #define __AUTHORS__ ? :) + __HOST__ the return value of gethostname() + __AUTHORS__ - character encoding inside strings: - decimal: \nnn - octal: \0nnn - hexadecimal: \0xnn - binary: \nnnnnnnnb - - multiline strings + - multiline strings (like this: + string s = "@@@FOO + blah + blah + blah + FOO"; + Or however it's done elsewhere. ? Better function lookup table (prog->nametable)? O(1) would be nice. @@ -106,16 +121,14 @@ - log using lib's facilities (master::log()?) - different prefixes have different debuglevels - save to different files - ? only report undeclared identifiers once (this is generally a Bad Thing) - warn about unused variables - initialization of global variables - dfun overrides, :: operator + ? check for lib root and folder of debug log with access() and exit gracefully if it fails. - ? if we crash while running apply(master::crash), then we should rerun with debugging on + ? IPv6 support? - ? Supply a malloc implementation with statistics (a la MudOS)? - ? Statistics and profiling ? Some work could be done on i18n. For example, allow for multilingual yyerror-messages. One way would be a master::error_msg() apply that takes a numeric code of the error message and should return the string. Mudlib coders can code in their own language. Index: Ideas =================================================================== RCS file: /cvsroot/agd/server/Ideas,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Ideas 8 Jun 2004 20:18:43 -0000 1.9 +++ Ideas 21 Jul 2004 12:13:09 -0000 1.10 @@ -1,5 +1,9 @@ This file contains features that will be or will be not in AGD in the future. lpc: + * The traditional naming conventions of LPC should be rationalized. + this_player() and this_object() are a bit too long to type out + each time. Just player() and this() or self() should suffice. + environment() -> env() etc, too. * superscope global variables. Maybe called world scope? i.e. global foo; - then can be accessed from any object. And this_object/this_player are driver-defined world globals. Index: ChangeLog =================================================================== RCS file: /cvsroot/agd/server/ChangeLog,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- ChangeLog 20 Jun 2004 14:05:16 -0000 1.21 +++ ChangeLog 21 Jul 2004 12:13:09 -0000 1.22 @@ -1,5 +1,14 @@ 0.0.3: ---------------------------------------------------------------------------- +2004-06-23 + * compile.c,lang.y,interpret.c,vars.c: + operator for arrays + * compile.c: fixed adding definitions for prototypes - their code wasn't + added + * main.c: startup_time is set before compiling master so that it could + use uptime(). + * lang.y: fixed popping locals after leaving block +2004-06-22 + * interpret.c,lang.y: arrays basically work. 2004-06-15 * interpret.c: TAKE_SLICE is now a function instead of a macro GET_ARGS changed: arg[0] is now the FIRST argument and |