Changeset 21628 for lang/elisp
- Timestamp:
- 10/19/08 18:47:57 (3 months ago)
- Location:
- lang/elisp/escm/trunk
- Files:
-
- 5 added
- 1 removed
- 21 modified
-
DEVELOPERSTOOLS.el (modified) (4 diffs)
-
Makefile.in (modified) (2 diffs)
-
configure.in (modified) (1 diff)
-
emacs-config.el (modified) (2 diffs)
-
escm-arity.el (modified) (2 diffs)
-
escm-base.el (modified) (4 diffs)
-
escm-cbos.el (modified) (16 diffs)
-
escm-compile.el (modified) (15 diffs)
-
escm-debug.el (modified) (6 diffs)
-
escm-devel.el (modified) (1 diff)
-
escm-elizer.el (modified) (12 diffs)
-
escm-env.el (modified) (18 diffs)
-
escm-iblock-content.el (modified) (10 diffs)
-
escm-iblock.el (modified) (1 diff)
-
escm-macro.el (modified) (3 diffs)
-
escm-proc.el (modified) (4 diffs)
-
escm-root-env.el (added)
-
escm-syntax-case.el (added)
-
escm-syntax-match.el (added)
-
escm-syntax.el (modified) (1 diff)
-
escm-test.el (modified) (6 diffs)
-
escm-util.el (modified) (9 diffs)
-
escm-vm.el (modified) (16 diffs)
-
escm.el (modified) (7 diffs)
-
escm/prelude.escm (added)
-
genprelude (deleted)
-
sample (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/elisp/escm/trunk/DEVELOPERSTOOLS.el
r12594 r21628 5 5 (setq load-path (cons dir load-path))) 6 6 7 (require 'escm )7 (require 'escm-devel) 8 8 (global-set-key [?\C-c ?e ?a] 'escm-debug::activate) 9 9 (global-set-key [?\C-c ?e ?d] 'escm-debug::deactivate) … … 13 13 (setq escm-default-vm nil) 14 14 (message "default vm is resetted."))) 15 15 16 (global-set-key [?\C-c ?e ?e] 'escm-eval-last-sexp)) 16 17 17 18 18 ;; dired … … 20 20 21 21 22 23 24 22 25 ;; sample codes 23 26 (when nil 24 27 25 (escm-vm::eval (escm-vm::new) '(+ 0 1 (* 2 3) 4))26 (escm-vm::eval (escm-vm::new) '(if nil 1 2))27 (escm-vm::eval (escm-vm::new)28 '((lambda ()29 (define (fact n) (if (= n 1) n (* n (fact (- n 1)))))30 (fact 131 32 (escm-vm::eval33 (escm-vm::new)34 '((lambda ()35 (message (call/cc (lambda (cont)36 (cont "abc")))))))37 38 (escm-vm::eval39 (escm-vm::new)40 '((lambda ()41 (define (fib n)42 (define (iter a b n)43 (if (= n 0) (+ a b) (iter b (+ a b) (- n 1))))44 (iter 0 1 n))45 (fib 10))))46 47 (insert (format "%S"48 (escm-vm::byte-compile49 (escm-vm::new)50 '((define (fib n)51 (define (iter a b n)52 (if (= n 0) (+ a b) (iter b (+ a b) (- n 1))))53 (iter 0 1 n))54 (fib 10)))))55 56 (when nil57 28 58 29 (escm-vm::eval … … 60 31 '((lambda () 61 32 (define (fib n) 62 (if (< n 2) 63 1 64 (+ (fib (- n 2)) 65 (fib (- n 1))))) 33 (define (iter a b n) 34 (if (= n 0) (+ a b) (iter b (+ a b) (- n 1)))) 35 (iter 0 1 n)) 66 36 (fib 10)))) 67 37 68 (escm-vm::eval 69 (escm-vm::new) 70 '((lambda () 71 (define (fib-iter a b n) 72 (if (= 0 n) 73 (+ a b) 74 (fib-iter b 75 (+ a b) 76 (- n 1)))) 77 (define (fib n) (fib-iter 0 1 n)) 78 (fib 12)))) 79 ;; 38 (escm-vm::eval 39 (escm-vm::new) 40 '((lambda () 41 (define (fib n) 42 (if (< n 2) 43 1 44 (+ (fib (- n 2)) 45 (fib (- n 1))))) 46 (fib 10)))) 47 48 (escm-vm::eval 49 (escm-vm::new) 50 '((lambda () 51 (define (fib-iter a b n) 52 (if (= 0 n) 53 (+ a b) 54 (fib-iter b 55 (+ a b) 56 (- n 1)))) 57 (define (fib n) (fib-iter 0 1 n)) 58 (fib 12)))) 80 59 81 (let* ((def '((define (fib-iter a b n) 82 (if (= 0 n) 83 (+ a b) 84 (fib-iter b 85 (+ a b) 86 (- n 1)))) 87 (define (fib n) (fib-iter 0 1 n)))) 88 (bm (lambda (x) 89 (escm-util::benchmark 90 (escm-vm::eval (escm-vm::new) x)) 91 escm-util::benchmark::result))) 92 (list (funcall bm nil) 93 (funcall bm `((lambda () ,@def ))) 94 (funcall bm `((lambda () ,@def (fib 1)))) 95 (funcall bm `((lambda () ,@def (fib 10)))) 96 (funcall bm `((lambda () ,@def (fib 15)))))) 60 61 (let* ((def '((define (fib-iter a b n) 62 (if (= 0 n) 63 (+ a b) 64 (fib-iter b 65 (+ a b) 66 (- n 1)))) 67 (define (fib n) (fib-iter 0 1 n)))) 68 (bm (lambda (x) 69 (escm-util::benchmark 70 (escm-vm::eval (escm-vm::new) x)) 71 escm-util::benchmark::result))) 72 (list (funcall bm nil) 73 (funcall bm `((lambda () ,@def ))) 74 (funcall bm `((lambda () ,@def (fib 1)))) 75 (funcall bm `((lambda () ,@def (fib 10)))) 76 (funcall bm `((lambda () ,@def (fib 15)))))) 97 77 98 (escm-vm::eval (escm-vm::new) '`a) 78 (escm-vm::eval (escm-vm::new) '`a) 79 (escm-vm::eval 80 (escm-vm::new) '((lambda () 81 (define-syntax a (lambda (_ . x) (list 'quote x))) 82 (a b c)))) 99 83 100 84 101 (escm-vm::eval 102 (escm-vm::new) '((lambda () 103 (define-syntax a (lambda (_ . x) (list 'quote x))) 104 (a b c)))) 85 (define (fact n) 86 (if (= n 1) n (* n (fact (- n 1))))) 105 87 106 107 (define (fact n) (if (= n 1) 108 n 109 (* n (fact (- n 1))))) 110 (fact 20) 111 ) 88 (fact 20) 89 ) -
lang/elisp/escm/trunk/Makefile.in
r12594 r21628 2 2 EMACS=@EMACS@ 3 3 SITELISP=@SITELISP@ 4 TAR=@TAR@ 4 5 5 ELDIR=src/elisp 6 ESCMDIR=src/escm 6 ELS=@ELS@ 7 7 8 ELS= escm-util.minimal.el \ 9 escm-test.el \ 10 escm-util.el \ 11 escm-cbos.el \ 12 \ 13 escm-base.el \ 14 \ 15 escm-env.el \ 16 \ 17 escm-arity.el \ 18 escm-proc.el \ 19 \ 20 escm-syntax.el \ 21 escm-iblock-content.el \ 22 escm-iblock.el \ 23 escm-icode.el \ 24 escm-elizer.el \ 25 escm-compile.el \ 26 escm-port.el \ 27 \ 28 escm-debug.el \ 29 escm-vm.el \ 30 escm.el 31 8 INSTDIR=$(SITELISP)/escm 32 9 EMACSFLAGS= -batch -q -L . 33 10 … … 35 12 36 13 .el.elc: 37 $(EMACS) $(EMACSFLAGS) -f batch-byte-compile $< 14 @echo 15 @echo Compiling $< ..... 16 @if test -f $@ ; then rm $@ ; fi 17 @$(EMACS) $(EMACSFLAGS) -l escm.el -f batch-byte-compile $< 38 18 39 19 .escm.escmc: 40 20 $(EMACS) $(EMACSFLAGS) -l escm.el -f escm-batch-byte-compile $< 41 21 42 prelude.escm: genprelude escm/init.escm43 ./genprelude escm/init.escm >$@44 22 45 all: elc escmc 23 #all: elc escmc 24 all: elc 46 25 47 elc: $(ELS:.el=.elc)26 elc: escm.elc 48 27 49 escmc: prelude.escmc 28 escmc: escm/prelude.escmc 29 30 distname: 31 @echo escm-` \ 32 grep escm-version escm-base.el \ 33 | sed -e 's/[( )"]\|defconst\|escm-version//g' \ 34 ` 35 install: all 36 mkdir -p $(INSTDIR) 37 cp $(ELS) $(INSTDIR) 38 cp $(ELS:.el=.elc) $(INSTDIR) 39 cp -r escm test $(INSTDIR) 40 chmod 777 $(INSTDIR)/test 50 41 51 42 clean: 52 find . -type f -name \*.elc |xargs rm 53 find . -type f -name \*.escmc |xargs rm 54 55 install: install.el all 56 mkdir -p $(SITELISP)/escm 57 cp -r escm test $(SITELISP)/escm/escm 58 cp $(ELS) $(ELS:.el=.elc) $(SITELISP)/escm 43 find . -type f -name \*.elc |xargs rm -f 44 find . -type f -name \*.escmc |xargs rm -f 59 45 60 46 uninstall: 61 rm -rf $( SITELISP)/escm47 rm -rf $(INSTDIR) 62 48 63 49 distclean: clean 64 rm -rf config.log config.status Makefile 50 rm -rf config.log config.status Makefile MANIFEST autom4te.cache 51 rm -rf .configure.swp 52 53 dist: MANIFEST 54 cat MANIFEST |xargs $(TAR) -cvzf `$(MAKE) distname`.tar.gz 55 56 MANIFEST: 57 echo $@ > $@ 58 find . | grep -v $@ \ 59 | grep -v 'config\..*' \ 60 | grep -v 'autom4te\.cache' \ 61 | grep -v '\.elc$$' \ 62 | grep -v '\.escmc' \ 63 | grep -v '\.configure.swp' \ 64 | grep -v '\.tar\.[bg]z$$' \ 65 >> $@ 66 67 @DEPENDENCIES@ -
lang/elisp/escm/trunk/configure.in
r10671 r21628 1 AC_INIT(escm.el) 2 AC_ARG_WITH([ emacs ] , 1 AC_INIT(escm,0.001,lieutar@1dk.jp) 2 AC_PREREQ(2.6) 3 4 5 ############################################################ 6 AC_SUBST(EMACSFLAGS) 7 EMACSFLAGS="-batch -no-site-file -q -L ." 8 9 ## 10 AC_SUBST(ELS) 11 ELS=`echo escm*.el` 12 echo el files ... $ELS 13 14 ## 15 AC_PATH_PROGS(TAR, gtar tar) 16 17 ## 18 AC_SUBST(EMACS) 19 AC_ARG_WITH(emacs, 3 20 AS_HELP_STRING([--with-emacs@<:@=PATH@:>@], 4 21 [PATH=emacs, xemacs, mule...]), 5 [ EMACS=$withval ], 6 [ AC_PATH_PROGS(EMACS, emacs xemacs mule, emacs) ]) 22 [ EMACS=$withval; ],[ 23 AC_PATH_PROGS(EMACS, emacs xemacs mule, emacs) 24 ]) 7 25 26 echo emacs ... $EMACS 27 econf="$EMACS $EMACSFLAGS -l emacs-config.el -f" 28 29 ## 30 AC_SUBST(SITELISP) 31 AC_ARG_WITH(site-lisp, 32 AC_HELP_STRING([--with-site-lisp=@<:@PATH@:>@]), 33 [SITELISP=$with_site_lisp;],[ 34 SITELISP=`$econf 'site-lisp'`;]) 35 echo site-lisp ... $SITELISP 36 37 ## 38 AC_SUBST(DEPENDENCIES) 39 echo Check dependencies ... 40 DEPENDENCIES=`$econf dependencies escm*.el` 41 42 43 ## 8 44 AC_OUTPUT(Makefile) -
lang/elisp/escm/trunk/emacs-config.el
r10654 r21628 1 ;;; emacs-config.el --- 2 3 ;; Copyright (C) 2008 root 4 5 ;; Author: root <lieutar@lieutar@1dk.jp> 6 ;; Keywords: 7 8 ;; This file is free software; you can redistribute it and/or modify 9 ;; it under the terms of the GNU General Public License as published by 10 ;; the Free Software Foundation; either version 3, or (at your option) 11 ;; any later version. 12 13 ;; This file is distributed in the hope that it will be useful, 14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 ;; GNU General Public License for more details. 17 18 ;; You should have received a copy of the GNU General Public License 19 ;; along with GNU Emacs; see the file COPYING. If not, write to 20 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 ;; Boston, MA 02110-1301, USA. 22 23 ;;; Commentary: 24 25 ;; 26 27 28 (defun args () 29 "Returns commandline arguments that contains function name and following arguments." 30 (cdr (member "-f" command-line-args))) 31 32 (defun echo () 33 "Outputs command line arguments." 34 (print (cdr (args)))) 35 36 ;; 1 37 (defun site-lisp () 38 "Prints a path to a site-lisp directory." 2 39 (let ((dir (car (apply 3 40 'append … … 9 46 load-path))))) 10 47 (princ dir))) 48 49 50 ;; 51 (defun read-dependency (file files) 52 "Read all dependency of an emacs lisp FILE in a set of FILES. 53 Targets of this survey is only require form." 54 (let ((buf (find-file file)) 55 (R ())) 56 (set-buffer buf) 57 (goto-char 1) 58 (while (re-search-forward "(require\\s +'\\([^) \t]+\\)" nil t) 59 (let ((match (intern (match-string 1)))) 60 (when (member (format "%s.el" match) files) 61 (setq R (cons match R))))) 62 (kill-buffer buf) 63 R)) 64 65 (defun dependencies () 66 "Print dependencies of files that was given as command line arguments. 67 An output of this function is formatted as Makefile targets and its dependencies." 68 (let ((files (cdr (args)))) 69 (princ (concat (mapconcat (lambda (f) 70 (format "%sc: %s %s" 71 f 72 f 73 (mapconcat (lambda (f) 74 (format "%s.elc" f)) 75 (read-dependency f 76 files) 77 " "))) 78 files 79 "\n") 80 "\n")))) 81 -
lang/elisp/escm/trunk/escm-arity.el
r10671 r21628 39 39 40 40 (defsubst escm-arity::new (argspec) 41 " "41 "Creates and returns a new escm-arity object by argspec." 42 42 (let ((new (create-escm-arity)) 43 43 (fields ()) … … 60 60 61 61 (defsubst escm-arity::inject-args! (self env args) 62 "Inject values of the ARGS into the given ENV by the SELF spec." 62 63 (let ((p (escm-arity::get-length self)) 63 64 (at-least (escm-arity::get-at-least self))) -
lang/elisp/escm/trunk/escm-base.el
r12594 r21628 1 ;;; escm-base.el --- 2 3 ;; Copyright (C) 2008 root 4 5 ;; Author: root <root@localhost.localdomain> 6 ;; Keywords: 7 8 ;; This file is free software; you can redistribute it and/or modify 9 ;; it under the terms of the GNU General Public License as published by 10 ;; the Free Software Foundation; either version 3, or (at your option) 11 ;; any later version. 12 13 ;; This file is distributed in the hope that it will be useful, 14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 ;; GNU General Public License for more details. 17 18 ;; You should have received a copy of the GNU General Public License 19 ;; along with GNU Emacs; see the file COPYING. If not, write to 20 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 ;; Boston, MA 02110-1301, USA. 22 23 ;;; Commentary: 24 25 ;; 26 27 ;;; Code: 28 29 1 30 (require 'escm-util) 2 31 (require 'escm-cbos) … … 14 43 (escm-object::to-string self)) 15 44 16 17 45 ;; errors for escm 18 46 (escm-util::define-signals … … 20 48 (escm-syntax-error "") 21 49 (escm-void-variable "") 22 (escm-unsupported ""))) 23 24 25 50 (escm-unsupported "") 51 (escm-syntax-pattern-expression-is-illegal ""))) 26 52 27 53 ;; variables 54 (defconst escm-version "0.01.01") 28 55 (defconst escm-compiler-version 0.01) 29 (defconst escm-icode::indent """")56 (defconst escm-icode::indent "") 30 57 31 58 ;; utilities that only in this project. … … 44 71 45 72 (provide 'escm-base) 73 ;;; escm-base.el ends here -
lang/elisp/escm/trunk/escm-cbos.el
r12594 r21628 3 3 ;; Copyright (C) 2008 Free Software Foundation, Inc. 4 4 5 ;; Author: ;;; < onishi@THOTH>5 ;; Author: ;;; <lieutar@1dk.jp> 6 6 ;; Keywords: oop 7 7 … … 35 35 (escm-cbos::error::no-such-method "No such method"))) 36 36 37 (defconst escm-cbos::default-method nil) 38 (defconst escm-cbos::class-vmt nil) 39 (defconst escm-cbos::class-fields nil) 37 (defgroup escm-cbos () "" 38 :group 'programming 39 ) 40 41 (defconst escm-cbos::default-method nil 42 "The symbol for the plist that is used as dictionary for methods.") 43 44 (defconst escm-cbos::class-vmt nil 45 "The symbol for the plist that is used as virtual method table.") 46 47 (defconst escm-cbos::class-fields nil 48 "The symbol for the plist that is used as dictionary of specification of fields of classes.") 40 49 41 50 (defsubst escm-cbos::classp (sym) 42 " returns true if sym is escm::cbos class."51 "Returns true if sym is escm::cbos class." 43 52 (and (symbolp sym) 44 53 (plist-member (symbol-plist 'escm-cbos::class-fields) sym) 45 54 t)) 46 55 47 (defsubst escm-cbos::get-class (obj )48 " "49 (and (arrayp obj )50 (< 0 (length obj ))51 (let ((cls (aref obj 0)))56 (defsubst escm-cbos::get-class (object) 57 "Returns symbol of a class name from escm-cbos OBJECT." 58 (and (arrayp object) 59 (< 0 (length object)) 60 (let ((cls (aref object 0))) 52 61 (when (escm-cbos::classp cls) 53 62 cls)))) … … 56 65 57 66 (defsubst escm-cbos::inheritance-list (class) 58 "" 67 "Returns list that contains classes. 68 The list contains ancestor of the given CLASS and itself. 69 " 59 70 (when (escm-cbos::classp class) 60 71 (symbol-value (get 'escm-cbos::class-vmt class)))) 61 72 62 73 (defsubst escm-cbos::get-fields-of (class) 63 " "74 "Returns symbols of the fields of the CLASS." 64 75 (get 'escm-cbos::class-fields class)) 65 76 … … 86 97 87 98 (defun escm-cbos::register-class (name super fields) 99 "" 88 100 (eval (cdr (escm-cbos::make-class-info name super fields)))) 89 101 90 102 (defmacro escm-cbos::define-method (class name args &rest body) 91 " defines method of escm-cbos objects."103 "Defines method of escm-cbos objects." 92 104 `(progn 93 105 (when (not (fboundp ',name)) … … 109 121 110 122 123 111 124 (defmacro escm-cbos::delete-method (class name) 112 125 "" 113 (put (get 'escm-cbos::class-vmt ',class) ',name nil))126 `(put (get 'escm-cbos::class-vmt ',class) ',name nil)) 114 127 115 128 (defsubst escm-cbos::find-method1 (sym name) 129 "" 116 130 (let ((meth nil) 117 131 (ilist (symbol-value sym))) … … 123 137 124 138 (defun escm-cbos::find-method (class method-name) 139 "" 125 140 (let ((ilist (escm-cbos::inheritance-list class))) 126 141 (escm-cbos::find-method1 'ilist method-name))) 127 142 128 143 (defsubst escm-cbos::run-method (name obj args) 144 "" 129 145 (let* ((class (escm-cbos::get-class obj)) 130 146 (ilist (symbol-value (get 'escm-cbos::class-vmt class))) … … 139 155 140 156 141 142 157 (defun escm-cbos::expand-method (args body) 158 "" 143 159 `(lambda ,(cons '*ilist* (cons '*method-name* args)) 144 160 ,@(escm-util::walk-node 145 161 (lambda (x) 146 162 (if (listp x) 147 (cond ((eq 'super (car x))163 (cond ((eq 'super (car x)) 148 164 `(apply 149 165 (or (escm-cbos::find-method '*ilist* *method-name*) … … 165 181 166 182 (defun escm-cbos::make-accessor (spec p) 183 "" 167 184 (let* ((spec (if (listp spec) spec (list spec))) 168 185 (f (car spec)) … … 193 210 " 194 211 (let* ((name (car inhspec)) 195 (super (or (cadr inhspec) 'escm-cbos::Object)) 212 (super (or (cadr inhspec) 213 'escm-cbos::Object)) 214 (document (or (caddr inhspec) 215 "undocumented class.")) 196 216 (classinfo (escm-cbos::make-class-info name super fields)) 197 217 (fields (car classinfo)) … … 199 219 (new (intern (format "create-%s" name))) 200 220 (pred (intern (format "%s-p" name)))) 221 201 222 `(progn 202 223 ,(cdr classinfo) 224 225 (defvar ,name ',name ,document) 226 203 227 (defsubst ,new () 204 228 (let ((new (make-vector ,(+ 1 len) nil))) … … 220 244 (:foreground "black" :background "white")) 221 245
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)