adding *error-stream* variable
removing unnecessary byte after :let in bytecode encoding adding script for easy bootstrapping
This commit is contained in:
parent
63edc82ba4
commit
c94774a5df
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mv flisp.boot flisp.boot.bak
|
||||||
|
|
||||||
|
echo "Creating stage 0 boot file..."
|
||||||
|
../../branches/interpreter/femtolisp/flisp mkboot0.lsp system.lsp compiler.lsp > flisp.boot
|
||||||
|
|
||||||
|
echo "Creating stage 1 boot file..."
|
||||||
|
./flisp mkboot1.lsp
|
||||||
|
|
||||||
|
echo "Testing..."
|
||||||
|
make test
|
|
@ -24,7 +24,7 @@
|
||||||
:loadg :loada :loadc :loadg.l
|
:loadg :loada :loadc :loadg.l
|
||||||
:setg :seta :setc :setg.l
|
:setg :seta :setc :setg.l
|
||||||
|
|
||||||
:closure :trycatch :argc :vargc :close :let :for :tapply :add2 :sub2 :neg
|
:closure :trycatch :argc :vargc :copyenv :let :for :tapply :add2 :sub2 :neg
|
||||||
|
|
||||||
dummy_t dummy_f dummy_nil]))
|
dummy_t dummy_f dummy_nil]))
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
(set! i (+ i 1)))
|
(set! i (+ i 1)))
|
||||||
|
|
||||||
((:loada :seta :call :tcall :loadv :loadg :setg
|
((:loada :seta :call :tcall :loadv :loadg :setg
|
||||||
:list :+ :- :* :/ :vector :argc :vargc :loadi8 :let)
|
:list :+ :- :* :/ :vector :argc :vargc :loadi8)
|
||||||
(io.write bcode (uint8 nxt))
|
(io.write bcode (uint8 nxt))
|
||||||
(set! i (+ i 1)))
|
(set! i (+ i 1)))
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@
|
||||||
(error (string "apply: incorrect number of arguments to " head)))
|
(error (string "apply: incorrect number of arguments to " head)))
|
||||||
(emit g :loadv (compile-f env head #t))
|
(emit g :loadv (compile-f env head #t))
|
||||||
(let ((nargs (compile-arglist g env args)))
|
(let ((nargs (compile-arglist g env args)))
|
||||||
(emit g :close)
|
(emit g :copyenv)
|
||||||
(emit g (if tail? :tcall :call) (+ 1 nargs)))))
|
(emit g (if tail? :tcall :call) (+ 1 nargs)))))
|
||||||
|
|
||||||
(define (builtin->instruction b)
|
(define (builtin->instruction b)
|
||||||
|
@ -416,7 +416,7 @@
|
||||||
(define (compile-f env f . let?)
|
(define (compile-f env f . let?)
|
||||||
(let ((g (make-code-emitter))
|
(let ((g (make-code-emitter))
|
||||||
(args (cadr f)))
|
(args (cadr f)))
|
||||||
(cond ((not (null? let?)) (emit g :let (1+ (length args))))
|
(cond ((not (null? let?)) (emit g :let))
|
||||||
((null? (lastcdr args)) (emit g :argc (length args)))
|
((null? (lastcdr args)) (emit g :argc (length args)))
|
||||||
(else (emit g :vargc (if (atom? args) 0 (length args)))))
|
(else (emit g :vargc (if (atom? args) 0 (length args)))))
|
||||||
(compile-in g (cons (to-proper args) env) #t (caddr f))
|
(compile-in g (cons (to-proper args) env) #t (caddr f))
|
||||||
|
@ -474,7 +474,7 @@
|
||||||
(set! i (+ i 1)))
|
(set! i (+ i 1)))
|
||||||
|
|
||||||
((:loada :seta :call :tcall :list :+ :- :* :/ :vector
|
((:loada :seta :call :tcall :list :+ :- :* :/ :vector
|
||||||
:argc :vargc :loadi8 :let)
|
:argc :vargc :loadi8)
|
||||||
(princ (number->string (aref code i)))
|
(princ (number->string (aref code i)))
|
||||||
(set! i (+ i 1)))
|
(set! i (+ i 1)))
|
||||||
|
|
||||||
|
|
|
@ -1,181 +1,183 @@
|
||||||
zero?
|
zero?
|
||||||
#function("n1e0_V;" [])
|
#function("n1e0_V;" [])
|
||||||
vector.map
|
vector.map
|
||||||
#function("n2b0d1e131p42;" [#function("q2b0d1e031p42;" [#function("q2_f00`S2b0lr2e0;" [#function("n1f00e0f20f21e0Z31[;" [])]) vector.alloc]) length])
|
#function("n2b0d1e131p42;" [#function("qb0d1e031p42;" [#function("q_f00`ub0lr2e0;" [#function("n1f00e0f20f21e0Z31[;" [])]) vector.alloc]) length])
|
||||||
vector->list
|
vector->list
|
||||||
#function("n1b0d1e031^p43;" [#function("q3`e0b0lr2e1;" [#function("n1f10f00e0S2Zf01Kj01;" [])]) length])
|
#function("n1b0d1e031^p43;" [#function("q`e0b0lr2e1;" [#function("n1f10f00e0uZf01Kj01;" [])]) length])
|
||||||
untrace
|
untrace
|
||||||
#function("n1b0d1e031p42;" [#function("q2e0Mb0<6U0d1f00d2d3d4d5e03131313142;];" [trace-lambda set-top-level-value! cadr caar last-pair caddr]) top-level-value])
|
#function("n1b0d1e031p42;" [#function("qe0Mb0<6T0d1f00d2d3d4d5e03131313142;];" [trace-lambda set-top-level-value! cadr caar last-pair caddr]) top-level-value])
|
||||||
|
trace
|
||||||
|
#function("n1b0d1e031p322b2;" [#function("qb0d1e031p42;" [#function("qb0d1e031p42;" [#function("qf10Mb0<@6\x920d1f20b0f00d2b3L1b4b5L2L1b6b7f20L2L2L1d8d9b:le03231b4b;L2L1d2b7f10L2L1d8e03132L136L342;];" [trace-lambda set-top-level-value! nconc begin princ "(" print quote copy-list map #function("n1b0b1b2L2b3e0L2L3;" [begin princ " " print]) ")\n"]) to-proper]) cadr]) top-level-value ok])
|
||||||
transpose
|
transpose
|
||||||
#function("n1d0d1e0Ks;" [mapcar list])
|
#function("n1d0d1e0Ks;" [mapcar list])
|
||||||
trace
|
|
||||||
#function("n1b0d1e031p322b2;" [#function("q2b0d1e031p42;" [#function("q2b0d1e031p42;" [#function("q2f10Mb0<@6\x930d1f20b0f00d2b3L1b4b5L2L1b6b7f20L2L2L1d8d9b:le03231b4b;L2L1d2b7f10L2L1d8e03132L136L342;];" [trace-lambda set-top-level-value! nconc begin princ "(" print quote copy-list map #function("n1b0b1b2L2b3e0L2L3;" [begin princ " " print]) ")\n"]) to-proper]) cadr]) top-level-value ok])
|
|
||||||
to-proper
|
to-proper
|
||||||
#function("n1e0A6;0e0;e0?6F0e0L1;e0Md0e0N31K;" [to-proper])
|
#function("n1e0A6;0e0;e0?6F0e0L1;e0Md0e0N31K;" [to-proper])
|
||||||
table.pairs
|
|
||||||
#function("n1d0b1l^e043;" [table.foldl #function("n3e0e1Ke2K;" [])])
|
|
||||||
table.keys
|
|
||||||
#function("n1d0b1l^e043;" [table.foldl #function("n3e0e2K;" [])])
|
|
||||||
table.invert
|
|
||||||
#function("n1b0d130p42;" [#function("q2d0b1l^f00332e0;" [table.foldl #function("n3d0f00e1e043;" [put!])]) table])
|
|
||||||
table.foreach
|
|
||||||
#function("n2d0b1l^e143;" [table.foldl #function("n3f00e0e1322\\;" [])])
|
|
||||||
table.values
|
table.values
|
||||||
#function("n1d0b1l^e043;" [table.foldl #function("n3e1e2K;" [])])
|
#function("n1d0b1l^e043;" [table.foldl #function("n3e1e2K;" [])])
|
||||||
|
table.foreach
|
||||||
|
#function("n2d0b1l^e143;" [table.foldl #function("n3f00e0e1322\\;" [])])
|
||||||
|
table.invert
|
||||||
|
#function("n1b0d130p42;" [#function("qd0b1l^f00332e0;" [table.foldl #function("n3d0f00e1e043;" [put!])]) table])
|
||||||
|
table.keys
|
||||||
|
#function("n1d0b1l^e043;" [table.foldl #function("n3e0e2K;" [])])
|
||||||
|
table.pairs
|
||||||
|
#function("n1d0b1l^e043;" [table.foldl #function("n3e0e1Ke2K;" [])])
|
||||||
table.clone
|
table.clone
|
||||||
#function("n1b0d130p42;" [#function("q2d0b1l^f00332e0;" [table.foldl #function("n3d0f00e0e143;" [put!])]) table])
|
#function("n1b0d130p42;" [#function("qd0b1l^f00332e0;" [table.foldl #function("n3d0f00e0e143;" [put!])]) table])
|
||||||
symbol-syntax
|
symbol-syntax
|
||||||
#function("n1d0d1e0]43;" [get *syntax-environment*])
|
#function("n1d0d1e0]43;" [get *syntax-environment*])
|
||||||
|
string.trim
|
||||||
|
#function("n3b0]]p43;" [#function("qb0li02b1li12b2d3f0031p42;" [#function("n4e2e3W16J02d0e1d1e0e232326a0f00e0e1d2e0e232e344;e2;" [string.find string.char string.inc]) #function("n3d0e2_3216R02d1e1d2e0d3e0e23232326g0f01e0e1d3e0e23243;e2;" [> string.find string.char string.dec]) #function("qd0f10f00f10f11_e034f01f10f12e03343;" [string.sub]) length])])
|
||||||
string.tail
|
string.tail
|
||||||
#function("n2d0e0d1e0_e133d2e03143;" [string.sub string.inc sizeof])
|
#function("n2d0e0d1e0_e133d2e03143;" [string.sub string.inc sizeof])
|
||||||
string.trim
|
|
||||||
#function("n3b0]]p43;" [#function("q3b0li02b1li12b2d3f0031p42;" [#function("n4e2e3W16J02d0e1d1e0e232326a0f00e0e1d2e0e232e344;e2;" [string.find string.char string.inc]) #function("n3d0e2_3216R02d1e1d2e0d3e0e23232326g0f01e0e1d3e0e23243;e2;" [> string.find string.char string.dec]) #function("q2d0f10f00f10f11_e034f01f10f12e03343;" [string.sub]) length])])
|
|
||||||
string.map
|
|
||||||
#function("n2b0d130d2e131p43;" [#function("q3b0_p322d1e041;" [#function("q2]e0f01W6a02d0f00f10d1f11e03231322d2f11e032i0530;" [io.putc string.char string.inc]) io.tostring!]) buffer length])
|
|
||||||
string.join
|
|
||||||
#function("n2e0A6;0b0;b1d230p42;" ["" #function("q2d0e0f00M322d1b2lf00N322d3e041;" [io.write for-each #function("n1d0f00f11322d0f00e042;" [io.write]) io.tostring!]) buffer])
|
|
||||||
string.rep
|
string.rep
|
||||||
#function("n2e1a4W6q0d0e1_326G0b1;e1`V6U0d2e041;e1a2V6f0d2e0e042;d2e0e0e043;d3e1316\x8c0d2e0d4e0e1`S23242;d4d2e0e032e1a2U242;" [<= "" string odd? string.rep])
|
#function("n2e1a4W6q0d0e1_326G0b1;e1`V6U0d2e041;e1a2V6f0d2e0e042;d2e0e0e043;d3e1316\x8b0d2e0d4e0e1`u3242;d4d2e0e032e1a2U242;" [<= "" string odd? string.rep])
|
||||||
|
string.join
|
||||||
|
#function("n2e0A6;0b0;b1d230p42;" ["" #function("qd0e0f00M322d1b2lf00N322d3e041;" [io.write for-each #function("n1d0f00f11322d0f00e042;" [io.write]) io.tostring!]) buffer])
|
||||||
|
string.map
|
||||||
|
#function("n2b0d130d2e131p43;" [#function("qb0_p322d1e041;" [#function("q]e0f01W6`02d0f00f10d1f11e03231322d2f11e032i0520;" [io.putc string.char string.inc]) io.tostring!]) buffer length])
|
||||||
splice-form?
|
splice-form?
|
||||||
#function("n1e0F16K02e0Mb0<17K02e0Mb1<17U02e0b2<;" [*comma-at* *comma-dot* *comma*])
|
#function("n1e0F16K02e0Mb0<17K02e0Mb1<17U02e0b2<;" [*comma-at* *comma-dot* *comma*])
|
||||||
set-syntax!
|
set-syntax!
|
||||||
#function("n2d0d1e0e143;" [put! *syntax-environment*])
|
#function("n2d0d1e0e143;" [put! *syntax-environment*])
|
||||||
separate
|
|
||||||
#function("n2f00e0e1^^44;" [] #0=[#function("n4e1A6>0e2e3K;e0e1M316[0f00e0e1Ne1Me2Ke344;f00e0e1Ne2e1Me3K44;" [] #0#) ()])
|
|
||||||
reverse
|
|
||||||
#function("n1d0d1^e043;" [foldl cons])
|
|
||||||
revappend
|
|
||||||
#function("n2d0d1e031e142;" [nconc reverse])
|
|
||||||
remainder
|
|
||||||
#function("n2e0e0e1U2e1T2S2;" [])
|
|
||||||
ref-uint32-LE
|
|
||||||
#function("n2d0e0e1_tZ_32d0e0e1`tZa832d0e0e1a2tZa@32d0e0e1a3tZaH32R4;" [ash])
|
|
||||||
ref-uint16-LE
|
|
||||||
#function("n2d0e0e1_tZ_32d0e0e1`tZa832t;" [ash])
|
|
||||||
repl
|
|
||||||
#function("n0b0]]p43;" [#function("q3b0li02b1li12e1302d240;" [#function("n0d0b1312d2d3312b4b5lb6lmp42;" [princ "> " io.flush *output-stream* #function("q2d0d131@16I02b2d3e031p42;" [io.eof? *input-stream* #function("q2d0e0312e0h12\\;" [print that]) load-process]) #function("n0d040;" [read]) #function("n1d0d1312d2e041;" [io.discardbuffer *input-stream* raise])]) #function("n0b0lb1lm6G0d2302f0140;];" [#function("n0f003016@02d040;" [newline]) #function("n1d0e041;" [print-exception]) newline]) newline])])
|
|
||||||
self-evaluating?
|
self-evaluating?
|
||||||
#function("n1e0?16>02e0C@17_02d0e03116_02e0C16_02e0d1e031<;" [constant? top-level-value])
|
#function("n1e0?16>02e0C@17_02d0e03116_02e0C16_02e0d1e031<;" [constant? top-level-value])
|
||||||
|
repl
|
||||||
|
#function("n0b0]]p43;" [#function("qb0li02b1li12e1302d240;" [#function("n0d0b1312d2d3312b4b5lb6lmp42;" [princ "> " io.flush *output-stream* #function("qd0d131@16H02b2d3e031p42;" [io.eof? *input-stream* #function("qd0e0312e0h12\\;" [print that]) load-process]) #function("n0d040;" [read]) #function("n1d0d1312d2e041;" [io.discardbuffer *input-stream* raise])]) #function("n0b0lb1lm6G0d2302f0140;];" [#function("n0f003016@02d040;" [newline]) #function("n1d0e041;" [print-exception]) newline]) newline])])
|
||||||
|
revappend
|
||||||
|
#function("n2d0d1e031e142;" [nconc reverse])
|
||||||
|
reverse
|
||||||
|
#function("n1d0d1^e043;" [foldl cons])
|
||||||
|
separate
|
||||||
|
#function("n2f00e0e1^^44;" [] #0=[#function("n4e1A6>0e2e3K;e0e1M316[0f00e0e1Ne1Me2Ke344;f00e0e1Ne2e1Me3K44;" [] #0#) ()])
|
||||||
|
ref-uint16-LE
|
||||||
|
#function("n2d0e0e1_tZ_32d0e0e1`tZa832t;" [ash])
|
||||||
|
ref-uint32-LE
|
||||||
|
#function("n2d0e0e1_tZ_32d0e0e1`tZa832d0e0e1a2tZa@32d0e0e1a3tZaH32R4;" [ash])
|
||||||
|
remainder
|
||||||
|
#function("n2e0e0e1U2e1T2u;" [])
|
||||||
quote-value
|
quote-value
|
||||||
#function("n1d0e0316>0e0;b1e0L2;" [self-evaluating? quote])
|
#function("n1d0e0316>0e0;b1e0L2;" [self-evaluating? quote])
|
||||||
|
print-exception
|
||||||
|
#function("n1b0]]p43;" [#function("qb0li02b1li12f00F16[02f00Mb2<16[02d3f00a4326\x850e0b4d5f0031b6d7f0031b8352e1d9f0031315G1f00F16\x9f02f00Mb:<16\x9f02f00NF6\xb40e0b;d5f0031b<335G1f00F16\xc402f00Mb=<6\xd80e0b>312e0f00NQ5G1f00F16\xe802f00Mb?<6\x070d@d7f0031312e0bAd5f0031325G1dBf003116\x1c02d3f00a232691e0f00MbC322bDd5f0031p325G1e0bE312e1f00312e0dF312\\;" [#function("o0d0d1e0Ks;" [io.princ *error-stream*]) #function("o0d0d1e0Ks;" [io.print *error-stream*]) type-error length= "type-error: " cadr ": expected " caddr ", got " cadddr unbound-error "unbound-error: eval: variable " " has no value" error "error: " load-error print-exception "in file " list? ": " #function("qd0e03117?02e0C6H0f005K0f01e041;" [string?]) "*** Unhandled exception: " *linefeed*])])
|
||||||
|
print-to-string
|
||||||
|
#function("n1b0d130p42;" [#function("qd0e0f00322d1e041;" [io.print io.tostring!]) buffer])
|
||||||
println
|
println
|
||||||
#function("o0d0e0Qd1302;" [print newline])
|
#function("o0d0e0Qd1302;" [print newline])
|
||||||
print-to-string
|
|
||||||
#function("n1b0d130p42;" [#function("q2d0e0f00322d1e041;" [io.print io.tostring!]) buffer])
|
|
||||||
print-exception
|
|
||||||
#function("n1e0F16M02e0Mb0<16M02d1e0a4326x0d2d3b4d5e031b6d7e031b8362d9d3d:e03132591e0F16\x8f02e0Mb;<16\x8f02e0NF6\xa50d2d3b<d5e031b=34591e0F16\xb302e0Mb><6\xcb0d2d3b?322d2d3e0NKQ591e0F16\xd902e0Mb@<6\xf80dAd7e031312d2d3bBd5e03133591dCe03116\x0b02d1e0a2326(0d2d3e0MbD332bEd5e031p32591d2d3bF322d9d3e0322d2d3dG322\\;" [type-error length= io.princ *stderr* "type-error: " cadr ": expected " caddr ", got " io.print cadddr unbound-error "unbound-error: eval: variable " " has no value" error "error: " load-error print-exception "in file " list? ": " #function("q2d0e03117@02e0C6H0d15J0d2d3e042;" [string? io.princ io.print *stderr*]) "*** Unhandled exception: " *linefeed*])
|
|
||||||
print
|
print
|
||||||
#function("o0d0d1e0Ks;" [io.print *output-stream*])
|
#function("o0d0d1e0Ks;" [io.print *output-stream*])
|
||||||