mirror of
https://github.com/false-schemers/skint.git
synced 2024-12-26 21:58:51 +01:00
file open refactoring -- done
This commit is contained in:
parent
c35bba32ec
commit
aac5aa4993
4 changed files with 36 additions and 14 deletions
13
i.c
13
i.c
|
@ -2727,6 +2727,19 @@ define_instruction(intp) {
|
|||
gonexti();
|
||||
}
|
||||
|
||||
define_instruction(ratp) {
|
||||
if (likely(is_fixnum(ac))) {
|
||||
ac = bool_obj(1);
|
||||
} else if (likely(is_flonum(ac))) {
|
||||
double f = get_flonum(ac);
|
||||
ac = bool_obj(f > -HUGE_VAL && f < HUGE_VAL);
|
||||
} else {
|
||||
ac = bool_obj(0);
|
||||
}
|
||||
gonexti();
|
||||
}
|
||||
|
||||
|
||||
define_instruction(nanp) {
|
||||
if (unlikely(is_fixnum(ac))) {
|
||||
ac = bool_obj(0);
|
||||
|
|
2
i.h
2
i.h
|
@ -348,6 +348,7 @@ declare_instruction(tan, "N5", 0, "tan",
|
|||
declare_instruction(asin, "N6", 0, "asin", '1', AUTOGL)
|
||||
declare_instruction(acos, "N7", 0, "acos", '1', AUTOGL)
|
||||
declare_instruction(atan, "N8\0f", 0, "atan", 'b', AUTOGL)
|
||||
declare_instruction(ratp, "Nv", 0, "rational?", '1', AUTOGL)
|
||||
declare_instruction(intp, "Nw", 0, "integer?", '1', AUTOGL)
|
||||
declare_instruction(nanp, "Nu", 0, "nan?", '1', AUTOGL)
|
||||
declare_instruction(finp, "Nf", 0, "finite?", '1', AUTOGL)
|
||||
|
@ -528,7 +529,6 @@ declare_instruction(igco, "U8", 0, "integrable-code",
|
|||
/* inlined integrables (no custom instructions) */
|
||||
declare_integrable(NULL, "N0", 0, "complex?", '1', AUTOGL)
|
||||
declare_integrable(NULL, "N0", 0, "real?", '1', AUTOGL)
|
||||
declare_integrable(NULL, "N0", 0, "rational?", '1', AUTOGL)
|
||||
declare_integrable(NULL, "I0", 0, "exact-integer?", '1', AUTOGL)
|
||||
declare_integrable(NULL, "%nI0", 0, "exact?", '1', AUTOGL)
|
||||
declare_integrable(NULL, "%nJ0", 0, "inexact?", '1', AUTOGL)
|
||||
|
|
25
s.c
25
s.c
|
@ -2,12 +2,6 @@
|
|||
|
||||
char *s_code[] = {
|
||||
|
||||
"C", 0,
|
||||
"@(y16:%25open-input-file)@!(y15:open-input-file)"
|
||||
"@(y17:%25open-output-file)@!(y16:open-output-file)"
|
||||
"@(y23:%25open-binary-input-file)@!(y22:open-binary-input-file)"
|
||||
"@(y24:%25open-binary-output-file)@!(y23:open-binary-output-file)",
|
||||
|
||||
"S", "let-syntax",
|
||||
"l4:y12:syntax-rules;n;l2:l2:y1:_;l2:l2:y2:kw;y4:init;;y3:...;;;l1:y5:b"
|
||||
"egin;;;l2:py1:_;pl2:l2:y2:kw;y4:init;;y3:...;;y5:forms;;;l3:py13:synta"
|
||||
|
@ -734,6 +728,21 @@ char *s_code[] = {
|
|||
"C", 0,
|
||||
"@(y5:port?)@!(y12:binary-port?)",
|
||||
|
||||
"P", "open-input-file",
|
||||
"%1.0P40,.0?{.0]2}.1,'(s22:cannot open input file),@(y10:file-error)[22",
|
||||
|
||||
"P", "open-output-file",
|
||||
"%1.0P41,.0?{.0]2}.1,'(s23:cannot open output file),@(y10:file-error)[2"
|
||||
"2",
|
||||
|
||||
"P", "open-binary-input-file",
|
||||
"%1.0P42,.0?{.0]2}.1,'(s29:cannot open binary input file),@(y10:file-er"
|
||||
"ror)[22",
|
||||
|
||||
"P", "open-binary-output-file",
|
||||
"%1.0P43,.0?{.0]2}.1,'(s30:cannot open binary output file),@(y10:file-e"
|
||||
"rror)[22",
|
||||
|
||||
"P", "close-port",
|
||||
"%1.0P00?{.0P60}.0P01?{.0P61]1}]1",
|
||||
|
||||
|
@ -742,10 +751,10 @@ char *s_code[] = {
|
|||
"st)[12},.1,.3,&2{%0:1,:0[01},@(y16:call-with-values)[22",
|
||||
|
||||
"P", "call-with-input-file",
|
||||
"%2.1,.1P40,@(y14:call-with-port)[22",
|
||||
"%2.1,${.3,@(y15:open-input-file)[01},@(y14:call-with-port)[22",
|
||||
|
||||
"P", "call-with-output-file",
|
||||
"%2.1,.1P41,@(y14:call-with-port)[22",
|
||||
"%2.1,${.3,@(y16:open-output-file)[01},@(y14:call-with-port)[22",
|
||||
|
||||
"P", "read-line",
|
||||
"%!0P51,.1u?{P10}{.1a},t,,#0.2,.4,.2,&3{%1:2R0,.0R8,.0?{.0}{'(c%0a),.2C"
|
||||
|
|
10
src/s.scm
10
src/s.scm
|
@ -473,7 +473,7 @@
|
|||
; (number? x)
|
||||
; (complex? x) == number? what about inf and nan?
|
||||
; (real? x) == number? what about inf and nan?
|
||||
; (rational? x) == number? what about inf and nan?
|
||||
; (rational? x)
|
||||
; (integer? x)
|
||||
; (exact? x)
|
||||
; (inexact? x)
|
||||
|
@ -1376,19 +1376,19 @@
|
|||
(define textual-port? port?) ; all ports are bimodal
|
||||
(define binary-port? port?) ; all ports are bimodal
|
||||
|
||||
(define-inline (open-input-file fn)
|
||||
(define (open-input-file fn)
|
||||
(or (%open-input-file fn)
|
||||
(file-error "cannot open input file" fn)))
|
||||
|
||||
(define-inline (open-output-file fn)
|
||||
(define (open-output-file fn)
|
||||
(or (%open-output-file fn)
|
||||
(file-error "cannot open output file" fn)))
|
||||
|
||||
(define-inline (open-binary-input-file fn)
|
||||
(define (open-binary-input-file fn)
|
||||
(or (%open-binary-input-file fn)
|
||||
(file-error "cannot open binary input file" fn)))
|
||||
|
||||
(define-inline (open-binary-output-file fn)
|
||||
(define (open-binary-output-file fn)
|
||||
(or (%open-binary-output-file fn)
|
||||
(file-error "cannot open binary output file" fn)))
|
||||
|
||||
|
|
Loading…
Reference in a new issue