Parent Directory | Revision Log
Links to HEAD: | (view) (annotate) |
Links to HEAD: | (view) (annotate) |
Sticky Tag: |
Extracted garbage collector to gc.c
stack.c (printerr): Modified to accept error type 5. (check_args): Modified to accept "empty" as argument. symbols.c: New symbols (sx_72616e646f6d), (seed), (ticks), (push) and (pop).
messages.h: Removed "\n" at the end of messages. stack.c, stack.h (printerr): Made function smarter. stack.c, symbols.c: Made better use of "check_args" and "printerr".
stack.c, symbols.c: Some functions changed to use check_args. Replaced printf with puts where possible.
(check_args) New function to ease the checking of parameters.
stack.c: Trying to clean up. Moving big text mass to separate file. Eliminating the use of function toss.
(mangle) Moved from "stack.c" to "symbols.c". Makefile: Added tail recursion optimization.
Removed some more "content.ptr".
(assocgen) Moved from "stack.c" to "symbols.c" + minor change in "stack.h".
Trying to remove "content.ptr" and type casts from the source.
(gc_init) Making use of macros "CAR" and "CDR".
(stack.c) Cleaning up.
stack.c (main): Exit on any error from "read", not just EOF. Loop around if the "toss" call fails. Don't call 'gc_init' if we already called "eval".
stack.c (gc_init): Don't GC ports. (nl): Added an "environment*" argument. All callers changed. (nlport): New function. (type): Know about ports. (print_val): Added a FILE* argument to print to. All callers changed. Also check for write errors from "fprintf". Also, print ports. If printing a list, goto out of it if a write error occurs and don't print any further. (print_): Check for errors after "print_val". (printport_, printport, princport_, princport): New functions. (print_st): Added an "environment*" argument. All callers changed. (eval): Toss empty lists; if lists are functions, then empty lists are NOPs. Also, don't eval ports. (main): Reset error after showing it to protect "nl" and "printstack". (copy_val): Don't protect the old value. Was there ever a need to do that? Also, know about ports. (readline): Just call "readlinestream". (readlineport, readlinestream): New functions. (read): Just call "readstream". (readport, readstream): New functions. (sx_6f70656e, sx_636c6f7365): New functions "open" and "close". stack.h (value.type): New type; "port". (value.content): New container; "p". (nl): Added an "environment*" argument. (nlport): New function. (print_val): Added a FILE* argument. (printport_, printport, princport_, princport): New functions. (print_st): Added an "environment*" argument. (readlineport, readlinestream, readport, readstream, sx_6f70656e, sx_636c6f7365): New functions.
stack.c: (sx_646f): New function "do".
stack.c: (foreach): Bugfix
stack.c: (to): Bugfix.
stack.c (assocgen): New function; generalized version of "assq". (assq): Changed to just call "assocgen" with proper arguments. stack.h (assocgen): New function.
stack.c (assq): New function. stack.h (assq): New function.
stack.c: Added a call to assert() after every malloc().
stack.h: Reordered to match the order in "stack.c". (print_h): Renamed to "print_val" and added an argument. (setcar, setcdr, car, cdr, cons): Added declarations. stack.c (CAR, CDR): Added more parentheses. (new_val): All new values are the empty list. All callers changed. (print_val): Print circular lists correctly by searching a stack which is passed recursively as a new argument. All callers changed.
stack.c: Specify coding system as UTF-8. (gc_init): Removed unused variable "iterator". Free pairs. (push_val, copy_val, cons): Increase env->gc_count when creating new pair. (eval): Changed "default:" case to an enumeration of all types. (copy_val): New case for type "empty". (sx_72656164 "read"): Removed unused variable "ctemp".
stack.h (cons): Renamed to "pair". All users changed. stack.c (cons): New function.
stack.c (gc_init): Bugfix: Calculate strings' memory usage correctly. (print_val): Inconsequential rewrite. (sx_72656164 "read"): Bugfix: Extra case for empty strings.
stack.c (CAR, CDR): Extra parentheses around macros is probably a good idea. (type): "list" renamed to "pair". (print_h): Renamed to "print_val", and it now takes a value, not a stack. All callers changed. Also, bugfix: print improper lists correctly. (setcar, setcdr, car, cdr): New functions.
stack.c (type): Eliminated unnecessary variable "typenum". Detect type of empty list value. Bugfix: Toss the *value*, not the *result*... (print_h): Print empty list value correctly.
The empty list and the indicator of the end of a list is no longer a value* which is NULL, but the "empty list" value, a type of its own. All affected functions changed. stack.h (value.type): New type, "empty". (environment): Comments added. stack.c (print_h): Print improper lists correctly. (rev): Don't bother reversing an empty list value. (forget): Eliminate unnecessary variable "stack_head". (copying): Fixed centering of first line.
stack.c (gc_init): Extra optional debugging output. (rcl): Don't call protect(), no need for it if we don't toss the value. (eval): Don't crash on lists with exactly one element. (quit): Print all defined words (hopefully none) just before quitting. (words): Extra optional debugging output. (main): Changed ` to ' where appropriate. On EOF, reset error flag before calling "quit".
stack.c: (sx_656c7365): "else" now requires a "then". (then): New function.
Makefile (LDFLAGS): Include commented-out alternate setting. stack.c (new_val): New values are integers. (push_val): Check malloc return value. (copy_val): Don't protect new_val.
stack.c (beep): #ifdef'ed out if not linux.
stack.c: (sx_656c7365): New function "else".
stack.h: (value->content.sym): New entry in content union. All callers changed. stack.c: (foreach): Bugfix.
stack.c: (CAR, CDR): New macros. All callers changed. stack.h: (environment.head): Changed type to "*value". All callers changed.
stack.h: Some comments added. stack.c (print_h, eval, rev, expand, copy_val, foreach, to): content.ptr changed to content.c in those places where the type already has been checked to be "tcons" or where it's part of the stack, (which always must be a proper list). (eval, expand, foreach): Check for improper lists. (copy_val): Don't loop, recurse into both car and cdr instead.
Modified internal data structure to use cons cells instead of simple linked lists. There is now a new value type "tcons".
stack.c (gc_init): printf format bug fix. (gc_init): Also decrease gc_count by length of strings. (push_cstring): Increase gc_count by string length.
stack.c: environment.gc_limit and environment.gc_count is now measured in bytes, not number of sizeof(value). All increasers and decreasers changed. (init_env): Default gc_limit is now 400000, same as Emacs. (toss): Don't decrease gc_limit or gc_count (both would be wrong). (gc_init): Print garbage collecting messages if interactive. (gc_init): Increase gc_count for every value not collected. (gc_init): Never make gc_limit smaller than its current value.
stack.h (value): Renamed gc_protect to gc.flag.protect and replaced gc_garb with gc.flag.mark with reversed meaning. All users changed. (value): New field "no_gc", which is both flag.protect and flag.mark. stack.c: All users of gc_protect and gc_garb changed. (gc_init): Check both mark and protect at the same time through gc.no_gc. (new_val): Initialize gc.flag.protect too.
(protect, unprotect): Changed behaviour to mimic gc_mark. All callers changed.
stack.c (new_val): Set gc_garb flag. (gc_mark): Removed check if val is NULL. (gc_init): Various optimizations. fib.st: Changed to calculate "15 fib;".
Makefile: Compile with "-pg" for profiling. stack.c: Some optimizing: (init_env): Increased gc_limit. (toss, new_val): Don't run GC. (gc_mark): Declare inline. (gc_maybe): New function, all callers of gc_init calls this one instead. (eval): Call gc_maybe.
Cosmetic changes. stack.c (to): Rewritten to mimic behaviour of "pack".
(sx_646976): New function "div", integer division.
(new_val, gc_init, push_sym, eval, pack, copy_val, to, sx_72656164): Bugfix in GC. (push_int, push_float, type, print_h, not, sx_2b, sx_2d, sx_3e, sx_6966, ifelse, sx_7768696c65, sx_666f72, to, beep, sx_2a, sx_2f, mod): New value type "tfloat". (sx_3c, sx_3c3d, sx_3e3d): New functions "<", "<=" and ">=".
(sx_2a, sx_2f, mod): "*", "/" and "mod". Arithmetic functions.
GPL stuff: stack.c, stack.h, Makefile: Added notices stack.c (copying, warranty): New functions. stack.h (copying, warranty): - '' - Other stuff: Makefile (stack): New explicit rule to depend on "stack.h" too. (mtrace): Depend on "stack", not "all". (check): New target. stack.c (main): Don't return error on EOF. (beep, wait): New functions. stack.h (beep, wait): - '' -
(protect, unprotect): New functions to protect values from GC.
(new_val, gc_init, main) GC bugfix/trimming. (sx_666f72 "for") Changed name to "foreach". (sx_666f72) New function. (eval) "(*func)()" is equal to "func()". (value) Data structure optimation. (stack.h) Removed variable names from prototypes.
Separated into header file and C file.
Added GC: (free_val) Removed (all callers changed). (new_val, gc_mark, gc_init) New functions. (copy_val) Added argument with pointer to current environment.
(push_sym): Search for the mangled name *before* trying the unmangled name.
(main): Only reset error flag after a complete read. More consistent comments on mangled functions.
(environment): New members "inputstream" and "interactive". (init_env): Init all members in the same order as in the struct. (quit): Bug fix: Don't run "words". (main): Read options with getopt. Set the interactive flag. Exit on error 4 (EOF) from "read". (dup): Renamed/mangled to "sx_647570". All callers changed. (readline): Push "" if EOF. (read): Renamed/mangled to "sx_72656164". All callers changed. Don't print prompt unless interactive. Abort with error 4 on EOF.
(Makefile) Added target to trace memory leaks. (push_int, push_cstring, pack, read, quit) Memory leaks patched.
(free_val) Can now free symbols. (push_int, push_cstring) Bugfix.
(environment) Removed non_eval_flag (all users changed). (free_val) Always free the value struct and id tag when refcount is 0. (push_int, push_cstring) Set id tag to NULL. (mangle) Use push_cstring instead of push_val.
(print_h): New argument "noquote"; used by "print_" and "print_st", which are changed. (princ, princ_): New; print strings unquoted. (printstack): Print message instead of nothing when stack is empty. (eval): Bug fix: Move label above error check to fix "[;];". (quit): Bug fix: Correctly forget all symbols. (main): Print a newline before the stack, and a prompt after it. (read): Print a prompt of our own if we are reading a list.
(quit) Bugfix.
(environment): New field "free_string". (rev): Reverted to version 1.75; there was nothing wrong with it. (read): Rewritten to use "%n" instead of "%[\001-\377]".
(quit): Free all memory before exiting. (forget): Call 'forget_sym' to do the work. (forget_sym): New internal function that doesn't do hashing.
(rev) Rewritten to allow reversion of lists with up to 1000000 elements.
(push) Removed. (changed every caller to call 'push_val' instead.)
(pack) Changed to use 'push_val' instead of 'push' (to) Changed to not use 'pack'. 'to' can now count upto 1000000 without segmentation fault.
(pack) Changed so that it only accepts '[' and ']' as delimiters (all callers changed).
(push, push_val, push_int, push_cstring) Changed first argument to "environment *env" similar to push_sym (all callers changed).
(eval) Removed possibility to eval strings. (stack_read) Removed. (main) Runs 'printstack' instead of printing "okidok". (read) Bugfix.
(environment) Added new member 'in_string' (all users changed). (read) Bug fix.
(main) Use 'read' instead of 'stack_read'.
(readline, read) New functions.
(to) Can count down.
(to) New function.
(sx_666f72 'for') New function.
(eval): Use "goto" to run tail recursive functions in constant space.
(sx_7768696c65 'while') Rewrite/bugfix.
(sx_2b, sx_2d, sx_3e): Reuse the top integer value, but only if it's safe.
(sx_3e): New function ">".
(sx_2d): New function "-".
(type, print_h): Removed default case. (eval): Various changes to try and make tail recursive lists eval in constant space.
(print_h) Don't print "string" when I want to print string. (sx_7768696c65 'while' mangled) New function.
(ift) changed name to sx_6966 ('if' mangled). (ifte) changed name to ifelse.
(rot, ift, ifte): New functions.
(copy_val): New function; makes a copy of a value. (dup): New function; uses 'copy_val' to make a copy of an item on the stack.
(free_val, eval): Changed "default:" cases to instead enumerate the possible types.
(mangle_str): Handle eight-bit characters.
Headers: Updated comments. Removed <assert.h>.
(mangle_): Renamed to "mangle_str". All callers changed.
(mangle_): Bug fix
(eval) Bugfix. (sx_2b) Can now concatenate strings.
(mangle, mangle_): New functions to mangle symbol names into acceptable C identifiers. (printerr, toss): Moved upward. We REALLY need a header file.
(eval) Cosmetic changes.
Cosmetic changes. (eval) Added possibility to eval strings. (environment) Now contains non_eval_flag.
(print_h): Fixed print<->read equivalence of symbols.
(eval) Added functionality to evaluate a list.
(stack_read) Added functionality to accept comments as in bourne shell. (expand) Flips list before expanding.
(main): Return EXIT_FAILURE as a fallback.
(main): Use "quit" function, not exit().
(pack): Reverse new lists so that they can be traversed in the correct order. (rev): Moved to before "pack". There really ought to be a header file.
(rev): New function to reverse a list.
Print lists.
(free_val): fixed bug when freeing string values (type): New function; gets the type of a value (printstack): An empty stack is not an error anymore (stack_read): Return void
Standardized all error messages. (errn): New function to get error number.
(value): Removed reference type. (push, push_int, push_cstring, push_sym): Changed to return void. (environment): New member "err". All functions adapted. (print_h): Differentiate between functions, lists, and unknown objects. (eval): Changed to use "rcl". (main): Show and clear error condition.
Added funtion 'forget'.
New error flag in environment. Bug fix in "rcl" for undefined variables.
Added function 'words'.
New function "rcl".
Cosmetic changes.
Fixed binding of variables.
Major data structure overhaul. Everything changed.
Remove Emacs local variables.
Now it's possible to store and access variables.
Minor changes.
Added possibility to make empty lists.
Cleanup of print_ .
Cleanup of function "eval".
Corrections.
Now it's possible to make lists with ';' as list elements, i.e. [ "Hey!" print; ].
Lists can now be made just by typing "[ 1 2 3 4 ]".
Some doc fixes and some checks.
Added error messages.
Minor changes. Added some more comments.
Made stack_read readable.
Added comments to the code.
stack_read modified to accept single characters escaped with backslash.
New function "def" for defining new variables and such. You can't access the variables yet though. This needs some thought and working on.
New functions: eq, not, neq.
New function "swap". No explanation needed.
Minor change in push_ref.
New function "expand" to match the "pack" function.
New funtion "pack" to make lists (made new type list in struct).
Now, print and printstack print the symbol name and dlopen(NULL, RTLD_LAZY) is only called once. The handle is stored in a static variable in push_ref().
(print): Changed if...else to a switch...case. (quit): New function.
New type: symbol.
Added some comments.
(print_st): Changed if...else to a switch...case.
Initial revision
This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, select a symbolic revision name using the selection box, or choose 'Use Text Field' and enter a numeric revision.
root@recompile.se | ViewVC Help |
Powered by ViewVC 1.1.26 |