mirror of
https://github.com/false-schemers/skint.git
synced 2024-12-26 21:58:51 +01:00
list, vector and others; '#' ig type
This commit is contained in:
parent
57df6ae121
commit
c90e1abcf2
6 changed files with 1217 additions and 1104 deletions
5
i.c
5
i.c
|
@ -3604,7 +3604,10 @@ static obj *rds_intgtab(obj *r, obj *sp, obj *hp)
|
||||||
pe0 = pe->enc; pe1 = pe0 + strlen(pe0) + 1; assert(*pe1);
|
pe0 = pe->enc; pe1 = pe0 + strlen(pe0) + 1; assert(*pe1);
|
||||||
sprintf(lbuf, "%%!1.0u?{%s,.2%s]2}.0du?{.0a,.2%s]2}%%%%", pe1, pe0, pe0);
|
sprintf(lbuf, "%%!1.0u?{%s,.2%s]2}.0du?{.0a,.2%s]2}%%%%", pe1, pe0, pe0);
|
||||||
} break;
|
} break;
|
||||||
default: assert(0);
|
case '#': /* must have explicit lcode */
|
||||||
|
assert(0);
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
if (!lcode || *lcode == 0) continue;
|
if (!lcode || *lcode == 0) continue;
|
||||||
ra = mksymbol(internsym(pe->igname));
|
ra = mksymbol(internsym(pe->igname));
|
||||||
|
|
10
i.h
10
i.h
|
@ -342,10 +342,10 @@ declare_instruction(ntoj, "M1", 0, "inexact", '1', AUTOGL)
|
||||||
declare_instruction(min, "M2", 0, "min", 'x', AUTOGL)
|
declare_instruction(min, "M2", 0, "min", 'x', AUTOGL)
|
||||||
declare_instruction(max, "M3", 0, "max", 'x', AUTOGL)
|
declare_instruction(max, "M3", 0, "max", 'x', AUTOGL)
|
||||||
declare_instruction(listp, "L0", 0, "list?", '1', AUTOGL)
|
declare_instruction(listp, "L0", 0, "list?", '1', AUTOGL)
|
||||||
declare_instruction(list, "l", 1, "%list", -1, "%!0_!]0")
|
declare_instruction(list, "l", 1, "list", '#', "%!0_!]0")
|
||||||
declare_instrshadow(list, "L1", 1, NULL, 0, INLINED)
|
//declare_instrshadow(list, "L1", 1, NULL, 0, INLINED)
|
||||||
declare_instruction(llen, "g", 0, "length", '1', AUTOGL)
|
declare_instruction(llen, "g", 0, "length", '1', AUTOGL)
|
||||||
declare_instrshadow(llen, "L3", 0, NULL, 0, INLINED)
|
//declare_instrshadow(llen, "L3", 0, NULL, 0, INLINED)
|
||||||
declare_instruction(lget, "L4", 0, "list-ref", '2', AUTOGL)
|
declare_instruction(lget, "L4", 0, "list-ref", '2', AUTOGL)
|
||||||
declare_instruction(lput, "L5", 0, "list-set!", '3', AUTOGL)
|
declare_instruction(lput, "L5", 0, "list-set!", '3', AUTOGL)
|
||||||
declare_instruction(lcat, "L6", 0, "list-cat", '2', AUTOGL)
|
declare_instruction(lcat, "L6", 0, "list-cat", '2', AUTOGL)
|
||||||
|
@ -379,7 +379,7 @@ declare_instruction(cile, "Ci>!", 0, "char-ci<=?", 'c', AUTOGL)
|
||||||
declare_instruction(cige, "Ci<!", 0, "char-ci>=?", 'c', AUTOGL)
|
declare_instruction(cige, "Ci<!", 0, "char-ci>=?", 'c', AUTOGL)
|
||||||
|
|
||||||
declare_instruction(strp, "S0", 0, "string?", '1', AUTOGL)
|
declare_instruction(strp, "S0", 0, "string?", '1', AUTOGL)
|
||||||
declare_instruction(str, "S1", 1, "%str", -1, "%!0.0X3]1")
|
declare_instruction(str, "S1", 1, "string", '#', "%!0.0X3]1")
|
||||||
declare_instruction(smk, "S2\0'(c )", 0, "make-string", 'b', AUTOGL)
|
declare_instruction(smk, "S2\0'(c )", 0, "make-string", 'b', AUTOGL)
|
||||||
declare_instruction(slen, "S3", 0, "string-length", '1', AUTOGL)
|
declare_instruction(slen, "S3", 0, "string-length", '1', AUTOGL)
|
||||||
declare_instruction(sget, "S4", 0, "string-ref", '2', AUTOGL)
|
declare_instruction(sget, "S4", 0, "string-ref", '2', AUTOGL)
|
||||||
|
@ -399,7 +399,7 @@ declare_instruction(sile, "Si>!", 0, "string-ci<=?", 'c', AUTOGL)
|
||||||
declare_instruction(sige, "Si<!", 0, "string-ci>=?", 'c', AUTOGL)
|
declare_instruction(sige, "Si<!", 0, "string-ci>=?", 'c', AUTOGL)
|
||||||
|
|
||||||
declare_instruction(vecp, "V0", 0, "vector?", '1', AUTOGL)
|
declare_instruction(vecp, "V0", 0, "vector?", '1', AUTOGL)
|
||||||
declare_instruction(vec, "V1", 1, "%vec", -1, "%!0.0X1]1")
|
declare_instruction(vec, "V1", 1, "vector", '#', "%!0.0X1]1")
|
||||||
declare_instruction(vmk, "V2\0f", 0, "make-vector", 'b', AUTOGL)
|
declare_instruction(vmk, "V2\0f", 0, "make-vector", 'b', AUTOGL)
|
||||||
declare_instruction(vlen, "V3", 0, "vector-length", '1', AUTOGL)
|
declare_instruction(vlen, "V3", 0, "vector-length", '1', AUTOGL)
|
||||||
declare_instruction(vget, "V4", 0, "vector-ref", '2', AUTOGL)
|
declare_instruction(vget, "V4", 0, "vector-ref", '2', AUTOGL)
|
||||||
|
|
16
s.c
16
s.c
|
@ -18,11 +18,6 @@ char *s_code[] = {
|
||||||
"py19:%25residual-make-list;y4:args;;;l2:y1:_;y19:%25residual-make-list"
|
"py19:%25residual-make-list;y4:args;;;l2:y1:_;y19:%25residual-make-list"
|
||||||
";;",
|
";;",
|
||||||
|
|
||||||
"list",
|
|
||||||
"l6:y12:syntax-rules;n;l2:l1:y1:_;;l2:y5:quote;n;;;l2:l2:y1:_;y1:x;;l3:"
|
|
||||||
"y4:cons;y1:x;l2:y5:quote;n;;;;l2:l3:y1:_;y1:x;y3:...;;l3:y5:%25list;y1"
|
|
||||||
":x;y3:...;;;l2:y1:_;y14:%25residual-list;;",
|
|
||||||
|
|
||||||
"append",
|
"append",
|
||||||
"l7:y12:syntax-rules;n;l2:l1:y1:_;;l2:y5:quote;n;;;l2:l2:y1:_;y1:x;;y1:"
|
"l7:y12:syntax-rules;n;l2:l1:y1:_;;l2:y5:quote;n;;;l2:l2:y1:_;y1:x;;y1:"
|
||||||
"x;;l2:l3:y1:_;y1:x;y1:y;;l3:y8:list-cat;y1:x;y1:y;;;l2:l5:y1:_;y1:x;y1"
|
"x;;l2:l3:y1:_;y1:x;y1:y;;l3:y8:list-cat;y1:x;y1:y;;;l2:l5:y1:_;y1:x;y1"
|
||||||
|
@ -63,10 +58,6 @@ char *s_code[] = {
|
||||||
"l4:y12:syntax-rules;n;l2:py1:_;y4:args;;py5:list*;y4:args;;;l2:y1:_;y5"
|
"l4:y12:syntax-rules;n;l2:py1:_;y4:args;;py5:list*;y4:args;;;l2:y1:_;y5"
|
||||||
":list*;;",
|
":list*;;",
|
||||||
|
|
||||||
"vector",
|
|
||||||
"l4:y12:syntax-rules;n;l2:py1:_;y4:args;;py4:%25vec;y4:args;;;l2:y1:_;y"
|
|
||||||
"4:%25vec;;",
|
|
||||||
|
|
||||||
0,
|
0,
|
||||||
"&0{%3n,'1,.4I-,,#0.3,.1,.6,&3{%2:0,.1I<?{.1]2}.1,.1,:2V4c,'1,.2I-,:1^["
|
"&0{%3n,'1,.4I-,,#0.3,.1,.6,&3{%2:0,.1I<?{.1]2}.1,.1,:2V4c,'1,.2I-,:1^["
|
||||||
"22}.!0.0^_1[32}@!(y15:subvector->list)",
|
"22}.!0.0^_1[32}@!(y15:subvector->list)",
|
||||||
|
@ -142,10 +133,6 @@ char *s_code[] = {
|
||||||
";l2:py1:_;y1:r;;py14:%25vector-append;y1:r;;;l2:y1:_;y14:%25vector-app"
|
";l2:py1:_;y1:r;;py14:%25vector-append;y1:r;;;l2:y1:_;y14:%25vector-app"
|
||||||
"end;;",
|
"end;;",
|
||||||
|
|
||||||
"string",
|
|
||||||
"l4:y12:syntax-rules;n;l2:l3:y1:_;y1:c;y3:...;;l3:y4:%25str;y1:c;y3:..."
|
|
||||||
";;;l2:y1:_;y16:%25residual-string;;",
|
|
||||||
|
|
||||||
0,
|
0,
|
||||||
"&0{%3n,'1,.4I-,,#0.3,.1,.6,&3{%2:0,.1I<?{.1]2}.1,.1,:2S4c,'1,.2I-,:1^["
|
"&0{%3n,'1,.4I-,,#0.3,.1,.6,&3{%2:0,.1I<?{.1]2}.1,.1,:2S4c,'1,.2I-,:1^["
|
||||||
"22}.!0.0^_1[32}@!(y15:substring->list)",
|
"22}.!0.0^_1[32}@!(y15:substring->list)",
|
||||||
|
@ -302,9 +289,6 @@ char *s_code[] = {
|
||||||
".2C=}_1?{.0R8?{.1}{f}?{.0]2}:1P9,:1P61.0]3}'(c%0d),.1C=?{f,:0^[21}:1,."
|
".2C=}_1?{.0R8?{.1}{f}?{.0]2}:1P9,:1P61.0]3}'(c%0d),.1C=?{f,:0^[21}:1,."
|
||||||
"1W0f,:0^[21}.!0.0^_1[31}@!(y9:read-line)",
|
"1W0f,:0^[21}.!0.0^_1[31}@!(y9:read-line)",
|
||||||
|
|
||||||
0,
|
|
||||||
"&0{%!0.0]1}@!(y14:%25residual-list)",
|
|
||||||
|
|
||||||
0,
|
0,
|
||||||
"&0{%!1.0u?{f,.2,@(y10:%25make-list)[22}.0a,.2,@(y10:%25make-list)[22}@"
|
"&0{%!1.0u?{f,.2,@(y10:%25make-list)[22}.0a,.2,@(y10:%25make-list)[22}@"
|
||||||
"!(y19:%25residual-make-list)",
|
"!(y19:%25residual-make-list)",
|
||||||
|
|
8
src/k.sf
8
src/k.sf
|
@ -359,6 +359,7 @@
|
||||||
[(#\0) (= n 0)] [(#\1) (= n 1)] [(#\2) (= n 2)] [(#\3) (= n 3)]
|
[(#\0) (= n 0)] [(#\1) (= n 1)] [(#\2) (= n 2)] [(#\3) (= n 3)]
|
||||||
[(#\p) (>= n 0)] [(#\m) (>= n 1)] [(#\c) (>= n 2)] [(#\x) (>= n 1)]
|
[(#\p) (>= n 0)] [(#\m) (>= n 1)] [(#\c) (>= n 2)] [(#\x) (>= n 1)]
|
||||||
[(#\u) (<= 0 n 1)] [(#\b) (<= 1 n 2)]
|
[(#\u) (<= 0 n 1)] [(#\b) (<= 1 n 2)]
|
||||||
|
[(#\#) (>= n 0)]
|
||||||
[else #f]))
|
[else #f]))
|
||||||
|
|
||||||
(define (xform-integrable ig tail env)
|
(define (xform-integrable ig tail env)
|
||||||
|
@ -1156,6 +1157,13 @@
|
||||||
(write-char #\, port)
|
(write-char #\, port)
|
||||||
(codegen (car args) (cons #f l) f s g #f port)
|
(codegen (car args) (cons #f l) f s g #f port)
|
||||||
(write-string igc0 port)]
|
(write-string igc0 port)]
|
||||||
|
[(#\#) ; (length args) >= 0
|
||||||
|
(do ([args (reverse args) (cdr args)] [l l (cons #f l)])
|
||||||
|
[(null? args)]
|
||||||
|
(codegen (car args) l f s g #f port)
|
||||||
|
(write-char #\, port))
|
||||||
|
(write-string igc0 port)
|
||||||
|
(write-serialized-arg (length args) port)]
|
||||||
[else (error 'codegen "NYI: unsupported integrable type" igty)]))
|
[else (error 'codegen "NYI: unsupported integrable type" igty)]))
|
||||||
(when k (write-char #\] port) (write-serialized-arg k port))]
|
(when k (write-char #\] port) (write-serialized-arg k port))]
|
||||||
[call (exp . args)
|
[call (exp . args)
|
||||||
|
|
23
src/s.scm
23
src/s.scm
|
@ -273,13 +273,7 @@
|
||||||
[(_ . args) (%residual-make-list . args)]
|
[(_ . args) (%residual-make-list . args)]
|
||||||
[_ %residual-make-list]))
|
[_ %residual-make-list]))
|
||||||
|
|
||||||
(define-syntax list
|
; (list x ...)
|
||||||
(syntax-rules ()
|
|
||||||
[(_) '()]
|
|
||||||
[(_ x) (cons x '())]
|
|
||||||
[(_ x ...) (%list x ...)]
|
|
||||||
[_ %residual-list]))
|
|
||||||
|
|
||||||
; (length l)
|
; (length l)
|
||||||
; (list-ref l i)
|
; (list-ref l i)
|
||||||
; (list-set! l i x)
|
; (list-set! l i x)
|
||||||
|
@ -353,9 +347,7 @@
|
||||||
;---------------------------------------------------------------------------------------------
|
;---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
; (vector? x)
|
; (vector? x)
|
||||||
|
; (vector x ...)
|
||||||
(define-syntax vector %vec)
|
|
||||||
|
|
||||||
; (make-vector n (i #f))
|
; (make-vector n (i #f))
|
||||||
; (vector-length v)
|
; (vector-length v)
|
||||||
; (vector-ref v i)
|
; (vector-ref v i)
|
||||||
|
@ -459,16 +451,11 @@
|
||||||
;---------------------------------------------------------------------------------------------
|
;---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
; (string? x)
|
; (string? x)
|
||||||
|
; (string c ...)
|
||||||
(define-syntax string
|
|
||||||
(syntax-rules ()
|
|
||||||
[(_ c ...) (%str c ...)]
|
|
||||||
[_ %residual-string]))
|
|
||||||
|
|
||||||
; (make-string n (i #\space))
|
; (make-string n (i #\space))
|
||||||
; (string-length s)
|
; (string-length s)
|
||||||
; (string-ref x i)
|
; (string-ref x i)
|
||||||
; (string-set! x i v) %residual-string-set! (%sput x i v))
|
; (string-set! x i v)
|
||||||
; (list->string l)
|
; (list->string l)
|
||||||
; (string-cat s1 s2)
|
; (string-cat s1 s2)
|
||||||
; (substring s from to)
|
; (substring s from to)
|
||||||
|
@ -820,8 +807,6 @@
|
||||||
(let ([y (car args)])
|
(let ([y (car args)])
|
||||||
(and (f x y) (loop y (cdr args))))))))]))
|
(and (f x y) (loop y (cdr args))))))))]))
|
||||||
|
|
||||||
(define (%residual-list . l) l)
|
|
||||||
|
|
||||||
(define %residual-make-list (unary-binary-adaptor make-list))
|
(define %residual-make-list (unary-binary-adaptor make-list))
|
||||||
|
|
||||||
(define-syntax minmax-reducer
|
(define-syntax minmax-reducer
|
||||||
|
|
Loading…
Reference in a new issue