Skip to content

Commit

Permalink
Add module declarations and exports to generated Wasp Lisp code
Browse files Browse the repository at this point in the history
  • Loading branch information
doublec committed Oct 8, 2018
1 parent fccb46f commit 28fad8d
Show file tree
Hide file tree
Showing 22 changed files with 706 additions and 669 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## unreleased

- Add module declarations to Wasp Lisp files and a `shen-libs.ms` that
can be imported to load all the compiled Shen code from Lisp.

## 0.10 - 2018-10-07

- Update to Shen OS Kernel 21.1.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,10 @@ Note that it takes a while to startup as it runs through the Shen and KLambda in

## Running from the Wasp REPL

Shen can be run and debugged from the Wasp REPL. To load the compiled code and run Shen:
Shen can be run and debugged from the Wasp REPL. To import the compiled code and run Shen:

$ rlwrap wasp
>> (import "driver")
>> (load-all)
>> (import "shen-lib")
>> (kl:shen.shen)
Shen, copyright (C) 2010-2015 Mark Tarver
www.shenlanguage.org, Shen 20.1
Expand All @@ -137,8 +136,9 @@ Shen can be run and debugged from the Wasp REPL. To load the compiled code and r

(0-)

When developing on the compiler it's useful to use `eval-all` instead of `load-all`. This will load the KLambda files, compile them to Scheme and `eval` them:
When developing on the compiler it's useful to use `eval-all`. This will load the KLambda files, compile them to Scheme and `eval` them:

>> (import "driver")
>> (eval-all)
>> (kl:shen.shen)
...
Expand Down
127 changes: 64 additions & 63 deletions compiled/core.kl.ms

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions compiled/declarations.kl.ms

Large diffs are not rendered by default.

