Commit Graph

278 Commits

Author SHA1 Message Date
Yuichi Nishiwaki f854e225c8 test implementation for closed variable reference 2013-10-24 00:33:37 +09:00
Yuichi Nishiwaki ec0f0d3572 add pic_calloc 2013-10-24 00:32:03 +09:00
Yuichi Nishiwaki 0fd1bbeae9 throw wrong number of arguments error for user defined lambda call 2013-10-24 00:09:40 +09:00
Yuichi Nishiwaki 2ec7f381d0 cleanup codegen.c 2013-10-23 17:26:02 +09:00
Yuichi Nishiwaki 79ee6f6ae4 introduce codegen_state structure 2013-10-23 17:25:39 +09:00
Yuichi Nishiwaki 035de0016b evaluate arguments in normal (lexical) order 2013-10-23 15:55:42 +09:00
Yuichi Nishiwaki d12ed0a139 rename pic_scope -> codegen_scope 2013-10-23 15:52:14 +09:00
Yuichi Nishiwaki 947ddc45c8 bugfix: lambda must use new_scope to gen body code 2013-10-23 15:46:18 +09:00
Yuichi Nishiwaki cc025626d5 use start state to parse strings 2013-10-23 13:44:45 +09:00
Yuichi Nishiwaki dd7958c3d6 reader supports quasiquote abbrev 2013-10-23 12:39:48 +09:00
Yuichi Nishiwaki f01ac50dd2 add set-car!/set-cdr! 2013-10-23 12:01:06 +09:00
Yuichi Nishiwaki 5f05fed38f add missing extended identifier characters 2013-10-23 12:00:53 +09:00
Yuichi Nishiwaki f31ddb36a2 reentrant scanner 2013-10-23 03:45:57 +09:00
Yuichi Nishiwaki bb0bb0e186 reentrant parser (but not for scanner) 2013-10-23 03:13:10 +09:00
Yuichi Nishiwaki dd3adf30e6 use xhash to manage scopes during codegin 2013-10-22 22:22:35 +09:00
Yuichi Nishiwaki 76cba3fad2 add some number-theoretic division functions 2013-10-22 18:29:55 +09:00
Yuichi Nishiwaki 828606aed5 throw an error when finding invalid argument specifier 2013-10-22 17:44:47 +09:00
Yuichi Nishiwaki 779199d571 add many many number primitive functions 2013-10-22 17:24:07 +09:00
Yuichi Nishiwaki d696339577 [bugfix] pic_get_args should ignore optional args when i > argc 2013-10-22 17:23:21 +09:00
Yuichi Nishiwaki b45d7d9592 add eof-object type 2013-10-22 16:02:20 +09:00
Yuichi Nishiwaki 176d167de8 add some file open functions 2013-10-22 15:44:03 +09:00
Yuichi Nishiwaki 6245ec7e05 finalize port objects when collected 2013-10-22 15:40:36 +09:00
Yuichi Nishiwaki d2e09fa2c7 add file related functions 2013-10-22 15:16:35 +09:00
Yuichi Nishiwaki 0c1babb6c5 add pic_reverse 2013-10-22 00:19:43 +09:00
Yuichi Nishiwaki 114d6b708b since pic_string is a first-class value, move it to value.h 2013-10-21 17:38:05 +09:00
Yuichi Nishiwaki f5154625ba add aux object field to proc object 2013-10-21 17:35:14 +09:00
Yuichi Nishiwaki 72a6e90d83 exit functions take an optional argument 2013-10-21 14:13:08 +09:00
Yuichi Nishiwaki 86177b7c4e pic_get_args supports optional argument 2013-10-21 13:57:02 +09:00
Yuichi Nishiwaki 6c8dd50ab8 add exit and emergency-exit 2013-10-21 12:08:46 +09:00
Yuichi Nishiwaki db1f977600 add pic_list_p 2013-10-21 12:03:35 +09:00
Yuichi Nishiwaki 15c4361381 return #f if get-environment-variable refers undefined env-var 2013-10-21 12:03:25 +09:00
Yuichi Nishiwaki adab797391 add system.c 2013-10-21 11:51:02 +09:00
Yuichi Nishiwaki 7dbb2c6de4 cleanup 2013-10-21 11:44:23 +09:00
Yuichi Nishiwaki b02f81760c pic_get_args supports strings 2013-10-21 11:42:21 +09:00
Yuichi Nishiwaki ba78a00d5c take care of escaped characters in string 2013-10-21 11:12:34 +09:00
Yuichi Nishiwaki 8f4788ca27 read strings 2013-10-21 10:48:03 +09:00
Yuichi Nishiwaki a49675c322 add OP_PUSHCONST 2013-10-21 09:29:56 +09:00
Yuichi Nishiwaki 5e43fe58fe add string type 2013-10-21 08:48:55 +09:00
Yuichi Nishiwaki cefa9a9885 handle runtime error 2013-10-20 23:30:01 +09:00
Yuichi Nishiwaki d57d8ff3c0 place main.c under etc/ 2013-10-20 18:44:26 +09:00
Yuichi Nishiwaki 05eb62cc4d do not abort when meet a compilation error 2013-10-20 18:17:12 +09:00
Yuichi Nishiwaki 4f8aa03b24 clarify the meanings of error functions 2013-10-20 17:41:48 +09:00
Yuichi Nishiwaki 12e2f10869 add error.c file 2013-10-20 17:26:18 +09:00
Yuichi Nishiwaki 444fc7c750 split codegen and vm 2013-10-20 17:06:47 +09:00
Yuichi Nishiwaki 510b84702e eq? compares symbol's ptr 2013-10-20 14:07:27 +09:00
Yuichi Nishiwaki 7322271d65 intern symbols using hash table 2013-10-20 14:05:48 +09:00
Yuichi Nishiwaki bde09e063a add pic_acons function 2013-10-20 14:04:39 +09:00
Yuichi Nishiwaki 40c996bd03 fix confusion of GC_DEBUG and VM_DEBUG 2013-10-20 13:07:14 +09:00
Yuichi Nishiwaki 6d8d7bb8bd exit repl with ^D 2013-10-20 12:57:15 +09:00
Yuichi Nishiwaki 50b9c2bd97 add pair.h 2013-10-20 12:34:57 +09:00
Yuichi Nishiwaki 6faaa5261c add time functions 2013-10-20 12:04:15 +09:00
Yuichi Nishiwaki cfae6f3c59 add OP_NILP 2013-10-20 03:53:02 +09:00
Yuichi Nishiwaki 78f301794a add OP_CAR/OP_CDR 2013-10-20 03:48:06 +09:00
Yuichi Nishiwaki 9bb3c4f4db suppress warnings around parser/scanner 2013-10-20 03:11:08 +09:00
Yuichi Nishiwaki daac4dd7f3 suppress compiler warnings 2013-10-20 03:05:42 +09:00
Yuichi Nishiwaki 5e96d05fd1 insert OP_POP into sequential operation 2013-10-18 02:29:11 +09:00
Yuichi Nishiwaki 3d523a8081 the first callinfo's argc is 1 2013-10-18 01:30:35 +09:00
Yuichi Nishiwaki a0e2089e56 mark global variables 2013-10-18 00:17:55 +09:00
Yuichi Nishiwaki e7a5784fd7 allocate global variable entry area by malloc and save it into pic_state 2013-10-18 00:15:15 +09:00
Yuichi Nishiwaki c92a672e01 change the stack layout: to hold proc object on the stack when procedure
call is invoked
2013-10-17 23:29:18 +09:00
Yuichi Nishiwaki 1646de5e8d initial port commit 2013-10-17 22:42:47 +09:00
Yuichi Nishiwaki e87f632327 writer writes lists in short form 2013-10-17 22:42:20 +09:00
Yuichi Nishiwaki b58c6d1e8b remove test_object_creation from main.c 2013-10-17 21:00:54 +09:00
Yuichi Nishiwaki 986afa2fc9 add missing preprocessor if statement 2013-10-17 20:55:33 +09:00
Yuichi Nishiwaki 1a6c8a3cca support multi-line input in REPL 2013-10-17 20:48:50 +09:00
Yuichi Nishiwaki 458ac6b9ab support dotted list 2013-10-17 18:14:18 +09:00
Yuichi Nishiwaki 87aae8dd8f refactor port.c 2013-10-17 17:57:27 +09:00
Yuichi Nishiwaki 5671c43a77 do not abort when finding syntax error 2013-10-17 17:57:12 +09:00
Yuichi Nishiwaki d9e47bdd05 add begin syntax 2013-10-17 17:54:28 +09:00
Yuichi Nishiwaki 17f0c928da add readline support 2013-10-17 17:08:33 +09:00
Yuichi Nishiwaki 0ccff2f626 free nested environment in codegen 2013-10-17 14:29:37 +09:00
Yuichi Nishiwaki 7925f2b502 implement direct threading VM 2013-10-17 13:54:48 +09:00
Yuichi Nishiwaki 3ecfe821e2 emit error message when compiling a reference to a closed variable 2013-10-17 13:38:09 +09:00
Yuichi Nishiwaki 840593f5f3 remove noisy debug print 2013-10-16 17:49:16 +09:00
Yuichi Nishiwaki fc152f034a debug printer supports OP_LREF 2013-10-16 17:49:07 +09:00
Yuichi Nishiwaki 6bd4747673 debug printer supports OP_JMP/OP_JMPIF 2013-10-16 17:46:33 +09:00
Yuichi Nishiwaki 27da3d030b add less than(<) operator 2013-10-16 17:43:38 +09:00
Yuichi Nishiwaki 4d4fbeb9aa allow recursive function definition 2013-10-16 17:43:23 +09:00
Yuichi Nishiwaki 6c903db758 if syntax 2013-10-16 17:42:47 +09:00
Yuichi Nishiwaki 87dce75c78 add local variables 2013-10-16 17:20:53 +09:00
Yuichi Nishiwaki 5c8d81e8b5 support closure call 2013-10-16 15:30:52 +09:00
Yuichi Nishiwaki 49e1f54195 fix stack operation bug 2013-10-16 13:24:19 +09:00
Yuichi Nishiwaki 9b7fdb0725 undef object must not appear in the user land 2013-10-16 13:24:08 +09:00
Yuichi Nishiwaki ff646e05dd support boolean values 2013-10-16 13:17:01 +09:00
Yuichi Nishiwaki a6920c192f add compiler option -Wall 2013-10-16 13:15:43 +09:00
Yuichi Nishiwaki f6eddbc6d3 save all ireps into pic_state
in order to decrease the stress GC will get, restore irep structures
under pic_state instead of under each procs and making it collectable object
2013-10-16 11:53:25 +09:00
Yuichi Nishiwaki c593a46a62 add OP_LAMBDA (lambda object creation) 2013-10-16 11:32:30 +09:00
Yuichi Nishiwaki 19abedf746 warn when a closure is applied 2013-10-16 11:28:57 +09:00
Yuichi Nishiwaki b60e4df3d9 add pic_realloc 2013-10-16 11:21:41 +09:00
Yuichi Nishiwaki 40a971230d read signed real numbers 2013-10-16 10:19:16 +09:00
Yuichi Nishiwaki 4340c23f20 cleanup 2013-10-16 09:30:35 +09:00
Yuichi Nishiwaki 728a4cb9d5 [gc] mark ci 2013-10-16 09:29:47 +09:00
Yuichi Nishiwaki 62303ed91e [gc] mark predefined symbols 2013-10-16 09:29:39 +09:00
Yuichi Nishiwaki a90e124697 change ways of taking care of CI 2013-10-16 09:28:58 +09:00
Yuichi Nishiwaki 04896bcd93 [gc] bugfix: do not mark a value out of the stack range 2013-10-16 09:28:13 +09:00
Yuichi Nishiwaki 136977f357 [gc] show freed object counts 2013-10-16 09:22:15 +09:00
Yuichi Nishiwaki c41c5533fe [gc] more debug prints 2013-10-16 09:21:57 +09:00
Yuichi Nishiwaki 1fc4ef18d1 fix gc bug 2013-10-16 09:21:13 +09:00
Yuichi Nishiwaki 36b455d9c2 do not pop sp in pic_get_args; OP_CALL takes care of stack unwinding 2013-10-16 09:19:43 +09:00
Yuichi Nishiwaki 910f370482 [gc] base header size is 1, not 0 2013-10-16 09:17:44 +09:00
Yuichi Nishiwaki 22abdae12a add callinfo 2013-10-15 23:29:34 +09:00
Yuichi Nishiwaki ea6230e90c configurable stack size 2013-10-15 23:28:23 +09:00
Yuichi Nishiwaki f280b0a5ce add some mathematic functions 2013-10-15 23:26:18 +09:00
Yuichi Nishiwaki 7f04cad34d scan real numbers 2013-10-15 23:25:31 +09:00
Yuichi Nishiwaki 0515b8ba2a pic_get_args supports double type (f) 2013-10-15 23:25:07 +09:00
Yuichi Nishiwaki e42eb5acd5 change ways of stack operation (no longer push dummy object at first) 2013-10-15 22:34:20 +09:00
Yuichi Nishiwaki a93c3caabf move pic_env to proc.h 2013-10-15 21:53:45 +09:00
Yuichi Nishiwaki b998c903a3 remove eval.c 2013-10-15 21:52:44 +09:00
Yuichi Nishiwaki d40c8b5921 add cfunc_p flag to pic_proc 2013-10-15 21:52:14 +09:00
Yuichi Nishiwaki a5dcaba970 add support for arithmetic operations 2013-10-15 21:29:07 +09:00
Yuichi Nishiwaki 2d4a5ed1ea add standard functions: write/newline 2013-10-15 21:14:33 +09:00
Yuichi Nishiwaki af9dd45e65 change the type of immediate number value from int to double 2013-10-15 20:05:12 +09:00
Yuichi Nishiwaki 02d52723ac add some FFI functions such as pic_defun and pic_get_args 2013-10-15 19:19:34 +09:00
Yuichi Nishiwaki 8a5ea7d7dc implement OP_CALL 2013-10-15 19:18:33 +09:00
Yuichi Nishiwaki e5ada35d9d directly change pic->sp via PUSH/POP macros 2013-10-15 19:15:51 +09:00
Yuichi Nishiwaki 266e6c6400 change repl prompt 2013-10-15 19:12:33 +09:00
Yuichi Nishiwaki 6a10162c2c add picrin/proc.h 2013-10-15 13:21:40 +09:00
Yuichi Nishiwaki daece7ae67 add object creation debug flag to picconf 2013-10-15 09:14:34 +09:00
Yuichi Nishiwaki 099d40cfb8 print raw read expression in repl 2013-10-15 09:08:10 +09:00
Yuichi Nishiwaki 78303a72e5 include necessary headers when GC_DEBUG 2013-10-15 09:07:55 +09:00
Yuichi Nishiwaki 2afdb54c16 print generated irep 2013-10-15 09:07:19 +09:00
Yuichi Nishiwaki fea6b7f633 push undef to the stack as a first dummy object 2013-10-15 09:02:49 +09:00
Yuichi Nishiwaki 528c2e2c15 bugfix around GC 2013-10-15 08:58:23 +09:00
Yuichi Nishiwaki 6bd38273d2 free arena objects created in main function 2013-10-14 18:29:30 +09:00
Yuichi Nishiwaki 42dbd5fe98 save some special symbols in pic_state structure 2013-10-14 18:28:52 +09:00
Yuichi Nishiwaki 8c73ded2c4 add debug prints at GC 2013-10-14 18:22:14 +09:00
Yuichi Nishiwaki 276e139ec6 fix bugs around GC 2013-10-14 18:21:56 +09:00
Yuichi Nishiwaki ed7a9d5758 fix commit bug introduced in HEAD^^ 2013-10-14 17:36:07 +09:00
Yuichi Nishiwaki 22414b61e8 let the printer output proc objects and unknown values 2013-10-14 17:35:01 +09:00
Yuichi Nishiwaki c706d4f326 sweep objects from base pointer (not from freep) 2013-10-14 17:34:04 +09:00
Yuichi Nishiwaki a7cc9bd69d add missing braek statement 2013-10-14 17:32:24 +09:00
Yuichi Nishiwaki c53bf58e7e move debug prints 2013-10-14 17:07:09 +09:00
Yuichi Nishiwaki daa65bdecf pop value from the stack at the end of VM execution 2013-10-14 17:05:49 +09:00
Yuichi Nishiwaki 298a8e685f replace use of malloc/free with pic_alloc/pic_free 2013-10-14 17:04:59 +09:00
Yuichi Nishiwaki a5db43ba91 add object finalizer 2013-10-13 19:00:39 +09:00
Yuichi Nishiwaki dc2f25ef2a initial GC commit 2013-10-13 19:00:12 +09:00
Yuichi Nishiwaki 2ef277d5bd add arena protection to the VM 2013-10-13 17:29:21 +09:00
Yuichi Nishiwaki 8b859d4dbc define stack operation macros POP and PUSH 2013-10-13 17:27:44 +09:00
Yuichi Nishiwaki f0541e0f6b arena doesn't have to be explicitly initialized 2013-10-13 17:26:17 +09:00
Yuichi Nishiwaki a6f561d66e change the type of argument pic_gc_protect accepts 2013-10-13 17:25:36 +09:00
Yuichi Nishiwaki ee985a31cd add GC arena 2013-10-13 17:02:29 +09:00
Yuichi Nishiwaki 012b387c89 change the semantics of pic_alloc/pic_free 2013-10-13 16:56:30 +09:00
Yuichi Nishiwaki a0556087f9 rename pic_gc_alloc to pic_obj_alloc 2013-10-13 16:55:07 +09:00
Yuichi Nishiwaki 1fb9ac5d03 let pic_proc be a first class object 2013-10-13 16:16:13 +09:00
Yuichi Nishiwaki d92bd71293 force alignment of headers 2013-10-13 16:02:08 +09:00
Yuichi Nishiwaki c250d3b07f use C malloc instead of pic_alloc 2013-10-13 16:01:40 +09:00
Yuichi Nishiwaki e3600a65c9 replace mock allocator with simple k&r malloc 2013-10-13 15:14:15 +09:00
Yuichi Nishiwaki 38858e7a11 replace big VM loop stuff with macros 2013-10-12 18:48:35 +09:00
Yuichi Nishiwaki 3eefa2669f depress compiler warnings 2013-10-12 18:46:41 +09:00
Yuichi Nishiwaki e4be084b0e skip whitespaces in lex 2013-10-12 18:46:11 +09:00