History

turn all +…+ definitions constant

Sigrid Solveig Haflínudóttir committed 3 months ago

Commit e68cd5f1 parent d6d0d7c4 files · +9 −4Browse files

Unified · Split

4 files
  1. boot/sl.boot +3 −4
  2. src/sl.c +2 −0
  3. src/vm_funcs.c +2 −0
  4. src/vm_jmptbl.c +2 −0
boot/sl.boot+3−4
@@ -276,8 +276,8 @@ group number) "Operations on numbers, mathematical constants." log "Return the · 275 unmodified lines
276276 (:doc-example . "(subseq '(1 2 3) 0 2)\n; ↳ (1 2)")
277277 (:doc-example . "(subseq #(a b c) 2)\n; ↳ #(c)") (:doc-group . list) (:doc-see . str-sub) (:doc-see . copy-list)
278278 (:doc-see . nthcdr)) set! ((:doc-example . "(def a NIL)\n(def b NIL)\n(def c NIL)\n(set! a 1 b 2 c (+ a b))\n; ↳ 3\na\n; ↳ 1\nb\n; ↳ 2\nc\n; ↳ 3")
279−(:doc-group . syntax) (:doc-see . set-top-level-value!) (:doc-see . let)) vm-stats ((:doc-group . debug)
280−(:doc-group . vm)) ptr ((:doc-group . number) (:doc-see . p32) (:doc-see . p64) (:doc-see . ptr?)) caddar ((:doc-group . list)) print-stack-trace ((:doc-group . error)
279+(:doc-group . syntax) (:doc-see . set-top-level-value!) (:doc-see . let)) vm-stats ((:doc-group . vm)) ptr ((:doc-group . number)
280+(:doc-see . p32) (:doc-see . p64) (:doc-see . ptr?)) caddar ((:doc-group . list)) print-stack-trace ((:doc-group . error)
281281 (:doc-see . stacktrace)) *stdin* ((:doc-group . io) (:doc-see . *stdout*) (:doc-see . *stderr*)) cosh ((:doc-group . number)) values ((:doc-group . syntax)
282282 (:doc-see . call-with-values) (:doc-see . receive)) < ((:doc-group . compare) (:doc-group . builtin)) copy-tree ((:doc-example . "(def a '(1 (2 3)))\n(def b (copy-tree a))\n(equal? a b)\n; ↳ T\n(eq? a b)\n; ↳ NIL\n(equal? (cadr a) (cadr b))\n; ↳ T\n(eq? (cadr a) (cadr b))\n; ↳ NIL")
283283 (:doc-group . list) (:doc-see . copy-list)) sin ((:doc-group . number)) f32 ((:doc-group . number)
@@ -479,8 +479,7 @@ group number) "Operations on numbers, mathematical constants." log "Return the · 195 unmodified lines
479479 (:doc-example . "(def b (buffer))\n(with-output (s b) (io-write s \"hello\"))\n; ↳ 5\n(length b)\n; ↳ 5")
480480 (:doc-group . io) (:doc-see . with-output-to)) cdaar ((:doc-group . list)) cdar ((:doc-group . list)) iota ((:doc-example . "(iota 4)\n; ↳ (0 1 2 3)")
481481 (:doc-example . "(iota 4 6)\n; ↳ (6 7 8 9)") (:doc-example . "(iota 4 6 -0.5)\n; ↳ (6 5.5 5.0 4.5)")
482−(:doc-group . list) (:doc-see . map-int)) caaddr ((:doc-group . list)) environment ((:doc-group . debug)
483−(:doc-group . vm)
482+(:doc-group . list) (:doc-see . map-int)) caaddr ((:doc-group . list)) environment ((:doc-group . vm)
484483 (:doc-see . print-stack-trace)) getprop ((:doc-example . "(def x '(1 2 3))\n(putprop x 'words \"one two three\")\n; ↳ \"one two three\"\n(getprop x 'words)\n; ↳ \"one two three\"\n(getprop x 'huh)\n; ‼ key not found: huh\n(getprop x 'huh \"fallback\")\n; ↳ \"fallback\"")
485484 (:doc-group . prop) (:doc-see . putprop) (:doc-see . remprop)) putprop ((:doc-example . "(def x '(1 2 3))\n(putprop x 'words \"one two three\")\n; ↳ \"one two three\"\n(getprop x 'words)\n; ↳ \"one two three\"")
486485 (:doc-group . prop) (:doc-see . getprop)
src/sl.c+2−0
@@ -1546,6 +1546,8 @@ sl_load_system_image(sl_v sys_image_io) · 1545 unmodified lines
15461546 sym->binding = car_(e);
15471547 if(isfn(sym->binding) && !isbuiltin(sym->binding) && fn_name(sym->binding))
15481548 fn_name(sym->binding) = s;
1549+ if(sym->name[0] == '+' && sym->name[1] != 0 && sym->name[strlen(sym->name)-1] == '+')
1550+ sym->flags |= FLAG_CONST;
15491551 e = cdr_(e);
15501552 }
15511553 }
src/vm_funcs.c+2−0
@@ -795,6 +795,8 @@ MAKE_OP(SETG_) · 794 unmodified lines
795795 cthrow(const_error(v), nargs);
796796 }
797797 sym->binding = sl.sp[-1];
798+ if(sym->name[0] == '+' && sym->name[1] != 0 && sym->name[strlen(sym->name)-1] == '+')
799+ sym->flags |= FLAG_CONST;
798800 NEXT_OP;
799801 }
800802
src/vm_jmptbl.c+2−0
@@ -862,6 +862,8 @@ OP(OP_SETGL) · 861 unmodified lines
862862 cthrow(const_error(v), nargs);
863863 }
864864 sym->binding = sl.sp[-1];
865+ if(sym->name[0] == '+' && sym->name[1] != 0 && sym->name[strlen(sym->name)-1] == '+')
866+ sym->flags |= FLAG_CONST;
865867 NEXT_OP;
866868 }
867869

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