diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-01-26 03:11:04 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-01-26 03:11:04 -0800 |
commit | b3bcdf5eb25486a6c642dc2c69fc9b98ef9ca926 (patch) | |
tree | 82d6e18a02afcd978aee36650ae0e13cb1c68ee9 | |
parent | ab1916bb210ebba36d9bdf2823a4208e7b255f70 (diff) | |
download | mu-b3bcdf5eb25486a6c642dc2c69fc9b98ef9ca926.tar.gz |
630 - routines can now allocate unlimited memory
-rw-r--r-- | mu.arc | 22 | ||||
-rw-r--r-- | mu.arc.t | 2 |
2 files changed, 11 insertions, 13 deletions
diff --git a/mu.arc b/mu.arc index 50ba0b95..3fe6423c 100644 --- a/mu.arc +++ b/mu.arc @@ -933,10 +933,10 @@ ;? (prn "1: " operand) ;? (tr "1: " operand) ; todo: why does this die? (zap absolutize operand) -;? (tr "2: @(tostring write.operand)") +;? (tr "2: @repr.operand") (while (pos '(deref) metadata.operand) (zap deref operand) -;? (tr "3: @(tostring write.operand)") +;? (tr "3: @repr.operand") ))) (def array-len (operand) @@ -1037,15 +1037,11 @@ (def new-string (literal-string) ;? (tr "new string: @literal-string") - (ret result rep.routine*!alloc - (= (memory* rep.routine*!alloc) len.literal-string) - (++ rep.routine*!alloc) - (each c literal-string - (= (memory* rep.routine*!alloc) c) - (++ rep.routine*!alloc)) -;? (tr "new-string: @result => @rep.routine*!alloc") - (assert (< rep.routine*!alloc rep.routine*!alloc-max) "allocation overflowed routine space @rep.routine*!alloc - @rep.routine*!alloc-max") - )) + (ret result (alloc (+ 1 len.literal-string)) + (= memory*.result len.literal-string) + (on c literal-string +;? (prn index " " repr.c) ;? 1 + (= (memory* (+ result 1 index)) c)))) ;; desugar structured assembly based on blocks @@ -1493,8 +1489,8 @@ t (~is memory*.addr value.idx) (do1 nil - (prn "@addr should contain @(tostring (write value.idx)) but contains @(tostring (write memory*.addr))") -;? (recur (+ addr 1) (+ idx 1)) + (prn "@addr should contain @(repr value.idx) but contains @(repr memory*.addr)") +;? (recur (+ addr 1) (+ idx 1)) ;? 1 ) :else (recur (+ addr 1) (+ idx 1)))))) diff --git a/mu.arc.t b/mu.arc.t index efa0bf57..565a06dc 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -3924,9 +3924,11 @@ (2:string-address <- new " world!") (3:string-address <- strcat 1:string-address 2:string-address) ]))) +;? (= dump-trace* (obj whitelist '("run"))) ;? 1 (run 'main) (when (~memory-contains-array memory*.3 "hello, world!") (prn "F - 'strcat' concatenates strings")) +;? (quit) ;? 1 (reset) (new-trace "interpolate") |