History

rename "byte" to "utf8"

Sigrid Solveig Haflínudóttir committed 1 year ago

Commit fc8bfb61 parent a70379d9 files · +25 −26Browse files

Unified · Split

9 files
  1. boot/sl.boot +1 −1
  2. src/builtins.c +1 −1
  3. src/cvalues.c +5 −5
  4. src/plan9/lsd.sl +4 −4
  5. src/print.c +2 −2
  6. src/sl.c +2 −2
  7. src/sl.h +3 −3
  8. test/unittest.sl +4 −5
  9. tools/gen.sl +3 −3
boot/sl.boot+1−1
@@ -110,7 +110,7 @@ · 109 unmodified lines
110 #fn("n10K~:" #() 1-) 1arg-lambda? #fn("n10B;3D040<20Q;3:04710TK62:" #(λ length=) 1arg-lambda?)110 #fn("n10K~:" #() 1-) 1arg-lambda? #fn("n10B;3D040<20Q;3:04710TK62:" #(λ length=) 1arg-lambda?)
111 <= #fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JL041<0L2;J5040V340q:A<1<1=62:")) <=) >111 <= #fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JL041<0L2;J5040V340q:A<1<1=62:")) <=) >
112 #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:")) >=)112 #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:")) >=)
113 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) fn? #byte(0x2c) eq? #byte(0x21) * #byte(0x39) load1 #byte(0x1b) bound? #byte(0x2a) 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) sym? #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))113 Instructions #table(call.l #u8(81) trycatch #u8(75) loadg.l #u8(68) aref2 #u8(23) box #u8(50) cadr #u8(36) argc #u8(62) setg #u8(71) load0 #u8(21) nan? #u8(38) fixnum? #u8(41) loadc0 #u8(17) loada0 #u8(0) div0 #u8(59) keyargs #u8(31) call #u8(5) loada.l #u8(69) num? #u8(40) sub2 #u8(78) add2 #u8(29) loadc.l #u8(70) loadc #u8(9) builtin? #u8(43) set-car! #u8(47) vargc.l #u8(80) vec #u8(63) ret #u8(10) loadi8 #u8(66) tapply #u8(77) loadvoid #u8(25) loada1 #u8(1) shift #u8(46) atom? #u8(24) cdr #u8(13) brne.l #u8(83) / #u8(58) equal? #u8(52) apply #u8(54) dup #u8(11) loadt #u8(20) jmp.l #u8(48) = #u8(60) not #u8(35) set-cdr! #u8(30) fn? #u8(44) eq? #u8(33) * #u8(57) load1 #u8(27) bound? #u8(42) box.l #u8(86) < #u8(28) brnn.l #u8(84) jmp #u8(16) loadv #u8(2) for #u8(76) dummy_eof #u8(88) + #u8(55) brne #u8(19) argc.l #u8(79) compare #u8(61) brn #u8(3) neg #u8(37) loadv.l #u8(67) vargc #u8(74) brbound #u8(39) loadc1 #u8(22) setg.l #u8(72) cons? #u8(18) aref #u8(85) sym? #u8(34) aset! #u8(64) car #u8(12) cons #u8(32) tcall.l #u8(82) - #u8(56) brn.l #u8(49) optargs #u8(87) closure #u8(14) vec? #u8(45) pop #u8(4) eqv? #u8(51) list #u8(53) seta #u8(15) seta.l #u8(73) brnn #u8(26) loadnil #u8(65) loadg #u8(7) loada #u8(8) tcall #u8(6))
114 __finish #fn("n120210>17262:" #(#fn(for-each)114 __finish #fn("n120210>17262:" #(#fn(for-each)
115 #fn("n10A61:") *exit-hooks*) __finish)115 #fn("n10A61:") *exit-hooks*) __finish)
116 __init_globals #fn("n07021d37022@402384w4^147025d;350426;J50427w8429w:4qw;47<w=47>w?47@wA:" #(*os-name*116 __init_globals #fn("n07021d37022@402384w4^147025d;350426;J50427w8429w:4qw;47<w=47>w?47@wA:" #(*os-name*
src/builtins.c+1−1
@@ -102,7 +102,7 @@ BUILTIN("length", length) · 101 unmodified lines
102 }102 }
103 if(iscprim(a)){103 if(iscprim(a)){
104 cv = ptr(a);104 cv = ptr(a);
105 if(cp_class(cv) == sl_bytetype)105 if(cp_class(cv) == sl_utf8type)
106 return fixnum(1);106 return fixnum(1);
107 if(cp_class(cv) == sl_runetype)107 if(cp_class(cv) == sl_runetype)
108 return fixnum(runelen(*(Rune*)cp_data(cv)));108 return fixnum(runelen(*(Rune*)cp_data(cv)));
src/cvalues.c+5−5
@@ -95,7 +95,7 @@ cvalue_(sl_type *type, usize sz, bool nofinalize) · 94 unmodified lines
95 return cprim(type, sz);95 return cprim(type, sz);
96 96
97 bool str = false;97 bool str = false;
98 if(type->eltype == sl_bytetype){98 if(type->eltype == sl_utf8type){
99 if(sz == 0)99 if(sz == 0)
100 return sl_emptystr;100 return sl_emptystr;
101 sz++;101 sz++;
@@ -261,7 +261,7 @@ num_ctor(s32, s32int, T_S32) · 159 unmodified lines
261num_ctor(u32, u32int, T_U32)261num_ctor(u32, u32int, T_U32)
262num_ctor(s64, s64int, T_S64)262num_ctor(s64, s64int, T_S64)
263num_ctor(u64, u64int, T_U64)263num_ctor(u64, u64int, T_U64)
264num_ctor_init(byte, u8int, T_U8)264num_ctor_init(utf8, u8int, T_U8)
265num_ctor(float, float, T_FLOAT)265num_ctor(float, float, T_FLOAT)
266num_ctor(double, double, T_DOUBLE)266num_ctor(double, double, T_DOUBLE)
267num_ctor(rune, u32int, T_U32)267num_ctor(rune, u32int, T_U32)
@@ -1322,7 +1322,7 @@ cvalues_init(void) · 1054 unmodified lines
1322 ctor_cv_intern(u32, T_U32, u32int);1322 ctor_cv_intern(u32, T_U32, u32int);
1323 ctor_cv_intern(s64, T_S64, s64int);1323 ctor_cv_intern(s64, T_S64, s64int);
1324 ctor_cv_intern(u64, T_U64, u64int);1324 ctor_cv_intern(u64, T_U64, u64int);
1325 ctor_cv_intern(byte, T_U8, u8int);1325 ctor_cv_intern(utf8, T_U8, u8int);
1326 ctor_cv_intern(rune, T_U32, u32int);1326 ctor_cv_intern(rune, T_U32, u32int);
1327 ctor_cv_intern(float, T_FLOAT, float);1327 ctor_cv_intern(float, T_FLOAT, float);
1328 ctor_cv_intern(double, T_DOUBLE, double);1328 ctor_cv_intern(double, T_DOUBLE, double);
@@ -1330,7 +1330,7 @@ cvalues_init(void) · 1 unmodified line
1330 ctor_cv_intern(arr, NONNUMERIC, int);1330 ctor_cv_intern(arr, NONNUMERIC, int);
1331 1331
1332 sl_strtypesym = mk_csym("*str-type*");1332 sl_strtypesym = mk_csym("*str-type*");
1333 setc(sl_strtypesym, mk_list2(sl_arrsym, sl_bytesym));1333 setc(sl_strtypesym, mk_list2(sl_arrsym, sl_utf8sym));
1334 1334
1335 mk_primtype(s8, s8int);1335 mk_primtype(s8, s8int);
1336 mk_primtype(u8, u8int);1336 mk_primtype(u8, u8int);
@@ -1340,7 +1340,7 @@ cvalues_init(void) · 3 unmodified lines
1340 mk_primtype(u32, u32int);1340 mk_primtype(u32, u32int);
1341 mk_primtype(s64, s64int);1341 mk_primtype(s64, s64int);
1342 mk_primtype(u64, u64int);1342 mk_primtype(u64, u64int);
1343 mk_primtype(byte, u8int);1343 mk_primtype(utf8, u8int);
1344 mk_primtype(rune, u32int);1344 mk_primtype(rune, u32int);
1345 mk_primtype(float, float);1345 mk_primtype(float, float);
1346 mk_primtype(double, double);1346 mk_primtype(double, double);
src/plan9/lsd.sl+4−4
@@ -151,11 +151,11 @@ · 150 unmodified lines
151 151
152(def (c-str loc)152(def (c-str loc)
153 (def (go a)153 (def (go a)
154 (let {[v (readcore a 'byte)]}154 (let {[v (readcore a 'utf8)]}
155 (if (= v (byte 0))155 (if (= v (utf8 0))
156 ()156 ()
157 (cons v (go (1+ a))))))157 (cons v (go (1+ a))))))
158 (apply arr (cons 'byte (go (c-ptr (loc->addr loc))))))158 (apply arr (cons 'utf8 (go (c-ptr (loc->addr loc))))))
159 159
160(def (hex n)160(def (hex n)
161 "Display an integer in hex format."161 "Display an integer in hex format."
@@ -167,7 +167,7 @@ · 5 unmodified lines
167 :doc-group lsd167 :doc-group lsd
168 (str "0" (num->str n 8)))168 (str "0" (num->str n 8)))
169 169
170(def (bpsave a) (readcore a 'byte (length bpinst)))170(def (bpsave a) (readcore a 'u8 (length bpinst)))
171 171
172(let {[bp_init (λ (loc)172(let {[bp_init (λ (loc)
173 (when (< pid 0) (error "no running process"))173 (when (< pid 0) (error "no running process"))
src/print.c+2−2
@@ -665,7 +665,7 @@ static void · 664 unmodified lines
665cvalue_printdata(sl_ios *f, void *data, usize len, sl_v type, int weak)665cvalue_printdata(sl_ios *f, void *data, usize len, sl_v type, int weak)
666{666{
667 int n;667 int n;
668 if(type == sl_bytesym){668 if(type == sl_utf8sym){
669 u8int ch = *(u8int*)data;669 u8int ch = *(u8int*)data;
670 if(sl.print_princ)670 if(sl.print_princ)
671 outc(f, ch);671 outc(f, ch);
@@ -794,7 +794,7 @@ cvalue_printdata(sl_ios *f, void *data, usize len, sl_v type, int weak) · 122 unmodified lines
794 elsize = ctype_sizeof(eltype);794 elsize = ctype_sizeof(eltype);
795 cnt = elsize ? len/elsize : 0;795 cnt = elsize ? len/elsize : 0;
796 }796 }
797 if(eltype == sl_bytesym){797 if(eltype == sl_utf8sym){
798 if(sl.print_princ){798 if(sl.print_princ){
799 outsn(f, data, len);799 outsn(f, data, len);
800 }else{800 }else{
src/sl.c+2−2
@@ -28,7 +28,7 @@ sl_v sl_tablesym, sl_arrsym; · 27 unmodified lines
28sl_v sl_iosym, sl_rdsym, sl_wrsym, sl_apsym, sl_crsym, sl_truncsym;28sl_v sl_iosym, sl_rdsym, sl_wrsym, sl_apsym, sl_crsym, sl_truncsym;
29sl_v sl_s8sym, sl_u8sym, sl_s16sym, sl_u16sym, sl_s32sym, sl_u32sym;29sl_v sl_s8sym, sl_u8sym, sl_s16sym, sl_u16sym, sl_s32sym, sl_u32sym;
30sl_v sl_s64sym, sl_u64sym, sl_bignumsym;30sl_v sl_s64sym, sl_u64sym, sl_bignumsym;
31sl_v sl_bytesym, sl_runesym, sl_floatsym, sl_doublesym;31sl_v sl_utf8sym, sl_runesym, sl_floatsym, sl_doublesym;
32sl_v sl_strtypesym;32sl_v sl_strtypesym;
33 33
34sl_type *sl_mptype, *sl_builtintype;34sl_type *sl_mptype, *sl_builtintype;
@@ -37,7 +37,7 @@ sl_type *sl_s16type, *sl_u16type; · 2 unmodified lines
37sl_type *sl_s32type, *sl_u32type;37sl_type *sl_s32type, *sl_u32type;
38sl_type *sl_s64type, *sl_u64type;38sl_type *sl_s64type, *sl_u64type;
39sl_type *sl_floattype, *sl_doubletype;39sl_type *sl_floattype, *sl_doubletype;
40sl_type *sl_bytetype, *sl_runetype;40sl_type *sl_utf8type, *sl_runetype;
41sl_type *sl_strtype;41sl_type *sl_strtype;
42 42
43sl_thread(Sl *slp);43sl_thread(Sl *slp);
src/sl.h+3−3
@@ -320,7 +320,7 @@ typedef struct { · 319 unmodified lines
320#define cv_len(cv) (((sl_cv*)(cv))->len)320#define cv_len(cv) (((sl_cv*)(cv))->len)
321#define cv_type(cv) (cv_class(cv)->type)321#define cv_type(cv) (cv_class(cv)->type)
322#define cv_data(cv) (((sl_cv*)(cv))->data)322#define cv_data(cv) (((sl_cv*)(cv))->data)
323#define cv_isstr(cv) (cv_class(cv)->eltype == sl_bytetype)323#define cv_isstr(cv) (cv_class(cv)->eltype == sl_utf8type)
324#define cv_isPOD(cv) (cv_class(cv)->init != nil)324#define cv_isPOD(cv) (cv_class(cv)->init != nil)
325#define cvalue_data(v) cv_data((sl_cv*)ptr(v))325#define cvalue_data(v) cv_data((sl_cv*)ptr(v))
326#define cvalue_len(v) cv_len((sl_cv*)ptr(v))326#define cvalue_len(v) cv_len((sl_cv*)ptr(v))
@@ -432,7 +432,7 @@ extern sl_v sl_arrsym; · 105 unmodified lines
432extern sl_v sl_iosym, sl_rdsym, sl_wrsym, sl_apsym, sl_crsym, sl_truncsym;432extern sl_v sl_iosym, sl_rdsym, sl_wrsym, sl_apsym, sl_crsym, sl_truncsym;
433extern sl_v sl_s8sym, sl_u8sym, sl_s16sym, sl_u16sym, sl_s32sym, sl_u32sym;433extern sl_v sl_s8sym, sl_u8sym, sl_s16sym, sl_u16sym, sl_s32sym, sl_u32sym;
434extern sl_v sl_s64sym, sl_u64sym, sl_bignumsym;434extern sl_v sl_s64sym, sl_u64sym, sl_bignumsym;
435extern sl_v sl_bytesym, sl_runesym, sl_floatsym, sl_doublesym;435extern sl_v sl_utf8sym, sl_runesym, sl_floatsym, sl_doublesym;
436extern sl_v sl_strtypesym;436extern sl_v sl_strtypesym;
437 437
438extern sl_type *sl_mptype, *sl_builtintype;438extern sl_type *sl_mptype, *sl_builtintype;
@@ -441,7 +441,7 @@ extern sl_type *sl_s16type, *sl_u16type; · 2 unmodified lines
441extern sl_type *sl_s32type, *sl_u32type;441extern sl_type *sl_s32type, *sl_u32type;
442extern sl_type *sl_s64type, *sl_u64type;442extern sl_type *sl_s64type, *sl_u64type;
443extern sl_type *sl_floattype, *sl_doubletype;443extern sl_type *sl_floattype, *sl_doubletype;
444extern sl_type *sl_bytetype, *sl_runetype;444extern sl_type *sl_utf8type, *sl_runetype;
445extern sl_type *sl_strtype, *sl_runestrtype;445extern sl_type *sl_strtype, *sl_runestrtype;
446 446
447void sys_init(void);447void sys_init(void);
test/unittest.sl+4−5
@@ -78,7 +78,7 @@ · 77 unmodified lines
78 78
79(assert (equal? (u64 (double -123)) #u64(0xffffffffffffff85)))79(assert (equal? (u64 (double -123)) #u64(0xffffffffffffff85)))
80 80
81(assert (equal? (str 'sym #byte(65) #rune(945) "blah") "symA\u03B1blah"))81(assert (equal? (str 'sym #utf8(65) #rune(945) "blah") "symA\u03B1blah"))
82(assert (= (length (str #\x0)) 1))82(assert (= (length (str #\x0)) 1))
83 83
84(assert (> 9223372036854775808 9223372036854775807))84(assert (> 9223372036854775808 9223372036854775807))
@@ -277,7 +277,7 @@ · 192 unmodified lines
277(assert (equal? (keys1 :a 11) 12))277(assert (equal? (keys1 :a 11) 12))
278 278
279; cvalues and arrays279; cvalues and arrays
280(assert (equal? (typeof "") '(arr byte)))280(assert (equal? (typeof "") '(arr utf8)))
281(assert-fail (aref #(1) 3) bounds-error)281(assert-fail (aref #(1) 3) bounds-error)
282(def iarr (arr 's64 32 16 8 7 1))282(def iarr (arr 's64 32 16 8 7 1))
283(assert (equal? (aref iarr 0) 32))283(assert (equal? (aref iarr 0) 32))
@@ -487,7 +487,7 @@ · 203 unmodified lines
487 (in (io-readall s))487 (in (io-readall s))
488 (packed (lz-pack in level))488 (packed (lz-pack in level))
489 (unpacked (lz-unpack packed :size (sizeof in)))489 (unpacked (lz-unpack packed :size (sizeof in)))
490 (unpacked2 (arr-alloc 'byte (sizeof in) 0)))490 (unpacked2 (arr-alloc 'u8 (sizeof in) 0)))
491 (io-close s)491 (io-close s)
492 (assert (< (sizeof packed) (sizeof in)))492 (assert (< (sizeof packed) (sizeof in)))
493 (assert (equal? in unpacked))493 (assert (equal? in unpacked))
@@ -619,7 +619,7 @@ · 125 unmodified lines
619(assert-fail (str-find s #\o -1))619(assert-fail (str-find s #\o -1))
620(assert-fail (str-find s #\o 16))620(assert-fail (str-find s #\o 16))
621(assert-fail (str-find s 0))621(assert-fail (str-find s 0))
622(assert-fail (str-find s (byte #\o)))622(assert-fail (str-find s (utf8 #\o)))
623 623
624(assert (not (str-find "" "1")))624(assert (not (str-find "" "1")))
625(assert (not (str-find "1" "11")))625(assert (not (str-find "1" "11")))
@@ -637,7 +637,6 @@ · 11 unmodified lines
637(assert (= 111111111111111111111111111111111 (str->num "111111111111111111111111111111111")))637(assert (= 111111111111111111111111111111111 (str->num "111111111111111111111111111111111")))
638(assert (= 0xfffffffffffffffffffffffffffffffff (str->num "fffffffffffffffffffffffffffffffff" 16)))638(assert (= 0xfffffffffffffffffffffffffffffffff (str->num "fffffffffffffffffffffffffffffffff" 16)))
639 639
640(assert (= (length (byte #\f)) 1))
641(assert (= (length #\я) 2))640(assert (= (length #\я) 2))
642(assert (= (length #\⁹) 3))641(assert (= (length #\⁹) 3))
643(assert-fail (= (length (u8 0)) 1))642(assert-fail (= (length (u8 0)) 1))
tools/gen.sl+3−3
@@ -398,7 +398,7 @@ · 397 unmodified lines
398 (instructions (new "instructions.sl"))398 (instructions (new "instructions.sl"))
399 (builtins (new "builtins.sl"))399 (builtins (new "builtins.sl"))
400 (docs-ops (new "docs_ops.sl"))400 (docs-ops (new "docs_ops.sl"))
401 (op-to-byte (table))401 (op-to-u8 (table))
402 (c-op-to-op-arg (table))402 (c-op-to-op-arg (table))
403 (op-to-argc (table))403 (op-to-argc (table))
404 (op-to-closure ())404 (op-to-closure ())
@@ -422,7 +422,7 @@ · 17 unmodified lines
422 (write `(doc-for ,signature ,@docargs :doc-group builtin) docs-ops)422 (write `(doc-for ,signature ,@docargs :doc-group builtin) docs-ops)
423 (newline docs-ops)))423 (newline docs-ops)))
424 (op-docs op))424 (op-docs op))
425 (put! op-to-byte lop (byte i))425 (put! op-to-u8 lop (u8 i))
426 (when argc426 (when argc
427 (put! c-op-to-op-arg (op-cname op) (list lop (if (eq? argc T) 'ANYARGS argc)))427 (put! c-op-to-op-arg (op-cname op) (list lop (if (eq? argc T) 'ANYARGS argc)))
428 (when (and (num? argc) (>= argc 0))428 (when (and (num? argc) (>= argc 0))
@@ -449,7 +449,7 @@ · 20 unmodified lines
449 (write `(def Instructions449 (write `(def Instructions
450 "VM instructions mapped to their encoded byte representation."450 "VM instructions mapped to their encoded byte representation."
451 :doc-group builtin451 :doc-group builtin
452 ,op-to-byte)452 ,op-to-u8)
453 instructions)453 instructions)
454 (newline instructions)454 (newline instructions)
455 (newline instructions)455 (newline instructions)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t