33 changes: 17 additions & 16 deletions compiled/dict.kl.ms
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
(module "compiled/dict.kl")
"Copyright (c) 2015, Mark Tarver\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n3. The name of Mark Tarver may not be used to endorse or promote products\n derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY Mark Tarver ''AS IS'' AND ANY\nEXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL Mark Tarver BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
(begin (register-function-arity (quote shen.dict) 1) (define (kl:shen.dict V3139) (cond ((< V3139 1) (simple-error (string-append "invalid initial dict size: " (kl:shen.app V3139 "" (quote shen.s))))) (#t (let ((D (make-vector (+ 3 V3139) (quote (quote shen.fail!))))) (let ((Tag (let ((_tmp D)) (vector-set! _tmp 0 (quote shen.dictionary)) _tmp))) (let ((Capacity (let ((_tmp D)) (vector-set! _tmp 1 V3139) _tmp))) (let ((Count (let ((_tmp D)) (vector-set! _tmp 2 0) _tmp))) (let ((Fill (kl:shen.fillvector D 3 (+ 2 V3139) (quote ())))) D)))))))) (quote shen.dict))
(begin (register-function-arity (quote shen.dict?) 1) (define (kl:shen.dict? V3141) (and (vector? V3141) (eq? (guard (lambda (E) (quote shen.not-dictionary)) (vector-ref V3141 0)) (quote shen.dictionary)))) (quote shen.dict?))
(begin (register-function-arity (quote shen.dict-capacity) 1) (define (kl:shen.dict-capacity V3143) (vector-ref V3143 1)) (quote shen.dict-capacity))
(begin (register-function-arity (quote shen.dict-count) 1) (define (kl:shen.dict-count V3145) (vector-ref V3145 2)) (quote shen.dict-count))
(begin (register-function-arity (quote shen.dict-count->) 2) (define (kl:shen.dict-count-> V3148 V3149) (let ((_tmp V3148)) (vector-set! _tmp 2 V3149) _tmp)) (quote shen.dict-count->))
(begin (register-function-arity (quote shen.<-dict-bucket) 2) (define (kl:shen.<-dict-bucket V3152 V3153) (vector-ref V3152 (+ 3 V3153))) (quote shen.<-dict-bucket))
(begin (register-function-arity (quote shen.dict-bucket->) 3) (define (kl:shen.dict-bucket-> V3157 V3158 V3159) (let ((_tmp V3157)) (vector-set! _tmp (+ 3 V3158) V3159) _tmp)) (quote shen.dict-bucket->))
(begin (register-function-arity (quote shen.dict-update-count) 3) (define (kl:shen.dict-update-count V3163 V3164 V3165) (let ((Diff (- (kl:length V3165) (kl:length V3164)))) (kl:shen.dict-count-> V3163 (+ Diff (kl:shen.dict-count V3163))))) (quote shen.dict-update-count))
(begin (register-function-arity (quote shen.dict->) 3) (define (kl:shen.dict-> V3169 V3170 V3171) (let ((N (kl:hash V3170 (kl:shen.dict-capacity V3169)))) (let ((Bucket (kl:shen.<-dict-bucket V3169 N))) (let ((NewBucket (kl:shen.assoc-set V3170 V3171 Bucket))) (let ((Change (kl:shen.dict-bucket-> V3169 N NewBucket))) (let ((Count (kl:shen.dict-update-count V3169 Bucket NewBucket))) V3171)))))) (quote shen.dict->))
(begin (register-function-arity (quote shen.<-dict) 2) (define (kl:shen.<-dict V3174 V3175) (let ((N (kl:hash V3175 (kl:shen.dict-capacity V3174)))) (let ((Bucket (kl:shen.<-dict-bucket V3174 N))) (let ((Result (kl:assoc V3175 Bucket))) (if (kl:empty? Result) (simple-error (string-append "value " (kl:shen.app V3175 " not found in dict\n" (quote shen.a)))) (cdr Result)))))) (quote shen.<-dict))
(begin (register-function-arity (quote shen.dict-rm) 2) (define (kl:shen.dict-rm V3178 V3179) (let ((N (kl:hash V3179 (kl:shen.dict-capacity V3178)))) (let ((Bucket (kl:shen.<-dict-bucket V3178 N))) (let ((NewBucket (kl:shen.assoc-rm V3179 Bucket))) (let ((Change (kl:shen.dict-bucket-> V3178 N NewBucket))) (let ((Count (kl:shen.dict-update-count V3178 Bucket NewBucket))) V3179)))))) (quote shen.dict-rm))
(begin (register-function-arity (quote shen.dict-fold) 3) (define (kl:shen.dict-fold V3183 V3184 V3185) (let ((Limit (kl:shen.dict-capacity V3184))) (kl:shen.dict-fold-h V3183 V3184 V3185 0 Limit))) (quote shen.dict-fold))
(begin (register-function-arity (quote shen.dict-fold-h) 5) (define (kl:shen.dict-fold-h V3192 V3193 V3194 V3195 V3196) (cond ((kl:= V3196 V3195) V3194) (#t (let ((B (kl:shen.<-dict-bucket V3193 V3195))) (let ((Acc (kl:shen.bucket-fold V3192 B V3194))) (kl:shen.dict-fold-h V3192 V3193 Acc (+ 1 V3195) V3196)))))) (quote shen.dict-fold-h))
(begin (register-function-arity (quote shen.bucket-fold) 3) (define (kl:shen.bucket-fold V3200 V3201 V3202) (cond ((null? V3201) V3202) ((and (pair? V3201) (pair? (car V3201))) (((V3200 (car (car V3201))) (cdr (car V3201))) (kl:shen.bucket-fold V3200 (cdr V3201) V3202))) (#t (kl:shen.f_error (quote shen.bucket-fold))))) (quote shen.bucket-fold))
(begin (register-function-arity (quote shen.dict-keys) 1) (define (kl:shen.dict-keys V3204) (kl:shen.dict-fold (lambda (K) (lambda (_) (lambda (Acc) (cons K Acc)))) V3204 (quote ()))) (quote shen.dict-keys))
(begin (register-function-arity (quote shen.dict-values) 1) (define (kl:shen.dict-values V3206) (kl:shen.dict-fold (lambda (_) (lambda (V) (lambda (Acc) (cons V Acc)))) V3206 (quote ()))) (quote shen.dict-values))
(begin (register-function-arity (quote shen.dict) 1) (define (kl:shen.dict V3139) (cond ((< V3139 1) (simple-error (string-append "invalid initial dict size: " (kl:shen.app V3139 "" (quote shen.s))))) (#t (let ((D (make-vector (+ 3 V3139) (quote (quote shen.fail!))))) (let ((Tag (let ((_tmp D)) (vector-set! _tmp 0 (quote shen.dictionary)) _tmp))) (let ((Capacity (let ((_tmp D)) (vector-set! _tmp 1 V3139) _tmp))) (let ((Count (let ((_tmp D)) (vector-set! _tmp 2 0) _tmp))) (let ((Fill (kl:shen.fillvector D 3 (+ 2 V3139) (quote ())))) D)))))))) (export shen.dict) (quote shen.dict))
(begin (register-function-arity (quote shen.dict?) 1) (define (kl:shen.dict? V3141) (and (vector? V3141) (eq? (guard (lambda (E) (quote shen.not-dictionary)) (vector-ref V3141 0)) (quote shen.dictionary)))) (export shen.dict?) (quote shen.dict?))
(begin (register-function-arity (quote shen.dict-capacity) 1) (define (kl:shen.dict-capacity V3143) (vector-ref V3143 1)) (export shen.dict-capacity) (quote shen.dict-capacity))
(begin (register-function-arity (quote shen.dict-count) 1) (define (kl:shen.dict-count V3145) (vector-ref V3145 2)) (export shen.dict-count) (quote shen.dict-count))
(begin (register-function-arity (quote shen.dict-count->) 2) (define (kl:shen.dict-count-> V3148 V3149) (let ((_tmp V3148)) (vector-set! _tmp 2 V3149) _tmp)) (export shen.dict-count->) (quote shen.dict-count->))
(begin (register-function-arity (quote shen.<-dict-bucket) 2) (define (kl:shen.<-dict-bucket V3152 V3153) (vector-ref V3152 (+ 3 V3153))) (export shen.<-dict-bucket) (quote shen.<-dict-bucket))
(begin (register-function-arity (quote shen.dict-bucket->) 3) (define (kl:shen.dict-bucket-> V3157 V3158 V3159) (let ((_tmp V3157)) (vector-set! _tmp (+ 3 V3158) V3159) _tmp)) (export shen.dict-bucket->) (quote shen.dict-bucket->))
(begin (register-function-arity (quote shen.dict-update-count) 3) (define (kl:shen.dict-update-count V3163 V3164 V3165) (let ((Diff (- (kl:length V3165) (kl:length V3164)))) (kl:shen.dict-count-> V3163 (+ Diff (kl:shen.dict-count V3163))))) (export shen.dict-update-count) (quote shen.dict-update-count))
(begin (register-function-arity (quote shen.dict->) 3) (define (kl:shen.dict-> V3169 V3170 V3171) (let ((N (kl:hash V3170 (kl:shen.dict-capacity V3169)))) (let ((Bucket (kl:shen.<-dict-bucket V3169 N))) (let ((NewBucket (kl:shen.assoc-set V3170 V3171 Bucket))) (let ((Change (kl:shen.dict-bucket-> V3169 N NewBucket))) (let ((Count (kl:shen.dict-update-count V3169 Bucket NewBucket))) V3171)))))) (export shen.dict->) (quote shen.dict->))
(begin (register-function-arity (quote shen.<-dict) 2) (define (kl:shen.<-dict V3174 V3175) (let ((N (kl:hash V3175 (kl:shen.dict-capacity V3174)))) (let ((Bucket (kl:shen.<-dict-bucket V3174 N))) (let ((Result (kl:assoc V3175 Bucket))) (if (kl:empty? Result) (simple-error (string-append "value " (kl:shen.app V3175 " not found in dict\n" (quote shen.a)))) (cdr Result)))))) (export shen.<-dict) (quote shen.<-dict))
(begin (register-function-arity (quote shen.dict-rm) 2) (define (kl:shen.dict-rm V3178 V3179) (let ((N (kl:hash V3179 (kl:shen.dict-capacity V3178)))) (let ((Bucket (kl:shen.<-dict-bucket V3178 N))) (let ((NewBucket (kl:shen.assoc-rm V3179 Bucket))) (let ((Change (kl:shen.dict-bucket-> V3178 N NewBucket))) (let ((Count (kl:shen.dict-update-count V3178 Bucket NewBucket))) V3179)))))) (export shen.dict-rm) (quote shen.dict-rm))
(begin (register-function-arity (quote shen.dict-fold) 3) (define (kl:shen.dict-fold V3183 V3184 V3185) (let ((Limit (kl:shen.dict-capacity V3184))) (kl:shen.dict-fold-h V3183 V3184 V3185 0 Limit))) (export shen.dict-fold) (quote shen.dict-fold))
(begin (register-function-arity (quote shen.dict-fold-h) 5) (define (kl:shen.dict-fold-h V3192 V3193 V3194 V3195 V3196) (cond ((kl:= V3196 V3195) V3194) (#t (let ((B (kl:shen.<-dict-bucket V3193 V3195))) (let ((Acc (kl:shen.bucket-fold V3192 B V3194))) (kl:shen.dict-fold-h V3192 V3193 Acc (+ 1 V3195) V3196)))))) (export shen.dict-fold-h) (quote shen.dict-fold-h))
(begin (register-function-arity (quote shen.bucket-fold) 3) (define (kl:shen.bucket-fold V3200 V3201 V3202) (cond ((null? V3201) V3202) ((and (pair? V3201) (pair? (car V3201))) (((V3200 (car (car V3201))) (cdr (car V3201))) (kl:shen.bucket-fold V3200 (cdr V3201) V3202))) (#t (kl:shen.f_error (quote shen.bucket-fold))))) (export shen.bucket-fold) (quote shen.bucket-fold))
(begin (register-function-arity (quote shen.dict-keys) 1) (define (kl:shen.dict-keys V3204) (kl:shen.dict-fold (lambda (K) (lambda (_) (lambda (Acc) (cons K Acc)))) V3204 (quote ()))) (export shen.dict-keys) (quote shen.dict-keys))
(begin (register-function-arity (quote shen.dict-values) 1) (define (kl:shen.dict-values V3206) (kl:shen.dict-fold (lambda (_) (lambda (V) (lambda (Acc) (cons V Acc)))) V3206 (quote ()))) (export shen.dict-values) (quote shen.dict-values))
Loading

0 comments on commit 28fad8d

Please sign in to comment.