From be453f2ed5132c1907228d3f640dc82e8fd4b3a3 Mon Sep 17 00:00:00 2001 From: JeffBezanson Date: Sat, 29 Aug 2009 00:54:51 +0000 Subject: [PATCH] improving portability to Mac OS fixes for big endian architectures (PowerPC) renaming exported symbol raise to fl_raise fixing some bugs and oversights discovered in the process --- femtolisp/Makefile | 2 +- femtolisp/Makefile.macosx | 2 +- femtolisp/builtins.c | 13 +++-- femtolisp/compiler.lsp | 8 +-- femtolisp/cvalues.c | 6 +-- femtolisp/flisp.boot | 98 +++++++++++++++++------------------ femtolisp/flisp.c | 104 ++++++++++++++++++++++++++++++-------- femtolisp/flisp.h | 2 +- femtolisp/read.c | 7 +-- femtolisp/system.lsp | 23 ++++----- llt/Makefile | 2 +- llt/dirpath.c | 3 +- llt/dtypes.h | 2 +- llt/ios.c | 3 +- llt/memalign.c | 2 +- llt/random.c | 2 +- llt/socket.c | 7 +++ llt/timefuncs.c | 3 +- llt/utf8.c | 3 ++ 19 files changed, 183 insertions(+), 109 deletions(-) diff --git a/femtolisp/Makefile b/femtolisp/Makefile index 8fea5b9..5182893 100644 --- a/femtolisp/Makefile +++ b/femtolisp/Makefile @@ -8,7 +8,7 @@ EXENAME = $(NAME) LLTDIR = ../llt LLT = $(LLTDIR)/libllt.a -FLAGS = -falign-functions -Wall -Wextra -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO +FLAGS = -falign-functions -Wall -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO LIBFILES = $(LLT) LIBS = $(LIBFILES) -lm diff --git a/femtolisp/Makefile.macosx b/femtolisp/Makefile.macosx index 5c5b3bf..b02ed91 100644 --- a/femtolisp/Makefile.macosx +++ b/femtolisp/Makefile.macosx @@ -8,7 +8,7 @@ EXENAME = $(NAME) LLTDIR = ../llt LLT = $(LLTDIR)/libllt.a -FLAGS = -falign-functions -Wall -Wextra -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO +FLAGS = -falign-functions -Wall -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO LIBFILES = $(LLT) LIBS = $(LIBFILES) -lm -framework ApplicationServices diff --git a/femtolisp/builtins.c b/femtolisp/builtins.c index 1140fc1..d45f899 100644 --- a/femtolisp/builtins.c +++ b/femtolisp/builtins.c @@ -110,10 +110,10 @@ static value_t fl_length(value_t *args, u_int32_t nargs) type_error("length", "sequence", a); } -static value_t fl_raise(value_t *args, u_int32_t nargs) +static value_t fl_f_raise(value_t *args, u_int32_t nargs) { argcount("raise", nargs, 1); - raise(args[0]); + fl_raise(args[0]); } static value_t fl_exit(value_t *args, u_int32_t nargs) @@ -144,7 +144,7 @@ static value_t fl_top_level_value(value_t *args, u_int32_t nargs) argcount("top-level-value", nargs, 1); symbol_t *sym = tosymbol(args[0], "top-level-value"); if (sym->binding == UNBOUND) - raise(list2(UnboundError, args[0])); + fl_raise(list2(UnboundError, args[0])); return sym->binding; } @@ -381,7 +381,12 @@ static value_t fl_os_setenv(value_t *args, uint32_t nargs) char *name = tostring(args[0], "os.setenv"); int result; if (args[1] == FL_F) { +#ifdef LINUX result = unsetenv(name); +#else + (void)unsetenv(name); + result = 0; +#endif } else { char *val = tostring(args[1], "os.setenv"); @@ -439,7 +444,7 @@ static builtinspec_t builtin_info[] = { { "constant?", fl_constantp }, { "top-level-value", fl_top_level_value }, { "set-top-level-value!", fl_set_top_level_value }, - { "raise", fl_raise }, + { "raise", fl_f_raise }, { "exit", fl_exit }, { "symbol", fl_symbol }, { "keyword?", fl_keywordp }, diff --git a/femtolisp/compiler.lsp b/femtolisp/compiler.lsp index 7eecdc1..e5d3755 100644 --- a/femtolisp/compiler.lsp +++ b/femtolisp/compiler.lsp @@ -168,9 +168,6 @@ (set! i (+ i 1))) ((eq? vi 'brbound) (io.write bcode (int32 nxt)) - (set! i (+ i 1)) - (put! fixup-to-label (sizeof bcode) (aref v i)) - (io.write bcode (int32 0)) (set! i (+ i 1))) ((number? nxt) (case vi @@ -549,7 +546,8 @@ ; i is the lexical var index of the opt arg to process next (if (pair? opta) (let ((nxt (make-label g))) - (emit g 'brbound i nxt) + (emit g 'brbound i) + (emit g 'brt nxt) (compile-in g (cons (list-head vars i) env) #f (cadar opta)) (emit g 'seta i) (emit g 'pop) @@ -701,8 +699,6 @@ ((brbound) (princ (number->string (ref-int32-LE code i)) " ") - (set! i (+ i 4)) - (princ "@" (hex5 (+ i -4 (ref-int32-LE code i)))) (set! i (+ i 4))) ((jmp brf brt brne brnn brn) diff --git a/femtolisp/cvalues.c b/femtolisp/cvalues.c index 91b71b8..dcec13d 100644 --- a/femtolisp/cvalues.c +++ b/femtolisp/cvalues.c @@ -495,7 +495,7 @@ static size_t cvalue_struct_offs(value_t type, value_t field, int computeTotal, while (iscons(fld)) { fsz = ctype_sizeof(car(cdr(car_(fld))), &al); - ssz = ALIGN(ssz, al); + ssz = LLT_ALIGN(ssz, al); if (al > *palign) *palign = al; @@ -507,7 +507,7 @@ static size_t cvalue_struct_offs(value_t type, value_t field, int computeTotal, ssz += fsz; fld = cdr_(fld); } - return ALIGN(ssz, *palign); + return LLT_ALIGN(ssz, *palign); } static size_t cvalue_union_size(value_t type, int *palign) @@ -523,7 +523,7 @@ static size_t cvalue_union_size(value_t type, int *palign) if (fsz > usz) usz = fsz; fld = cdr_(fld); } - return ALIGN(usz, *palign); + return LLT_ALIGN(usz, *palign); } // *palign is an output argument giving the alignment required by type diff --git a/femtolisp/flisp.boot b/femtolisp/flisp.boot index 42504f8..f0fcb7c 100644 --- a/femtolisp/flisp.boot +++ b/femtolisp/flisp.boot @@ -15,13 +15,13 @@ lambda prog1 trycatch begin raise]) gensym]) define-macro #fn("?000s1c0c1|ML2e2c3L1|NL1e4}3133L3;" [set-syntax! quote nconc lambda copy-list]) receive #fn("@000s2c0c1_}L3e2c1L1|L1e3g23133L3;" [call-with-values lambda nconc copy-list]) unless #fn("=000s1c0|^c1}KL4;" [if begin]) let #fn(":000s1c0q^41;" [#fn("<000r1~C6D0~m02\x7fMo002\x7fNo01530^2c0qe1c2L1e3c4~32L1e5\x7f3133e3c6~3242;" [#fn("8000r2~6;0c0~|L3530|}K;" [label]) - nconc lambda map #fn("6000r1|F650|M;|;" []) copy-list #fn("6000r1|F650|\x84;^;" [])])]) cond #fn("9000s0c0q^41;" [#fn("7000r1c0qm02|~41;" [#fn("7000r1|?640^;c0q|M41;" [#fn("<000r1|Mc0<17702|M]<6@0|N\x8550|M;c1|NK;|N\x85@0c2|Mi10~N31L3;|\x84c3\x82W0e4e5|31316A0c6qe7e5|313141;c8qe93041;c:|Mc1|NKi10~N31L4;" [else + nconc lambda map #fn("6000r1|F650|M;|;" []) copy-list #fn("6000r1|F650|\x84;^;" [])])]) cond #fn("9000s0c0q^41;" [#fn("7000r1c0qm02|~41;" [#fn("7000r1|?640^;c0q|M41;" [#fn(":000r1|Mc0<17702|M]<6@0|N\x8550|M;c1|NK;|N\x85@0c2|Mi10~N31L3;|\x84c3\x82W0e4e5|31316A0c6qe7e5|313141;c8qe93041;c:|Mc1|NKi10~N31L4;" [else begin or => 1arg-lambda? caddr #fn("=000r1c0|~ML2L1c1|c2e3e4~3131Ki20i10N31L4L3;" [let if begin cddr caddr]) caadr #fn("<000r1c0|~ML2L1c1|e2~31|L2i20i10N31L4L3;" [let if caddr]) gensym if])] cond-clauses->if)])]) throw #fn(":000r2c0c1c2c3L2|}L4L2;" [raise list quote thrown-value]) time #fn("7000r1c0qe13041;" [#fn(">000r1c0|c1L1L2L1c2~c3c4c5c1L1|L3c6L4L3L3;" [let time.now prog1 princ "Elapsed time: " - " seconds\n"]) gensym]) let* #fn("A000s1|?6E0e0c1L1_L1e2}3133L1;e0c1L1e3|31L1L1e2|NF6H0e0c4L1|NL1e2}3133L1530}3133e5|31L2;" [nconc - lambda copy-list caar let* cadar]) case #fn(":000s1c0q^41;" [#fn("7000r1c0m02c1qe23041;" [#fn(";000r2}c0\x8250c0;}\x8540^;}C6=0c1|e2}31L3;}?6=0c3|e2}31L3;}N\x85>0c3|e2}M31L3;e4c5}326=0c6|c7}L2L3;c8|c7}L2L3;" [else + lambda copy-list caar let* cadar]) case #fn(":000s1c0q^41;" [#fn("7000r1c0m02c1qe23041;" [#fn("9000r2}c0\x8250c0;}\x8540^;}C6=0c1|e2}31L3;}?6=0c3|e2}31L3;}N\x85>0c3|e2}M31L3;e4c5}326=0c6|c7}L2L3;c8|c7}L2L3;" [else eq? quote-value eqv? every #.symbol? memq quote memv] vals->cond) #fn(";000r1c0|i10L2L1c1e2c3qi1132KL3;" [let cond map #fn("8000r1i10~|M32|NK;" [])]) gensym])]) with-output-to #fn("=000s1e0c1L1c2|L2L1L1e3}3143;" [nconc @@ -29,14 +29,14 @@ *output-stream* copy-list]) catch #fn("7000r2c0qe13041;" [#fn("@000r1c0\x7fc1|L1c2c3c4|L2c5c6|L2c7c8L2L3c5c9|L2~L3L4c:|L2c;|L2L4L3L3;" [trycatch lambda if and pair? eq car quote thrown-value cadr caddr raise]) gensym])) - *whitespace* "\t\n\v\f\r \u0085  ᠎           \u2028\u2029   " 1+ - #fn("7000r1|aw;" [] 1+) 1- #fn("7000r1|ax;" [] 1-) 1arg-lambda? - #fn("8000r1|F16T02|Mc0<16J02|NF16B02|\x84F16:02e1|\x84a42;" [lambda + *whitespace* "\t\n\v\f\r \u0085\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000" + 1+ #fn("7000r1|aw;" [] 1+) 1- + #fn("7000r1|ax;" [] 1-) 1arg-lambda? #fn("8000r1|F16T02|Mc0<16J02|NF16B02|\x84F16:02e1|\x84a42;" [lambda length=] 1arg-lambda?) <= #fn("7000r2|}X17602|}W;" [] <=) > #fn("7000r2}|X;" [] >) >= #fn("7000r2}|X17602|}W;" [] >=) Instructions #table(not 16 vargc 67 load1 49 = 39 setc.l 64 sub2 72 brne.l 83 largc 74 brnn 85 loadc.l 58 loadi8 50 < 40 nop 0 set-cdr! 32 loada 55 bound? 21 / 37 neg 73 brn.l 88 lvargc 75 brt 7 trycatch 68 null? 17 load0 48 jmp.l 8 loadv 51 seta 61 keyargs 91 * 36 function? 26 builtin? 23 aref 43 optargs 89 vector? 24 loadt 45 brf 6 symbol? 19 cdr 30 for 69 loadc00 78 pop 2 pair? 22 cadr 84 closure 65 loadf 46 compare 41 loadv.l 52 setg.l 60 brn 87 eqv? 13 aset! 44 eq? 12 atom? 15 boolean? 18 brt.l 10 tapply 70 dummy_nil 94 loada0 76 brbound 90 list 28 dup 1 apply 33 loadc 57 loadc01 79 dummy_t 92 setg 59 loada1 77 tcall.l 81 jmp 5 fixnum? 25 cons 27 loadg.l 54 tcall 4 call 3 - 35 brf.l 9 + 34 dummy_f 93 add2 71 seta.l 62 loadnil 47 brnn.l 86 setc 63 set-car! 31 vector 42 loadg 53 loada.l 56 argc 66 div0 38 ret 11 number? 20 equal? 14 car 29 call.l 80 brne 82) - __init_globals #fn("7000r0c0c1<17B02c0c2<17802c0c3<6>0c4k52c6k75;0c8k52c9k72e:k;2ek?;" [linux + __init_globals #fn("7000r0c0c1<17B02c0c2<17802c0c3<6>0c4k52c6k75;0c8k52c9k72e:k;2ek?;" [macos win32 win64 windows "\\" *directory-separator* "\r\n" *linefeed* "/" "\n" *stdout* *output-stream* *stdin* *input-stream* *stderr* *error-stream*] __init_globals) __script #fn("7000r1c0qc1t;" [#fn("7000r0e0~41;" [load]) @@ -60,12 +60,12 @@ bcode:nconst #fn("7000r1|b2[;" [] bcode:nconst) bq-bracket #fn("8000r1|?6<0c0e1|31L2;|Mc2\x8290c0|\x84L2;|Mc3\x8290c4|\x84L2;|Mc5\x8250|\x84;c0e1|31L2;" [#.list bq-process unquote unquote-splicing copy-list unquote-nsplicing] bq-bracket) - bq-process #fn("8000r1c0q^^42;" [#fn("<000r2c0m02c1m12e2~316G0~H6@0c3e4e5~313141;~;~?680c6~L2;~Mc7\x82=0e4e4~\x843141;~Mc8\x8250~\x84;e9|~327B0c:e;~31e<}~3242;c=~_42;" [#fn("7000r1|F16B02|Mc0<17802|Mc1<17702|c2<;" [unquote-splicing + bq-process #fn("8000r1c0q^^42;" [#fn(":000r2c0m02c1m12e2~316G0~H6@0c3e4e5~313141;~;~?680c6~L2;~Mc7\x82=0e4e4~\x843141;~Mc8\x8250~\x84;e9|~327B0c:e;~31e<}~3242;c=~_42;" [#fn("7000r1|F16B02|Mc0<17802|Mc1<17702|c2<;" [unquote-splicing unquote-nsplicing unquote] splice-form?) #fn("7000r1|F16802|Mc0<650|\x84;e1|41;" [unquote bq-process] bq-bracket1) self-evaluating? #fn("8000r1|Mc0\x8280c1|NK;c2c1|L3;" [list #.vector #.apply]) - bq-process vector->list quote quasiquote unquote any #fn("8000r2|\x8570c0}K;}N\x85>0c1}Me2|31L3;e3c4}Ke2|31L142;" [list - #.cons bq-process nconc list*]) lastcdr map #fn(":000r2^|F16902|Mc0<@6E02e1|M31}Km12|Nm05\x0f/2c2|F6>0e3}|\x84L1325J0|\x85:0e4}315>0e3}e5|31L13241;" [unquote + bq-process vector->list quote quasiquote unquote any #fn("9000r2|\x8570c0}K;}N\x85>0c1}Me2|31L3;e3c4}Ke2|31L142;" [list + #.cons bq-process nconc list*]) lastcdr map #fn("<000r2^|F16902|Mc0<@6E02e1|M31}Km12|Nm05\x0f/2c2|F6>0e3}|\x84L1325J0|\x85:0e4}315>0e3}e5|31L13241;" [unquote bq-bracket #fn("8000r1|N\x8550|M;e0|b23216H02e0|Mb23216;02c1e2|31<6>0c3e4|31|\x84L3;c5|K;" [length= #.list caar #.cons cadar nconc]) nreconc reverse! bq-process])])] bq-process) builtin->instruction #fn("9000r1e0~|^43;" [get] [#table(#.number? number? #.cons cons #.fixnum? fixnum? #.equal? equal? #.eq? eq? #.symbol? symbol? #.div0 div0 #.builtin? builtin? #.aset! aset! #.- - #.boolean? boolean? #.not not #.apply apply #.atom? atom? #.set-cdr! set-cdr! #./ / #.function? function? #.vector vector #.list list #.bound? bound? #.< < #.* * #.cdr cdr #.null? null? #.+ + #.eqv? eqv? #.compare compare #.aref aref #.set-car! set-car! #.car car #.pair? pair? #.= = #.vector? vector?) @@ -105,27 +105,27 @@ compile-begin #fn(":000r4g3?6<0e0|}g2^44;g3N?6>0e0|}g2g3M44;e0|}^g3M342e1|c2322e3|}g2g3N44;" [compile-in emit pop compile-begin] compile-begin) compile-builtin-call #fn(":000r7c0qe1e2g5^3341;" [#fn("8000r1|16=02e0i03N|32@6=0e1i04|32530^2c2qi0541;" [length= - argc-error #fn("O000r1|c0\x82R0i16`W6<0e1i10c242;e1i10i15i1643;|c3\x82e0i16`W6<0e1i10c442;i16b2W6<0e1i10c542;e1i10i15i1643;|c6\x82v0i16`W6;0e7i14a42;i16aW6<0e1i10c842;i16b2W6<0e1i10c942;e1i10i15i1643;|c:\x82R0i16`W6<0e1i10c;42;e1i10i15i1643;|c<\x82Q0i16`W6;0e7i14a42;e1i10i15i1643;|c=\x82T0i16`W6>0e1i10c>c?43;e1i10i15i1643;|c@\x82]0i16b2X6<0e7i14b242;e1i10i12670cA540c@i1643;e1i10i1542;" [list + argc-error #fn(":000r1|c0\x82R0i16`W6<0e1i10c242;e1i10i15i1643;|c3\x82e0i16`W6<0e1i10c442;i16b2W6<0e1i10c542;e1i10i15i1643;|c6\x82v0i16`W6;0e7i14a42;i16aW6<0e1i10c842;i16b2W6<0e1i10c942;e1i10i15i1643;|c:\x82R0i16`W6<0e1i10c;42;e1i10i15i1643;|c<\x82Q0i16`W6;0e7i14a42;e1i10i15i1643;|c=\x82T0i16`W6>0e1i10c>c?43;e1i10i15i1643;|c@\x82]0i16b2X6<0e7i14b242;e1i10i12670cA540c@i1643;e1i10i1542;" [list emit loadnil + load0 add2 - argc-error neg sub2 * load1 / vector loadv [] apply tapply])]) get arg-counts] compile-builtin-call) compile-f #fn("8000r2e0c1qc242;" [call-with-values #fn("8000r0e0~\x7f42;" [compile-f-]) #fn("6000r2|;" [])] compile-f) - compile-f- #fn("7000r2c0q^41;" [#fn("=000r1c0qm02c1qe230\x7f\x84e3\x7f\x8431e4\x7f\x8431e5c6\x7f\x8432e3\x7f31i10\x8270c7570e3\x7f3146;" [#fn("9000r1c0qe1|31F6N0e2|31F6=0c3e1|31K570e4|31530^41;" [#fn("8000r1c0qe1|3141;" [#fn(";000r1|\x8540~;e0c1|~i4034e2c3|32K;" [list* + compile-f- #fn("7000r2c0q^41;" [#fn(">000r1c0qm02c1qe230\x7f\x84e3\x7f\x8431e4\x7f\x8431e5c6\x7f\x8432e3\x7f31i10\x8270c7570e3\x7f3146;" [#fn("9000r1c0qe1|31F6N0e2|31F6=0c3e1|31K570e4|31530^41;" [#fn("8000r1c0qe1|3141;" [#fn(":000r1|\x8540~;e0c1|~i4034e2c3|32K;" [list* lambda map #fn("6000r1^;" [])]) get-defined-vars]) cddr cdddr begin caddr] lambda-body) - #fn("9000r6c0q}?660`570e1}3141;" [#fn("9000r1c0q|e1i0431x41;" [#fn("9000r1c0qe1e2i143241;" [#fn("F000r1i24\x87\xa90|\x85O0e0i20c1~i22\x8580i10560i10y345s0e2i20e3e4c5e4c6|32e7e8|31313331322e0i20c9~e8|31i22\x8580i10560i10y352e:i20i40i24i23~35530^2e;i10c<326L0e0i20i22\x8570c=540c>i10335]0i22\x87A0e0i20c?i10335H0i24\x85A0e0i20c@i1033530^2eAi20i23i40K]eBi4131i50\x82<0eCi41315:0i30i4131342e0i20cD322eEeFeGeHi203131eIi2031i2533i20b3[42;" [emit + #fn("9000r6c0q}?660`570e1}3141;" [#fn("9000r1c0q|e1i0431x41;" [#fn("9000r1c0qe1e2i143241;" [#fn("D000r1i24\x87\xa90|\x85O0e0i20c1~i22\x8580i10560i10y345s0e2i20e3e4c5e4c6|32e7e8|31313331322e0i20c9~e8|31i22\x8580i10560i10y352e:i20i40i24i23~35530^2e;i10c<326L0e0i20i22\x8570c=540c>i10335]0i22\x87A0e0i20c?i10335H0i24\x85A0e0i20c@i1033530^2eAi20i23i40K]eBi4131i50\x82<0eCi41315:0i30i4131342e0i20cD322eEeFeGeHi203131eIi2031i2533i20b3[42;" [emit optargs bcode:indexfor make-perfect-hash-table map #.cons #.car iota length keyargs emit-optional-arg-inits > 255 largc lvargc vargc argc compile-in lastcdr caddr ret values function encode-byte-code bcode:code const-to-idx-vec]) filter keyword-arg?]) length]) length]) make-code-emitter - lastcdr lambda-vars filter #.pair? lambda])] #0=[#:g705 ()]) + lastcdr lambda-vars filter #.pair? lambda])] #0=[#:g704 ()]) compile-for #fn(":000r5e0g4316X0e1|}^g2342e1|}^g3342e1|}^g4342e2|c342;e4c541;" [1arg-lambda? compile-in emit for error "for: third form must be a 1-argument lambda"] compile-for) - compile-if #fn("<000r4c0qe1|31e1|31g3\x84e2g331e3g331F6;0e4g331530^45;" [#fn("=000r5g2]\x82>0e0~\x7fi02g344;g2^\x82>0e0~\x7fi02g444;e0~\x7f^g2342e1~c2|332e0~\x7fi02g3342i026<0e1~c3325:0e1~c4}332e5~|322e0~\x7fi02g4342e5~}42;" [compile-in + compile-if #fn("<000r4c0qe1|31e1|31g3\x84e2g331e3g331F6;0e4g331530^45;" [#fn(";000r5g2]\x82>0e0~\x7fi02g344;g2^\x82>0e0~\x7fi02g444;e0~\x7f^g2342e1~c2|332e0~\x7fi02g3342i026<0e1~c3325:0e1~c4}332e5~|322e0~\x7fi02g4342e5~}42;" [compile-in emit brf ret jmp mark-label]) make-label caddr cdddr cadddr] compile-if) - compile-in #fn(":000r4g3C6=0e0|}g3c144;g3?6\xaf0g3`\x82:0e2|c342;g3a\x82:0e2|c442;g3]\x82:0e2|c542;g3^\x82:0e2|c642;g3_\x82:0e2|c742;e8g3316<0e2|c9g343;e:g3316C0e;|}g2eg343;g3MC@17D02g3ME17;02e?g3M}326=0e@|}g2g344;cAqg3M41;" [compile-sym + compile-in #fn(";000r4g3C6=0e0|}g3c144;g3?6\xaf0g3`\x82:0e2|c342;g3a\x82:0e2|c442;g3]\x82:0e2|c542;g3^\x82:0e2|c642;g3_\x82:0e2|c742;e8g3316<0e2|c9g343;e:g3316C0e;|}g2eg343;g3MC@17D02g3ME17;02e?g3M}326=0e@|}g2g344;cAqg3M41;" [compile-sym [loada loadc loadg] emit load0 load1 loadt loadf loadnil fits-i8 loadi8 eof-object? compile-in top-level-value eof-object loadv in-env? compile-app - #fn("T000r1|c0\x82W0e1i03\x84316@0e2~\x7fi02i03\x8444;e3~c4i03\x8443;|c5\x82?0e6~\x7fi02i0344;|c7\x82@0e8~\x7fi02i03N44;|c9\x82<0e:~\x7fi0343;|c;\x82=0eq42;|c?\x82@0e@~\x7fi02i03N44;|cA\x82@0eB~\x7fi02i03N44;|cC\x82G0eD~\x7fi03\x84c7eEi0331K44;|cF\x82K0eG~\x7fi03\x84eHi0331eIi033145;|cJ\x82F0e2~\x7f]i03\x84342e3~cK42;|cL\x82N0e2~\x7f^eHi0331342eM~\x7fi03\x84cN44;|cO\x82C0e2~\x7fi02ePi033144;|cQ\x82s0e2~\x7f^c;_i03\x84L3342eReHi033131660^580eScT312e2~\x7f^eHi0331342e3~cQ42;eU~\x7fi02i0344;" [quote + #fn("<000r1|c0\x82W0e1i03\x84316@0e2~\x7fi02i03\x8444;e3~c4i03\x8443;|c5\x82?0e6~\x7fi02i0344;|c7\x82@0e8~\x7fi02i03N44;|c9\x82<0e:~\x7fi0343;|c;\x82=0eq42;|c?\x82@0e@~\x7fi02i03N44;|cA\x82@0eB~\x7fi02i03N44;|cC\x82G0eD~\x7fi03\x84c7eEi0331K44;|cF\x82K0eG~\x7fi03\x84eHi0331eIi033145;|cJ\x82F0e2~\x7f]i03\x84342e3~cK42;|cL\x82N0e2~\x7f^eHi0331342eM~\x7fi03\x84cN44;|cO\x82C0e2~\x7fi02ePi033144;|cQ\x82s0e2~\x7f^c;_i03\x84L3342eReHi033131660^580eScT312e2~\x7f^eHi0331342e3~cQ42;eU~\x7fi02i0344;" [quote self-evaluating? compile-in emit loadv if compile-if begin compile-begin prog1 compile-prog1 lambda call-with-values #fn("8000r0e0i11i1342;" [compile-f-]) #fn("9000r2e0i10c1|332e2i10}322}e3i1131X6<0e0i10c442;^;" [emit loadv @@ -149,37 +149,37 @@ const-to-idx-vec #fn("9000r1c0qe1e2|313141;" [#fn("9000r1e0c1qe2~31322|;" [table.foreach #fn("8000r2~}|\\;" []) bcode:ctable]) vector.alloc bcode:nconst] const-to-idx-vec) copy-tree #fn("8000r1|?640|;e0|M31e0|N31K;" [copy-tree] copy-tree) - count #fn("7000r2c0q^41;" [#fn("9000r1c0qm02|~\x7f`43;" [#fn("9000r3}\x8550g2;~|}N|}M31690g2aw540g243;" [] count-)])] count) + count #fn("7000r2c0q^41;" [#fn("9000r1c0qm02|~\x7f`43;" [#fn(":000r3}\x8550g2;~|}N|}M31690g2aw540g243;" [] count-)])] count) delete-duplicates #fn("8000r1|?640|;c0|M|N42;" [#fn("8000r2e0|}32680e1}41;|e1}31K;" [member delete-duplicates])] delete-duplicates) - disassemble #fn(">000s1}\x85C0e0|`322e1302];530^2c2}Me3|31e4|3143;" [disassemble + disassemble #fn("=000s1}\x85C0e0|`322e1302];530^2c2}Me3|31e4|3143;" [disassemble newline #fn("7000r3c0q^41;" [#fn(":000r1c0qm02`~axc1u2e2c3e4\x7f`32c5332c6qb4e7\x7f3142;" [#fn("9000r1|J16602|G@6D0e0c1312e2|i10aw42;e3|41;" [princ "\n" disassemble print] print-val) #fn("7000r1e0c141;" [princ "\t"]) princ "maxstack " ref-int32-LE "\n" #fn(":000r2^|}X6E02c0qe1c2q^e333315\x19/;" [#fn(";000r1e0~b432690e130530^2`i20axc2u2e3e4~b4x31c5e6|31c7342~awo002c8q|41;" [> - newline #fn("7000r1e0c141;" [princ "\t"]) princ hex5 ": " string "\t" #fn(">000r1e0|c1326P0i20i32e2i31i1032[312i10b4wo10;e0|c3326L0i20i32i31i10[[312i10awo10;e0|c4326K0e5e6i31i10[31312i10awo10;e0|c7326O0e5e6e2i31i103231312i10b4wo10;e0|c8326f0e5e6i31i10[31c9322i10awo102e5e6i31i10[31312i10awo10;e0|c:326\x9c0e5e6e2i31i103231c9322i10b4wo102e5e6e2i31i103231312i10b4wo102~c;\x82X0e5c9312e5e6e2i31i103231c9322i10b4wo10;^;|c<=6w0e5e6e2i31i103231c9322i10b4wo102e5c=e>i10b,e2i31i1032R331322i10b4wo10;e0|c?326X0e5c=e>i10b,e@i31i1032R331322i10b2wo10;e0|cA326X0e5c=e>i10b,e2i31i1032R331322i10b4wo10;^;" [memq + newline #fn("7000r1e0c141;" [princ "\t"]) princ hex5 ": " string "\t" #fn("=000r1e0|c1326P0i20i32e2i31i1032[312i10b4wo10;e0|c3326L0i20i32i31i10[[312i10awo10;e0|c4326K0e5e6i31i10[31312i10awo10;e0|c7326O0e5e6e2i31i103231312i10b4wo10;e0|c8326f0e5e6i31i10[31c9322i10awo102e5e6i31i10[31312i10awo10;e0|c:326\x9c0e5e6e2i31i103231c9322i10b4wo102e5e6e2i31i103231312i10b4wo102~c;\x82X0e5c9312e5e6e2i31i103231c9322i10b4wo10;^;|c<=6Q0e5e6e2i31i103231c9322i10b4wo10;e0|c=326X0e5c>e?i10b,e@i31i1032R331322i10b2wo10;e0|cA326X0e5c>e?i10b,e2i31i1032R331322i10b4wo10;^;" [memq (loadv.l loadg.l setg.l) ref-int32-LE (loadv loadg setg) (loada seta call tcall list + - * / vector argc vargc loadi8 apply tapply) princ number->string (loada.l seta.l largc lvargc call.l tcall.l) (loadc setc) - " " (loadc.l setc.l optargs keyargs) keyargs brbound "@" hex5 (jmp brf brt - brne brnn brn) ref-int16-LE (jmp.l brf.l brt.l brne.l brnn.l brn.l)])]) - table.foldl #fn("8000r3g217@02}i21~[<16402|;" []) + " " (loadc.l setc.l optargs keyargs) keyargs brbound (jmp brf brt brne brnn + brn) "@" hex5 + ref-int16-LE (jmp.l brf.l brt.l brne.l brnn.l brn.l)])]) table.foldl #fn("8000r3g217@02}i21~[<16402|;" []) Instructions]) length])]) function:code function:vals] disassemble) div #fn("8000r2|}V|`X16C02}`X16402a17502b/17402`w;" [] div) emit - #fn("I000s2g2\x85b0}c0<16C02|`[F16:02|`[Mc1<6;0|`[c2O5:0|`}|`[K\\5\xe20e3}c4326A0e5|g2M32L1m2530^2c6qe7}c832312c9qe7}c:32312}c;\x82\\0g2c<>6=0c=m12_m25F0g2c>>6=0c?m12_m2530^530^2}c@\x82\\0g2cA>6=0cBm12_m25F0g2cC>6=0cDm12_m2530^530^2cEq|`[F690|`[M530_|`[322|;" [car + #fn("G000s2g2\x85b0}c0<16C02|`[F16:02|`[Mc1<6;0|`[c2O5:0|`}|`[K\\5\xe20e3}c4326A0e5|g2M32L1m2530^2c6qe7}c832312c9qe7}c:32312}c;\x82\\0g2c<>6=0c=m12_m25F0g2c>>6=0c?m12_m2530^530^2}c@\x82\\0g2cA>6=0cBm12_m25F0g2cC>6=0cDm12_m2530^530^2cEq|`[F690|`[M530_|`[322|;" [car cdr cadr memq (loadv loadg setg) bcode:indexfor #fn("8000r1|16=02e0i02Mc132680|\x84o01;^;" [> 255]) assq ((loadv loadv.l) (loadg loadg.l) (setg setg.l) (loada loada.l) (seta seta.l)) #fn("8000r1|16L02e0i02Mc13217=02e0i02\x84c132680|\x84o01;^;" [> 255]) ((loadc loadc.l) (setc setc.l)) loada (0) loada0 (1) loada1 loadc (0 0) - loadc00 (0 1) loadc01 #fn("D000r2\x7fc0<16\x9a02|c1<16802}\x84c2<6E0~`i02Mc3e4}31KK\\5u0|c1\x82B0~`i02Mc5}NKK\\5_0|c6\x82B0~`i02Mc7}NKK\\5I0|c2\x82B0~`i02Mc8}NKK\\530^17^02\x7fc5<16702|c2<6@0~`i02Mc3}NKK\\;~`e9\x7fi02K}32\\;" [brf + loadc00 (0 1) loadc01 #fn(">000r2\x7fc0<16\x9a02|c1<16802}\x84c2<6E0~`i02Mc3e4}31KK\\5u0|c1\x82B0~`i02Mc5}NKK\\5_0|c6\x82B0~`i02Mc7}NKK\\5I0|c2\x82B0~`i02Mc8}NKK\\530^17^02\x7fc5<16702|c2<6@0~`i02Mc3}NKK\\;~`e9\x7fi02K}32\\;" [brf not null? brn cddr brt eq? brne brnn nreconc])] emit) - emit-optional-arg-inits #fn("8000r5g2F6=0c0qe1|3141;^;" [#fn("<000r1e0~c1i04|342e2~e3i03i0432\x7fK^e4i0231342e0~c5i04332e0~c6322e7~|322e8~\x7fi02Ni03i04aw45;" [emit - brbound compile-in list-head cadar seta pop mark-label + emit-optional-arg-inits #fn("8000r5g2F6=0c0qe1|3141;^;" [#fn("<000r1e0~c1i04332e0~c2|332e3~e4i03i0432\x7fK^e5i0231342e0~c6i04332e0~c7322e8~|322e9~\x7fi02Ni03i04aw45;" [emit + brbound brt compile-in list-head cadar seta pop mark-label emit-optional-arg-inits]) make-label] emit-optional-arg-inits) - encode-byte-code #fn("8000r1c0e1|3141;" [#fn("8000r1c0e1|3141;" [#fn(";000r1c0qe1e2|31b3e2|31b2VT2wc33241;" [#fn("=000r1c0qe1~31`e230e230e330^^47;" [#fn("B000r7e0g4c1322^}|X6#02i10}[m52g5c2\x82O0e3g2i10}aw[e4g431332}b2wm15\xf30e0g4e5e6e7~6<0c8qg531540g53231322}awm12}|X6:0i10}[530^m62e9g5c:326^0e3g3e4g431g6332e0g4~670e;540e<`31322}awm15\x830g5c=\x82k0e0g4e;g631322}awm12e3g3e4g431i10}[332e0g4e;`31322}awm15C0g6D6<0c>qg531530^5;/2e?c@qg3322eAg441;" [io.write - #int32(0) label put! sizeof byte get Instructions #fn("9000r1|c0\x8250c1;|c2\x8250c3;|c4\x8250c5;|c6\x8250c7;|c8\x8250c9;|c:\x8250c;;i05;" [jmp + encode-byte-code #fn("8000r1c0e1|3141;" [#fn("8000r1c0e1|3141;" [#fn(";000r1c0qe1e2|31b3e2|31b2VT2wc33241;" [#fn("=000r1c0qe1~31`e230e230e330^^47;" [#fn("?000r7e0g4c1322^}|X6\xff02i10}[m52g5c2\x82O0e3g2i10}aw[e4g431332}b2wm15\xcf0e0g4e5e6e7~6<0c8qg531540g53231322}awm12}|X6:0i10}[530^m62e9g5c:326^0e3g3e4g431g6332e0g4~670e;540e<`31322}awm15_0g5c=\x82G0e0g4e;g631322}awm15C0g6D6<0c>qg531530^5_/2e?c@qg3322eAg441;" [io.write + #int32(0) label put! sizeof byte get Instructions #fn("7000r1|c0\x8250c1;|c2\x8250c3;|c4\x8250c5;|c6\x8250c7;|c8\x8250c9;|c:\x8250c;;i05;" [jmp jmp.l brt brt.l brf brf.l brne brne.l brnn brnn.l brn brn.l]) memq (jmp brf - brt brne brnn brn) int32 int16 brbound #fn("<000r1e0|c1326H0e2i04e3i0631322\x7fawo01;e0|c4326`0e2i04e5i0631322\x7fawo012e2i04e5i20\x7f[31322\x7fawo01;e0|c6326\x820e2i04e3i0631322\x7fawo012e2i04e3i20\x7f[31322\x7fawo012i05c7\x82J0e2i04e3i20\x7f[31322\x7fawo01;^;e2i04e5i0631322\x7fawo01;" [memq + brt brne brnn brn) int32 int16 brbound #fn(":000r1e0|c1326H0e2i04e3i0631322\x7fawo01;e0|c4326`0e2i04e5i0631322\x7fawo012e2i04e5i20\x7f[31322\x7fawo01;e0|c6326\x820e2i04e3i0631322\x7fawo012e2i04e3i20\x7f[31322\x7fawo012i05c7\x82J0e2i04e3i20\x7f[31322\x7fawo01;^;e2i04e5i0631322\x7fawo01;" [memq (loadv.l loadg.l setg.l loada.l seta.l largc lvargc call.l tcall.l) io.write int32 (loadc setc) uint8 (loadc.l setc.l optargs keyargs) keyargs]) table.foreach #fn("<000r2e0i04|322e1i04i10670e2540e3e4i02}32|x3142;" [io.seek @@ -193,20 +193,20 @@ caar begin append cdar] splice-begin) *expanded* #fn("9000r2|?640|;c0q~c1}32690\x7f|31530|41;" [#fn("9000r1c0qi10c1\x7f3241;" [#fn("8000r1c0q|6:0e1~31530_41;" [#fn(":000r1c0qe1e2c3|32i213241;" [#fn("8000r1i107=0e0c1qi2042;c2qc3q^31i203141;" [map #fn("8000r1i5:|~42;" []) #fn("7000r1c0q|41;" [#fn("9000r1^|F6]02i62e0|31<7A0|i6:|Mi1032O590|e1|31O2|Nm05\x02/2~;" [caar cdar])]) #fn("6000r1c0qm0;" [#fn("9000r1|?640|;|MF16;02c0e1|31<6;0|M~|N31K;c2qi6:|Mi103241;" [define - caar #fn(":000r1e0e1c2e3|3132i2032o202i72|Ki10~N31K;" [nconc map1 #.list + caar #fn(":000r1e0e1c2e3|3132i2032o202i72|Ki10~N31K;" [nconc map #.list get-defined-vars])])])]) - nconc map1 #.list]) get-defined-vars]) define]) begin] expand-body) + nconc map #.list]) get-defined-vars]) define]) begin] expand-body) #fn(":000r2|?640|;|MF16702|MNF6G0e0|31i0:e1|31}32L2540|Mi04|N}32K;" [caar cadar] expand-lambda-list) #fn("8000r1|?660|L1;|MF6@0e0|31i05|N31K;|Mi05|N31K;" [caar] l-vars) #fn(";000r2c0q|\x84e1|31e2|31i05|\x843144;" [#fn(":000r4c0qe1e2c3g332\x7f3241;" [#fn(";000r1e0c1L1i24~|32L1i23i02|32\x7f44;" [nconc - lambda]) nconc map1 #.list]) lastcdr cddr] expand-lambda) - #fn("=000r2|NA17602|\x84?6N0e0|31\x8540|;c1|\x84i0:e2|31}32L3;c3qe4|31e5|31e0|31i05e4|313144;" [cddr + lambda]) nconc map #.list]) lastcdr cddr] expand-lambda) + #fn("<000r2|NA17602|\x84?6N0e0|31\x8540|;c1|\x84i0:e2|31}32L3;c3qe4|31e5|31e0|31i05e4|313144;" [cddr define caddr #fn(":000r4c0qe1e2c3g332\x7f3241;" [#fn(";000r1e0c1L1\x7fi24~|32KL1i23i02|3243;" [nconc - define]) nconc map1 #.list]) cdadr caadr] expand-define) + define]) nconc map #.list]) cdadr caadr] expand-define) #fn("7000r2c0q|\x8441;" [#fn("<000r1c0i13e1~31e2e3c4q|32\x7f3232K;" [begin cddr nconc map #fn(":000r1|Me0i2:|\x84i11323130i11L3;" [compile-thunk])])] expand-let-syntax) #fn("6000r2|;" [] local-expansion-env) #fn("7000r2|?640|;c0q|M41;" [#fn("9000r1c0qe1|\x7f3241;" [#fn("7000r1c0qc1q41;" [#fn(":000r1~16602~NF6M0i3:~\x84i20NQ2i39e0~31i213242;~17A02i10C@17702i10E660|40;c1qe2i203141;" [caddr - #fn(";000r1|6B0i4:|i30NQ2i3142;i20c0\x8260i30;i20c1\x82>0i46i30i3142;i20c2\x82>0i47i30i3142;i20c3\x82>0i48i30i3142;~40;" [quote + #fn("8000r1|6B0i4:|i30NQ2i3142;i20c0\x8260i30;i20c1\x82>0i46i30i3142;i20c2\x82>0i47i30i3142;i20c3\x82>0i48i30i3142;~40;" [quote lambda define let-syntax]) macrocall?]) #fn("7000r0c0q^31i2041;" [#fn("6000r1c0qm0;" [#fn("9000r1|?640|;|M?670|M5<0i4:|Mi3132~|N31K;" [])])])]) assq])] expand-in)])] expand) @@ -215,15 +215,15 @@ print-to-string] expand-define) filter #fn("7000r2c0q^41;" [#fn("9000r1c0qm02|~\x7f_L143;" [#fn("9000r3g2^}F6S02i10}M316?0g2}M_KPNm2530^2}Nm15\f/2N;" [] filter-)])] filter) fits-i8 #fn("8000r1|I16F02e0|b\xb03216:02e1|b\xaf42;" [>= <=] fits-i8) - foldl #fn(";000r3g2\x8540};e0||g2M}32g2N43;" [foldl] foldl) foldr - #fn("<000r3g2\x8540};|g2Me0|}g2N3342;" [foldr] foldr) for-each #fn(";000s2c0q^41;" [#fn(";000r1c0qm02i02\x85J0^\x7fF6A02~\x7fM312\x7fNo015\x1e/5;0|~\x7fi02K322];" [#fn(":000r2}MF6I0|e0c1}32Q22~|e0c2}3242;^;" [map + foldl #fn(":000r3g2\x8540};e0||g2M}32g2N43;" [foldl] foldl) foldr + #fn(";000r3g2\x8540};|g2Me0|}g2N3342;" [foldr] foldr) for-each #fn(";000s2c0q^41;" [#fn(":000r1c0qm02i02\x85J0^\x7fF6A02~\x7fM312\x7fNo015\x1e/5;0|~\x7fi02K322];" [#fn(":000r2}MF6I0|e0c1}32Q22~|e0c2}3242;^;" [map #.car #.cdr] for-each-n)])] for-each) - get-defined-vars #fn("8000r1e0~|3141;" [delete-duplicates] #1=[#fn(":000r1|?640_;|Mc0<16602|NF6d0|\x84C16702|\x84L117S02|\x84F16E02e1|31C16:02e1|31L117402_;|Mc2\x82>0e3e4~|N32v2;_;" [define + get-defined-vars #fn("8000r1e0~|3141;" [delete-duplicates] #1=[#fn("9000r1|?640_;|Mc0<16602|NF6d0|\x84C16702|\x84L117S02|\x84F16E02e1|31C16:02e1|31L117402_;|Mc2\x82>0e3e4~|N32v2;_;" [define caadr begin nconc map] #1#) ()]) hex5 #fn("9000r1e0e1|b@32b5c243;" [string.lpad number->string #\0] hex5) identity #fn("6000r1|;" [] identity) in-env? #fn("8000r2}F16F02e0|}M3217:02e1|}N42;" [memq in-env?] in-env?) - index-of #fn(";000r3}\x8540^;|}M\x8250g2;e0|}Ng2aw43;" [index-of] index-of) + index-of #fn(":000r3}\x8540^;|}M\x8250g2;e0|}Ng2aw43;" [index-of] index-of) io.readall #fn("7000r1c0qe13041;" [#fn("8000r1e0|~322c1qe2|3141;" [io.copy #fn("7000r1|c0>16:02e1i1031670e240;|;" ["" io.eof? eof-object]) io.tostring!]) buffer] io.readall) @@ -276,21 +276,21 @@ *print-readably* *print-level* *print-length*)] make-system-image) - map #fn(";000s2c0q^41;" [#fn("9000r1c0qm02i02\x85<0e1~\x7f_L143;|~\x7fi02K42;" [#fn("=000r2}M\x8540_;|e0c1}_L133Q2~|e0c2}_L13332K;" [map1 - #.car #.cdr] mapn) map1])] map) + map #fn("<000s2c0q^^42;" [#fn("9000r2c0m02c1qm12i02\x85;0|~\x7f_L143;}~\x7fi02K42;" [#fn("9000r3g2^}F6H02g2|}M31_KPNm22}Nm15\x17/2N;" [] map1) + #fn("<000r2}M\x8540_;|~c0}_L133Q2\x7f|~c1}_L13332K;" [#.car #.cdr] mapn)])] map) map! #fn("9000r2}^}F6B02}|}M31O2}Nm15\x1d/2;" [] map!) map-int #fn("8000r2e0}`32640_;c1q|`31_K_42;" [<= #fn(":000r2|m12a\x7faxc0qu2|;" [#fn("8000r1\x7fi10|31_KP2\x7fNo01;" [])])] map-int) - map1 #fn(":000\x8920003000\x8a2000:000_L1m22g2^}F6H02g2|}M31_KPNm22}Nm15\x17/2N;" [] map1) mark-label #fn("9000r2e0|c1}43;" [emit label] mark-label) max - #fn("=000s1}\x8540|;e0c1|}43;" [foldl #fn("7000r2|}X640};|;" [])] max) + #fn("<000s1}\x8540|;e0c1|}43;" [foldl #fn("7000r2|}X640};|;" [])] max) member #fn("8000r2}?640^;}M|>640};e0|}N42;" [member] member) memv - #fn("8000r2}?640^;}M|=640};e0|}N42;" [memv] memv) min #fn("=000s1}\x8540|;e0c1|}43;" [foldl + #fn("8000r2}?640^;}M|=640};e0|}N42;" [memv] memv) min #fn("<000s1}\x8540|;e0c1|}43;" [foldl #fn("7000r2|}X640|;};" [])] min) mod #fn("9000r2|e0|}32}T2x;" [div] mod) mod0 #fn("8000r2||}V}T2x;" [] mod0) negative? #fn("7000r1|`X;" [] negative?) nestlist #fn(";000r3e0g2`32640_;}e1||}31g2ax33K;" [<= nestlist] nestlist) - newline #fn("9000\x8900001000\x8a00009000e0m02e1|e2322];" [*output-stream* - io.write *linefeed*] newline) + newline #fn("9000\x8900001000\x8a0000770e0m02e1|e2322];" [*output-stream* + io.write + *linefeed*] newline) nnn #fn("8000r1e0c1|42;" [count #fn("6000r1|A@;" [])] nnn) nreconc #fn("8000r2e0e1|31}42;" [nconc reverse!] nreconc) odd? #fn("7000r1e0|31@;" [even?] odd?) positive? #fn("8000r1e0|`42;" [>] positive?) princ @@ -305,7 +305,7 @@ " has no value" error "error: " load-error print-exception "in file " list? ": " #fn("8000r1e0|3117502|C670e1540e2|41;" [string? princ print]) "*** Unhandled exception: " *linefeed*] print-exception) - print-stack-trace #fn("8000r1c0q^^42;" [#fn("=000r2c0qm02c1qm12c2qe3e4~e5670b5540b43231e6e7e8c9e:303232`43;" [#fn("8000r3c0qe1|31g2K41;" [#fn(":000r1e0~31e0\x7f31\x82>0e1c2c3|L341;c4qe5~3141;" [function:code + print-stack-trace #fn("8000r1c0q^^42;" [#fn("=000r2c0qm02c1qm12c2qe3e4~e5670b5540b43231e6e7e8c9e:303232`43;" [#fn("8000r3c0qe1|31g2K41;" [#fn("9000r1e0~31e0\x7f31\x82>0e1c2c3|L341;c4qe5~3141;" [function:code raise thrown-value ffound #fn(":000r1`e0e1|3131c2qu;" [1- length #fn("9000r1e0~|[316A0i30~|[i21i1043;^;" [closure?])]) function:vals]) function:name] find-in-f) #fn("8000r2c0c1qc2t41;" [#fn(";000r1|6H0e0e1e2e3e4|3132c53241;c6;" [symbol @@ -340,7 +340,7 @@ #fn("9000r1e0c1_|43;" [foldl #.cons] reverse) reverse! #fn("7000r1c0q_41;" [#fn("9000r1^~F6C02~N~|~m02P2o005\x1c/2|;" [])] reverse!) self-evaluating? #fn("8000r1|?16602|C@17K02e0|3116A02|C16:02|e1|31<;" [constant? top-level-value] self-evaluating?) - separate #fn(":000r2~|}__44;" [] #2=[#fn("6000r4}\x8580g2g3K;|}M316@0~|}N}Mg2Kg344;~|}Ng2}Mg3K44;" [] #2#) + separate #fn(":000r2~|}__44;" [] #2=[#fn(";000r4}\x8580g2g3K;|}M316@0~|}N}Mg2Kg344;~|}Ng2}Mg3K44;" [] #2#) ()]) set-syntax! #fn("9000r2e0e1|}43;" [put! *syntax-environment*] set-syntax!) simple-sort #fn("7000r1|A17602|NA640|;c0q|M41;" [#fn("9000r1c0qe1c2q~N3241;" [#fn(":000r1e0e1|M31~L1e1|N3143;" [nconc @@ -369,7 +369,7 @@ table.keys #fn("9000r1e0c1_|43;" [table.foldl #fn("7000r3|g2K;" [])] table.keys) table.pairs #fn("9000r1e0c1_|43;" [table.foldl #fn("7000r3|}Kg2K;" [])] table.pairs) table.values #fn("9000r1e0c1_|43;" [table.foldl #fn("7000r3}g2K;" [])] table.values) - to-proper #fn("9000r1|\x8540|;|?660|L1;|Me0|N31K;" [to-proper] to-proper) + to-proper #fn("8000r1|\x8540|;|?660|L1;|Me0|N31K;" [to-proper] to-proper) top-level-exception-handler #fn("7000r1c0qe141;" [#fn("7000r1e0k12c2qc3q41;" [*stderr* *output-stream* #fn("7000r1c0qc1qt|302;" [#fn("7000r0e0i20312e1e23041;" [print-exception print-stack-trace stacktrace]) #fn("7000r1~302e0|41;" [raise])]) diff --git a/femtolisp/flisp.c b/femtolisp/flisp.c index dbc856a..a6e3268 100644 --- a/femtolisp/flisp.c +++ b/femtolisp/flisp.c @@ -158,7 +158,7 @@ static uint32_t throwing_frame=0; // active frame when exception was thrown for (l__ca=1; l__ca; l__ca=0, \ lasterror=NIL, throwing_frame=0, SP=_ctx.sp, curr_frame=_ctx.frame) -void raise(value_t e) +void fl_raise(value_t e) { lasterror = e; // unwind read state @@ -191,7 +191,7 @@ void lerrorf(value_t e, char *format, ...) va_end(args); e = POP(); - raise(list2(e, msg)); + fl_raise(list2(e, msg)); } void lerror(value_t e, const char *msg) @@ -199,17 +199,17 @@ void lerror(value_t e, const char *msg) PUSH(e); value_t m = cvalue_static_cstring(msg); e = POP(); - raise(list2(e, m)); + fl_raise(list2(e, m)); } void type_error(char *fname, char *expected, value_t got) { - raise(listn(4, TypeError, symbol(fname), symbol(expected), got)); + fl_raise(listn(4, TypeError, symbol(fname), symbol(expected), got)); } void bounds_error(char *fname, value_t arr, value_t ind) { - raise(listn(4, BoundsError, symbol(fname), arr, ind)); + fl_raise(listn(4, BoundsError, symbol(fname), arr, ind)); } // safe cast operators -------------------------------------------------------- @@ -349,7 +349,7 @@ static value_t *alloc_words(int n) value_t *first; assert(n > 0); - n = ALIGN(n, 2); // only allocate multiples of 2 words + n = LLT_ALIGN(n, 2); // only allocate multiples of 2 words if (__unlikely((value_t*)curheap > ((value_t*)lim)+2-n)) { gc(0); while ((value_t*)curheap > ((value_t*)lim)+2-n) { @@ -578,7 +578,7 @@ void gc(int mustgrow) if (grew || ((lim-curheap) < (int)(heapsize/5)) || mustgrow) { temp = realloc(tospace, grew ? heapsize : heapsize*2); if (temp == NULL) - raise(memory_exception_value); + fl_raise(memory_exception_value); tospace = temp; if (!grew) { heapsize*=2; @@ -586,7 +586,7 @@ void gc(int mustgrow) else { temp = bitvector_resize(consflags, heapsize/sizeof(cons_t), 1); if (temp == NULL) - raise(memory_exception_value); + fl_raise(memory_exception_value); consflags = (uint32_t*)temp; } grew = !grew; @@ -885,19 +885,23 @@ static uint32_t process_keys(value_t kwtable, #if _BYTE_ORDER == __BIG_ENDIAN #define GET_INT32(a) \ + ((int32_t) \ ((((int32_t)a[0])<<0) | \ (((int32_t)a[1])<<8) | \ (((int32_t)a[2])<<16) | \ - (((int32_t)a[3])<<24)) + (((int32_t)a[3])<<24))) #define GET_INT16(a) \ + ((int16_t) \ ((((int16_t)a[0])<<0) | \ - (((int16_t)a[1])<<8)) + (((int16_t)a[1])<<8))) #define PUT_INT32(a,i) (*(int32_t*)(a) = bswap_32((int32_t)(i))) #else #define GET_INT32(a) (*(int32_t*)a) #define GET_INT16(a) (*(int16_t*)a) #define PUT_INT32(a,i) (*(int32_t*)(a) = (int32_t)(i)) #endif +#define SWAP_INT32(a) (*(int32_t*)(a) = bswap_32(*(int32_t*)(a))) +#define SWAP_INT16(a) (*(int16_t*)(a) = bswap_16(*(int16_t*)(a))) #ifdef USE_COMPUTED_GOTO #define OP(x) L_##x: @@ -1022,8 +1026,8 @@ static value_t apply_cl(uint32_t nargs) v = vector_elt(Stack[bp], i); else v = Stack[bp+i]; - if (v != UNBOUND) ip += (ptrint_t)GET_INT32(ip); - else ip += 4; + if (v != UNBOUND) PUSH(FL_T); + else PUSH(FL_F); NEXT_OP; OP(OP_DUP) SP++; Stack[SP-1] = Stack[SP-2]; NEXT_OP; OP(OP_POP) POPN(1); NEXT_OP; @@ -1075,7 +1079,7 @@ static value_t apply_cl(uint32_t nargs) } else if (iscbuiltin(func)) { s = SP; - v = (((builtin_t*)ptr(func))[3])(&Stack[SP-n], n); + v = ((builtin_t)(((void**)ptr(func))[3]))(&Stack[SP-n], n); SP = s-n; Stack[SP-1] = v; NEXT_OP; @@ -1125,7 +1129,7 @@ static value_t apply_cl(uint32_t nargs) } else if (iscbuiltin(func)) { s = SP; - v = (((builtin_t*)ptr(func))[3])(&Stack[SP-n], n); + v = ((builtin_t)(((void**)ptr(func))[3]))(&Stack[SP-n], n); SP = s-n; Stack[SP-1] = v; NEXT_OP; @@ -1579,7 +1583,7 @@ static value_t apply_cl(uint32_t nargs) assert(issymbol(v)); sym = (symbol_t*)ptr(v); if (sym->binding == UNBOUND) - raise(list2(UnboundError, v)); + fl_raise(list2(UnboundError, v)); PUSH(sym->binding); NEXT_OP; @@ -1787,7 +1791,7 @@ static value_t apply_cl(uint32_t nargs) #endif } -static uint32_t compute_maxstack(uint8_t *code, size_t len) +static uint32_t compute_maxstack(uint8_t *code, size_t len, int bswap) { uint8_t *ip = code+4, *end = code+len; uint8_t op; @@ -1806,38 +1810,78 @@ static uint32_t compute_maxstack(uint8_t *code, size_t len) sp += (n+2); break; case OP_LARGC: + if (bswap) SWAP_INT32(ip); n = GET_INT32(ip); ip+=4; break; case OP_LVARGC: + if (bswap) SWAP_INT32(ip); n = GET_INT32(ip); ip+=4; sp += (n+2); break; case OP_OPTARGS: + if (bswap) SWAP_INT32(ip); i = GET_INT32(ip); ip+=4; + if (bswap) SWAP_INT32(ip); n = abs(GET_INT32(ip)); ip+=4; sp += (n-i); break; case OP_KEYARGS: + if (bswap) SWAP_INT32(ip); i = GET_INT32(ip); ip+=4; + if (bswap) SWAP_INT32(ip); n = GET_INT32(ip); ip+=4; + if (bswap) SWAP_INT32(ip); n = abs(GET_INT32(ip)); ip+=4; sp += (n-i); break; case OP_BRBOUND: - ip+=8; + if (bswap) SWAP_INT32(ip); + ip+=4; + sp++; break; case OP_TCALL: case OP_CALL: n = *ip++; // nargs sp -= n; break; - case OP_JMP: ip += 2; break; - case OP_JMPL: ip += 4; break; + case OP_TCALLL: case OP_CALLL: + if (bswap) SWAP_INT32(ip); + n = GET_INT32(ip); ip+=4; + sp -= n; + break; + case OP_JMP: + if (bswap) SWAP_INT16(ip); + ip += 2; break; + case OP_JMPL: + if (bswap) SWAP_INT32(ip); + ip += 4; break; case OP_BRF: case OP_BRT: + if (bswap) SWAP_INT16(ip); ip+=2; sp--; break; case OP_BRFL: case OP_BRTL: + if (bswap) SWAP_INT32(ip); + ip += 4; + sp--; + break; + case OP_BRNE: + if (bswap) SWAP_INT16(ip); + ip += 2; + sp -= 2; + break; + case OP_BRNEL: + if (bswap) SWAP_INT32(ip); + ip += 4; + sp -= 2; + break; + case OP_BRNN: case OP_BRN: + if (bswap) SWAP_INT16(ip); + ip += 2; + sp--; + break; + case OP_BRNNL: case OP_BRNL: + if (bswap) SWAP_INT32(ip); ip += 4; sp--; break; @@ -1886,6 +1930,7 @@ static uint32_t compute_maxstack(uint8_t *code, size_t len) sp++; break; case OP_LOADVL: case OP_LOADGL: case OP_LOADAL: + if (bswap) SWAP_INT32(ip); ip+=4; sp++; break; @@ -1894,6 +1939,7 @@ static uint32_t compute_maxstack(uint8_t *code, size_t len) ip++; break; case OP_SETGL: case OP_SETAL: + if (bswap) SWAP_INT32(ip); ip+=4; break; @@ -1901,9 +1947,17 @@ static uint32_t compute_maxstack(uint8_t *code, size_t len) case OP_SETC: ip+=2; break; - case OP_LOADCL: ip+=8; sp++; break; + case OP_LOADCL: + if (bswap) SWAP_INT32(ip); + ip+=4; + if (bswap) SWAP_INT32(ip); + ip+=4; + sp++; break; case OP_SETCL: - ip+=8; + if (bswap) SWAP_INT32(ip); + ip+=4; + if (bswap) SWAP_INT32(ip); + ip+=4; break; } } @@ -1956,13 +2010,19 @@ static value_t fl_function(value_t *args, uint32_t nargs) cvalue_t *arr = (cvalue_t*)ptr(args[0]); cv_pin(arr); char *data = cv_data(arr); + int swap = 0; if ((uint8_t)data[4] >= N_OPCODES) { // read syntax, shifted 48 for compact text representation size_t i, sz = cv_len(arr); for(i=0; i < sz; i++) data[i] -= 48; } - uint32_t ms = compute_maxstack((uint8_t*)data, cv_len(arr)); + else { +#if _BYTE_ORDER == __BIG_ENDIAN + swap = 1; +#endif + } + uint32_t ms = compute_maxstack((uint8_t*)data, cv_len(arr), swap); PUT_INT32(data, ms); function_t *fn = (function_t*)alloc_words(4); value_t fv = tagptr(fn, TAG_FUNCTION); diff --git a/femtolisp/flisp.h b/femtolisp/flisp.h index 7b5a2b5..23fe192 100644 --- a/femtolisp/flisp.h +++ b/femtolisp/flisp.h @@ -149,7 +149,7 @@ char *tostring(value_t v, char *fname); /* error handling */ void lerrorf(value_t e, char *format, ...) __attribute__ ((__noreturn__)); void lerror(value_t e, const char *msg) __attribute__ ((__noreturn__)); -void raise(value_t e) __attribute__ ((__noreturn__)); +void fl_raise(value_t e) __attribute__ ((__noreturn__)); void type_error(char *fname, char *expected, value_t got) __attribute__ ((__noreturn__)); void bounds_error(char *fname, value_t arr, value_t ind) __attribute__ ((__noreturn__)); extern value_t ArgError, IOError, KeyError, MemoryError, EnumerationError; diff --git a/femtolisp/read.c b/femtolisp/read.c index 9a01f1a..c7dd179 100644 --- a/femtolisp/read.c +++ b/femtolisp/read.c @@ -79,7 +79,8 @@ static int read_numtok(char *tok, value_t *pval, int base) int result; errno = 0; result = isnumtok_base(tok, pval, base); - if (errno) lerror(ParseError, "read: overflow in numeric constant"); + if (errno == ERANGE) + lerrorf(ParseError, "read: overflow in numeric constant %s", tok); return result; } @@ -610,7 +611,7 @@ static value_t do_read_sexpr(value_t label) } v = symbol_value(sym); if (v == UNBOUND) - raise(list2(UnboundError, sym)); + fl_raise(list2(UnboundError, sym)); return apply(v, POP()); case TOK_OPENB: return read_vector(label, TOK_CLOSEB); @@ -626,7 +627,7 @@ static value_t do_read_sexpr(value_t label) if (issymbol(sym)) { v = symbol_value(sym); if (v == UNBOUND) - raise(list2(UnboundError, sym)); + fl_raise(list2(UnboundError, sym)); return v; } return toplevel_eval(sym); diff --git a/femtolisp/system.lsp b/femtolisp/system.lsp index ade1d48..ce8332a 100644 --- a/femtolisp/system.lsp +++ b/femtolisp/system.lsp @@ -16,15 +16,14 @@ (define-macro (label name fn) `((lambda (,name) (set! ,name ,fn)) #f)) -(define (map1 f lst (acc (list ()))) - (cdr - (prog1 acc - (while (pair? lst) - (begin (set! acc - (cdr (set-cdr! acc (cons (f (car lst)) ())))) - (set! lst (cdr lst))))))) - (define (map f lst . lsts) + (define (map1 f lst acc) + (cdr + (prog1 acc + (while (pair? lst) + (begin (set! acc + (cdr (set-cdr! acc (cons (f (car lst)) ())))) + (set! lst (cdr lst))))))) (define (mapn f lsts) (if (null? (car lsts)) () @@ -721,7 +720,7 @@ body)) (def? (top? 'define env)) (dvars (if def? (get-defined-vars body) ())) - (env (nconc (map1 list dvars) env))) + (env (nconc (map list dvars) env))) (if (not def?) (map (lambda (x) (expand-in x env)) body) (let* ((ex-nondefs ; expand non-definitions @@ -733,7 +732,7 @@ (else (let ((form (expand-in (car body) env))) (set! env (nconc - (map1 list (get-defined-vars form)) + (map list (get-defined-vars form)) env)) (cons (cons *expanded* form) @@ -763,7 +762,7 @@ (name (lastcdr e)) (body (cddr e)) (vars (l-vars (cadr e)))) - (let ((env (nconc (map1 list vars) env))) + (let ((env (nconc (map list vars) env))) `(lambda ,(expand-lambda-list formals env) ,.(expand-body body env) . ,name)))) @@ -777,7 +776,7 @@ (name (caadr e)) (body (cddr e)) (vars (l-vars (cdadr e)))) - (let ((env (nconc (map1 list vars) env))) + (let ((env (nconc (map list vars) env))) `(define ,(cons name (expand-lambda-list formals env)) ,.(expand-body body env)))))) diff --git a/llt/Makefile b/llt/Makefile index bec581a..d58396a 100644 --- a/llt/Makefile +++ b/llt/Makefile @@ -10,7 +10,7 @@ TARGET = libllt.a TESTSRC = unittest.c TESTER = llttest -FLAGS = -Wall -Wextra -Wno-strict-aliasing $(CFLAGS) +FLAGS = -Wall -Wno-strict-aliasing $(CFLAGS) LIBS = DEBUGFLAGS = -g -DDEBUG $(FLAGS) diff --git a/llt/dirpath.c b/llt/dirpath.c index 2c91a75..cfe6063 100644 --- a/llt/dirpath.c +++ b/llt/dirpath.c @@ -8,6 +8,8 @@ #include #include +#include "dtypes.h" + #ifdef WIN32 #include #include @@ -23,7 +25,6 @@ #include #endif -#include "dtypes.h" #include "dirpath.h" void get_cwd(char *buf, size_t size) diff --git a/llt/dtypes.h b/llt/dtypes.h index 4bd890b..b144b46 100644 --- a/llt/dtypes.h +++ b/llt/dtypes.h @@ -85,7 +85,7 @@ typedef u_int32_t uint32_t; typedef u_int64_t uint64_t; typedef u_ptrint_t uptrint_t; -#define ALIGN(x, sz) (((x) + (sz-1)) & (-sz)) +#define LLT_ALIGN(x, sz) (((x) + (sz-1)) & (-sz)) // branch prediction annotations #ifdef __GNUC__ diff --git a/llt/ios.c b/llt/ios.c index 3fd7e33..287b546 100644 --- a/llt/ios.c +++ b/llt/ios.c @@ -7,6 +7,8 @@ #include #include // for printf +#include "dtypes.h" + #ifdef WIN32 #include #include @@ -20,7 +22,6 @@ #include #endif -#include "dtypes.h" #include "utils.h" #include "utf8.h" #include "ios.h" diff --git a/llt/memalign.c b/llt/memalign.c index 41d02aa..240972b 100644 --- a/llt/memalign.c +++ b/llt/memalign.c @@ -12,7 +12,7 @@ static void *aligned_ptr(char *ptr, size_t align_size) char *ptr2, *aligned_ptr; ptr2 = ptr + sizeof(long); - aligned_ptr = (char*)ALIGN(((uptrint_t)ptr2), align_size); + aligned_ptr = (char*)LLT_ALIGN(((uptrint_t)ptr2), align_size); ((long*)aligned_ptr)[-1] = (long)(aligned_ptr - ptr); diff --git a/llt/random.c b/llt/random.c index 43dd606..e29b5bb 100644 --- a/llt/random.c +++ b/llt/random.c @@ -4,8 +4,8 @@ #include #include #include -#include "ieee754.h" #include "dtypes.h" +#include "ieee754.h" #include "utils.h" #include "random.h" #include "timefuncs.h" diff --git a/llt/socket.c b/llt/socket.c index 2921d13..484b496 100644 --- a/llt/socket.c +++ b/llt/socket.c @@ -6,6 +6,13 @@ #include #include "dtypes.h" + +#if defined(MACOSX) || defined(MACINTEL) +#include +#include +#include +#endif + #include "socket.h" diff --git a/llt/timefuncs.c b/llt/timefuncs.c index efb8db7..fe2269b 100644 --- a/llt/timefuncs.c +++ b/llt/timefuncs.c @@ -8,6 +8,8 @@ #include #include +#include "dtypes.h" + #ifdef WIN32 #include #include @@ -18,7 +20,6 @@ #include #endif -#include "dtypes.h" #include "timefuncs.h" #ifdef WIN32 diff --git a/llt/utf8.c b/llt/utf8.c index c7d7427..3102220 100644 --- a/llt/utf8.c +++ b/llt/utf8.c @@ -18,6 +18,9 @@ #include #include #include + +#include "dtypes.h" + #ifdef WIN32 #include #define snprintf _snprintf