elco-svn Mailing List for elco
Status: Planning
Brought to you by:
esden
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(6) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: <no...@gi...> - 2008-07-26 17:24:47
|
Commits to esden/elco Ref: refs/heads/elco-arc Home: http://github.com/esden/elco |
From: <no...@gi...> - 2008-07-21 18:35:06
|
Commits to esden/elco Ref: refs/heads/master Home: http://github.com/esden/elco 2008-07-21T11:33:54-07:00 - Piotr Esden-Tempski (pi...@es...) http://github.com/esden/elco/commit/c5549a4e5f75b6730be7a680ab70c54a0f191ff9 Added a simple execute.sh to make running simple programs easier. |
From: <es...@us...> - 2008-07-20 23:20:45
|
Revision: 44 http://elco.svn.sourceforge.net/elco/?rev=44&view=rev Author: esden Date: 2008-07-20 23:20:38 +0000 (Sun, 20 Jul 2008) Log Message: ----------- ELCO MOVED TO GITHUB! You can find the current version of elco under: http://github.com/esden/elco/tree/master Added Paths: ----------- trunk/ELCO-MOVED-TO-GITHUB Added: trunk/ELCO-MOVED-TO-GITHUB =================================================================== --- trunk/ELCO-MOVED-TO-GITHUB (rev 0) +++ trunk/ELCO-MOVED-TO-GITHUB 2008-07-20 23:20:38 UTC (rev 44) @@ -0,0 +1,5 @@ +ELCO has moved to github. + +You can find the current version of ELCO on: + +http://github.com/esden/elco/tree/master This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <es...@us...> - 2008-07-14 15:17:52
|
Revision: 43 http://elco.svn.sourceforge.net/elco/?rev=43&view=rev Author: esden Date: 2008-07-14 08:17:50 -0700 (Mon, 14 Jul 2008) Log Message: ----------- - Preparing for reimplementation in arc (the language implemented will be arc too probably with future bit-/registerfiddeling extentions) - Moved current CommonLisp implementation to cl-elco for reference Added Paths: ----------- trunk/cl-elco/ trunk/cl-elco/COPYING trunk/cl-elco/README trunk/cl-elco/elco/ trunk/cl-elco/elco/character-table.h trunk/cl-elco/elco/driver-helpers.lisp trunk/cl-elco/elco/driver.c trunk/cl-elco/elco/driver.lisp trunk/cl-elco/elco/elco.lisp trunk/cl-elco/elco/package.lisp trunk/cl-elco/elco-test.asd trunk/cl-elco/elco.asd trunk/cl-elco/examples/ trunk/cl-elco/examples/README_pokertimer trunk/cl-elco/examples/pokertimer.lisp trunk/cl-elco/examples/run_pokertimer.sh trunk/cl-elco/maintainer/ trunk/cl-elco/maintainer/generate-elco-driver.sh trunk/cl-elco/test/ trunk/cl-elco/test/package.lisp trunk/cl-elco/test/tests.lisp trunk/cl-elco/utils/ trunk/cl-elco/utils/build.sh trunk/cl-elco/utils/run-tests.sh Removed Paths: ------------- trunk/COPYING trunk/README trunk/cl-elco/elco/character-table.h trunk/cl-elco/elco/driver-helpers.lisp trunk/cl-elco/elco/driver.c trunk/cl-elco/elco/driver.lisp trunk/cl-elco/elco/elco.lisp trunk/cl-elco/elco/package.lisp trunk/cl-elco/examples/README_pokertimer trunk/cl-elco/examples/pokertimer.lisp trunk/cl-elco/examples/run_pokertimer.sh trunk/cl-elco/maintainer/generate-elco-driver.sh trunk/cl-elco/test/package.lisp trunk/cl-elco/test/tests.lisp trunk/cl-elco/utils/build.sh trunk/elco/ trunk/elco-test.asd trunk/elco.asd trunk/examples/ trunk/maintainer/ trunk/test/ trunk/utils/ Deleted: trunk/COPYING =================================================================== --- trunk/COPYING 2008-07-13 00:52:58 UTC (rev 42) +++ trunk/COPYING 2008-07-14 15:17:50 UTC (rev 43) @@ -1,27 +0,0 @@ -Copyright (c) 2008, Piotr Esden-Tempski <piotr at esden.net> -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -* Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -* The names of its contributors may not be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file Deleted: trunk/README =================================================================== --- trunk/README 2008-07-13 00:52:58 UTC (rev 42) +++ trunk/README 2008-07-14 15:17:50 UTC (rev 43) @@ -1,55 +0,0 @@ -ELCO stands for Esdens Lisp COmpiler - -The project started while trying out the Steps provided in two papers -by Abdulaziz Ghuloum called "Compilers: Backend to Frontend and Back -to Front Again" and "An Incremental Approach to Compiler Construction" - -The tests are mostly translated from sheme examples provided on -Abdulazizs site http://www.cs.indiana.edu/~aghuloum. - -Otherwise you can see in the tags directory of the svn tree all the -steps from "Compilers: Backend to Frontend" - -The syntax of the ELCO language is not stable and will probably change -before I consider it stable. Furthermore see project homepage on -http://elco.sourceforge.net. - -You need asdf to run elco. - -Loading the compiler: - -(asdf:operate 'asdf:load-op 'elco) - -Loading test system: - -(asdf:operate 'asdf:load-op 'elco-test) - -Running all tests in the console: - -utils/run-tests.sh - -Running all tests in lisp: - -(elco-test:run-tests) - -Running a specific testsuite: - -(elco-test:run-tests :select "test suite name") - -Compiling a program: - -(elco:compile-program '(elco:fx+ 1 2)) - -[NOTE: this only generates the elco.s file in the current working - directory of your lisp world] - -Compiling and executing a program: - -(elco:execute-program '(elco:fx+ 1 2)) - -The syntax of the ELCO langage can be seen in elco-package.lisp -export section. Full documentation is pending. But currently because -the langauge is not stable enough, there is no sense in writing it. - -Cheers - Piotr Esden-Tempski Copied: trunk/cl-elco/COPYING (from rev 39, trunk/COPYING) =================================================================== --- trunk/cl-elco/COPYING (rev 0) +++ trunk/cl-elco/COPYING 2008-07-14 15:17:50 UTC (rev 43) @@ -0,0 +1,27 @@ +Copyright (c) 2008, Piotr Esden-Tempski <piotr at esden.net> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +* The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file Copied: trunk/cl-elco/README (from rev 37, trunk/README) =================================================================== --- trunk/cl-elco/README (rev 0) +++ trunk/cl-elco/README 2008-07-14 15:17:50 UTC (rev 43) @@ -0,0 +1,55 @@ +ELCO stands for Esdens Lisp COmpiler + +The project started while trying out the Steps provided in two papers +by Abdulaziz Ghuloum called "Compilers: Backend to Frontend and Back +to Front Again" and "An Incremental Approach to Compiler Construction" + +The tests are mostly translated from sheme examples provided on +Abdulazizs site http://www.cs.indiana.edu/~aghuloum. + +Otherwise you can see in the tags directory of the svn tree all the +steps from "Compilers: Backend to Frontend" + +The syntax of the ELCO language is not stable and will probably change +before I consider it stable. Furthermore see project homepage on +http://elco.sourceforge.net. + +You need asdf to run elco. + +Loading the compiler: + +(asdf:operate 'asdf:load-op 'elco) + +Loading test system: + +(asdf:operate 'asdf:load-op 'elco-test) + +Running all tests in the console: + +utils/run-tests.sh + +Running all tests in lisp: + +(elco-test:run-tests) + +Running a specific testsuite: + +(elco-test:run-tests :select "test suite name") + +Compiling a program: + +(elco:compile-program '(elco:fx+ 1 2)) + +[NOTE: this only generates the elco.s file in the current working + directory of your lisp world] + +Compiling and executing a program: + +(elco:execute-program '(elco:fx+ 1 2)) + +The syntax of the ELCO langage can be seen in elco-package.lisp +export section. Full documentation is pending. But currently because +the langauge is not stable enough, there is no sense in writing it. + +Cheers + Piotr Esden-Tempski Copied: trunk/cl-elco/elco (from rev 37, trunk/elco) Deleted: trunk/cl-elco/elco/character-table.h =================================================================== --- trunk/elco/character-table.h 2008-06-28 02:41:36 UTC (rev 37) +++ trunk/cl-elco/elco/character-table.h 2008-07-14 15:17:50 UTC (rev 43) @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2008, Piotr Esden-Tempski - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of its contributors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef ELCO_CHARACTER_TABLE_C -#define ELCO_CHARACTER_TABLE_C - -char *character_table[128] = { - "#\\nul", - "#\\soh", - "#\\stx", - "#\\etx", - "#\\eot", - "#\\enq", - "#\\ack", - "#\\bel", - "#\\bs", - "#\\tab", - "#\\newline", - "#\\vt", - "#\\ff", - "#\\return", - "#\\so", - "#\\si", - "#\\dle", - "#\\dc1", - "#\\dc2", - "#\\dc3", - "#\\dc4", - "#\\nak", - "#\\syn", - "#\\etb", - "#\\can", - "#\\em", - "#\\sub", - "#\\esc", - "#\\fs", - "#\\gs", - "#\\rs", - "#\\us", - "#\\space", - "#\\!", - "#\\\"", - "#\\#", - "#\\$", - "#\\%", - "#\\&", - "#\\'", - "#\\(", - "#\\)", - "#\\*", - "#\\+", - "#\\,", - "#\\-", - "#\\.", - "#\\/", - "#\\0", - "#\\1", - "#\\2", - "#\\3", - "#\\4", - "#\\5", - "#\\6", - "#\\7", - "#\\8", - "#\\9", - "#\\:", - "#\\;", - "#\\<", - "#\\=", - "#\\>", - "#\\?", - "#\\@", - "#\\A", - "#\\B", - "#\\C", - "#\\D", - "#\\E", - "#\\F", - "#\\G", - "#\\H", - "#\\I", - "#\\J", - "#\\K", - "#\\L", - "#\\M", - "#\\N", - "#\\O", - "#\\P", - "#\\Q", - "#\\R", - "#\\S", - "#\\T", - "#\\U", - "#\\V", - "#\\W", - "#\\X", - "#\\Y", - "#\\Z", - "#\\[", - "#\\\\", - "#\\]", - "#\\^", - "#\\_", - "#\\`", - "#\\a", - "#\\b", - "#\\c", - "#\\d", - "#\\e", - "#\\f", - "#\\g", - "#\\h", - "#\\i", - "#\\j", - "#\\k", - "#\\l", - "#\\m", - "#\\n", - "#\\o", - "#\\p", - "#\\q", - "#\\r", - "#\\s", - "#\\t", - "#\\u", - "#\\v", - "#\\w", - "#\\x", - "#\\y", - "#\\z", - "#\\{", - "#\\|", - "#\\}", - "#\\~", - "#\\del" -}; - -#endif /* ELCO_CHARACTER_TABLE_C */ Copied: trunk/cl-elco/elco/character-table.h (from rev 42, trunk/elco/character-table.h) =================================================================== --- trunk/cl-elco/elco/character-table.h (rev 0) +++ trunk/cl-elco/elco/character-table.h 2008-07-14 15:17:50 UTC (rev 43) @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2008, Piotr Esden-Tempski <piotr at esden.net> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * The names of its contributors may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef ELCO_CHARACTER_TABLE_C +#define ELCO_CHARACTER_TABLE_C + +char *character_table[128] = { + "#\\nul", + "#\\soh", + "#\\stx", + "#\\etx", + "#\\eot", + "#\\enq", + "#\\ack", + "#\\bel", + "#\\bs", + "#\\tab", + "#\\newline", + "#\\vt", + "#\\ff", + "#\\return", + "#\\so", + "#\\si", + "#\\dle", + "#\\dc1", + "#\\dc2", + "#\\dc3", + "#\\dc4", + "#\\nak", + "#\\syn", + "#\\etb", + "#\\can", + "#\\em", + "#\\sub", + "#\\esc", + "#\\fs", + "#\\gs", + "#\\rs", + "#\\us", + "#\\space", + "#\\!", + "#\\\"", + "#\\#", + "#\\$", + "#\\%", + "#\\&", + "#\\'", + "#\\(", + "#\\)", + "#\\*", + "#\\+", + "#\\,", + "#\\-", + "#\\.", + "#\\/", + "#\\0", + "#\\1", + "#\\2", + "#\\3", + "#\\4", + "#\\5", + "#\\6", + "#\\7", + "#\\8", + "#\\9", + "#\\:", + "#\\;", + "#\\<", + "#\\=", + "#\\>", + "#\\?", + "#\\@", + "#\\A", + "#\\B", + "#\\C", + "#\\D", + "#\\E", + "#\\F", + "#\\G", + "#\\H", + "#\\I", + "#\\J", + "#\\K", + "#\\L", + "#\\M", + "#\\N", + "#\\O", + "#\\P", + "#\\Q", + "#\\R", + "#\\S", + "#\\T", + "#\\U", + "#\\V", + "#\\W", + "#\\X", + "#\\Y", + "#\\Z", + "#\\[", + "#\\\\", + "#\\]", + "#\\^", + "#\\_", + "#\\`", + "#\\a", + "#\\b", + "#\\c", + "#\\d", + "#\\e", + "#\\f", + "#\\g", + "#\\h", + "#\\i", + "#\\j", + "#\\k", + "#\\l", + "#\\m", + "#\\n", + "#\\o", + "#\\p", + "#\\q", + "#\\r", + "#\\s", + "#\\t", + "#\\u", + "#\\v", + "#\\w", + "#\\x", + "#\\y", + "#\\z", + "#\\{", + "#\\|", + "#\\}", + "#\\~", + "#\\del" +}; + +#endif /* ELCO_CHARACTER_TABLE_C */ Deleted: trunk/cl-elco/elco/driver-helpers.lisp =================================================================== --- trunk/elco/driver-helpers.lisp 2008-06-28 02:41:36 UTC (rev 37) +++ trunk/cl-elco/elco/driver-helpers.lisp 2008-07-14 15:17:50 UTC (rev 43) @@ -1,46 +0,0 @@ -;;; Copyright (c) 2008, Piotr Esden-Tempski -;;; All rights reserved. -;;; -;;; Redistribution and use in source and binary forms, with or without -;;; modification, are permitted provided that the following conditions are -;;; met: -;;; -;;; * Redistributions of source code must retain the above copyright notice, -;;; this list of conditions and the following disclaimer. -;;; * Redistributions in binary form must reproduce the above copyright -;;; notice, this list of conditions and the following disclaimer in the -;;; documentation and/or other materials provided with the distribution. -;;; * The names of its contributors may not be used to endorse or promote -;;; products derived from this software without specific prior written -;;; permission. -;;; -;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -;;; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -;;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -;;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -;;; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -;;; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -(in-package #:elco) - -(defun make-temp-file-name (&optional suffix) - (merge-pathnames #P "/tmp/" - (if suffix - (format nil "elco-~s~s~s~s~s.~a" - (random 10) - (random 10) - (random 10) - (random 10) - (random 10) - suffix) - (format nil "elco-~s~s~s~s~s" - (random 10) - (random 10) - (random 10) - (random 10) - (random 10))))) \ No newline at end of file Copied: trunk/cl-elco/elco/driver-helpers.lisp (from rev 42, trunk/elco/driver-helpers.lisp) =================================================================== --- trunk/cl-elco/elco/driver-helpers.lisp (rev 0) +++ trunk/cl-elco/elco/driver-helpers.lisp 2008-07-14 15:17:50 UTC (rev 43) @@ -0,0 +1,46 @@ +;;; Copyright (c) 2008, Piotr Esden-Tempski <piotr at esden.net> +;;; All rights reserved. +;;; +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions are +;;; met: +;;; +;;; * Redistributions of source code must retain the above copyright notice, +;;; this list of conditions and the following disclaimer. +;;; * Redistributions in binary form must reproduce the above copyright +;;; notice, this list of conditions and the following disclaimer in the +;;; documentation and/or other materials provided with the distribution. +;;; * The names of its contributors may not be used to endorse or promote +;;; products derived from this software without specific prior written +;;; permission. +;;; +;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +;;; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +;;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +;;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +;;; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +;;; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(in-package #:elco) + +(defun make-temp-file-name (&optional suffix) + (merge-pathnames #P "/tmp/" + (if suffix + (format nil "elco-~s~s~s~s~s.~a" + (random 10) + (random 10) + (random 10) + (random 10) + (random 10) + suffix) + (format nil "elco-~s~s~s~s~s" + (random 10) + (random 10) + (random 10) + (random 10) + (random 10))))) \ No newline at end of file Deleted: trunk/cl-elco/elco/driver.c =================================================================== --- trunk/elco/driver.c 2008-06-28 02:41:36 UTC (rev 37) +++ trunk/cl-elco/elco/driver.c 2008-07-14 15:17:50 UTC (rev 43) @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2008, Piotr Esden-Tempski - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of its contributors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* a simple driver for elco_entry */ -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <sys/mman.h> -#include <stdbool.h> -#include <string.h> - -//#include "elco-character-table.h" - -/* define all lisp constants */ -#define FXMASK 0x03 -#define FXSHIFT 2 -#define FXTAG 0x00 -#define NIL 0x3F -#define CHARMASK 0xFF -#define CHARSHIFT 8 -#define CHARTAG 0x0F -#define F 0x2F -#define T 0x6F -#define CONSMASK 0x07 -#define CONSTAG 0x01 -#define STRINGMASK 0x07 -#define STRINGTAG 0x02 - -/* - * context struct for the elco code - * elco_entry stores registers there - */ -typedef struct { - void *eax; /* 0 scratch */ - void *ebx; /* 4 preserve */ - void *ecx; /* 8 scratch */ - void *edx; /* 12 scratch */ - void *esi; /* 16 preserve */ - void *edi; /* 20 preserve */ - void *ebp; /* 24 preserve */ - void *esp; /* 28 preserve */ -} context; - -/* all lisp values are of type ptr */ -typedef unsigned int ptr_t; - -extern ptr_t elco_entry (context *ctxt, char *stack_base, char *heap_base) asm("elco_entry"); - -/* stack handling functions */ -static char *allocate_protected_space(int size){ - int i; - int page = getpagesize(); - int status; - int aligned_size = ((size + page + 1) / page) * page; - char *p = mmap(0, aligned_size + 2 * page, - PROT_READ | PROT_WRITE, - MAP_ANON | MAP_PRIVATE, - 0, 0); - if(p == MAP_FAILED){ - printf("Could not map memory!\n"); - exit(1); - } - status = mprotect(p, page, PROT_NONE); - if(status != 0){ - printf("First protection page failed to initialize!\n"); - exit(1); - } - status = mprotect(p + page + aligned_size, page, PROT_NONE); - if(status != 0){ - printf("Second protection page failed to initialize!\n"); - exit(1); - } - for(i=0; i < size/4; i++){ - *(p+page+i*4+0) = 0xDE; - *(p+page+i*4+1) = 0xAD; - *(p+page+i*4+2) = 0xBE; - *(p+page+i*4+3) = 0xEF; - } - return(p + page); -} - -static void deallocate_protected_space(char *p, int size){ - int page = getpagesize(); - int status; - int aligned_size = ((size + page + 1) / page) * page; - status = munmap(p - page, aligned_size + 2 * page); - if(status != 0){ - printf("Could not free allocated protected space!\n"); - exit(1); - } -} - -/* foreign function helpers */ -int unshift(ptr_t val){ - return val >> FXSHIFT; -} - -ptr_t shift(int val){ - return val << FXSHIFT; -} - -char* string_data(ptr_t str){ - return (char *)(str + 2); -} - -/* foreign function wrappers */ -extern ptr_t e_write(ptr_t fd, ptr_t str, ptr_t len) asm("e_write"); -ptr_t e_write(ptr_t fd, ptr_t str, ptr_t len){ - //printf("Writing to %i the string %s with length %i!\n", unshift(fd), string_data(str), unshift(len)); - return shift(write(unshift(fd), string_data(str), unshift(len))); -} - -extern void e_exit (ptr_t val) asm("e_exit"); -void e_exit(ptr_t val){ - printf("An exit issued from elco, with return code %i!\n", unshift(val)); - exit(unshift(val)); -} - -extern ptr_t e_sleep (ptr_t seconds) asm("e_sleep"); -ptr_t e_sleep(ptr_t seconds){ - return shift(sleep(unshift(seconds))); -} - -/* print immediate value */ -static void print_ptr(ptr_t x, ptr_t parent, bool car){ - //printf("%08X", x); - - if((x & FXMASK) == FXTAG){ - printf("%d", (int)((int)(x) >> FXSHIFT)); - }else if(x == NIL){ - printf("NIL"); - }else if(x == T){ - printf("T"); - }else if(x == F){ - printf("F"); - }else if((x & CHARMASK) == CHARTAG){ - if((x >> CHARSHIFT) < 128) - printf("%s", character_table[x >> CHARSHIFT]); - else - printf("#\\%02X", x >> CHARSHIFT); - }else if((x & CONSMASK) == CONSTAG){ - if((parent == NIL) || ((parent != NIL) && car)){ - printf("("); - } - - if(*((ptr_t *)(x + 3)) == NIL){ - print_ptr(*((ptr_t *)(x - 1)), x, true); - printf(")"); - }else if((*((ptr_t *)(x + 3)) & CONSMASK) == CONSTAG){ - print_ptr(*((ptr_t *)(x - 1)), x, true); - printf(" "); - print_ptr(*((ptr_t *)(x + 3)), x, false); - }else{ - print_ptr(*((ptr_t *)(x - 1)), x, true); - printf(" . "); - print_ptr(*((ptr_t *)(x + 3)), x, true); - printf(")"); - } - }else if((x & STRINGMASK) == STRINGTAG){ - //printf("%08x\n", x); - //printf("%08x\n", (int)*((ptr_t *)(x - 2)) >> FXSHIFT); - - int i; - int size = (int)*((ptr_t *)(x - 2)) >> FXSHIFT; - unsigned char ch; - - printf("\""); - for(i=0; i < size; i++){ - ch = (unsigned char)*((ptr_t *)(x + 2 + i)); - - if(ch == '\0') continue; - - if(ch == '\"'){ - printf("\\\""); - }else if(ch == '\\'){ - printf("\\\\"); - }else if(ch > 32 && ch < 127){ - printf("%c", ch); - }else if(ch < 128){ - printf("%s", character_table[(int)ch]); - }else{ - printf("#\\%02X", ch); - } - } - printf("\""); - }else{ - printf("#<unknown 0x%08X>", x); - } - - fflush(stdout); -} - -int main(int argc, char **argv){ - int stack_size = (16 * 4096); /* holds 16K cells */ - char *stack_top = allocate_protected_space(stack_size); - char *stack_base = stack_top + stack_size; - - int heap_size = (16 * 4096); /* holds 16K cells */ - char *heap_top = allocate_protected_space(heap_size); - //char *heap_base = heap_top + heap_size; - - context ctxt; - - print_ptr(elco_entry(&ctxt, stack_base, heap_top), NIL, true); - printf("\n"); - - deallocate_protected_space(heap_top, heap_size); - deallocate_protected_space(stack_top, stack_size); - return 0; -} Copied: trunk/cl-elco/elco/driver.c (from rev 42, trunk/elco/driver.c) =================================================================== --- trunk/cl-elco/elco/driver.c (rev 0) +++ trunk/cl-elco/elco/driver.c 2008-07-14 15:17:50 UTC (rev 43) @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2008, Piotr Esden-Tempski <piotr at esden.net> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * The names of its contributors may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* a simple driver for elco_entry */ +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/mman.h> +#include <stdbool.h> +#include <string.h> + +//#include "elco-character-table.h" + +/* define all lisp constants */ +#define FXMASK 0x03 +#define FXSHIFT 2 +#define FXTAG 0x00 +#define NIL 0x3F +#define CHARMASK 0xFF +#define CHARSHIFT 8 +#define CHARTAG 0x0F +#define F 0x2F +#define T 0x6F +#define CONSMASK 0x07 +#define CONSTAG 0x01 +#define STRINGMASK 0x07 +#define STRINGTAG 0x02 + +/* + * context struct for the elco code + * elco_entry stores registers there + */ +typedef struct { + void *eax; /* 0 scratch */ + void *ebx; /* 4 preserve */ + void *ecx; /* 8 scratch */ + void *edx; /* 12 scratch */ + void *esi; /* 16 preserve */ + void *edi; /* 20 preserve */ + void *ebp; /* 24 preserve */ + void *esp; /* 28 preserve */ +} context; + +/* all lisp values are of type ptr */ +typedef unsigned int ptr_t; + +extern ptr_t elco_entry (context *ctxt, char *stack_base, char *heap_base) asm("elco_entry"); + +/* stack handling functions */ +static char *allocate_protected_space(int size){ + int i; + int page = getpagesize(); + int status; + int aligned_size = ((size + page + 1) / page) * page; + char *p = mmap(0, aligned_size + 2 * page, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, + 0, 0); + if(p == MAP_FAILED){ + printf("Could not map memory!\n"); + exit(1); + } + status = mprotect(p, page, PROT_NONE); + if(status != 0){ + printf("First protection page failed to initialize!\n"); + exit(1); + } + status = mprotect(p + page + aligned_size, page, PROT_NONE); + if(status != 0){ + printf("Second protection page failed to initialize!\n"); + exit(1); + } + for(i=0; i < size/4; i++){ + *(p+page+i*4+0) = 0xDE; + *(p+page+i*4+1) = 0xAD; + *(p+page+i*4+2) = 0xBE; + *(p+page+i*4+3) = 0xEF; + } + return(p + page); +} + +static void deallocate_protected_space(char *p, int size){ + int page = getpagesize(); + int status; + int aligned_size = ((size + page + 1) / page) * page; + status = munmap(p - page, aligned_size + 2 * page); + if(status != 0){ + printf("Could not free allocated protected space!\n"); + exit(1); + } +} + +/* foreign function helpers */ +int unshift(ptr_t val){ + return val >> FXSHIFT; +} + +ptr_t shift(int val){ + return val << FXSHIFT; +} + +char* string_data(ptr_t str){ + return (char *)(str + 2); +} + +/* foreign function wrappers */ +extern ptr_t e_write(ptr_t fd, ptr_t str, ptr_t len) asm("e_write"); +ptr_t e_write(ptr_t fd, ptr_t str, ptr_t len){ + //printf("Writing to %i the string %s with length %i!\n", unshift(fd), string_data(str), unshift(len)); + return shift(write(unshift(fd), string_data(str), unshift(len))); +} + +extern void e_exit (ptr_t val) asm("e_exit"); +void e_exit(ptr_t val){ + printf("An exit issued from elco, with return code %i!\n", unshift(val)); + exit(unshift(val)); +} + +extern ptr_t e_sleep (ptr_t seconds) asm("e_sleep"); +ptr_t e_sleep(ptr_t seconds){ + return shift(sleep(unshift(seconds))); +} + +/* print immediate value */ +static void print_ptr(ptr_t x, ptr_t parent, bool car){ + //printf("%08X", x); + + if((x & FXMASK) == FXTAG){ + printf("%d", (int)((int)(x) >> FXSHIFT)); + }else if(x == NIL){ + printf("NIL"); + }else if(x == T){ + printf("T"); + }else if(x == F){ + printf("F"); + }else if((x & CHARMASK) == CHARTAG){ + if((x >> CHARSHIFT) < 128) + printf("%s", character_table[x >> CHARSHIFT]); + else + printf("#\\%02X", x >> CHARSHIFT); + }else if((x & CONSMASK) == CONSTAG){ + if((parent == NIL) || ((parent != NIL) && car)){ + printf("("); + } + + if(*((ptr_t *)(x + 3)) == NIL){ + print_ptr(*((ptr_t *)(x - 1)), x, true); + printf(")"); + }else if((*((ptr_t *)(x + 3)) & CONSMASK) == CONSTAG){ + print_ptr(*((ptr_t *)(x - 1)), x, true); + printf(" "); + print_ptr(*((ptr_t *)(x + 3)), x, false); + }else{ + print_ptr(*((ptr_t *)(x - 1)), x, true); + printf(" . "); + print_ptr(*((ptr_t *)(x + 3)), x, true); + printf(")"); + } + }else if((x & STRINGMASK) == STRINGTAG){ + //printf("%08x\n", x); + //printf("%08x\n", (int)*((ptr_t *)(x - 2)) >> FXSHIFT); + + int i; + int size = (int)*((ptr_t *)(x - 2)) >> FXSHIFT; + unsigned char ch; + + printf("\""); + for(i=0; i < size; i++){ + ch = (unsigned char)*((ptr_t *)(x + 2 + i)); + + if(ch == '\0') continue; + + if(ch == '\"'){ + printf("\\\""); + }else if(ch == '\\'){ + printf("\\\\"); + }else if(ch > 32 && ch < 127){ + printf("%c", ch); + }else if(ch < 128){ + printf("%s", character_table[(int)ch]); + }else{ + printf("#\\%02X", ch); + } + } + printf("\""); + }else{ + printf("#<unknown 0x%08X>", x); + } + + fflush(stdout); +} + +int main(int argc, char **argv){ + int stack_size = (16 * 4096); /* holds 16K cells */ + char *stack_top = allocate_protected_space(stack_size); + char *stack_base = stack_top + stack_size; + + int heap_size = (16 * 4096); /* holds 16K cells */ + char *heap_top = allocate_protected_space(heap_size); + //char *heap_base = heap_top + heap_size; + + context ctxt; + + print_ptr(elco_entry(&ctxt, stack_base, heap_top), NIL, true); + printf("\n"); + + deallocate_protected_space(heap_top, heap_size); + deallocate_protected_space(stack_top, stack_size); + return 0; +} Deleted: trunk/cl-elco/elco/driver.lisp =================================================================== --- trunk/elco/driver.lisp 2008-06-28 02:41:36 UTC (rev 37) +++ trunk/cl-elco/elco/driver.lisp 2008-07-14 15:17:50 UTC (rev 43) @@ -1,420 +0,0 @@ -(in-package #:elco) -(defun create-driver-object () - (let ((tmp (make-temp-file-name "c")) - (driver-object (make-temp-file-name "o"))) - (with-open-file (driver-stream tmp :direction :output :if-exists :supersede) - (princ " -/* - * Copyright (c) 2008, Piotr Esden-Tempski - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of its contributors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef ELCO_CHARACTER_TABLE_C -#define ELCO_CHARACTER_TABLE_C - -char *character_table[128] = { - \"#\\\\nul\", - \"#\\\\soh\", - \"#\\\\stx\", - \"#\\\\etx\", - \"#\\\\eot\", - \"#\\\\enq\", - \"#\\\\ack\", - \"#\\\\bel\", - \"#\\\\bs\", - \"#\\\\tab\", - \"#\\\\newline\", - \"#\\\\vt\", - \"#\\\\ff\", - \"#\\\\return\", - \"#\\\\so\", - \"#\\\\si\", - \"#\\\\dle\", - \"#\\\\dc1\", - \"#\\\\dc2\", - \"#\\\\dc3\", - \"#\\\\dc4\", - \"#\\\\nak\", - \"#\\\\syn\", - \"#\\\\etb\", - \"#\\\\can\", - \"#\\\\em\", - \"#\\\\sub\", - \"#\\\\esc\", - \"#\\\\fs\", - \"#\\\\gs\", - \"#\\\\rs\", - \"#\\\\us\", - \"#\\\\space\", - \"#\\\\!\", - \"#\\\\\\\"\", - \"#\\\\#\", - \"#\\\\$\", - \"#\\\\%\", - \"#\\\\&\", - \"#\\\\'\", - \"#\\\\(\", - \"#\\\\)\", - \"#\\\\*\", - \"#\\\\+\", - \"#\\\\,\", - \"#\\\\-\", - \"#\\\\.\", - \"#\\\\/\", - \"#\\\\0\", - \"#\\\\1\", - \"#\\\\2\", - \"#\\\\3\", - \"#\\\\4\", - \"#\\\\5\", - \"#\\\\6\", - \"#\\\\7\", - \"#\\\\8\", - \"#\\\\9\", - \"#\\\\:\", - \"#\\\\;\", - \"#\\\\<\", - \"#\\\\=\", - \"#\\\\>\", - \"#\\\\?\", - \"#\\\\@\", - \"#\\\\A\", - \"#\\\\B\", - \"#\\\\C\", - \"#\\\\D\", - \"#\\\\E\", - \"#\\\\F\", - \"#\\\\G\", - \"#\\\\H\", - \"#\\\\I\", - \"#\\\\J\", - \"#\\\\K\", - \"#\\\\L\", - \"#\\\\M\", - \"#\\\\N\", - \"#\\\\O\", - \"#\\\\P\", - \"#\\\\Q\", - \"#\\\\R\", - \"#\\\\S\", - \"#\\\\T\", - \"#\\\\U\", - \"#\\\\V\", - \"#\\\\W\", - \"#\\\\X\", - \"#\\\\Y\", - \"#\\\\Z\", - \"#\\\\[\", - \"#\\\\\\\\\", - \"#\\\\]\", - \"#\\\\^\", - \"#\\\\_\", - \"#\\\\`\", - \"#\\\\a\", - \"#\\\\b\", - \"#\\\\c\", - \"#\\\\d\", - \"#\\\\e\", - \"#\\\\f\", - \"#\\\\g\", - \"#\\\\h\", - \"#\\\\i\", - \"#\\\\j\", - \"#\\\\k\", - \"#\\\\l\", - \"#\\\\m\", - \"#\\\\n\", - \"#\\\\o\", - \"#\\\\p\", - \"#\\\\q\", - \"#\\\\r\", - \"#\\\\s\", - \"#\\\\t\", - \"#\\\\u\", - \"#\\\\v\", - \"#\\\\w\", - \"#\\\\x\", - \"#\\\\y\", - \"#\\\\z\", - \"#\\\\{\", - \"#\\\\|\", - \"#\\\\}\", - \"#\\\\~\", - \"#\\\\del\" -}; - -#endif /* ELCO_CHARACTER_TABLE_C */ -/* - * Copyright (c) 2008, Piotr Esden-Tempski - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of its contributors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* a simple driver for elco_entry */ -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <sys/mman.h> -#include <stdbool.h> -#include <string.h> - -//#include \"elco-character-table.h\" - -/* define all lisp constants */ -#define FXMASK 0x03 -#define FXSHIFT 2 -#define FXTAG 0x00 -#define NIL 0x3F -#define CHARMASK 0xFF -#define CHARSHIFT 8 -#define CHARTAG 0x0F -#define F 0x2F -#define T 0x6F -#define CONSMASK 0x07 -#define CONSTAG 0x01 -#define STRINGMASK 0x07 -#define STRINGTAG 0x02 - -/* - * context struct for the elco code - * elco_entry stores registers there - */ -typedef struct { - void *eax; /* 0 scratch */ - void *ebx; /* 4 preserve */ - void *ecx; /* 8 scratch */ - void *edx; /* 12 scratch */ - void *esi; /* 16 preserve */ - void *edi; /* 20 preserve */ - void *ebp; /* 24 preserve */ - void *esp; /* 28 preserve */ -} context; - -/* all lisp values are of type ptr */ -typedef unsigned int ptr_t; - -extern ptr_t elco_entry (context *ctxt, char *stack_base, char *heap_base) asm(\"elco_entry\"); - -/* stack handling functions */ -static char *allocate_protected_space(int size){ - int i; - int page = getpagesize(); - int status; - int aligned_size = ((size + page + 1) / page) * page; - char *p = mmap(0, aligned_size + 2 * page, - PROT_READ | PROT_WRITE, - MAP_ANON | MAP_PRIVATE, - 0, 0); - if(p == MAP_FAILED){ - printf(\"Could not map memory!\\n\"); - exit(1); - } - status = mprotect(p, page, PROT_NONE); - if(status != 0){ - printf(\"First protection page failed to initialize!\\n\"); - exit(1); - } - status = mprotect(p + page + aligned_size, page, PROT_NONE); - if(status != 0){ - printf(\"Second protection page failed to initialize!\\n\"); - exit(1); - } - for(i=0; i < size/4; i++){ - *(p+page+i*4+0) = 0xDE; - *(p+page+i*4+1) = 0xAD; - *(p+page+i*4+2) = 0xBE; - *(p+page+i*4+3) = 0xEF; - } - return(p + page); -} - -static void deallocate_protected_space(char *p, int size){ - int page = getpagesize(); - int status; - int aligned_size = ((size + page + 1) / page) * page; - status = munmap(p - page, aligned_size + 2 * page); - if(status != 0){ - printf(\"Could not free allocated protected space!\\n\"); - exit(1); - } -} - -/* foreign function helpers */ -int unshift(ptr_t val){ - return val >> FXSHIFT; -} - -ptr_t shift(int val){ - return val << FXSHIFT; -} - -char* string_data(ptr_t str){ - return (char *)(str + 2); -} - -/* foreign function wrappers */ -extern ptr_t e_write(ptr_t fd, ptr_t str, ptr_t len) asm(\"e_write\"); -ptr_t e_write(ptr_t fd, ptr_t str, ptr_t len){ - //printf(\"Writing to %i the string %s with length %i!\\n\", unshift(fd), string_data(str), unshift(len)); - return shift(write(unshift(fd), string_data(str), unshift(len))); -} - -extern void e_exit (ptr_t val) asm(\"e_exit\"); -void e_exit(ptr_t val){ - printf(\"An exit issued from elco, with return code %i!\\n\", unshift(val)); - exit(unshift(val)); -} - -extern ptr_t e_sleep (ptr_t seconds) asm(\"e_sleep\"); -ptr_t e_sleep(ptr_t seconds){ - return shift(sleep(unshift(seconds))); -} - -/* print immediate value */ -static void print_ptr(ptr_t x, ptr_t parent, bool car){ - //printf(\"%08X\", x); - - if((x & FXMASK) == FXTAG){ - printf(\"%d\", (int)((int)(x) >> FXSHIFT)); - }else if(x == NIL){ - printf(\"NIL\"); - }else if(x == T){ - printf(\"T\"); - }else if(x == F){ - printf(\"F\"); - }else if((x & CHARMASK) == CHARTAG){ - if((x >> CHARSHIFT) < 128) - printf(\"%s\", character_table[x >> CHARSHIFT]); - else - printf(\"#\\\\%02X\", x >> CHARSHIFT); - }else if((x & CONSMASK) == CONSTAG){ - if((parent == NIL) || ((parent != NIL) && car)){ - printf(\"(\"); - } - - if(*((ptr_t *)(x + 3)) == NIL){ - print_ptr(*((ptr_t *)(x - 1)), x, true); - printf(\")\"); - }else if((*((ptr_t *)(x + 3)) & CONSMASK) == CONSTAG){ - print_ptr(*((ptr_t *)(x - 1)), x, true); - printf(\" \"); - print_ptr(*((ptr_t *)(x + 3)), x, false); - }else{ - print_ptr(*((ptr_t *)(x - 1)), x, true); - printf(\" . \"); - print_ptr(*((ptr_t *)(x + 3)), x, true); - printf(\")\"); - } - }else if((x & STRINGMASK) == STRINGTAG){ - //printf(\"%08x\\n\", x); - //printf(\"%08x\\n\", (int)*((ptr_t *)(x - 2)) >> FXSHIFT); - - int i; - int size = (int)*((ptr_t *)(x - 2)) >> FXSHIFT; - unsigned char ch; - - printf(\"\\\"\"); - for(i=0; i < size; i++){ - ch = (unsigned char)*((ptr_t *)(x + 2 + i)); - - if(ch == '\\0') continue; - - if(ch == '\\\"'){ - printf(\"\\\\\\\"\"); - }else if(ch == '\\\\'){ - printf(\"\\\\\\\\\"); - }else if(ch > 32 && ch < 127){ - printf(\"%c\", ch); - }else if(ch < 128){ - printf(\"%s\", character_table[(int)ch]); - }else{ - printf(\"#\\\\%02X\", ch); - } - } - printf(\"\\\"\"); - }else{ - printf(\"#<unknown 0x%08X>\", x); - } - - fflush(stdout); -} - -int main(int argc, char **argv){ - int stack_size = (16 * 4096); /* holds 16K cells */ - char *stack_top = allocate_protected_space(stack_size); - char *stack_base = stack_top + stack_size; - - int heap_size = (16 * 4096); /* holds 16K cells */ - char *heap_top = allocate_protected_space(heap_size); - //char *heap_base = heap_top + heap_size; - - context ctxt; - - print_ptr(elco_entry(&ctxt, stack_base, heap_top), NIL, true); - printf(\"\\n\"); - - deallocate_protected_space(heap_top, heap_size); - deallocate_protected_space(stack_top, stack_size); - return 0; -} -" driver-stream)) - (sb-ext:run-program "/usr/bin/gcc" - `("-O3" - "-Wall" - "-c" - ,(namestring tmp) - "-o" - ,(namestring driver-object))) - (sb-ext:run-program "/bin/rm" `("-f" ,(namestring tmp))) - (format t "Created driver object with name ~a~%" driver-object) - driver-object)) - -(defvar *driver-object* (create-driver-object)) \ No newline at end of file Copied: trunk/cl-elco/elco/driver.lisp (from rev 42, trunk/elco/driver.lisp) =================================================================== --- trunk/cl-elco/elco/driver.lisp (rev 0) +++ trunk/cl-elco/elco/driver.lisp 2008-07-14 15:17:50 UTC (rev 43) @@ -0,0 +1,417 @@ +(in-package #:elco) +(defun create-driver-object () + (let ((tmp (make-temp-file-name "c")) + (driver-object (make-temp-file-name "o"))) + (with-open-file (driver-stream tmp :direction :output :if-exists :supersede) + (princ " +/* + * Copyright (c) 2008, Piotr Esden-Tempski <piotr at esden.net> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * The names of its contributors may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef ELCO_CHARACTER_TABLE_C +#define ELCO_CHARACTER_TABLE_C + +char *character_table[128] = { + \"#\\\\nul\", + \"#\\\\soh\", + \"#\\\\stx\", + \"#\\\\etx\", + \"#\\\\eot\", + \"#\\\\enq\", + \"#\\\\ack\", + \"#\\\\bel\", + \"#\\\\bs\", + \"#\\\\tab\", + \"#\\\\newline\", + \"#\\\\vt\", + \"#\\\\ff\", + \"#\\\\return\", + \"#\\\\so\", + \"#\\\\si\", + \"#\\\\dle\", + \"#\\\\dc1\", + \"#\\\\dc2\", + \"#\\\\dc3\", + \"#\\\\dc4\", + \"#\\\\nak\", + \"#\\\\syn\", + \"#\\\\etb\", + \"#\\\\can\", + \"#\\\\em\", + \"#\\\\sub\", + \"#\\\\esc\", + \"#\\\\fs\", + \"#\\\\gs\", + \"#\\\\rs\", + \"#\\\\us\", + \"#\\\\space\", + \"#\\\\!\", + \"#\\\\\\\"\", + \"#\\\\#\", + \"#\\\\$\", + \"#\\\\%\", + \"#\\\\&\", + \"#\\\\'\", + \"#\\\\(\", + \"#\\\\)\", + \"#\\\\*\", + \"#\\\\+\", + \"#\\\\,\", + \"#\\\\-\", + \"#\\\\.\", + \"#\\\\/\", + \"#\\\\0\", + \"#\\\\1\", + \"#\\\\2\", + \"#\\\\3\", + \"#\\\\4\", + \"#\\\\5\", + \"#\\\\6\", + \"#\\\\7\", + \"#\\\\8\", + \"#\\\\9\", + \"#\\\\:\", + \"#\\\\;\", + \"#\\\\<\", + \"#\\\\=\", + \"#\\\\>\", + \"#\\\\?\", + \"#\\\\@\", + \"#\\\\A\", + \"#\\\\B\", + \"#\\\\C\", + \"#\\\\D\", + \"#\\\\E\", + \"#\\\\F\", + \"#\\\\G\", + \"#\\\\H\", + \"#\\\\I\", + \"#\\\\J\", + \"#\\\\K\", + \"#\\\\L\", + \"#\\\\M\", + \"#\\\\N\", + \"#\\\\O\", + \"#\\\\P\", + \"#\\\\Q\", + \"#\\\\R\", + \"#\\\\S\", + \"#\\\\T\", + \"#\\\\U\", + \"#\\\\V\", + \"#\\\\W\", + \"#\\\\X\", + \"#\\\\Y\", + \"#\\\\Z\", + \"#\\\\[\", + \"#\\\\\\\\\", + \"#\\\\]\", + \"#\\\\^\", + \"#\\\\_\", + \"#\\\\`\", + \"#\\\\a\", + \"#\\\\b\", + \"#\\\\c\", + \"#\\\\d\", + \"#\\\\e\", + \"#\\\\f\", + \"#\\\\g\", + \"#\\\\h\", + \"#\\\\i\", + \"#\\\\j\", + \"#\\\\k\", + \"#\\\\l\", + \"#\\\\m\", + \"#\\\\n\", + \"#\\\\o\", + \"#\\\\p\", + \"#\\\\q\", + \"#\\\\r\", + \"#\\\\s\", + \"#\\\\t\", + \"#\\\\u\", + \"#\\\\v\", + \"#\\\\w\", + \"#\\\\x\", + \"#\\\\y\", + \"#\\\\z\", + \"#\\\\{\", + \"#\\\\|\", + \"#\\\\}\", + \"#\\\\~\", + \"#\\\\del\" +}; + +#endif /* ELCO_CHARACTER_TABLE_C */ +/* + * Copyright (c) 2008, Piotr Esden-Tempski <piotr at esden.net> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * The names of its contributors may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* a simple driver for elco_entry */ +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/mman.h> +#include <stdbool.h> +#include <string.h> + +//#include \"elco-character-table.h\" + +/* define all lisp constants */ +#define FXMASK 0x03 +#define FXSHIFT 2 +#define FXTAG 0x00 +#define NIL 0x3F +#define CHARMASK 0xFF +#define CHARSHIFT 8 +#define CHARTAG 0x0F +#define F 0x2F +#define T 0x6F +#define CONSMASK 0x07 +#define CONSTAG 0x01 +#define STRINGMASK 0x07 +#define STRINGTAG 0x02 + +/* + * context struct for the elco code + * elco_entry stores registers there + */ +typedef struct { + void *eax; /* 0 scratch */ + void *ebx; /* 4 preserve */ + void *ecx; /* 8 scratch */ + void *edx; /* 12 scratch */ + void *esi; /* 16 preserve */ + void *edi; /* 20 preserve */ + void *ebp; /* 24 preserve */ + void *esp; /* 28 preserve */ +} context; + +/* all lisp values are of type ptr */ +typedef unsigned int ptr_t; + +extern ptr_t elco_entry (context *ctxt, char *stack_base, char *heap_base) asm(\"elco_entry\"); + +/* stack handling functions */ +static char *allocate_protected_space(int size){ + int i; + int page = getpagesize(); + int status; + int aligned_size = ((size + page + 1) / page) * page; + char *p = mmap(0, aligned_size + 2 * page, + PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, + 0, 0); + if(p == MAP_FAILED){ + printf(\"Could not map memory!\\n\"); + exit(1); + } + status = mprotect(p, page, PROT_NONE); + if(status != 0){ + printf(\"First protection page failed to initialize!\\n\"); + exit(1); + } + status = mprotect(p + page + aligned_size, page, PROT_NONE); + if(status != 0){ + printf(\"Second protection page failed to initialize!\\n\"); + exit(1); + } + for(i=0; i < size/4; i++){ + *(p+page+i*4+0) = 0xDE; + *(p+page+i*4+1) = 0xAD; + *(p+page+i*4+2) = 0xBE; + *(p+page+i*4+3) = 0xEF; + } + return(p + page); +} + +static void deallocate_protected_space(char *p, int size){ + int page = getpagesize(); + int status; + int aligned_size = ((size + page + 1) / page) * page; + status = munmap(p - page, aligned_size + 2 * page); + if(status != 0){ + printf(\"Could not free allocated protected space!\\n\"); + exit(1); + } +} + +/* foreign function helpers */ +int unshift(ptr_t val){ + return val >> FXSHIFT; +} + +ptr_t shift(int val){ + return val << FXSHIFT; +} + +char* string_data(ptr_t str){ + return (char *)(str + 2); +} + +/* foreign function wrappers */ +extern ptr_t e_write(ptr_t fd, ptr_t str, ptr_t len) asm(\"e_write\"); +ptr_t e_write(ptr_t fd, ptr_t str, ptr_t len){ + //printf(\"Writing to %i the string %s with length %i!\\n\", unshift(fd), string_data(str), unshift(len)); + return shift(write(unshift(fd), string_data(str), unshift(len))); +} + +extern void e_exit (ptr_t val) asm(\"e_exit\"); +void e_exit(ptr_t val){ + printf(\"An exit issued from elco, with return code %i!\\n\", unshift(val)); + exit(unshift(val)); +} + +extern ptr_t e_sleep (ptr_t seconds) asm(\"e_sleep\"); +ptr_t e_sleep(ptr_t seconds){ + return shift(sleep(unshift(seconds))); +} + +/* print immediate value */ +static void print_ptr(ptr_t x, ptr_t parent, bool car){ + //printf(\"%08X\", x); + + if((x & FXMASK) == FXTAG){ + printf(\"%d\", (int)((int)(x) >> FXSHIFT)); + }else if(x == NIL){ + printf(\"NIL\"); + }else if(x == T){ + printf(\"T\"); + }else if(x == F){ + printf(\"F\"); + }else if((x & CHARMASK) == CHARTAG){ + if((x >> CHARSHIFT) < 128) + printf(\"%s\", character_table[x >> CHARSHIFT]); + else + printf(\"#\\\\%02X\", x >> CHARSHIFT); + }else if((x & CONSMASK) == CONSTAG){ + if((parent == NIL) || ((parent != NIL) && car)){ + printf(\"(\"); + } + + if(*((ptr_t *)(x + 3)) == NIL){ + print_ptr(*((ptr_t *)(x - 1)), x, true); + printf(\")\"); + }else if((*((ptr_t *)(x + 3)) & CONSMASK) == CONSTAG){ + print_ptr... [truncated message content] |
From: <es...@us...> - 2008-07-13 00:53:02
|
Revision: 42 http://elco.svn.sourceforge.net/elco/?rev=42&view=rev Author: esden Date: 2008-07-12 17:52:58 -0700 (Sat, 12 Jul 2008) Log Message: ----------- - removed the global *compile-port* variable - emit now returns strings with the emitted code (is more functional) (makes debugging easier) - now no files are being dropped in the current directory unless user requests that explicitly (everything runs on /tmp/ directory) - no temp files ramain anymore, everything should be cleaned up after the run of run-tests and execute-program (build leaves the binary in the tmp directory and returns it's name and location - compile-program does not create a file anymore, it returns the code of the program (thanks to the emit change) Modified Paths: -------------- trunk/elco/driver.lisp trunk/elco/elco.lisp trunk/elco/package.lisp trunk/maintainer/generate-elco-driver.sh trunk/test/tests.lisp Modified: trunk/elco/driver.lisp =================================================================== --- trunk/elco/driver.lisp 2008-07-07 17:00:08 UTC (rev 41) +++ trunk/elco/driver.lisp 2008-07-13 00:52:58 UTC (rev 42) @@ -415,4 +415,3 @@ ,(namestring driver-object))) (sb-ext:run-program "/bin/rm" `("-f" ,(namestring tmp))) driver-object)) -(defvar *driver-object* (create-driver-object)) Modified: trunk/elco/elco.lisp =================================================================== --- trunk/elco/elco.lisp 2008-07-07 17:00:08 UTC (rev 41) +++ trunk/elco/elco.lisp 2008-07-13 00:52:58 UTC (rev 42) @@ -34,26 +34,22 @@ (defvar *compile-directory* *default-pathname-defaults*) -(defvar *compile-port* nil) +(defun emit (form &rest params) + (with-output-to-string (emit-string) + (apply #'format emit-string form params) + (terpri emit-string))) -(defun open-compile-port (file) - (setf *compile-port* (open file :direction :output :if-exists :supersede))) +(defmacro emitn (&body body) + `(concatenate 'string ,@body)) -(defun close-compile-port () - (close *compile-port*) - (setf *compile-port* nil)) - -(defun emit (form &rest params) - (progn (apply #'format `(,*compile-port* ,form ,@params)) - (format *compile-port* "~%"))) - ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; Header and footer emission. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% (defun emit-function-header (name) - (emit ".globl ~a" name) - (emit "~a:" name)) + (emitn + (emit ".globl ~a" name) + (emit "~a:" name))) (defun emit-function-footer () (emit " ret")) @@ -135,7 +131,7 @@ `(setf (gethash (symbol-name ',prim) *prim-symbol-list*) (make-prim :is-prim t :arg-count ,(length args) - :emitter (lambda (,si ,env ,@args) ,@body)))) + :emitter (lambda (,si ,env ,@args) (emitn ,@body))))) (defun next-stack-index (si) (- si +wordsize+)) @@ -458,14 +454,15 @@ (defun emit-if (si env expr) (let ((alt-label (unique-label)) (end-label (unique-label))) - (emit-expr si env (if-test expr)) - (emit " cmp $~s, %al" +bool-f+) - (emit " je ~a" alt-label) - (emit-expr si env (if-conseq expr)) - (emit " jmp ~a" end-label) - (emit "~a:" alt-label) - (emit-expr si env (if-altern expr)) - (emit "~a:" end-label))) + (emitn + (emit-expr si env (if-test expr)) + (emit " cmp $~s, %al" +bool-f+) + (emit " je ~a" alt-label) + (emit-expr si env (if-conseq expr)) + (emit " jmp ~a" end-label) + (emit "~a:" alt-label) + (emit-expr si env (if-altern expr)) + (emit "~a:" end-label)))) ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; Variables (let, let*) @@ -503,12 +500,13 @@ (labels ((process-let (bindings si new-env) (if bindings (let ((b (car bindings))) - (emit-expr si (if (let*p expr) new-env env) (cadr b)) - (emit-stack-save si) - (process-let - (cdr bindings) - (next-stack-index si) - (extend-env (car b) si new-env))) + (emitn + (emit-expr si (if (let*p expr) new-env env) (cadr b)) + (emit-stack-save si) + (process-let + (cdr bindings) + (next-stack-index si) + (extend-env (car b) si new-env)))) (emit-expr si new-env (let-body expr))))) (process-let (let-bindings expr) si env))) @@ -545,16 +543,17 @@ (cons 'elco:progn (cddr expr))) (defun emit-lambda (env) - (lambda (expr label) - (emit-function-header label) - (labels ((emit-lambda-closure (fmls si env) - (if (not fmls) - (emit-tail-expr si env (lambda-body expr)) - (emit-lambda-closure (cdr fmls) - (next-stack-index si) - (extend-env (car fmls) si env))))) - (emit-lambda-closure (lambda-formals expr) (- +wordsize+) env)) - (emit-function-footer))) + (lambda (expr label) + (emitn + (emit-function-header label) + (labels ((emit-lambda-closure (fmls si env) + (if (not fmls) + (emit-tail-expr si env (lambda-body expr)) + (emit-lambda-closure (cdr fmls) + (next-stack-index si) + (extend-env (car fmls) si env))))) + (emit-lambda-closure (lambda-formals expr) (- +wordsize+) env)) + (emit-function-footer)))) (defun emit-letrec (expr) (let* ((bindings (letrec-bindings expr)) @@ -562,8 +561,9 @@ (lambdas (mapcar #'cadr bindings)) (asm-labels (unique-labels lvars)) (env (make-initial-env lvars asm-labels))) - (mapcan (emit-lambda env) lambdas asm-labels) - (emit-elco-entry env (letrec-body expr)))) + (emitn + (apply #'concatenate (cons 'string (mapcar (emit-lambda env) lambdas asm-labels))) + (emit-elco-entry env (letrec-body expr))))) (defun call-target (expr) (if (equal (symbol-name (car expr)) "APP") @@ -589,14 +589,15 @@ (defun emit-app (si env expr) (labels ((emit-arguments (si args) (unless (not args) - (progn + (emitn (emit-expr si env (car args)) - (emit-stack-save si)) - (emit-arguments (next-stack-index si) (cdr args))))) - (emit-arguments (next-stack-index si) (call-args expr)) - (emit-adjust-base (+ si +wordsize+)) - (emit-call env (call-target expr)) - (emit-adjust-base (- (+ si +wordsize+))))) + (emit-stack-save si) + (emit-arguments (next-stack-index si) (cdr args)))))) + (emitn + (emit-arguments (next-stack-index si) (call-args expr)) + (emit-adjust-base (+ si +wordsize+)) + (emit-call env (call-target expr)) + (emit-adjust-base (- (+ si +wordsize+)))))) ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; Tail calls @@ -620,25 +621,27 @@ (defun emit-tail-if (si env expr) (let ((alt-label (unique-label)) (end-label (unique-label))) - (emit-expr si env (if-test expr)) - (emit " cmp $~s, %al" +bool-f+) - (emit " je ~a" alt-label) - (emit-tail-expr si env (if-conseq expr)) - (emit " jmp ~a" end-label) - (emit "~a:" alt-label) - (emit-tail-expr si env (if-altern expr)) - (emit "~a:" end-label))) + (emitn + (emit-expr si env (if-test expr)) + (emit " cmp $~s, %al" +bool-f+) + (emit " je ~a" alt-label) + (emit-tail-expr si env (if-conseq expr)) + (emit " jmp ~a" end-label) + (emit "~a:" alt-label) + (emit-tail-expr si env (if-altern expr)) + (emit "~a:" end-label)))) (defun emit-tail-let (si env expr) (labels ((process-let (bindings si new-env) (if bindings (let ((b (car bindings))) - (emit-expr si (if (let*p expr) new-env env) (cadr b)) - (emit-stack-save si) - (process-let - (cdr bindings) - (next-stack-index si) - (extend-env (car b) si new-env))) + (emitn + (emit-expr si (if (let*p expr) new-env env) (cadr b)) + (emit-stack-save si) + (process-let + (cdr bindings) + (next-stack-index si) + (extend-env (car b) si new-env)))) (emit-tail-expr si new-env (let-body expr))))) (process-let (let-bindings expr) si env))) @@ -648,19 +651,20 @@ (defun emit-tail-app (si env expr) (labels ((emit-arguments (si args) (unless (not args) - (progn + (emitn (emit-expr si env (car args)) - (emit-stack-save si)) - (emit-arguments (next-stack-index si) (cdr args)))) + (emit-stack-save si) + (emit-arguments (next-stack-index si) (cdr args))))) (emit-move-args (pos si count) (unless (zerop count) - (progn + (emitn (emit " movl ~s(%esp), %eax" si) (emit " movl %eax, ~s(%esp)" pos) (emit-move-args (next-stack-index pos) (next-stack-index si) (1- count)))))) - (emit-arguments si (call-args expr)) - (emit-move-args (- +wordsize+) si (length (call-args expr))) - (emit-tail-call env (call-target expr)))) + (emitn + (emit-arguments si (call-args expr)) + (emit-move-args (- +wordsize+) si (length (call-args expr))) + (emit-tail-call env (call-target expr))))) (defun emit-tail-progn (si env expr) (emit-progn si env expr)) @@ -694,7 +698,7 @@ (if (= (length expr) 1) (emit-tail-expr si env (car expr)) - (progn + (emitn (emit-expr si env (car expr)) (emit-progn si env (cdr expr)))))) @@ -712,24 +716,26 @@ (cadr expr)) (defun emit-foreign-call (si env expr) - (emit " movl %esp, %edi") - (emit " addl $~s, %edi" (- si (* +wordsize+ (1- (length (cddr expr)))))) - (emit " andl $15, %edi") - (labels ((emit-params (si expr) - (if (not expr) - si - (progn - (emit-expr si env (car expr)) - (emit " subl %edi, %esp") - (emit-stack-save si) - (emit " addl %edi, %esp") - (emit-params (next-stack-index si) (cdr expr)))))) - (let ((end-of-si (+ +wordsize+ (emit-params si (reverse (cddr expr)))))) - (emit " subl %edi, %esp") - (emit-adjust-base end-of-si) - (emit " call e_~a" (foreign-call-label expr)) - (emit-adjust-base (- end-of-si)) - (emit " addl %edi, %esp")))) + (emitn + (emit " movl %esp, %edi") + (emit " addl $~s, %edi" (- si (* +wordsize+ (1- (length (cddr expr)))))) + (emit " andl $15, %edi") + (labels ((emit-params (si expr) + (if (not expr) + si + (emitn + (emit-expr si env (car expr)) + (emit " subl %edi, %esp") + (emit-stack-save si) + (emit " addl %edi, %esp") + (emit-params (next-stack-index si) (cdr expr)))))) + (let ((end-of-si (+ +wordsize+ (emit-params si (reverse (cddr expr)))))) + (emitn + (emit " subl %edi, %esp") + (emit-adjust-base end-of-si) + (emit " call e_~a" (foreign-call-label expr)) + (emit-adjust-base (- end-of-si)) + (emit " addl %edi, %esp")))))) ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; Highlevel emission @@ -749,64 +755,72 @@ (t (error "Supplied argument not an elco expression! ~a" expr)))) (defun emit-elco-entry (env expr) - (emit-function-header "E_elco_entry") - (emit-expr (- +wordsize+) env expr) - (emit-function-footer)) + (emitn + (emit-function-header "E_elco_entry") + (emit-expr (- +wordsize+) env expr) + (emit-function-footer))) (defun emit-program (expr) - (if (letrecp expr) - (emit-letrec expr) - (emit-elco-entry nil expr)) - (emit-function-header "elco_entry") - (emit " movl 4(%esp), %ecx /* get context save pointer */") - (emit " movl %ebx, 4(%ecx) /* save ebx */") - (emit " movl %esi, 16(%ecx) /* save esi */") - (emit " movl %edi, 20(%ecx) /* save edi */") - (emit " movl %ebp, 24(%ecx) /* save ebp */") - (emit " movl %esp, 28(%ecx) /* save esp */") - (emit " movl %ecx, %esi") - (emit " movl 12(%esp), %ebp /* get heap pointer */") - (emit " movl 8(%esp), %esp /* get stack pointer */") - (emit " call E_elco_entry") - (emit " movl %esi, %ecx") - (emit " movl 4(%ecx), %ebx /* restore ebx */") - (emit " movl 16(%ecx), %esi /* restore esi */") - (emit " movl 20(%ecx), %edi /* restore edi */") - (emit " movl 24(%ecx), %ebp /* restore ebp */") - (emit " movl 28(%ecx), %esp /* restore esp */") - (emit-function-footer)) + (emitn + (if (letrecp expr) + (emit-letrec expr) + (emit-elco-entry nil expr)) + (emit-function-header "elco_entry") + (emit " movl 4(%esp), %ecx /* get context save pointer */") + (emit " movl %ebx, 4(%ecx) /* save ebx */") + (emit " movl %esi, 16(%ecx) /* save esi */") + (emit " movl %edi, 20(%ecx) /* save edi */") + (emit " movl %ebp, 24(%ecx) /* save ebp */") + (emit " movl %esp, 28(%ecx) /* save esp */") + (emit " movl %ecx, %esi") + (emit " movl 12(%esp), %ebp /* get heap pointer */") + (emit " movl 8(%esp), %esp /* get stack pointer */") + (emit " call E_elco_entry") + (emit " movl %esi, %ecx") + (emit " movl 4(%ecx), %ebx /* restore ebx */") + (emit " movl 16(%ecx), %esi /* restore esi */") + (emit " movl 20(%ecx), %edi /* restore edi */") + (emit " movl 24(%ecx), %ebp /* restore ebp */") + (emit " movl 28(%ecx), %esp /* restore esp */") + (emit-function-footer))) (defun compile-program (expr) - (open-compile-port (merge-pathnames *compile-directory* #P"elco.s")) - (emit-program expr) - (close-compile-port)) + (emit-program expr)) ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; Convinience code ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -(defun build () - (with-output-to-string (gcc-output-stream) - (sb-ext:run-program "/usr/bin/gcc" - `("-O3" - "-Wall" - ,(namestring *driver-object*) - ,(namestring (merge-pathnames *compile-directory* #P"elco.s")) - "-o" ,(namestring (merge-pathnames *compile-directory* #P"elco.bin"))) - :output gcc-output-stream - :error :output))) +(defun build (code &key output driver-o) + (let ((assembler-file-name (make-temp-file-name "s")) + (binary-file-name (if output output (make-temp-file-name "bin"))) + (driver-object (if driver-o driver-o (create-driver-object)))) + (with-open-file (assembler-file assembler-file-name :direction :output :if-exists :supersede) + (princ code assembler-file)) + (let ((gcc-output (with-output-to-string (gcc-output-stream) + (sb-ext:run-program "/usr/bin/gcc" + `("-O3" + "-Wall" + ,(namestring driver-object) + ,(namestring assembler-file-name) + "-o" ,(namestring binary-file-name)) + :output gcc-output-stream + :error :output)))) + (unless (string= "" gcc-output) (format t "gcc-error: ~s~%" gcc-output))) + (sb-ext:run-program "/bin/rm" `("-f" ,(namestring assembler-file-name))) + (unless driver-o (sb-ext:run-program "/bin/rm" `("-f" ,(namestring driver-object)))) + binary-file-name)) -(defun execute () +(defun execute (binary) (with-output-to-string (elco-output-stream) - (sb-ext:run-program (namestring (merge-pathnames *compile-directory* #P"elco.bin")) + (sb-ext:run-program (namestring binary) nil :output elco-output-stream))) -(defun execute-program (expr) - (compile-program expr) - (let ((gcc-output-string (build)) - (elco-output-string (execute))) - (format t "gcc: ~a~%" gcc-output-string) - (format t "elco: ~a" elco-output-string))) +(defun execute-program (expr &key driver-o) + (let* ((binary-file (build (compile-program expr) :driver-o driver-o)) + (elco-output (execute binary-file))) + (sb-ext:run-program "/bin/rm" `("-f" ,(namestring binary-file))) + elco-output)) Modified: trunk/elco/package.lisp =================================================================== --- trunk/elco/package.lisp 2008-07-07 17:00:08 UTC (rev 41) +++ trunk/elco/package.lisp 2008-07-13 00:52:58 UTC (rev 42) @@ -33,6 +33,7 @@ :compile-program :build :execute + :create-driver-object ; immediates :T :F Modified: trunk/maintainer/generate-elco-driver.sh =================================================================== --- trunk/maintainer/generate-elco-driver.sh 2008-07-07 17:00:08 UTC (rev 41) +++ trunk/maintainer/generate-elco-driver.sh 2008-07-13 00:52:58 UTC (rev 42) @@ -53,5 +53,3 @@ ,(namestring driver-object))) (sb-ext:run-program "/bin/rm" `("-f" ,(namestring tmp))) driver-object))' >> $ELCO_DRIVER_FILE - -echo '(defvar *driver-object* (create-driver-object))' >> $ELCO_DRIVER_FILE Modified: trunk/test/tests.lisp =================================================================== --- trunk/test/tests.lisp 2008-07-07 17:00:08 UTC (rev 41) +++ trunk/test/tests.lisp 2008-07-13 00:52:58 UTC (rev 42) @@ -30,17 +30,13 @@ (defvar *all-tests* '()) -(defun run-test (input output) - (elco:compile-program input) - (let ((gcc-output (elco:build))) - (if (not (equal gcc-output "")) - (format t "gcc problem: ~s~%" gcc-output) - (let ((elco-output (elco:execute))) - (if (not (equal elco-output (format nil output))) - (format t "FAILED, expected output was ~s but got ~s~%" output elco-output) - t))))) +(defun run-test (input output &key object-file) + (let ((elco-output (elco:execute-program input :driver-o object-file))) + (if (not (equal elco-output (format nil output))) + (format t "FAILED, expected output was ~s but got ~s~%" output elco-output) + t))) -(defun run-tests (&key tests select) +(defun run-rec-tests (&key tests select object-file) (if tests (if (stringp (car tests)) (let ((break-loop nil)) @@ -49,7 +45,7 @@ (loop for i in (cadr tests) until break-loop do (format t "test ~s : ~s ... " (car tests) i) - (if (run-test (car i) (caddr i)) + (if (run-test (car i) (caddr i) :object-file object-file) (format t "PASSED~%") (setf break-loop T))) (if break-loop @@ -60,13 +56,18 @@ (loop for i in tests until (if select (if (equal (car i) select) - (not (run-tests :tests i)) + (not (run-rec-tests :tests i)) nil) - (not (run-tests :tests i))))) + (not (run-rec-tests :tests i))))) (if select - (run-tests :select select :tests *all-tests*) - (run-tests :tests *all-tests*)))) + (run-rec-tests :select select :tests *all-tests*) + (run-rec-tests :tests *all-tests*)))) +(defun run-tests (&key select) + (let ((object-file (elco:create-driver-object))) + (run-rec-tests :select select :object-file object-file) + (sb-ext:run-program "/bin/rm" `("-f" ,(namestring object-file))))) + (defmacro deftest ((test-id) &body body) `(setf *all-tests* (append *all-tests* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <es...@us...> - 2008-07-07 17:00:37
|
Revision: 41 http://elco.svn.sourceforge.net/elco/?rev=41&view=rev Author: esden Date: 2008-07-07 10:00:08 -0700 (Mon, 07 Jul 2008) Log Message: ----------- - Added description to the generate-elco-driver shell script Modified Paths: -------------- trunk/maintainer/generate-elco-driver.sh Modified: trunk/maintainer/generate-elco-driver.sh =================================================================== --- trunk/maintainer/generate-elco-driver.sh 2008-07-06 23:47:16 UTC (rev 40) +++ trunk/maintainer/generate-elco-driver.sh 2008-07-07 17:00:08 UTC (rev 41) @@ -28,6 +28,10 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# This script takes the elco driver written in c and embeds it in lisp +# this way you don't need the c file lying somewhere around while in +# the lisp word. + ELCO_DRIVER_FILE="elco/driver.lisp" echo '(in-package #:elco)' > $ELCO_DRIVER_FILE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Piotr Esden-T. <pi...@es...> - 2008-06-28 12:06:53
|
Testmail, please ignore. |