ref: a39283b2e8309b551459f992bc981da20c11e3cd
parent: 70b910bc7b5f1354c70cd297e4887cc178866a9a
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Mar 14 00:41:15 EDT 2025
vector → vec
--- a/boot/sl.boot
+++ b/boot/sl.boot
@@ -9,7 +9,7 @@
#fn("z0700}2:" #(+)) #fn("z0700}2:" #(-))
#fn("z0700}2:" #(*)) #fn("z0700}2:" #(/))
#fn("z0700}2:" #(div0)) #fn("z0700}2:" #(=))
- #fn("n201m:" #()) NIL #fn("z0700}2:" #(vector))
+ #fn("n201m:" #()) NIL #fn("z0700}2:" #(vec))
#fn("z0700}2:" #(aset!)) NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL #fn("n3012082>1|:" #(#fn("n1A061:" #())))
NIL NIL NIL NIL NIL NIL NIL NIL #fn("z0700}2:" #(aref)) NIL NIL NIL)
*properties* #table(*funvars* #table(*prompt* (NIL) lz-unpack ((data :to destination)
@@ -16,7 +16,7 @@
(data :size
decompressed-bytes)) void? ((x)) >= ((a . rest)) defstruct ((name
doc options... (slot-1 DEFAULT) slot-2 (slot-3 :read-only))
- (name (:type vector) (:named T) (:constructor T) (:conc-name NIL) (:predicate NIL) . slots)) help ((term)) length= ((lst
+ (name (:type vec) (:named T) (:constructor T) (:conc-name NIL) (:predicate NIL) . slots)) help ((term)) length= ((lst
n)) __finish ((status)) doc-for ((term (doc NIL))) rand-u32 (NIL) = ((a . rest)) rand-u64 (NIL) car ((lst)) <= ((a . rest)) add-exit-hook ((fun)) /= ((a . rest)) lz-pack ((data
(level 0))) rand (NIL) nan? ((x)) rand-float (NIL) void (rest) cons? ((value)) vm-stats (NIL) rand-double (NIL) * ((num…)) cdr ((lst)) + ((num…)) > ((a . rest))) *doc* #table(>= "Return T if the arguments are in non-increasing order (previous\none is greater than or equal to the next one)." void? "Return T if x is #<void>, NIL otherwise." length= "Bounded length test.\nUse this instead of (= (length lst) n), since it avoids unnecessary\nwork and always terminates." doc-for "Define documentation for a top level term.\nIf the optional doc argument is missing and the term is a function\nsignture, adds it to the documentation." car "Return the first element of a list or NIL if not available." *builtins* "VM instructions as closures." <= "Return T if the arguments are in non-decreasing order (previous\none is less than or equal to the next one)." void "Return the constant #<void> while ignoring any arguments.\n#<void> is mainly used when a function has side effects but does not\nproduce any meaningful value to return, so even though T or NIL could\nbe returned instead, in case of #<void> alone, REPL will not print\nit." rand "Return a random non-negative fixnum on its maximum range." nan? "Return T if the argument is NaN, regardless of the sign." Instructions "VM instructions mapped to their encoded byte representation." rand-double "Return a random double on [0.0, 1.0] interval." > "Return T if the arguments are in strictly decreasing order (previous\none is greater than the next one)." cdr "Return the tail of a list or NIL if not available." + "Return sum of the numbers or 0 with no arguments." __finish "A function called right before exit by the VM." lz-unpack "Return decompressed data previously compressed using lz-pack.\nEither destination for the decompressed data or the expected size of\nthe decompressed data must be specified. In the latter case a new\narray is allocated." help "Display documentation for the specified term, if available." defstruct "Defines a structure type with a specific name and slots.\nThe default underlying type is a named vector, ie the first element is\nthe name of the structure type, the rest are the slot values. If the\nname as the first element isn't required, \":named NIL\" should be\nused. A list can be used instead of a vector by adding \":type list\"\noption.\n\nThe option :conc-name specifies the slot accessor prefix, which\ndefaults to \"name-\".\n\nDefault predicate name (\"name?\") can be changed:\n (defstruct blah :predicate blargh? a b c)" rand-u32 "Return a random integer on [0, 2³²-1] interval." = "Return T if the arguments are equal." rand-u64 "Return a random integer on [0, 2⁶⁴-1] interval." add-exit-hook "Puts an one-argument function on top of the list of exit hooks.\nOn shutdown each exit hook is called with the exit status as a single\nargument, which is (usually) 0 on success and any other number on\nerror." /= "Return T if not all arguments are equal. Shorthand for (not (= …))." lz-pack "Return data compressed using Lempel-Ziv.\nThe data must be an array, returned value will have the same type.\nThe optional level is between 0 and 10. With level 0 a simple LZSS\nusing hashing will be performed. Levels between 1 and 9 offer a\ntrade-off between time/space and ratio. Level 10 is optimal but very\nslow." arg-counts "VM instructions mapped to their expected arguments count." rand-float "Return a random float on [0.0, 1.0] interval." *prompt* "Function called by REPL to signal the user input is required.\nDefault function prints \"#;> \"." cons? "Return T if the value is a cons cell." vm-stats "Print various VM-related information, such as the number of GC calls\nso far, heap and stack size, etc." * "Return product of the numbers or 1 with no arguments." *properties* "All properties of symbols recorded with putprop are recorded in this table."))
*syntax-environment* #table(bcode:nconst #fn("n1200r2e3:" #(aref)) doc-for #fn("\x8710002000W1000J60q?140B86;35040<;J404086;35040=863H020212287e212288e2e4e2:20212287e21e3e2:" #(void
@@ -38,8 +38,8 @@
*doc* princ newline #fn(for-each) #fn("n17050471A0P61:" #(newline print)) *funvars* "no help for "
void)) defstruct #fn("O10005000*///W1000J7071?14W2000J60D?24W3000J60D?34W4000J60q?44W5000J60q?54z6IIb;228;230>1_5142224?<5142586<51;360486<8=;360486=;J50486268>5127288>528<8>51292:12;525185;J>04292:02;525183;3`0483H;3Q0483DQ;3>04292:2<05251;J504838AP;J5048382;36040e184;J:042:02=522>2?e12@8C2Ae22B8B2Ae22C2D2E8Ee2e22F2G2AEe32E0e2e3e32H2I2Ae2268E518?Me3e4e3e12J8=2K2E0e28=e3e3e18D3X02@8D2>1e12>2Ee12L8E5152e12L8@5153e3@30qe12L7M2N8;8A8@8F8C8E0>78?525165:" #(#(NIL
NIL :named 1 :conc-name 3 :type 0 NIL NIL NIL NIL NIL NIL :predicate 4 NIL NIL NIL NIL NIL NIL
- :constructor 2) vector #0# #fn("n17005121220A>28552485:" #(cddr #fn(for-each)
- #fn("n17002152340q:722324A<25F2605661:" #(member
+ :constructor 2) vec #0# #fn("n17005121220A>28552485:" #(cddr #fn(for-each)
+ #fn("n17002152340q:722324A<25F2605661:" #(member
(:read-only) error #fn(str) "invalid option in slot " " of struct " ": "))) slot-opts)
#fn("n17021062:" #(map! #fn("n10B;35040<85;J404085;35040=;J604qe186RS;J9042086513=071228652@30q4232425268652512087<51390q87P@408762:" #(#fn(keyword?)
error "invalid slot name: " #fn(list*) #fn(symbol)
@@ -65,7 +65,7 @@
<= #fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JL041<0L2;J5040V340q:A<1<1=62:" #())) <=)
> #fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JE041<0L2;3;04A<1<1=62:" #())) >) >=
#fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JL0401<L2;J5040V340q:A<1<1=62:" #())) >=)
- Instructions #table(call.l #byte(0x51) trycatch #byte(0x4b) loadg.l #byte(0x44) aref2 #byte(0x17) box #byte(0x32) cadr #byte(0x24) argc #byte(0x3e) setg #byte(0x47) load0 #byte(0x15) nan? #byte(0x26) vector? #byte(0x2d) fixnum? #byte(0x29) loadc0 #byte(0x11) loada0 #byte(0x0) div0 #byte(0x3b) keyargs #byte(0x1f) call #byte(0x5) loada.l #byte(0x45) num? #byte(0x28) sub2 #byte(0x4e) add2 #byte(0x1d) loadc.l #byte(0x46) loadc #byte(0x9) builtin? #byte(0x2b) set-car! #byte(0x2f) vargc.l #byte(0x50) ret #byte(0xa) loadi8 #byte(0x42) tapply #byte(0x4d) loadvoid #byte(0x19) loada1 #byte(0x1) shift #byte(0x2e) atom? #byte(0x18) cdr #byte(0xd) brne.l #byte(0x53) / #byte(0x3a) equal? #byte(0x34) apply #byte(0x36) dup #byte(0xb) loadt #byte(0x14) jmp.l #byte(0x30) = #byte(0x3c) not #byte(0x23) set-cdr! #byte(0x1e) eq? #byte(0x21) * #byte(0x39) load1 #byte(0x1b) bound? #byte(0x2a) function? #byte(0x2c) box.l #byte(0x56) < #byte(0x1c) brnn.l #byte(0x54) jmp #byte(0x10) loadv #byte(0x2) for #byte(0x4c) dummy_eof #byte(0x58) + #byte(0x37) brne #byte(0x13) argc.l #byte(0x4f) compare #byte(0x3d) brn #byte(0x3) neg #byte(0x25) loadv.l #byte(0x43) vargc #byte(0x4a) brbound #byte(0x27) vector #byte(0x3f) loadc1 #byte(0x16) setg.l #byte(0x48) cons? #byte(0x12) aref #byte(0x55) symbol? #byte(0x22) aset! #byte(0x40) car #byte(0xc) cons #byte(0x20) tcall.l #byte(0x52) - #byte(0x38) brn.l #byte(0x31) optargs #byte(0x57) closure #byte(0xe) pop #byte(0x4) eqv? #byte(0x33) list #byte(0x35) seta #byte(0xf) seta.l #byte(0x49) brnn #byte(0x1a) loadnil #byte(0x41) loadg #byte(0x7) loada #byte(0x8) tcall #byte(0x6))
+ Instructions #table(call.l #byte(0x51) trycatch #byte(0x4b) loadg.l #byte(0x44) aref2 #byte(0x17) box #byte(0x32) cadr #byte(0x24) argc #byte(0x3e) setg #byte(0x47) load0 #byte(0x15) nan? #byte(0x26) fixnum? #byte(0x29) loadc0 #byte(0x11) loada0 #byte(0x0) div0 #byte(0x3b) keyargs #byte(0x1f) call #byte(0x5) loada.l #byte(0x45) num? #byte(0x28) sub2 #byte(0x4e) add2 #byte(0x1d) loadc.l #byte(0x46) loadc #byte(0x9) builtin? #byte(0x2b) set-car! #byte(0x2f) vargc.l #byte(0x50) vec #byte(0x3f) ret #byte(0xa) loadi8 #byte(0x42) tapply #byte(0x4d) loadvoid #byte(0x19) loada1 #byte(0x1) shift #byte(0x2e) atom? #byte(0x18) cdr #byte(0xd) brne.l #byte(0x53) / #byte(0x3a) equal? #byte(0x34) apply #byte(0x36) dup #byte(0xb) loadt #byte(0x14) jmp.l #byte(0x30) = #byte(0x3c) not #byte(0x23) set-cdr! #byte(0x1e) eq? #byte(0x21) * #byte(0x39) load1 #byte(0x1b) bound? #byte(0x2a) function? #byte(0x2c) box.l #byte(0x56) < #byte(0x1c) brnn.l #byte(0x54) jmp #byte(0x10) loadv #byte(0x2) for #byte(0x4c) dummy_eof #byte(0x58) + #byte(0x37) brne #byte(0x13) argc.l #byte(0x4f) compare #byte(0x3d) brn #byte(0x3) neg #byte(0x25) loadv.l #byte(0x43) vargc #byte(0x4a) brbound #byte(0x27) loadc1 #byte(0x16) setg.l #byte(0x48) cons? #byte(0x12) aref #byte(0x55) symbol? #byte(0x22) aset! #byte(0x40) car #byte(0xc) cons #byte(0x20) tcall.l #byte(0x52) - #byte(0x38) brn.l #byte(0x31) optargs #byte(0x57) closure #byte(0xe) vec? #byte(0x2d) pop #byte(0x4) eqv? #byte(0x33) list #byte(0x35) seta #byte(0xf) seta.l #byte(0x49) brnn #byte(0x1a) loadnil #byte(0x41) loadg #byte(0x7) loada #byte(0x8) tcall #byte(0x6))
__finish #fn("n120210>17262:" #(#fn(for-each)
#fn("n10A61:" #()) *exit-hooks*) __finish)
__init_globals #fn("n07021d37022@402384w4^147025d;350426;J50427w8429w:4qw;47<w=47>w?47@wA:" #(*os-name*
@@ -86,7 +86,7 @@
#fn(exit)) __start)
abs #fn("n10EL23500U:0:" #() abs) add-exit-hook
#fn("n1070Pw047160:" #(*exit-hooks* void) add-exit-hook) any #fn("n21B;3D0401<51;J:047001=62:" #(any) any)
- arg-counts #table(bound? 1 function? 1 symbol? 1 car 1 cons 2 cadr 1 nan? 1 for 3 fixnum? 1 vector? 1 cdr 1 atom? 1 div0 2 equal? 2 eqv? 2 compare 2 not 1 set-cdr! 2 num? 1 eq? 2 builtin? 1 cons? 1 set-car! 2)
+ arg-counts #table(bound? 1 function? 1 symbol? 1 car 1 cons 2 cadr 1 nan? 1 for 3 fixnum? 1 cdr 1 atom? 1 div0 2 vec? 1 equal? 2 eqv? 2 compare 2 not 1 set-cdr! 2 num? 1 eq? 2 builtin? 1 cons? 1 set-car! 2)
argc-error #fn("n2702102211Kl237023@402465:" #(error "compile error: " " expects " " argument."
" arguments.") argc-error)
array? #fn("n10];JF042005185B;390485<21Q:" #(#fn(typeof) array) array?) assoc
@@ -103,11 +103,11 @@
bq-bracket1 #fn("n20B3S00<20CL01El23500T:7122730=1K~52e3:730162:" #(unquote cons 'unquote
bq-process) bq-bracket1)
bq-process #fn("n20R380200e2:0]3T0717205115286<73C907486=P:757486e3:0H3400:0<26CB07327710T1KM52e3:0<28CV01El23?0790r2523500T:7:2;710=1K~52e3:7<7=052Jt07>0512?2@1>105286J807387P:87=JA07:87<7186152e3:2A7B87P7186152e162:Ib6862C186>2_486<^10q62:" #(quote
- bq-process vector->list list vector apply quasiquote 'quasiquote unquote length= cons 'unquote
- any splice-form? lastcdr #fn(map) #fn("n1700A62:" #(bq-bracket1))
+ bq-process vec->list list vec apply quasiquote 'quasiquote unquote length= cons 'unquote any
+ splice-form? lastcdr #fn(map) #fn("n1700A62:" #(bq-bracket1))
#fn(nconc) list* #fn("n20J;02071151P:0B3o00<22CX020731AEl23700=@C07425e2760=AK~52e252P:F<0=770<A521P62:2071760A521P51P:" #(nconc
reverse! unquote nreconc list 'unquote bq-process bq-bracket))) bq-process)
- builtin->instruction #fn("n120A0q63:" #(#fn(get)) #(#table(#.cadr cadr #.aset! aset! #.+ + #.- - #.equal? equal? #.eq? eq? #.builtin? builtin? #.not not #.cons? cons? #.cdr cdr #./ / #.div0 div0 #.set-car! set-car! #.vector vector #.set-cdr! set-cdr! #.< < #.aref aref #.for for #.cons cons #.apply apply #.eqv? eqv? #.vector? vector? #.list list #.car car #.bound? bound? #.nan? nan? #.function? function? #.symbol? symbol? #.compare compare #.fixnum? fixnum? #.atom? atom? #.= = #.num? num? #.* *)))
+ builtin->instruction #fn("n120A0q63:" #(#fn(get)) #(#table(#.cadr cadr #.aset! aset! #.+ + #.- - #.equal? equal? #.eq? eq? #.builtin? builtin? #.not not #.cons? cons? #.cdr cdr #./ / #.div0 div0 #.set-car! set-car! #.vec vec #.set-cdr! set-cdr! #.< < #.aref aref #.for for #.cons cons #.apply apply #.eqv? eqv? #.vec? vec? #.list list #.car car #.bound? bound? #.nan? nan? #.function? function? #.symbol? symbol? #.compare compare #.fixnum? fixnum? #.atom? atom? #.= = #.num? num? #.* *)))
caaaar #fn("n10<<<<:" #() caaaar) caaadr
#fn("n10T<<:" #() caaadr) caaar #fn("n10<<<:" #() caaar) caadar
#fn("n10<T<:" #() caadar) caaddr #fn("n10=T<:" #() caaddr) caadr
@@ -140,7 +140,7 @@
compile-builtin-call #fn("n7I202186850>3?;514227385q538<3I07483=8<52J=075858<52@30q4858=26CL086El23:07702862:770858663:8=29C708;60:8=2:C708;60:8=2;C]086El23:07702<62:86r2l23:07702=62:770858663:8=2>Cm086El23:07585K62:86Kl23:07702?62:86r2l23:07702@62:770858663:8=2ACL086El23:07702B62:770858663:8=2CCL086El23:07585K62:770858663:8=2DCN086El23<07702E2F63:770858663:8=2GCX086r2L23;07585r262:770823702H@402G8663:8=2ICb086r2l23:07702J62:r286L23?07708586r3~63:7585r262:7708562:" #(#0#
#fn("n0AEl239070FK62:7192FA63:" #(argc-error emit) num-compare)
#fn(get) arg-counts length= argc-error list emit loadnil < = + load0 add2 - neg sub2 * load1 /
- vector loadv #() apply tapply aref aref2) compile-builtin-call)
+ vec loadv #() apply tapply aref aref2) compile-builtin-call)
compile-f #fn("n2702101>22262:" #(call-with-values #fn("n070AF62:" #(compile-f-))
#fn("n20:" #())) compile-f)
compile-f- #fn("n270501T711T517215173741T52711518;J7025@408;87H360E@802687518=268:51~73778:528:3\xa208?JL07886298>883808=U@408=54@r07:867;2<7=2<7>8?527?268?5151535152478862@8>268?51883808=U@408=5547A8608:898>55@30q42B8=L23I07886883702C@402D8=53@W0883?078862E8=53@E08:J?078862F8=53@30q47G0897H7I1518952537J868@<52486r4268951r4Mp47K868@D7I15154478862L5247M2N7O86EG517P86518<5386r3G62:" #(make-code-emitter
@@ -181,7 +181,7 @@
complex-bindings- #fn("n61J40q:0R3K0833D02001523;021840D63:q:0H;J80472051340q:0<23Co0200T1523Q021850TD534833>021840TD53@30q@30q474750511q83848566:760<513U074770517817905152q82S;J50483848566:740<17:051838485562;2<1838485>40=52P:" #(#fn(memq)
#fn(put!) quoted? set! complex-bindings- caddr lambda? lambda:body diff lambda:vars inlineable?
#fn(map) #fn("n1700AqF929366:" #(complex-bindings-))) complex-bindings-)
- const-to-idx-vec #fn("n1200r2G51212285>10KG52485:" #(#fn(vector-alloc)
+ const-to-idx-vec #fn("n1200r2G51212285>10KG52485:" #(#fn(vec-alloc)
#fn(for-each)
#fn("n2A10p:" #())) const-to-idx-vec)
copy-tree #fn("n10H3400:700<51700=51P:" #(copy-tree) copy-tree) count
@@ -199,7 +199,7 @@
": " " ") print-inst)
#fn(length) #fn(table-foldl) #fn("n382;J@041AF<Gl2;34040:" #()) Instructions #fn("n1702161:" #(princ
"\t")) #fn(memq) (loadv.l loadg.l setg.l) ref-s32-LE (loadv loadg setg)
- (loada seta loadc call tcall list + - * / < = vector argc vargc loadi8 apply tapply closure box
+ (loada seta loadc call tcall list + - * / < = vec argc vargc loadi8 apply tapply closure box
shift aref) princ #fn(num->str) aref (loada.l seta.l loadc.l argc.l vargc.l call.l tcall.l box.l)
(optargs keyargs) keyargs " " brbound (jmp brne brnn brn) "@" hex5 ref-s16-LE (jmp.l brne.l
brnn.l brn.l)) disassemble)
@@ -213,7 +213,7 @@
emit-optional-arg-inits #fn("n582B3\x91020507102284534710238953474075176838452q53q7782515447102884534710295247102:895347;0182=8384KM65:q:" #(#fn(gensym)
emit brbound brnn compile-in extend-env list-head cadar seta pop label emit-optional-arg-inits) emit-optional-arg-inits)
encode-byte-code #fn("n17005171855172238651r3238651r2ki2M2452238651E255025502650qqI8988L23\xbc148689G?=48=27CP0288:8689KMG298<5153489r2M?9@\x8b12:8<2;7<873k08=8C2=C702>@X08C2?C702@@L08C2AC702B@@08C2CC702D@408=^1@408=5252489KM?948988L2;38048689G?>42E8=2F523`0288;298<518>5342:8<873707G@407HE5152489KM?9@\xeb08=2ICH02:8<2J8>5152489KM?9@\xce08>X3\xc708=2E8?2K523H02:8<2J8>5152489KM?9@\x9f02E8?2L523\x8102:8<2J8>5152489KM?942:8<2J8689G5152489KM?948=2MCK02:8<2J8689G5152489KM?9@30q@E02:8<2N8>5152489KM?9^1@30q@\x9f.42O2P8<878:>38;5242Q8<61:" #(reverse!
- list->vector >= #fn(length) 65536 #fn(table) #fn(buffer) label #fn(put!)
+ list->vec >= #fn(length) 65536 #fn(table) #fn(buffer) label #fn(put!)
#fn(sizeof) #fn(io-write) #fn(get) Instructions jmp jmp.l brne brne.l brnn brnn.l brn brn.l #fn(memq)
(jmp brne brnn brn) s32 s16 brbound #fn(s32) (loadv.l loadg.l setg.l loada.l seta.l argc.l
vargc.l call.l tcall.l loadc.l box.l) (optargs
@@ -266,7 +266,7 @@
last-pair #fn("n10=H3400:700=61:" #(last-pair) last-pair) lastcdr
#fn("n10H3400:70051=:" #(last-pair) lastcdr) length= #fn("n21EL2340q:1El23500H:0H3701El2:700=1K~62:" #(length=) length=)
length> #fn("n21EL23400:1El23;00B;34040:0H3701EL2:700=1K~62:" #(length>) length>)
- list->vector #fn("n1700}2:" #(vector) list->vector) list-head
+ list->vec #fn("n1700}2:" #(vec) list->vec) list-head
#fn("n2701E52340q:0<710=1K~52P:" #(<= list-head) list-head) list-ref #fn("n2700152<:" #(list-tail) list-ref)
list-tail #fn("n2701E523400:710=1K~62:" #(<= list-tail) list-tail) list?
#fn("n10S;J@040B;3904700=61:" #(list?) list?) load #fn("n120021522285>123850>2{:" #(#fn(file)
@@ -302,7 +302,7 @@
make-code-emitter #fn("n0q2050EqEo5:" #(#fn(table)) make-code-emitter)
make-perfect-hash-table #fn("n1Ib5208521_514Ib6862285860>3_486<^12305161:" #(#1#
#fn("n270712205151162:" #(mod0 abs #fn(hash)) $hash-keyword)
- #fn("n120r20i2q52Ib68621A085F86>5_486<^19261:" #(#fn(vector-alloc)
+ #fn("n120r20i2q52Ib68621A085F86>5_486<^19261:" #(#fn(vec-alloc)
#fn("n10B3p070051r2A<85F52i29286G3;093<FKM61:928685p49286KM71051p494<0=61:92:" #(caar
cdar)))) #fn(length)) make-perfect-hash-table)
make-system-image #fn("n120021222354247576Dw54Dw64278788>2288685>22989>1{89504:" #(#fn(file)
@@ -352,8 +352,7 @@
ffound caddr #fn(raise))) str-join #fn(map) str reverse! "/" "λ") fn-name) reverse! length>
list-tail *interactive* filter closure? #fn(map) #fn("n10Z;380420061:" #(#fn(top-level-value)))
#fn(environment) #fn(for-each) #fn("n17021A<0KGF52524222374051==52470257652492<El23?0770KG0EG52@30q49292<KM_:" #(princ
- "(" #fn(for-each) #fn("n1702151472061:" #(princ " " print)) vector->list ")" *linefeed*
- disassemble))) print-stack-trace)
+ "(" #fn(for-each) #fn("n1702151472061:" #(princ " " print)) vec->list ")" *linefeed* disassemble))) print-stack-trace)
print-to-str #fn("n1205021085524228561:" #(#fn(buffer)
#fn(write)
#fn(io->str)) print-to-str)
@@ -442,11 +441,11 @@
value-get-doc #fn("n10<0=208551;3=0486B;350485:" #(#fn(str?)) value-get-doc) values
#fn("z00B3:00=J500<:A0P:" #() #(#3#)) vars-to-env #fn("n32021182>2072230515163:" #(#fn(map)
#fn("n2700210A52SS1FM63:" #(vinfo #fn(memq))) iota #fn(length)) vars-to-env)
- vector->list #fn("n120051qb6K852186085>3|486<:" #(#fn(length)
- #fn("n1AF920~GA<P_:" #())) vector->list)
- vector-map #fn("n220151218651E86K~228701>3|487:" #(#fn(length)
- #fn(vector-alloc)
- #fn("n1A0F920G51p:" #())) vector-map)
+ vec->list #fn("n120051qb6K852186085>3|486<:" #(#fn(length)
+ #fn("n1AF920~GA<P_:" #())) vec->list)
+ vec-map #fn("n220151218651E86K~228701>3|487:" #(#fn(length)
+ #fn(vec-alloc)
+ #fn("n1A0F920G51p:" #())) vec-map)
vinfo #fn("n30182e3:" #() vinfo) vinfo:heap? #.cadr vinfo:index
#4# vinfo:sym #.car void
#1# void? #fn("n10IQ:" #() void?) zero?
--- a/src/builtins.c
+++ b/src/builtins.c
@@ -109,8 +109,8 @@
}
if(iscvalue(a) && cv_class(ptr(a))->eltype != nil)
return size_wrap(cvalue_arraylen(a));
- if(isvector(a))
- return size_wrap(vector_size(a));
+ if(isvec(a))
+ return size_wrap(vec_size(a));
if(ishashtable(a)){
sl_htable *h = totable(a);
void **t = h->table;
@@ -311,16 +311,16 @@
type_error("num", v);
}
-BUILTIN("vector-alloc", vector_alloc)
+BUILTIN("vec-alloc", vec_alloc)
{
if(nargs < 1)
argcount(nargs, 1);
usize i = tosize(args[0]);
- sl_v v = alloc_vector(i, 0);
+ sl_v v = alloc_vec(i, 0);
int a = 1;
for(usize k = 0; k < i; k++){
sl_v f = a < nargs ? args[a] : sl_void;
- vector_elt(v, k) = f;
+ vec_elt(v, k) = f;
if((a = (a + 1) % nargs) < 1)
a = 1;
}
--- a/src/compiler.lsp
+++ b/src/compiler.lsp
@@ -1,6 +1,6 @@
;; code generation state, constant tables, bytecode encoding
-(def (make-code-emitter) (vector () (table) 0 () 0))
+(def (make-code-emitter) (vec () (table) 0 () 0))
(defmacro (bcode:code b) `(aref ,b 0))
(defmacro (bcode:ctable b) `(aref ,b 1))
(defmacro (bcode:nconst b) `(aref ,b 2))
@@ -75,7 +75,7 @@
;; labels are fixed-up.
(def (encode-byte-code e)
(let* ((cl (reverse! e))
- (v (list->vector cl))
+ (v (list->vec cl))
(long? (>= (+ (length v) ;; 1 byte for each entry, plus...
;; at most half the entries in this vector can be
;; instructions accepting 32-bit arguments
@@ -144,7 +144,7 @@
(io->str bcode))))
(def (const-to-idx-vec e)
- (let ((cvec (vector-alloc (bcode:nconst e))))
+ (let ((cvec (vec-alloc (bcode:nconst e))))
(for-each (λ (val idx) (aset! cvec idx val))
(bcode:ctable e))
cvec))
@@ -356,12 +356,12 @@
aset! 'aset! - '- not 'not
apply 'apply atom? 'atom? nan? 'nan?
set-cdr! 'set-cdr! / '/
- function? 'function? vector 'vector
+ function? 'function? vec 'vec
list 'list bound? 'bound?
< '< * '* cdr 'cdr cadr 'cadr
+ '+ eqv? 'eqv? compare 'compare aref 'aref
set-car! 'set-car! car 'car for 'for
- cons? 'cons? = '= vector? 'vector?)))
+ cons? 'cons? = '= vec? 'vec?)))
(λ (b)
(get b2i b nil))))
@@ -392,7 +392,7 @@
(/ (if (= nargs 0)
(argc-error b 1)
(emit g b nargs)))
- (vector (if (= nargs 0)
+ (vec (if (= nargs 0)
(emit g 'loadv #())
(emit g b nargs)))
(apply (if (< nargs 2)
@@ -791,7 +791,7 @@
(print-val (aref vals (aref code i)))
(set! i (+ i 1)))
- ((loada seta loadc call tcall list + - * / < = vector
+ ((loada seta loadc call tcall list + - * / < = vec
argc vargc loadi8 apply tapply closure box shift aref)
(print-inst inst i 1)
(princ (num->str (+ (aref code i) (if (eq? inst 'aref) 3 0))))
@@ -844,7 +844,7 @@
(def (make-perfect-hash-table alist)
(def ($hash-keyword key n) (mod0 (abs (hash key)) n))
(let loop1 ((n (length alist)))
- (let ((v (vector-alloc (* 2 n) nil)))
+ (let ((v (vec-alloc (* 2 n) nil)))
(let loop2 ((lst alist))
(if (cons? lst)
(let ((key (caar lst)))
--- a/src/cvalues.c
+++ b/src/cvalues.c
@@ -361,8 +361,8 @@
static usize
predict_arraylen(sl_v arg)
{
- if(isvector(arg))
- return vector_size(arg);
+ if(isvec(arg))
+ return vec_size(arg);
if(iscons(arg))
return llength(arg);
if(arg == sl_nil)
@@ -390,10 +390,10 @@
sz = elsize * cnt;
- if(isvector(arg)){
- assert(cnt <= vector_size(arg));
+ if(isvec(arg)){
+ assert(cnt <= vec_size(arg));
for(i = 0; i < cnt; i++){
- cvalue_init(eltype, vector_elt(arg, i), dest);
+ cvalue_init(eltype, vec_elt(arg, i), dest);
dest = (char*)dest + elsize;
}
return;
@@ -567,7 +567,7 @@
case TAG_CONS: return sl_conssym;
case TAG_NUM1: case TAG_NUM: return sl_fixnumsym;
case TAG_SYM: return sl_symbolsym;
- case TAG_VECTOR: return sl_vectorsym;
+ case TAG_VEC: return sl_vecsym;
case TAG_FUNCTION:
if(args[0] == sl_t)
return sl_booleansym;
@@ -635,7 +635,7 @@
BUILTIN("copy", copy)
{
argcount(nargs, 1);
- if(iscons(args[0]) || isvector(args[0]))
+ if(iscons(args[0]) || isvec(args[0]))
lerrorf(sl_errarg, "argument must be a leaf atom");
if(!iscvalue(args[0]))
return args[0];
--- a/src/equal.c
+++ b/src/equal.c
@@ -43,16 +43,16 @@
static sl_v cyc_compare(sl_v a, sl_v b, sl_htable *table, bool eq);
static sl_v
-bounded_vector_compare(sl_v a, sl_v b, int bound, bool eq)
+bounded_vec_compare(sl_v a, sl_v b, int bound, bool eq)
{
- usize la = vector_size(a);
- usize lb = vector_size(b);
+ usize la = vec_size(a);
+ usize lb = vec_size(b);
usize m, i;
if(eq && la != lb)
return fixnum(1);
m = la < lb ? la : lb;
for(i = 0; i < m; i++){
- sl_v d = bounded_compare(vector_elt(a, i), vector_elt(b, i), bound-1, eq);
+ sl_v d = bounded_compare(vec_elt(a, i), vec_elt(b, i), bound-1, eq);
if(d == sl_nil || numval(d) != 0)
return d;
}
@@ -64,7 +64,7 @@
}
// strange comparisons are resolved arbitrarily but consistently.
-// ordering: number < cprim < function < vector < cvalue < symbol < cons
+// ordering: num < cprim < function < vec < cvalue < symbol < cons
static sl_v
bounded_compare(sl_v a, sl_v b, int bound, bool eq)
{
@@ -101,9 +101,9 @@
if(tagb > TAG_SYM)
return fixnum(-1);
return fixnum(strcmp(symbol_name(a), symbol_name(b)));
- case TAG_VECTOR:
- if(isvector(b))
- return bounded_vector_compare(a, b, bound, eq);
+ case TAG_VEC:
+ if(isvec(b))
+ return bounded_vec_compare(a, b, bound, eq);
break;
case TAG_CPRIM:
if(cp_class(ptr(a)) == sl_runetype){
@@ -160,10 +160,10 @@
}
static sl_v
-cyc_vector_compare(sl_v a, sl_v b, sl_htable *table, bool eq)
+cyc_vec_compare(sl_v a, sl_v b, sl_htable *table, bool eq)
{
- usize la = vector_size(a);
- usize lb = vector_size(b);
+ usize la = vec_size(a);
+ usize lb = vec_size(b);
usize m, i;
sl_v d, xa, xb, ca, cb;
@@ -172,8 +172,8 @@
return fixnum(1);
m = la < lb ? la : lb;
for(i = 0; i < m; i++){
- xa = vector_elt(a, i);
- xb = vector_elt(b, i);
+ xa = vec_elt(a, i);
+ xb = vec_elt(b, i);
if(leafp(xa) || leafp(xb)){
d = bounded_compare(xa, xb, 1, eq);
if(d != sl_nil && numval(d) != 0)
@@ -192,8 +192,8 @@
eq_union(table, a, b, ca, cb);
for(i = 0; i < m; i++){
- xa = vector_elt(a, i);
- xb = vector_elt(b, i);
+ xa = vec_elt(a, i);
+ xb = vec_elt(b, i);
if(!leafp(xa) || tag(xa) == TAG_FUNCTION){
d = cyc_compare(xa, xb, table, eq);
if(numval(d) != 0)
@@ -260,8 +260,8 @@
return fixnum(1);
}
}
- if(isvector(a) && isvector(b))
- return cyc_vector_compare(a, b, table, eq);
+ if(isvec(a) && isvec(b))
+ return cyc_vec_compare(a, b, table, eq);
if(isfunction(a) && isfunction(b)){
sl_fn *fa = ptr(a);
sl_fn *fb = ptr(b);
@@ -362,14 +362,14 @@
}
return h;
- case TAG_VECTOR:
+ case TAG_VEC:
if(bound <= 0){
*oob = true;
return 1;
}
- len = vector_size(a);
+ len = vec_size(a);
for(i = 0; i < len; i++){
- h = MIX(h, bounded_hash(vector_elt(a, i), bound/2, &oob2)^1);
+ h = MIX(h, bounded_hash(vec_elt(a, i), bound/2, &oob2)^1);
if(oob2)
bound /= 2;
*oob = *oob || oob2;
--- a/src/opcodes.c
+++ b/src/opcodes.c
@@ -3,6 +3,7 @@
const Builtin builtins[N_OPCODES] = {
[OP_NANP] = {"nan?", 1},
[OP_SETCAR] = {"set-car!", 2},
+ [OP_VECP] = {"vec?", 1},
[OP_CDR] = {"cdr", 1},
[OP_FUNCTIONP] = {"function?", 1},
[OP_CADR] = {"cadr", 1},
@@ -15,10 +16,9 @@
[OP_NOT] = {"not", 1},
[OP_LIST] = {"list", ANYARGS},
[OP_CONS] = {"cons", 2},
- [OP_VECTORP] = {"vector?", 1},
+ [OP_NUMP] = {"num?", 1},
[OP_BOUNDP] = {"bound?", 1},
[OP_LT] = {"<", -1},
- [OP_NUMP] = {"num?", 1},
[OP_CAR] = {"car", 1},
[OP_EQV] = {"eqv?", 2},
[OP_IDIV] = {"div0", 2},
@@ -28,11 +28,11 @@
[OP_SYMBOLP] = {"symbol?", 1},
[OP_SUB] = {"-", -1},
[OP_COMPARE] = {"compare", 2},
+ [OP_VEC] = {"vec", ANYARGS},
[OP_FOR] = {"for", 3},
[OP_MUL] = {"*", ANYARGS},
[OP_ADD] = {"+", ANYARGS},
[OP_AREF] = {"aref", -2},
[OP_DIV] = {"/", -1},
- [OP_VECTOR] = {"vector", ANYARGS},
[OP_EQUAL] = {"equal?", 2},
};
--- a/src/opcodes.h
+++ b/src/opcodes.h
@@ -44,7 +44,7 @@
OP_BOUNDP,
OP_BUILTINP,
OP_FUNCTIONP,
- OP_VECTORP,
+ OP_VECP,
OP_SHIFT,
OP_SETCAR,
OP_JMPL,
@@ -62,7 +62,7 @@
OP_NUMEQ,
OP_COMPARE,
OP_ARGC,
- OP_VECTOR,
+ OP_VEC,
OP_ASET,
OP_LOADNIL,
OP_LOADI8,
--- a/src/plan9/lsd.c
+++ b/src/plan9/lsd.c
@@ -67,12 +67,12 @@
b[0] = s->type;
chartorune(&r, b);
- v = alloc_vector(4, 0);
+ v = alloc_vec(4, 0);
sl_gc_handle(&v);
- vector_elt(v, 0) = lsd_symsym;
- vector_elt(v, 1) = str_from_cstr(s->name);
- vector_elt(v, 2) = mk_rune(r);
- vector_elt(v, 3) = size_wrap(s->value);
+ vec_elt(v, 0) = lsd_symsym;
+ vec_elt(v, 1) = str_from_cstr(s->name);
+ vec_elt(v, 2) = mk_rune(r);
+ vec_elt(v, 3) = size_wrap(s->value);
sl_free_gc_handles(1);
return v;
}
@@ -130,13 +130,13 @@
sl_v v;
USED(map);
- v = alloc_vector(5, 0);
+ v = alloc_vec(5, 0);
sl_gc_handle(&v);
- vector_elt(v, 0) = lsd_framesym;
- vector_elt(v, 1) = mk_sym(fn);
- vector_elt(v, 2) = mk_u64(retpc);
- vector_elt(v, 3) = mk_u64(sp);
- vector_elt(v, 4) = localslist(fn, sp);
+ vec_elt(v, 0) = lsd_framesym;
+ vec_elt(v, 1) = mk_sym(fn);
+ vec_elt(v, 2) = mk_u64(retpc);
+ vec_elt(v, 3) = mk_u64(sp);
+ vec_elt(v, 4) = localslist(fn, sp);
sl_free_gc_handles(1);
tracelist = mk_cons(v, tracelist);
}
@@ -274,17 +274,17 @@
sl_gc_handle(®isters);
sl_gc_handle(&v);
for(r = mach->reglist; r->rname != nil; r++){
- v = alloc_vector(5, 0);
- vector_elt(v, 0) = lsd_regsym;
- vector_elt(v, 1) = str_from_cstr(r->rname);
- vector_elt(v, 2) = r->rflags == RINT ? lsd_gpregsym : lsd_fpregsym;
- vector_elt(v, 3) = size_wrap(r->roffs);
+ v = alloc_vec(5, 0);
+ vec_elt(v, 0) = lsd_regsym;
+ vec_elt(v, 1) = str_from_cstr(r->rname);
+ vec_elt(v, 2) = r->rflags == RINT ? lsd_gpregsym : lsd_fpregsym;
+ vec_elt(v, 3) = size_wrap(r->roffs);
switch(r->rformat){
default:
- vector_elt(v, 4) = sl_u32sym;
+ vec_elt(v, 4) = sl_u32sym;
break;
case 'V': case 'W': case 'Y': case 'Z':
- vector_elt(v, 4) = sl_u64sym;
+ vec_elt(v, 4) = sl_u64sym;
break;
}
set(symbol(r->rname, 1), v);
@@ -292,13 +292,13 @@
}
sl_free_gc_handles(2);
- v = alloc_vector(5, 0);
+ v = alloc_vec(5, 0);
sl_gc_handle(&v);
- vector_elt(v, 0) = fixnum(pid);
- vector_elt(v, 1) = registers;
- vector_elt(v, 2) = cvalue_from_ref(sl_strtype, machdata->bpinst, machdata->bpsize);
- vector_elt(v, 3) = symslist(textsym);
- vector_elt(v, 4) = symslist(globalsym);
+ vec_elt(v, 0) = fixnum(pid);
+ vec_elt(v, 1) = registers;
+ vec_elt(v, 2) = cvalue_from_ref(sl_strtype, machdata->bpinst, machdata->bpsize);
+ vec_elt(v, 3) = symslist(textsym);
+ vec_elt(v, 4) = symslist(globalsym);
sl_free_gc_handles(1);
return v;
@@ -322,10 +322,10 @@
ios_fd(proc_stdin, p, 0, 0);
proc_stdin->loc.filename = MEM_STRDUP("proc-stdin");
- v = alloc_vector(2, 0);
+ v = alloc_vec(2, 0);
sl_gc_handle(&v);
- vector_elt(v, 0) = fixnum(pid);
- vector_elt(v, 1) = cvalue_from_ref(sl_iotype, proc_stdin, sizeof(*proc_stdin));
+ vec_elt(v, 0) = fixnum(pid);
+ vec_elt(v, 1) = cvalue_from_ref(sl_iotype, proc_stdin, sizeof(*proc_stdin));
sl_free_gc_handles(1);
return v;
}
--- a/src/print.c
+++ b/src/print.c
@@ -95,12 +95,12 @@
*bp = fixnum(sl.printlabel++);
return;
}
- if(isvector(v)){
- if(vector_size(v) > 0)
+ if(isvec(v)){
+ if(vec_size(v) > 0)
mark_cons(v);
unsigned int i;
- for(i = 0; i < vector_size(v); i++)
- print_traverse(vector_elt(v, i));
+ for(i = 0; i < vec_size(v); i++)
+ print_traverse(vec_elt(v, i));
}else if(iscprim(v)){
// don't consider shared references to e.g. chars
}else if(isfunction(v)){
@@ -201,11 +201,11 @@
return true;
return false;
}
- if(isvector(v)){
- usize s = vector_size(v);
+ if(isvec(v)){
+ usize s = vec_size(v);
return (
s == 0 ||
- (tinyp(vector_elt(v, 0)) && (s == 1 || (s == 2 && tinyp(vector_elt(v, 1)))))
+ (tinyp(vec_elt(v, 0)) && (s == 1 || (s == 2 && tinyp(vec_elt(v, 1)))))
);
}
return false;
@@ -409,7 +409,7 @@
sl_print_child(sl_ios *f, sl_v v)
{
const char *name;
- if(sl.print_level >= 0 && sl.p_level >= sl.print_level && (iscons(v) || isvector(v) || isfunction(v))){
+ if(sl.print_level >= 0 && sl.p_level >= sl.print_level && (iscons(v) || isvec(v) || isfunction(v))){
outc(f, '#');
return;
}
@@ -483,28 +483,28 @@
cvalue_print(f, v);
break;
case TAG_CVALUE:
- case TAG_VECTOR:
+ case TAG_VEC:
case TAG_CONS:
if(!sl.print_princ && print_circle_prefix(f, v))
break;
- if(isvector(v)){
+ if(isvec(v)){
outs(f, "#(");
int newindent = sl.hpos, est;
- int i, sz = vector_size(v);
+ int i, sz = vec_size(v);
for(i = 0; i < sz; i++){
if(sl.print_length >= 0 && i >= sl.print_length && i < sz-1){
outsn(f, "...", 3);
break;
}
- sl_print_child(f, vector_elt(v, i));
+ sl_print_child(f, vec_elt(v, i));
if(i < sz-1){
if(!sl.print_pretty)
outc(f, ' ');
else{
- est = lengthestimate(vector_elt(v, i+1));
+ est = lengthestimate(vec_elt(v, i+1));
if(sl.hpos > sl.scr_width-4 ||
(est != -1 && (sl.hpos+est > sl.scr_width-2)) ||
- (sl.hpos > sl.scr_width/2 && !smallp(vector_elt(v, i+1)) && !tinyp(vector_elt(v, i))))
+ (sl.hpos > sl.scr_width/2 && !smallp(vec_elt(v, i+1)) && !tinyp(vec_elt(v, i))))
newindent = outindent(f, newindent);
else
outc(f, ' ');
@@ -904,7 +904,7 @@
if(sl.print_level >= 0 || sl.print_length >= 0)
memset(sl.consflags, 0, 4*bitvector_nwords(slg.heapsize/sizeof(sl_cons)));
- if((iscons(v) || isvector(v) || isfunction(v) || iscvalue(v)) &&
+ if((iscons(v) || isvec(v) || isfunction(v) || iscvalue(v)) &&
!sl_isstr(v) && v != sl_t && v != sl_nil && v != sl_void)
htable_reset(&sl.printconses, 32);
}
--- a/src/read.c
+++ b/src/read.c
@@ -390,21 +390,21 @@
// NOTE: this is NOT an efficient operation. it is only used by the
// reader, and requires at least 1 and up to 3 garbage collections!
static sl_v
-vector_grow(sl_v v, bool rewrite_refs)
+vec_grow(sl_v v, bool rewrite_refs)
{
- usize i, s = vector_size(v);
- usize d = vector_grow_amt(s);
+ usize i, s = vec_size(v);
+ usize d = vec_grow_amt(s);
PUSH(v);
assert(s+d > s);
- sl_v newv = alloc_vector(s+d, 1);
+ sl_v newv = alloc_vec(s+d, 1);
v = sl.sp[-1];
for(i = 0; i < s; i++)
- vector_elt(newv, i) = vector_elt(v, i);
+ vec_elt(newv, i) = vec_elt(v, i);
// use gc to rewrite references from the old vector to the new
sl.sp[-1] = newv;
if(s > 0 && rewrite_refs){
((usize*)ptr(v))[0] |= 0x1;
- vector_elt(v, 0) = newv;
+ vec_elt(v, 0) = newv;
sl_gc(false);
}
return POP();
@@ -411,7 +411,7 @@
}
static sl_v
-read_vector(Rctx *ctx, sl_v label, u32int closer)
+read_vec(Rctx *ctx, sl_v label, u32int closer)
{
sl_v v = sl_emptyvec, elt;
u32int i = 0;
@@ -422,20 +422,20 @@
if(ios_eof(RS))
parse_error(&ctx->loc, "unexpected end of input");
v = sl.sp[-1]; // reload after possible alloc in peek()
- if(i >= vector_size(v)){
- v = sl.sp[-1] = vector_grow(v, label != UNBOUND);
+ if(i >= vec_size(v)){
+ v = sl.sp[-1] = vec_grow(v, label != UNBOUND);
if(label != UNBOUND)
ptrhash_put(&sl.readstate->backrefs, (void*)label, (void*)v);
}
elt = do_read_sexpr(ctx, UNBOUND);
v = sl.sp[-1];
- assert(i < vector_size(v));
- vector_elt(v, i) = elt;
+ assert(i < vec_size(v));
+ vec_elt(v, i) = elt;
i++;
}
take(ctx);
if(i > 0)
- vector_setsize(v, i);
+ vec_setsize(v, i);
return POP();
}
@@ -674,7 +674,7 @@
unbound_error(sym);
return sl_apply(v, POP());
case TOK_SHARPOPEN:
- return read_vector(ctx, label, TOK_CLOSE);
+ return read_vec(ctx, label, TOK_CLOSE);
case TOK_SHARPDOT:
// eval-when-read
// evaluated expressions can refer to existing backreferences, but they
--- a/src/sl.c
+++ b/src/sl.c
@@ -13,7 +13,7 @@
sl_v sl_builtinssym, sl_quote, sl_lambda, sl_function, sl_comma, sl_commaat;
sl_v sl_commadot, sl_trycatch, sl_backquote;
-sl_v sl_conssym, sl_symbolsym, sl_fixnumsym, sl_vectorsym, sl_builtinsym, sl_vu8sym;
+sl_v sl_conssym, sl_symbolsym, sl_fixnumsym, sl_vecsym, sl_builtinsym, sl_vu8sym;
sl_v sl_defsym, sl_defmacrosym, sl_forsym, sl_setqsym;
sl_v sl_booleansym, sl_nullsym, sl_evalsym, sl_fnsym, sl_trimsym;
sl_v sl_nulsym, sl_alarmsym, sl_backspacesym, sl_tabsym, sl_linefeedsym, sl_newlinesym;
@@ -333,16 +333,16 @@
}
sl_v
-alloc_vector(usize n, bool init)
+alloc_vec(usize n, bool init)
{
if(n == 0)
return sl_emptyvec;
sl_v *c = alloc_words(n+1);
- sl_v v = tagptr(c, TAG_VECTOR);
- vector_setsize(v, n);
+ sl_v v = tagptr(c, TAG_VEC);
+ vec_setsize(v, n);
if(init){
for(usize i = 0; i < n; i++)
- vector_elt(v, i) = sl_void;
+ vec_elt(v, i) = sl_void;
}
return v;
}
@@ -401,22 +401,22 @@
if(t == TAG_CVALUE)
return cvalue_relocate(v);
- if(t == TAG_VECTOR){
+ if(t == TAG_VEC){
// N.B.: 0-length vectors secretly have space for a first element
- usize i, sz = vector_size(v);
- if(vector_elt(v, -1) & 0x1){
+ usize i, sz = vec_size(v);
+ if(vec_elt(v, -1) & 0x1){
// grown vector
- nc = sl_relocate(vector_elt(v, 0));
+ nc = sl_relocate(vec_elt(v, 0));
forward(v, nc);
}else{
- nc = tagptr(alloc_words(sz+1), TAG_VECTOR);
- vector_setsize(nc, sz);
- a = vector_elt(v, 0);
+ nc = tagptr(alloc_words(sz+1), TAG_VEC);
+ vec_setsize(nc, sz);
+ a = vec_elt(v, 0);
forward(v, nc);
if(sz > 0){
- vector_elt(nc, 0) = sl_relocate(a);
+ vec_elt(nc, 0) = sl_relocate(a);
for(i = 1; i < sz; i++)
- vector_elt(nc, i) = sl_relocate(vector_elt(v, i));
+ vec_elt(nc, i) = sl_relocate(vec_elt(v, i));
}
}
return nc;
@@ -579,7 +579,7 @@
sl_v tab = symbol_value(sl_builtinssym);
if(sl_unlikely(ptr(tab) == nil))
unbound_error(tab);
- saveSP[-n-1] = vector_elt(tab, uintval(f));
+ saveSP[-n-1] = vec_elt(tab, uintval(f));
v = apply_cl(n);
}else{
type_error("function", f);
@@ -789,7 +789,7 @@
if(i >= nargs)
goto no_kw;
// now process keywords
- uintptr n = vector_size(kwtable)/2;
+ uintptr n = vec_size(kwtable)/2;
do{
i++;
if(sl_unlikely(i >= nargs))
@@ -797,8 +797,8 @@
sl_v hv = fixnum(((sl_sym*)ptr(v))->hash);
sl_fx lx = numval(hv);
uintptr x = 2*((lx < 0 ? -lx : lx) % n);
- if(sl_likely(vector_elt(kwtable, x) == v)){
- intptr idx = numval(vector_elt(kwtable, x+1));
+ if(sl_likely(vec_elt(kwtable, x) == v)){
+ intptr idx = numval(vec_elt(kwtable, x+1));
assert(idx < nkw);
idx += nopt;
if(args[idx] == UNBOUND){
@@ -911,14 +911,14 @@
sl_v func = bp[0];
const u8int *ip0 = cvalue_data(fn_bcode(func));
intptr ip = ip1 - ip0 - 1; /* -1: ip1 is *after* the one that was being executed */
- sl_v v = alloc_vector(sz+1, 0);
- vector_elt(v, 0) = fixnum(ip);
- vector_elt(v, 1) = func;
+ sl_v v = alloc_vec(sz+1, 0);
+ vec_elt(v, 0) = fixnum(ip);
+ vec_elt(v, 1) = func;
for(int i = 1; i < sz; i++){
sl_v si = bp[i];
// if there's an error evaluating argument defaults some slots
// might be left set to UNBOUND
- vector_elt(v, i+1) = si == UNBOUND ? sl_void : si;
+ vec_elt(v, i+1) = si == UNBOUND ? sl_void : si;
}
lst = mk_cons(v, lst);
top = (sl_v*)top[-3];
@@ -945,8 +945,8 @@
argcount(nargs, 2);
if(sl_unlikely(!sl_isstr(args[0])))
type_error("str", args[0]);
- if(sl_unlikely(!isvector(args[1])))
- type_error("vector", args[1]);
+ if(sl_unlikely(!isvec(args[1])))
+ type_error("vec", args[1]);
csl_v *arr = ptr(args[0]);
cv_pin(arr);
u8int *data = cv_data(arr);
@@ -1120,10 +1120,10 @@
args[i] = cdr_(v);
continue;
}
- if(isvector(v)){
- usize sz = vector_size(v);
+ if(isvec(v)){
+ usize sz = vec_size(v);
if(n < sz){
- PUSH(vector_elt(v, n));
+ PUSH(vec_elt(v, n));
continue;
}
}
@@ -1260,7 +1260,7 @@
sl_conssym = csymbol("cons");
sl_symbolsym = csymbol("symbol");
sl_fixnumsym = csymbol("fixnum");
- sl_vectorsym = csymbol("vector");
+ sl_vecsym = csymbol("vec");
sl_builtinsym = csymbol("builtin");
sl_booleansym = csymbol("boolean");
sl_nullsym = csymbol("null");
@@ -1300,8 +1300,8 @@
setc(csymbol("procedure?"), builtin(OP_FUNCTIONP));
setc(csymbol("top-level-bound?"), builtin(OP_BOUNDP));
- sl_emptyvec = tagptr(alloc_words(1), TAG_VECTOR);
- vector_setsize(sl_emptyvec, 0);
+ sl_emptyvec = tagptr(alloc_words(1), TAG_VEC);
+ vec_setsize(sl_emptyvec, 0);
cvalues_init();
--- a/src/sl.h
+++ b/src/sl.h
@@ -14,7 +14,7 @@
TAG_NUM,
TAG_CPRIM,
TAG_FUNCTION,
- TAG_VECTOR,
+ TAG_VEC,
TAG_NUM1,
TAG_CVALUE,
TAG_SYM,
@@ -21,7 +21,7 @@
TAG_CONS,
/* those were set to 7 and 3 strategically on purpose */
- TAG_NONLEAF_MASK = TAG_CONS & TAG_VECTOR,
+ TAG_NONLEAF_MASK = TAG_CONS & TAG_VEC,
};
enum {
@@ -110,7 +110,7 @@
#define issymbol(x) (tag(x) == TAG_SYM)
#define isfixnum(x) (((x)&3) == TAG_NUM)
#define bothfixnums(x, y) (isfixnum(x) && isfixnum(y))
-#define isvector(x) (tag(x) == TAG_VECTOR)
+#define isvec(x) (tag(x) == TAG_VEC)
#define iscvalue(x) (tag(x) == TAG_CVALUE)
#define iscprim(x) (tag(x) == TAG_CPRIM)
// doesn't lead to other values
@@ -130,10 +130,10 @@
*(sl_v*)ptr(v) = (sl_v)(to) | FWD_BIT; \
}while(0)
-#define vector_size(v) (((usize*)ptr(v))[0]>>2)
-#define vector_setsize(v, n) (((usize*)ptr(v))[0] = ((n)<<2))
-#define vector_elt(v, i) (((sl_v*)ptr(v))[1+(i)])
-#define vector_grow_amt(x) ((x)<8 ? 5 : 6*((x)>>3))
+#define vec_size(v) (((usize*)ptr(v))[0]>>2)
+#define vec_setsize(v, n) (((usize*)ptr(v))[0] = ((n)<<2))
+#define vec_elt(v, i) (((sl_v*)ptr(v))[1+(i)])
+#define vec_grow_amt(x) ((x)<8 ? 5 : 6*((x)>>3))
// functions ending in _ are unsafe, faster versions
#define car_(v) (((sl_cons*)ptr(v))->car)
#define cdr_(v) (((sl_cons*)ptr(v))->cdr)
@@ -203,7 +203,7 @@
sl_v mk_list2(sl_v a, sl_v b);
sl_v mk_listn(int n, ...);
bool sl_isnum(sl_v v) sl_purefn;
-sl_v alloc_vector(usize n, bool init);
+sl_v alloc_vec(usize n, bool init);
/* consistent iswprint and wcwidth */
int sl_iswprint(Rune c) sl_constfn;
@@ -413,7 +413,7 @@
extern sl_v sl_builtinssym, sl_quote, sl_lambda, sl_function, sl_comma, sl_commaat;
extern sl_v sl_commadot, sl_trycatch, sl_backquote;
-extern sl_v sl_conssym, sl_symbolsym, sl_fixnumsym, sl_vectorsym, sl_builtinsym, sl_vu8sym;
+extern sl_v sl_conssym, sl_symbolsym, sl_fixnumsym, sl_vecsym, sl_builtinsym, sl_vu8sym;
extern sl_v sl_defsym, sl_defmacrosym, sl_forsym, sl_setqsym;
extern sl_v sl_booleansym, sl_nullsym, sl_evalsym, sl_fnsym, sl_trimsym;
extern sl_v sl_nulsym, sl_alarmsym, sl_backspacesym, sl_tabsym, sl_linefeedsym, sl_newlinesym;
--- a/src/system.lsp
+++ b/src/system.lsp
@@ -270,7 +270,7 @@
(eq? (typeof x) 'rune))
(def (array? x)
- (or (vector? x)
+ (or (vec? x)
(let ((tx (typeof x)))
(and (cons? tx) (eq? (car tx) 'array)))))
@@ -536,11 +536,11 @@
(def (bq-process x d)
(cond ((symbol? x) (list 'quote x))
- ((vector? x)
- (let ((body (bq-process (vector->list x) d)))
+ ((vec? x)
+ (let ((body (bq-process (vec->list x) d)))
(if (eq? (car body) list)
- (cons vector (cdr body))
- (list apply vector body))))
+ (cons vec (cdr body))
+ (list apply vec body))))
((atom? x) x)
((eq? (car x) 'quasiquote)
(list list ''quasiquote (bq-process (cadr x) (+ d 1))))
@@ -763,8 +763,8 @@
;;; vector functions
-(def (list->vector l) (apply vector l))
-(def (vector->list v)
+(def (list->vec l) (apply vec l))
+(def (vec->list v)
(let ((n (length v))
(l ()))
(for 1 n
@@ -772,9 +772,9 @@
(set! l (cons (aref v (- n i)) l))))
l))
-(def (vector-map f v)
+(def (vec-map f v)
(let* ((n (length v))
- (nv (vector-alloc n)))
+ (nv (vec-alloc n)))
(for 0 (- n 1)
(λ (i)
(aset! nv i (f (aref v i)))))
@@ -858,7 +858,7 @@
;;; structs
-(defmacro (defstruct name (:type vector)
+(defmacro (defstruct name (:type vec)
(:named T)
(:constructor T)
(:conc-name NIL)
@@ -915,7 +915,7 @@
; slots, but with default values added (if not set)
; and keywords for names
[slots-kw (tokw slots)]
- ; struct's underlying type's predicate (either vector? or list?)
+ ; struct's underlying type's predicate (either vec? or list?)
[type? (symbol (str type "?"))]
; struct's predicate name
[is? (or predicate
@@ -1194,7 +1194,7 @@
(λ (f)
(princ "(" (fn-name (aref f 1) e))
(for-each (λ (p) (princ " ") (print p))
- (cdr (cdr (vector->list f))))
+ (cdr (cdr (vec->list f))))
(princ ")" *linefeed*)
(when (= n 0)
(disassemble (aref f 1) (aref f 0)))
--- a/src/vm.h
+++ b/src/vm.h
@@ -66,17 +66,17 @@
p[0] = p[1];
sp--;
switch(i){
- case OP_VECTOR: goto LABEL(apply_vector);
- case OP_ADD: goto LABEL(apply_add);
- case OP_LIST: goto LABEL(apply_list);
- case OP_APPLY: goto LABEL(apply_apply);
- case OP_SUB: goto LABEL(apply_sub);
- case OP_MUL: goto LABEL(apply_mul);
- case OP_DIV: goto LABEL(apply_div);
- case OP_AREF: goto LABEL(apply_aref);
- case OP_ASET: goto LABEL(apply_aset);
- case OP_LT: goto LABEL(apply_lt);
- case OP_NUMEQ: goto LABEL(apply_numeq);
+ case OP_VEC: goto LABEL(apply_vec);
+ case OP_ADD: goto LABEL(apply_add);
+ case OP_LIST: goto LABEL(apply_list);
+ case OP_APPLY: goto LABEL(apply_apply);
+ case OP_SUB: goto LABEL(apply_sub);
+ case OP_MUL: goto LABEL(apply_mul);
+ case OP_DIV: goto LABEL(apply_div);
+ case OP_AREF: goto LABEL(apply_aref);
+ case OP_ASET: goto LABEL(apply_aset);
+ case OP_LT: goto LABEL(apply_lt);
+ case OP_NUMEQ: goto LABEL(apply_numeq);
default:
#if defined(COMPUTED_GOTO)
goto *ops[i];
@@ -145,13 +145,13 @@
OP(OP_LOADG) {
sl_v v = fn_vals(bp[-1]);
- assert(*ip < vector_size(v));
- v = vector_elt(v, *ip);
+ assert(*ip < vec_size(v));
+ v = vec_elt(v, *ip);
ip++;
if(0){
OP(OP_LOADGL)
v = fn_vals(bp[-1]);
- v = vector_elt(v, GET_S32(ip));
+ v = vec_elt(v, GET_S32(ip));
ip += 4;
}
assert(issymbol(v));
@@ -195,8 +195,8 @@
OP(OP_LOADV) {
sl_v v = fn_vals(bp[-1]);
- assert(*ip < vector_size(v));
- *sp++ = vector_elt(v, *ip++);
+ assert(*ip < vec_size(v));
+ *sp++ = vec_elt(v, *ip++);
NEXT_OP;
}
@@ -245,7 +245,7 @@
NEXT_OP;
OP(OP_LOADC0)
- *sp++ = vector_elt(bp[nargs], 0);
+ *sp++ = vec_elt(bp[nargs], 0);
NEXT_OP;
OP(OP_CAR) {
@@ -271,7 +271,7 @@
!(x&1)+
#endif
sizeof(sl_fn)/sizeof(sl_v));
- sl_v v = tagptr(pv, TAG_VECTOR);
+ sl_v v = tagptr(pv, TAG_VEC);
*pv++ = fixnum(x);
for(int i = 0; i < x; i++)
*pv++ = sp[-x+i];
@@ -430,12 +430,12 @@
}
sl_v e = sp[-i];
usize isz = tosize(e);
- if(isvector(v)){
- if(sl_unlikely(isz >= vector_size(v))){
+ if(isvec(v)){
+ if(sl_unlikely(isz >= vec_size(v))){
sl.sp = sp;
bounds_error(v, e);
}
- v = vector_elt(v, isz);
+ v = vec_elt(v, isz);
continue;
}
if(!iscons(v) && v != sl_nil){
@@ -498,7 +498,7 @@
}
OP(OP_LOADC1)
- *sp++ = vector_elt(bp[nargs], 1);
+ *sp++ = vec_elt(bp[nargs], 1);
NEXT_OP;
OP(OP_ASET) {
@@ -516,12 +516,12 @@
}
sl_v e = sp[-i];
usize isz = tosize(e);
- if(isvector(v)){
- if(sl_unlikely(isz >= vector_size(v))){
+ if(isvec(v)){
+ if(sl_unlikely(isz >= vec_size(v))){
sl.sp = sp;
bounds_error(v, e);
}
- v = vector_elt(v, isz);
+ v = vec_elt(v, isz);
continue;
}
if(!iscons(v) && v != sl_nil){
@@ -544,12 +544,12 @@
}
sl_v e = sp[-2];
usize isz = tosize(e);
- if(isvector(v)){
- if(sl_unlikely(isz >= vector_size(v))){
+ if(isvec(v)){
+ if(sl_unlikely(isz >= vec_size(v))){
sl.sp = sp;
bounds_error(v, e);
}
- vector_elt(v, isz) = (e = sp[-1]);
+ vec_elt(v, isz) = (e = sp[-1]);
}else if(iscons(v) || v == sl_nil){
for(sl_v v0 = v;; isz--){
if(isz == 0){
@@ -587,9 +587,9 @@
OP(OP_LOADC) {
sl_v v = bp[nargs];
int i = *ip++;
- assert(isvector(v));
- assert(i < (int)vector_size(v));
- *sp++ = vector_elt(v, i);
+ assert(isvec(v));
+ assert(i < (int)vec_size(v));
+ *sp++ = vec_elt(v, i);
NEXT_OP;
}
@@ -802,12 +802,12 @@
NEXT_OP;
}
-OP(OP_VECTOR) {
+OP(OP_VEC) {
n = *ip++;
-LABEL(apply_vector):;
+LABEL(apply_vec):;
sl.sp = sp;
- sl_v v = alloc_vector(n, 0);
- memcpy(&vector_elt(v, 0), sp-n, n*sizeof(sl_v));
+ sl_v v = alloc_vec(n, 0);
+ memcpy(&vec_elt(v, 0), sp-n, n*sizeof(sl_v));
sp -= n;
*sp++ = v;
NEXT_OP;
@@ -844,8 +844,8 @@
ip += 4;
}
sl_v v = fn_vals(bp[-1]);
- assert(i < (int)vector_size(v));
- v = vector_elt(v, i);
+ assert(i < (int)vec_size(v));
+ v = vec_elt(v, i);
assert(issymbol(v));
sl_sym *sym = ptr(v);
v = sp[-1];
@@ -854,8 +854,8 @@
NEXT_OP;
}
-OP(OP_VECTORP)
- sp[-1] = isvector(sp[-1]) ? sl_t : sl_nil;
+OP(OP_VECP)
+ sp[-1] = isvec(sp[-1]) ? sl_t : sl_nil;
NEXT_OP;
OP(OP_TRYCATCH) {
@@ -894,7 +894,7 @@
OP(OP_KEYARGS) {
sl_v v = fn_vals(bp[-1]);
- v = vector_elt(v, 0);
+ v = vec_elt(v, 0);
int i = GET_S32(ip);
ip += 4;
int x = GET_S32(ip);
@@ -976,13 +976,13 @@
OP(OP_LOADCL)
ip += 4;
- *sp++ = vector_elt(bp[nargs], GET_S32(ip));
+ *sp++ = vec_elt(bp[nargs], GET_S32(ip));
ip += 4;
NEXT_OP;
OP(OP_LOADVL) {
sl_v v = fn_vals(bp[-1]);
- v = vector_elt(v, GET_S32(ip));
+ v = vec_elt(v, GET_S32(ip));
ip += 4;
*sp++ = v;
NEXT_OP;
--- a/test/test.lsp
+++ b/test/test.lsp
@@ -51,6 +51,6 @@
compile-app separate nconc get-defined-vars
compile-in compile compile-f delete-duplicates
map length> length= count filter append
- lastcdr to-proper reverse reverse! list->vector
+ lastcdr to-proper reverse reverse! list->vec
taboreach list-head list-tail assq memq assoc member
assv memv nreconc bq-process))
--- a/test/unittest.lsp
+++ b/test/unittest.lsp
@@ -465,7 +465,7 @@
cons? 1 symbol? 1
num? 1 bound? 1
cons? 1 builtin? 1
- vector? 1 fixnum? 1
+ vec? 1 fixnum? 1
cons 2 car 1
cdr 1 set-car! 2
set-cdr! 2 = 2
--- a/tools/gen.lsp
+++ b/tools/gen.lsp
@@ -48,7 +48,7 @@
OP_BOUNDP bound? 1 (λ (x) (bound? x)) nil
OP_BUILTINP builtin? 1 (λ (x) (builtin? x)) nil
OP_FUNCTIONP function? 1 (λ (x) (function? x)) nil
- OP_VECTORP vector? 1 (λ (x) (vector? x)) nil
+ OP_VECP vec? 1 (λ (x) (vec? x)) nil
OP_SHIFT shift nil nil nil
OP_SETCAR set-car! 2 (λ (x y) (set-car! x y)) nil
OP_JMPL jmp.l nil nil nil
@@ -68,7 +68,7 @@
OP_NUMEQ = -1 (λ rest (apply = rest)) nil
OP_COMPARE compare 2 (λ (x y) (compare x y)) nil
OP_ARGC argc nil nil nil
- OP_VECTOR vector ANYARGS (λ rest (apply vector rest)) nil
+ OP_VEC vec ANYARGS (λ rest (apply vec rest)) nil
OP_ASET aset! -3 (λ rest (apply aset! rest)) nil
OP_LOADNIL loadnil nil nil nil
OP_LOADI8 loadi8 nil nil nil
@@ -163,7 +163,7 @@
instructions)
(io-write instructions "\n")
(io-close instructions)
- (set! lms (cons vector (reverse! lms)))
+ (set! lms (cons vec (reverse! lms)))
(write `(def *builtins*
"VM instructions as closures."
,lms)
--
⑨