home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
bbs
/
may94
/
util
/
edit
/
jade.lha
/
Jade
/
lisp
/
compiler.jlc
< prev
next >
Wrap
Text File
|
1994-04-20
|
21KB
|
549 lines
(provide (quote compiler))
(defvar comp-eval-constants-p t 60339)
(defvar comp-write-docs-p nil 60487)
(defconst op-call 8)
(defconst op-push 16)
(defconst op-vrefc 24)
(defconst op-vsetc 32)
(defconst op-list 40)
(defconst op-bind 48)
(defconst op-last-with-args 55)
(defconst op-vref 64)
(defconst op-vset 65)
(defconst op-fref 66)
(defconst op-fset 67)
(defconst op-init-bind 68)
(defconst op-unbind 69)
(defconst op-dup 70)
(defconst op-swap 71)
(defconst op-pop 72)
(defconst op-nil 73)
(defconst op-t 74)
(defconst op-cons 75)
(defconst op-car 76)
(defconst op-cdr 77)
(defconst op-rplaca 78)
(defconst op-rplacd 79)
(defconst op-nth 80)
(defconst op-nthcdr 81)
(defconst op-aset 82)
(defconst op-aref 83)
(defconst op-length 84)
(defconst op-eval 85)
(defconst op-plus-2 86)
(defconst op-negate 87)
(defconst op-minus-2 88)
(defconst op-product-2 89)
(defconst op-divide-2 90)
(defconst op-mod-2 91)
(defconst op-bit-not 92)
(defconst op-not 93)
(defconst op-bit-or-2 94)
(defconst op-bit-and-2 95)
(defconst op-equal 96)
(defconst op-eq 97)
(defconst op-num-eq 98)
(defconst op-num-noteq 99)
(defconst op-gtthan 100)
(defconst op-gethan 101)
(defconst op-ltthan 102)
(defconst op-lethan 103)
(defconst op-inc 104)
(defconst op-dec 105)
(defconst op-lsh 106)
(defconst op-zerop 107)
(defconst op-null 108)
(defconst op-atom 109)
(defconst op-consp 110)
(defconst op-listp 111)
(defconst op-numberp 112)
(defconst op-stringp 113)
(defconst op-vectorp 114)
(defconst op-catch-kludge 115)
(defconst op-throw 116)
(defconst op-unwind-pro 117)
(defconst op-un-unwind-pro 118)
(defconst op-fboundp 119)
(defconst op-boundp 120)
(defconst op-symbolp 121)
(defconst op-get 122)
(defconst op-put 123)
(defconst op-error-pro 124)
(defconst op-signal 125)
(defconst op-set-current-buffer 176)
(defconst op-swap-buffer 177)
(defconst op-current-buffer 178)
(defconst op-bufferp 179)
(defconst op-mark-p 180)
(defconst op-windowp 181)
(defconst op-swap-window 182)
(defconst op-last-before-jmps 250)
(defconst op-jmp 251)
(defconst op-jmp-nil 252)
(defconst op-jmp-t 253)
(defconst op-jmp-nil-else-pop 254)
(defconst op-jmp-t-else-pop 255)
(defconst comp-max-1-byte-arg 5)
(defconst comp-max-2-byte-arg 127)
(defconst comp-max-3-byte-arg 16383)
(defvar comp-constant-alist nil)
(defvar comp-constant-index 0)
(defvar comp-current-stack 0)
(defvar comp-max-stack 0)
(defvar comp-output nil)
(defvar comp-output-pc 0)
(defvar comp-macro-env nil)
(defun compile-file (file-name) 60586 (lisp-code "DI0I1I2I3\nF þ\n\nF!þ«|HJE" [src-file dst-file form comp-macro-env open file-name "r" concat 99 "w" (lisp-code "u\tH\t]þ´\t\tF&þ°\nH\nHûv" [(lisp-code "\tH\t" [close dst-file src-file] 2) title-now concat "Compiling file " file-name "..." file-eof-p src-file comp-compile-file-form read form print dst-file write 10] 5) (error (lisp-code "D\n3\tþ\tEHLM" [concat file-name 99 fname file-exists-p delete-file funcall signal error-info] 4)) 2] 4))
(defun compile-directory (dir-name &optional force-p) 60733 (lisp-code "D\t2nþ¼L\nþ³DL\n6\n6\nþ²\tEHMF\"Hû HJE" [directory-files dir-name dir regexp-match "\\.jl$" file-concat file concat 99 cfile file-newer-than-file-p compile-file] 3))
(defun compile-lisp-lib (&optional force-p) 60967 (lisp-code "DJ0\nE" [comp-write-docs-p compile-directory lisp-lib-dir force-p] 3))
(put (quote compile-error) (quote error-message) "Compilation mishap")
(defun comp-error (&rest data) (lisp-code "}" [compile-error data] 2))
(defun comp-compile-file-form (form) (lisp-code "n]üûËDL1aüÁDP\n6þ«INHIOEHPQK\tMKKûÊaüDQK\tP\n66üêOûôPKKF%HPMKKEûÊaÿaü³DP6þ qþQ\tNEHûÊaüÁUHûÊJüÉûÊIE" [form fun defun assq 1 comp-macro-env tmp comp-compile-lambda lambda 2 defmacro code defconst defvar 3 doc comp-write-docs-p add-doc-string require] 6))
(defun compile-top-level-form (form) (lisp-code "DI0234I56\tHþ¢,E" [comp-constant-alist 0 comp-constant-index comp-current-stack comp-max-stack comp-output comp-output-pc comp-compile-form form lisp-code comp-make-code-string comp-make-const-vec] 4))
(defun comp-make-code-string nil (lisp-code "D\nnþLMLLRHMF$HûHE" [make-string comp-output-pc 42 comp-output data code-string] 3))
(defun comp-make-const-vec nil (lisp-code "D\t34nþLMLLRHMF#HûHE" [make-vector comp-constant-index comp-constant-alist consts vec] 3))
(defun comp-inc-stack nil (lisp-code "hF dþF!" [comp-current-stack comp-max-stack] 2))
(defmacro comp-dec-stack (&optional n) (lisp-code "ü+û*+" [setq comp-current-stack n - 1-] 5))
(defun comp-compile-form (form) (lisp-code "Iaü\tHûJaü\tHûyüÊþ«\tü¼\t\t\nûÄ\t\nHûnü DI6LyþáLzF&üí\nû\nF HLyþLzF&ü\nûLF&Hyü¤\tûÍnþ°Laü¾\t\tûÍJüÌ\nûÍIHMF HD6nþðL\tHh&MF HûØH\nHXF&EEûJü\tûI" [form comp-write-op 73 comp-inc-stack 74 comp-eval-constants-p const-variable-p 16 comp-add-constant symbol-value 24 fun compile-fun funcall macroexpand comp-macro-env comp-compile-constant lambda comp-compile-lambda comp-error "Bad function name" 0 i comp-compile-form 8 comp-current-stack] 5))
(defun comp-compile-constant (form) (lisp-code "\t\nH" [comp-write-op 16 comp-add-constant form comp-inc-stack] 4))
(defun comp-add-constant (const) (lisp-code "\nMÿKK\"hF#Hi" [assoc const comp-constant-alist comp-constant-index] 3))
(defun comp-compile-body (body) (lisp-code "lü\tHû°nþ°L\tHMþ§\tHiF&HMF Hû" [body comp-write-op 73 comp-inc-stack comp-compile-form 72 comp-current-stack] 2))
(defun comp-compile-lambda (list) (lisp-code "DQI23Lqü«M#Pü¢P\tû¥P+F\"ûºJü¹P*F\"ûºIHK\tIK\nE" [2 list new-head body lambda 1 comp-write-docs-p add-doc-string nconc compile-top-level-form progn] 5))
(defmacro comp-make-label nil (lisp-code "" [(cons nil nil)] 1))
(defun comp-compile-jmp (opcode label) (lisp-code "\tHLpüLj^\tHL_^\tû¶JüµMKOHVF&û¶I" [comp-byte-out opcode label 128 -7 127 comp-output-pc 2] 4))
(defun comp-set-label (label) (lisp-code "dþ\tHNHMF$Hnþ»j^LK_^LhKKKF&HMF$Hû" [comp-output-pc 16383 comp-error "Jump destination overflow!" label 128 -7 127 comp-output] 4))
(defun comp-write-op (opcode &optional arg) (lisp-code "lü\tûÞgüV\tûÞgü®V\tH^\tûÞgüÑV\tHj^\tH_^\tûÞJüÝ\tûÞI" [arg comp-byte-out opcode 5 127 6 128 16383 7 -7 comp-error "Opcode overflow!"] 4))
(defun comp-byte-out (byte) (lisp-code "KK\"hF!" [byte comp-output-pc comp-output] 2))
(put (quote if) (quote compile-fun) (quote comp-compile-if))
(defun comp-compile-if (form) (lisp-code "P\tHTbü®DIIK4\nHiF&HP\tH\tEûìDIIK4IIK6\nHiF&HP\tH\nH\tHiF&HQ\tH\tE" [comp-compile-form 1 form 3 end-label comp-compile-jmp 254 comp-current-stack 2 comp-set-label else-label 252 251 comp-compile-body] 3))
(put (quote when) (quote compile-fun) (quote comp-compile-when))
(defun comp-compile-when (form) (lisp-code "P\tHDIIK3\nHiF&HQ\tH\tE" [comp-compile-form 1 form end-label comp-compile-jmp 254 comp-current-stack comp-compile-body 2 comp-set-label] 3))
(put (quote unless) (quote compile-fun) (quote comp-compile-unless))
(defun comp-compile-unless (form) (lisp-code "P\tHDIIK3\nHiF&HQ\tH\tE" [comp-compile-form 1 form end-label comp-compile-jmp 255 comp-current-stack comp-compile-body 2 comp-set-label] 3))
(put (quote quote) (quote compile-fun) (quote comp-compile-quote))
(defun comp-compile-quote (form) (lisp-code "ML\t" [comp-compile-constant form] 2))
(put (quote function) (quote compile-fun) (quote comp-compile-function))
(defun comp-compile-function (form) (lisp-code "MLF Hyü\tû\t\t" [form comp-compile-constant comp-compile-lambda] 3))
(put (quote